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::TransformPolicyInterface;
35 : using block_graph::transforms::NamedBlockGraphTransformImpl;
36 :
37 : // A PE BlockGraph transform for adding/updating the a debug directory entry
38 : // of a given type.
39 : class AddPdbInfoTransform
40 : : public NamedBlockGraphTransformImpl<AddPdbInfoTransform> {
41 : public:
42 : // Configures this transform.
43 : //
44 : // @param pdb_path the path of the PDB file to link to.
45 : // @param pdb_age the age of the PDB file to link to.
46 : // @param pdb_guid the GUID of the PDB file to link to.
47 E : AddPdbInfoTransform(const base::FilePath& pdb_path,
48 : uint32 pdb_age,
49 : const GUID& pdb_guid)
50 : : pdb_path_(pdb_path), pdb_age_(pdb_age), pdb_guid_(pdb_guid) {
51 E : }
52 :
53 : // Adds or finds the debug data directory of the given type.
54 : //
55 : // @param policy The policy object restricting how the transform is applied.
56 : // @param block_graph The block graph to transform.
57 : // @param dos_header_block The DOS header block of the block graph.
58 : // @returns true on success, false otherwise.
59 : virtual bool TransformBlockGraph(
60 : const TransformPolicyInterface* policy,
61 : BlockGraph* block_graph,
62 : BlockGraph::Block* dos_header_block) override;
63 :
64 : // The transform name.
65 : static const char kTransformName[];
66 :
67 : private:
68 : base::FilePath pdb_path_;
69 : uint32 pdb_age_;
70 : GUID pdb_guid_;
71 :
72 : DISALLOW_COPY_AND_ASSIGN(AddPdbInfoTransform);
73 : };
74 :
75 : } // namespace transforms
76 : } // namespace pe
77 :
78 : #endif // SYZYGY_PE_TRANSFORMS_ADD_PDB_INFO_TRANSFORM_H_
|