OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 Google Inc. All Rights Reserved. |
| 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at |
| 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 // See the License for the specific language governing permissions and |
| 13 // limitations under the License. |
| 14 |
| 15 #ifndef SYZYGY_PROTECT_PROTECT_LIB_PROTECTED_BASIC_BLOCK_FILTER_H_ |
| 16 #define SYZYGY_PROTECT_PROTECT_LIB_PROTECTED_BASIC_BLOCK_FILTER_H_ |
| 17 |
| 18 #include <vector> |
| 19 #include "syzygy/block_graph/basic_block_subgraph.h" |
| 20 #include "syzygy/block_graph/block_builder.h" |
| 21 #include "syzygy/block_graph/block_graph.h" |
| 22 |
| 23 |
| 24 namespace protect { |
| 25 |
| 26 class ProtectedBBlockFilter { |
| 27 public: |
| 28 // Constructor |
| 29 |
| 30 ProtectedBBlockFilter() {} |
| 31 |
| 32 ProtectedBBlockFilter( |
| 33 std::vector<std::pair<block_graph::BlockGraph::RelativeAddress, |
| 34 block_graph::BlockGraph::Size> >& filter) |
| 35 : filter(filter) {} |
| 36 |
| 37 // Adds another address <-> size pair tot the filter |
| 38 // |
| 39 // @param tuple Address/size pair to be inserted |
| 40 void Add(std::pair<block_graph::BlockGraph::RelativeAddress, |
| 41 block_graph::BlockGraph::Size> &tuple); |
| 42 |
| 43 // This is the main function for filtering basic blocks in a subgraph |
| 44 // It checks if the blocks in the subgraph overalp with any of the defined |
| 45 // filter ranges |
| 46 // |
| 47 // @param to_protect Vector through which all the found blocks are returned. |
| 48 // @param subgraph Subgraph that contains all the basic blocks. |
| 49 // @return true if filtering was successfull, false otherwise |
| 50 bool Filter(std::vector<block_graph::BasicBlock *>& to_protect, |
| 51 block_graph::BasicBlockSubGraph *subgraph); |
| 52 |
| 53 // Helper function for the current filter |
| 54 // @return String representation of the filter |
| 55 std::string ToString(); |
| 56 |
| 57 private: |
| 58 // Vector of <Address, Size> pairs used for storing address ranges for filte
ring. |
| 59 std::vector < std::pair<block_graph::BlockGraph::RelativeAddress, |
| 60 block_graph::BlockGraph::Size> > filter; |
| 61 }; |
| 62 } // namespace protect |
| 63 #endif // SYZYGY_PROTECT_PROTECT_LIB_PROTECTED_BASIC_BLOCK_FILTER_H_ |
OLD | NEW |