1 : // Copyright 2013 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 : // Implements the JumpTableCaseCountTransform class.
16 :
17 : #include "syzygy/instrument/transforms/jump_table_count_transform.h"
18 :
19 : #include "base/logging.h"
20 : #include "syzygy/pe/block_util.h"
21 : #include "syzygy/pe/pe_utils.h"
22 : #include "syzygy/pe/transforms/add_imports_transform.h"
23 :
24 : namespace instrument {
25 : namespace transforms {
26 :
27 : namespace {
28 :
29 : using block_graph::BasicBlock;
30 : using block_graph::BlockGraph;
31 :
32 : const char kDefaultModuleName[] = "jump_table_count.dll";
33 :
34 : } // namespace
35 :
36 : const char JumpTableCaseCountTransform::kTransformName[] =
37 : "JumpTableCountTransform";
38 :
39 : JumpTableCaseCountTransform::JumpTableCaseCountTransform()
40 E : : instrument_dll_name_(kDefaultModuleName) {
41 E : }
42 :
43 : bool JumpTableCaseCountTransform::PreBlockGraphIteration(
44 : BlockGraph* block_graph,
45 E : BlockGraph::Block* header_block) {
46 E : DCHECK(block_graph != NULL);
47 E : DCHECK(header_block != NULL);
48 :
49 : // TODO(sebmarchand): Implement this function.
50 :
51 E : return true;
52 E : }
53 :
54 : bool JumpTableCaseCountTransform::OnBlock(BlockGraph* block_graph,
55 E : BlockGraph::Block* block) {
56 E : DCHECK(block_graph != NULL);
57 E : DCHECK(block != NULL);
58 :
59 E : if (block->type() != BlockGraph::CODE_BLOCK)
60 E : return true;
61 :
62 E : if (!pe::CodeBlockIsBasicBlockDecomposable(block))
63 E : return true;
64 :
65 E : if (!ApplyBasicBlockSubGraphTransform(this, block_graph, block, NULL))
66 i : return false;
67 :
68 E : return true;
69 E : }
70 :
71 : bool JumpTableCaseCountTransform::TransformBasicBlockSubGraph(
72 E : BlockGraph* block_graph , BasicBlockSubGraph* subgraph) {
73 E : DCHECK(block_graph != NULL);
74 E : DCHECK(subgraph != NULL);
75 :
76 : // TODO(sebmarchand): Implement this function.
77 :
78 E : return true;
79 E : }
80 :
81 : bool JumpTableCaseCountTransform::PostBlockGraphIteration(
82 E : BlockGraph* block_graph, BlockGraph::Block* header_block) {
83 E : DCHECK(block_graph != NULL);
84 E : DCHECK(header_block != NULL);
85 :
86 : // TODO(sebmarchand): Implement this function.
87 :
88 E : return true;
89 E : }
90 :
91 : } // namespace transforms
92 : } // namespace instrument
|