Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: syzygy/experimental/protect/protect_lib/protected_basic_block_filter.cc

Issue 2535563002: Added all code for integrity check transform (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "syzygy/protect/protect_lib/protected_basic_block_filter.h"
16
17 namespace protect {
18
19 using block_graph::BlockGraph;
20 using block_graph::BasicBlockSubGraph;
21 using block_graph::BasicBlock;
22
23 void ProtectedBBlockFilter::Add(
24 std::pair<block_graph::BlockGraph::RelativeAddress,
25 block_graph::BlockGraph::Size> &tuple)
26 {
27 this->filter.push_back(tuple);
28 }
29
30 bool ProtectedBBlockFilter::Filter(
31 std::vector<BasicBlock *>& to_protect,
32 BasicBlockSubGraph *subgraph)
33 {
34 std::vector < std::pair<BlockGraph::RelativeAddress,
35 BlockGraph::Size> > ::iterator adr_range = filter.begin();
36
37 BlockGraph::RelativeAddress start_addr, block_addr;
38 const BlockGraph::Block *original_block = subgraph->original_block();
39
40 if (original_block == NULL) // the subgraph is new; it has no original block
41 return false;
42 // else
43 const BasicBlockSubGraph::BasicBlockOrdering& original_order =
44 subgraph->block_descriptions().front().basic_block_order;
45 BasicBlockSubGraph::BasicBlockOrdering::const_iterator bb_iter =
46 original_order.begin();
47 for (; bb_iter != original_order.end(); ++bb_iter) {
48 if ((*bb_iter)->type() != BasicBlock::BasicBlockType::BASIC_CODE_BLOCK)
49 continue;
50
51 const block_graph::BasicCodeBlock* bb =
52 block_graph::BasicCodeBlock::Cast(*bb_iter);
53 if (bb == NULL)
54 continue;
55
56 // BasicBlock is in the protected area, adding to the vector
57 to_protect.push_back(*bb_iter);
58 }
59
60 return true;
61 }
62
63 std::string ProtectedBBlockFilter::ToString()
64 {
65 std::stringstream ss;
66
67 ss << "Filter" << std::endl;
68 ss << "size: " << filter.size() << std::endl << std::endl;
69
70 for (size_t i = 0; i < filter.size(); ++i) {
71 ss << "Entry " << i << std::endl;
72 ss << " Addr: " << filter[i].first << std::endl;
73 ss << " Size: " << filter[i].second << std::endl;
74 }
75
76 ss << std::endl;
77 std::string ret = ss.str();
78
79 return ret;
80 }
81
82 } // namespace protect
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698