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 basic BlockGraphTransform for adding a Syzygy-toolchain metadata
16 : // section to a PE image.
17 :
18 : #ifndef SYZYGY_PE_TRANSFORMS_ADD_METADATA_TRANSFORM_H_
19 : #define SYZYGY_PE_TRANSFORMS_ADD_METADATA_TRANSFORM_H_
20 :
21 : #include "base/files/file_path.h"
22 : #include "syzygy/block_graph/transforms/named_transform.h"
23 :
24 : namespace pe {
25 : namespace transforms {
26 :
27 : using block_graph::BlockGraph;
28 : using block_graph::transforms::NamedBlockGraphTransformImpl;
29 :
30 : class AddMetadataTransform
31 : : public NamedBlockGraphTransformImpl<AddMetadataTransform> {
32 : public:
33 : // @param module_path the path to the module that the metadata will refer to.
34 : // This should be the original module from which the block-graph was
35 : // generated.
36 : explicit AddMetadataTransform(const base::FilePath& module_path);
37 :
38 : // Applies this transform to the provided PE image block graph.
39 : //
40 : // @param block_graph The block graph to transform.
41 : // @param dos_header_block The DOS header block of the block graph. This is
42 : // unused in this transform.
43 : // @returns true on success, false otherwise.
44 : virtual bool TransformBlockGraph(
45 : BlockGraph* block_graph,
46 : BlockGraph::Block* /*dos_header_block*/) OVERRIDE;
47 :
48 E : BlockGraph::Block* metadata_block() const { return metadata_block_; }
49 :
50 : // The name of this transform.
51 : static const char kTransformName[];
52 :
53 : private:
54 : // The path to the module which the metadata refers to.
55 : base::FilePath module_path_;
56 :
57 : // The block that has been created or reused to hold metadata.
58 : BlockGraph::Block* metadata_block_;
59 :
60 : DISALLOW_COPY_AND_ASSIGN(AddMetadataTransform);
61 : };
62 :
63 : } // namespace transforms
64 : } // namespace pe
65 :
66 : #endif // SYZYGY_PE_TRANSFORMS_ADD_METADATA_TRANSFORM_H_
|