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 : // Defines OperationInterface, which all PEHacker operations must implement.
16 :
17 : #ifndef SYZYGY_PEHACKER_OPERATION_H_
18 : #define SYZYGY_PEHACKER_OPERATION_H_
19 :
20 : #include "base/values.h"
21 : #include "syzygy/block_graph/block_graph.h"
22 :
23 : namespace pehacker {
24 :
25 : class OperationInterface {
26 : public:
27 : typedef block_graph::BlockGraph BlockGraph;
28 : typedef block_graph::TransformPolicyInterface TransformPolicyInterface;
29 :
30 : // Virtual destructor.
31 E : virtual ~OperationInterface() { }
32 :
33 : // @returns the name of this operation.
34 : virtual const char* name() const = 0;
35 :
36 : // Initializes this operation with the given configuration. This will only
37 : // ever be called once for a given operation object.
38 : // @param policy The policy to use in guiding the operation.
39 : // @param operation The configuration for this operation.
40 : // @returns true on success, false otherwise.
41 : virtual bool Init(const TransformPolicyInterface* policy,
42 : const base::DictionaryValue* operation) = 0;
43 :
44 : // Applies this operation to the given block-graph. This will only be called
45 : // after a successful call to Init. This will only ever be called once for a
46 : // given operation object.
47 : // @param policy The policy to use in guiding the operation.
48 : // @param block_graph The decomposed PE image on which to apply the operation.
49 : // @param header_block The PE header block.
50 : // @returns true on success, false otherwise.
51 : virtual bool Apply(const TransformPolicyInterface* policy,
52 : BlockGraph* block_graph,
53 : BlockGraph::Block* header_block) = 0;
54 : };
55 :
56 : } // namespace pehacker
57 :
58 : #endif // SYZYGY_PEHACKER_OPERATION_H_
|