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