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