1 : // Copyright 2011 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 simple class for extracting PDB information from a PE file.
16 : #ifndef SYZYGY_PE_PDB_INFO_H_
17 : #define SYZYGY_PE_PDB_INFO_H_
18 :
19 : #include "base/basictypes.h"
20 : #include "base/files/file_path.h"
21 : #include "syzygy/pdb/pdb_data.h"
22 : #include "syzygy/pe/pe_data.h"
23 :
24 : namespace pe {
25 :
26 : // Forward declaration.
27 : class PEFile;
28 :
29 : // This class is analogous to CvInfoPdb70, but with a FilePath instead of a
30 : // char*. It contains functionality for loading the debug information directly
31 : // from a PE file using our PE parser rather than loading the whole image.
32 : class PdbInfo {
33 : public:
34 : PdbInfo();
35 :
36 : // Initializes this object from @p cv_info_pdb.
37 : // @returns true on success, false otherwise.
38 : bool Init(const CvInfoPdb70& cv_info_pdb);
39 :
40 : // Initializes this object from an already loaded PE file @p pe_file.
41 : // @returns true on success, false otherwise.
42 : bool Init(const PEFile& pe_file);
43 :
44 : // Initializes this object from the provided PE file @pe_path.
45 : // @returns true on success, false otherwise.
46 : bool Init(const base::FilePath& pe_path);
47 :
48 : // Accessors.
49 E : uint32 pdb_age() const { return pdb_age_; }
50 E : const base::FilePath& pdb_file_name() const { return pdb_file_name_; }
51 E : const GUID& signature() const { return signature_; }
52 :
53 : // Compares this object with the given PdbInfoHeader @p pdb_info_header.
54 : // @returns true if they are consistent, false otherwise.
55 : bool IsConsistent(const pdb::PdbInfoHeader70& pdb_info_header) const;
56 :
57 : private:
58 : uint32 pdb_age_;
59 : base::FilePath pdb_file_name_;
60 : GUID signature_;
61 : };
62 :
63 : } // namespace pe
64 :
65 : #endif // SYZYGY_PE_PDB_INFO_H_
|