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 : // This file allows reading the content of the symbol record table from a PDB
16 : // stream.
17 :
18 : #ifndef SYZYGY_PDB_PDB_SYMBOL_RECORD_H_
19 : #define SYZYGY_PDB_PDB_SYMBOL_RECORD_H_
20 :
21 : #include <vector>
22 :
23 : #include "base/callback.h"
24 : #include "syzygy/common/binary_stream.h"
25 : #include "syzygy/pdb/pdb_data_types.h"
26 : #include "syzygy/pdb/pdb_stream.h"
27 :
28 m : namespace pdb {
29 :
30 : // Read a symbol record table from a Pdb stream.
31 : // @param stream The stream containing the table.
32 : // @param symbol_table_offset The start offset of the symbol record table.
33 : // @param symbol_table_size The size of the symbol record table.
34 : // @param symbol_vector The vector where the symbol records should be stored.
35 : // @returns true on success, false otherwise.
36 m : bool ReadSymbolRecord(PdbStream* stream,
37 m : size_t symbol_table_offset,
38 m : size_t symbol_table_size,
39 m : SymbolRecordVector* symbol_vector);
40 :
41 : // Defines a symbol visitor callback. This needs to return true on success
42 : // (indicating that the symbol visitor should continue), and false on failure
43 : // (indicating that it should terminate). The reader is positioned at the
44 : // beginning of the symbol data, which is of the provided length, the type
45 : // having already been read from the stream.
46 m : typedef base::Callback<bool(uint16_t /* symbol_length */,
47 m : uint16_t /* symbol_type */,
48 m : common::BinaryStreamReader* /* symbol_reader */)>
49 m : VisitSymbolsCallback;
50 :
51 : // Reads symbols from the given symbol stream until the end of the stream.
52 : // @param callback The callback to be invoked for each symbol.
53 : // @param symbol_table_offset The start offset of the symbol table to visit.
54 : // @param symbol_table_size The size of the symbol record table.
55 : // @param has_header If true then this will first parse the symbol stream
56 : // header and ensure it is of the expected type. If false it will assume
57 : // it is the expected type and start parsing symbols immediately.
58 : // @param symbols The stream containing symbols to be visited. The stream
59 : // will be read starting from its current position, and will be advanced
60 : // past the symbols one by one.
61 : // @returns true on success, false otherwise.
62 m : bool VisitSymbols(VisitSymbolsCallback callback,
63 m : size_t symbol_table_offset,
64 m : size_t symbol_table_size,
65 m : bool has_header,
66 m : PdbStream* symbols);
67 :
68 m : } // namespace pdb
69 :
70 : #endif // SYZYGY_PDB_PDB_SYMBOL_RECORD_H_
|