1 : // Copyright 2012 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 a BlockGraphTransform that trims the DOS header and ensures the NT
16 : // headers are sufficiently big to represent all sections in the block graph.
17 : // To be applied before layout so that the layout remains valid after
18 : // finalizing the headers.
19 : //
20 : // After this transform both the DOS header and the NT headers have been sized
21 : // appropriately for the resulting image. The DOS header has also been finalized
22 : // and will be valid after the transform. The NT headers are not necessarily
23 : // valid.
24 :
25 : #ifndef SYZYGY_PE_TRANSFORMS_PE_PREPARE_HEADERS_TRANSFORM_H_
26 : #define SYZYGY_PE_TRANSFORMS_PE_PREPARE_HEADERS_TRANSFORM_H_
27 :
28 : #include "syzygy/block_graph/transforms/named_transform.h"
29 :
30 m : namespace pe {
31 m : namespace transforms {
32 :
33 m : class PEPrepareHeadersTransform
34 m : : public block_graph::transforms::NamedBlockGraphTransformImpl<
35 m : PEPrepareHeadersTransform> {
36 m : public:
37 m : typedef block_graph::BlockGraph BlockGraph;
38 m : typedef block_graph::TransformPolicyInterface TransformPolicyInterface;
39 :
40 : // Applies this transform to the provided PE image block graph.
41 : //
42 : // @param policy The policy object restricting how the transform is applied.
43 : // @param block_graph The block graph to transform.
44 : // @param dos_header_block The DOS header block of the block graph.
45 : // @returns true on success, false otherwise.
46 m : virtual bool TransformBlockGraph(
47 m : const TransformPolicyInterface* policy,
48 m : BlockGraph* block_graph,
49 m : BlockGraph::Block* dos_header_block) override;
50 :
51 : // The name of this transform.
52 m : static const char kTransformName[];
53 m : };
54 :
55 m : } // namespace transforms
56 m : } // namespace pe
57 :
58 : #endif // SYZYGY_PE_TRANSFORMS_PE_PREPARE_HEADERS_TRANSFORM_H_
|