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 the AddPdbInfoTransform. This adorns a PE BlockGraph with a
16 : // debug data directory entry, which contains information regarding the PDB file
17 : // for this block-graph (actually, for the module that will be created from it).
18 : //
19 : // If the module already contains a debug directory entry it will be modified
20 : // in-place.
21 :
22 : #ifndef SYZYGY_PE_TRANSFORMS_ADD_PDB_INFO_TRANSFORM_H_
23 : #define SYZYGY_PE_TRANSFORMS_ADD_PDB_INFO_TRANSFORM_H_
24 :
25 : #include <guiddef.h>
26 :
27 : #include "base/files/file_path.h"
28 : #include "syzygy/block_graph/transforms/named_transform.h"
29 :
30 : namespace pe {
31 : namespace transforms {
32 :
33 : using block_graph::BlockGraph;
34 : using block_graph::transforms::NamedBlockGraphTransformImpl;
35 :
36 : // A PE BlockGraph transform for adding/updating the a debug directory entry
37 : // of a given type.
38 : class AddPdbInfoTransform
39 : : public NamedBlockGraphTransformImpl<AddPdbInfoTransform> {
40 : public:
41 : // Configures this transform.
42 : //
43 : // @param pdb_path the path of the PDB file to link to.
44 : // @param pdb_age the age of the PDB file to link to.
45 : // @param pdb_guid the GUID of the PDB file to link to.
46 E : AddPdbInfoTransform(const base::FilePath& pdb_path,
47 : uint32 pdb_age,
48 : const GUID& pdb_guid)
49 : : pdb_path_(pdb_path), pdb_age_(pdb_age), pdb_guid_(pdb_guid) {
50 E : }
51 :
52 : // Adds or finds the debug data directory of the given type.
53 : //
54 : // @param block_graph The block graph to transform.
55 : // @param dos_header_block The DOS header block of the block graph.
56 : // @returns true on success, false otherwise.
57 : virtual bool TransformBlockGraph(
58 : BlockGraph* block_graph, BlockGraph::Block* dos_header_block) OVERRIDE;
59 :
60 : // The tranform name.
61 : static const char kTransformName[];
62 :
63 : private:
64 : base::FilePath pdb_path_;
65 : uint32 pdb_age_;
66 : GUID pdb_guid_;
67 :
68 : DISALLOW_COPY_AND_ASSIGN(AddPdbInfoTransform);
69 : };
70 :
71 : } // namespace transforms
72 : } // namespace pe
73 :
74 : #endif // SYZYGY_PE_TRANSFORMS_ADD_PDB_INFO_TRANSFORM_H_
|