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 : // Declares the AddImportsOperation. This is effectively a wrapper for
16 : // pe::AddImportsTransform.
17 :
18 : #ifndef SYZYGY_PEHACKER_OPERATIONS_ADD_IMPORTS_OPERATION_H_
19 : #define SYZYGY_PEHACKER_OPERATIONS_ADD_IMPORTS_OPERATION_H_
20 :
21 : #include "base/memory/scoped_vector.h"
22 : #include "syzygy/block_graph/transform.h"
23 : #include "syzygy/pe/transforms/pe_add_imports_transform.h"
24 : #include "syzygy/pehacker/operation.h"
25 :
26 : namespace pehacker {
27 : namespace operations {
28 :
29 : class AddImportsOperation : public OperationInterface {
30 : public:
31 E : AddImportsOperation() { }
32 :
33 : // Virtual destructor.
34 E : virtual ~AddImportsOperation() { }
35 :
36 : // @name OperationInterface implementation.
37 : // @{
38 : virtual const char* name() const OVERRIDE;
39 : virtual bool Init(const TransformPolicyInterface* policy,
40 : const base::DictionaryValue* operation);
41 : virtual bool Apply(const TransformPolicyInterface* policy,
42 : BlockGraph* block_graph,
43 : BlockGraph::Block* header_block);
44 : // @}
45 :
46 : // The name of this operation.
47 : static const char kName[];
48 :
49 : protected:
50 : typedef pe::transforms::ImportedModule ImportedModule;
51 : typedef std::map<std::string, ImportedModule*> ImportedModuleMap;
52 :
53 : // Unittesting seam.
54 : virtual bool ApplyTransform(block_graph::BlockGraphTransformInterface* tx,
55 : const TransformPolicyInterface* policy,
56 : BlockGraph* block_graph,
57 : BlockGraph::Block* header_block);
58 :
59 : // The actual transform that will be applied.
60 : pe::transforms::PEAddImportsTransform add_imports_tx_;
61 :
62 : // The modules that will be imported.
63 : ScopedVector<ImportedModule> imported_modules_;
64 : ImportedModuleMap imported_module_map_;
65 :
66 : private:
67 : DISALLOW_COPY_AND_ASSIGN(AddImportsOperation);
68 : };
69 :
70 : } // namespace operations
71 : } // namespace pehacker
72 :
73 : #endif // SYZYGY_PEHACKER_OPERATIONS_ADD_IMPORTS_OPERATION_H_
|