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 PE-specific orderer. This orderer ensures that no expectations of
16 : // a valid PE image are violated. For example, that relocations are in the
17 : // last section and that resources are in the second to last section.
18 : //
19 : // NOTE: It currently does not, but will eventually, ensure that data
20 : // directories and their associated data structures are laid out as
21 : // expected (contiguous when they need to be, in the appropriate sections,
22 : // etc).
23 :
24 : #ifndef SYZYGY_PE_ORDERERS_PE_ORDERER_H_
25 : #define SYZYGY_PE_ORDERERS_PE_ORDERER_H_
26 :
27 : #include "syzygy/block_graph/orderers/named_orderer.h"
28 :
29 : namespace pe {
30 : namespace orderers {
31 :
32 : class PEOrderer
33 : : public block_graph::orderers::NamedOrdererImpl<PEOrderer> {
34 : public:
35 : typedef block_graph::BlockGraph BlockGraph;
36 : typedef block_graph::OrderedBlockGraph OrderedBlockGraph;
37 :
38 E : PEOrderer() { }
39 :
40 : // Applies this orderer to the provided block graph.
41 : //
42 : // @param ordered_block_graph the block graph to order.
43 : // @param dos_header_block The header block of the block graph to transform.
44 : // This must be a valid DOS header block, and refer to a valid NT
45 : // headers block.
46 : // @returns true on success, false otherwise.
47 : virtual bool OrderBlockGraph(OrderedBlockGraph* ordered_block_graph,
48 : BlockGraph::Block* dos_header_block) OVERRIDE;
49 :
50 : static const char kOrdererName[];
51 :
52 : private:
53 : DISALLOW_COPY_AND_ASSIGN(PEOrderer);
54 : };
55 :
56 : } // namespace orderers
57 : } // namespace pe
58 :
59 : #endif // SYZYGY_PE_ORDERERS_PE_ORDERER_H_
|