MCPcopy Create free account
hub / github.com/crosire/blink / pdb_reader

Method pdb_reader

source/pdb_reader.cpp:130–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128#pragma endregion
129
130blink::pdb_reader::pdb_reader(const std::string &path) : msf_reader(path)
131{
132 // PDB files should have 4 streams at the beginning that are always at the same index
133 _is_valid &= stream_count() > 4;
134
135 if (!is_valid())
136 return;
137
138 // Read PDB info stream
139 stream_reader pdb_stream(msf_reader::stream(1));
140 if (pdb_stream.size() == 0)
141 return;
142
143 const pdb_header &header = pdb_stream.read<pdb_header>();
144 _version = header.version;
145 _timestamp = header.time_date_stamp;
146 _guid = header.guid;
147
148 // Read stream names from string hash map
149 pdb_stream.skip(header.names_map_offset);
150
151 const auto count = pdb_stream.read<uint32_t>();
152 const auto hash_table_size = pdb_stream.read<uint32_t>();
153 _named_streams.reserve(count);
154
155 const auto num_bitset_present = pdb_stream.read<uint32_t>();
156 std::vector<uint32_t> bitset_present(num_bitset_present);
157 pdb_stream.read(bitset_present.data(), num_bitset_present * sizeof(uint32_t));
158
159 const auto num_bitset_deleted = pdb_stream.read<uint32_t>();
160 pdb_stream.skip(num_bitset_deleted * sizeof(uint32_t));
161
162 for (uint32_t i = 0; i < hash_table_size; i++)
163 {
164 if ((bitset_present[i / 32] & (1 << (i % 32))) == 0)
165 continue;
166
167 const auto name_offset = pdb_stream.read<uint32_t>();
168 const auto stream_index = pdb_stream.read<uint32_t>();
169
170 const auto pos = pdb_stream.tell();
171 pdb_stream.seek(sizeof(header) + name_offset); // Seek into the string table that stores the name
172 const std::string name(pdb_stream.read_string());
173 pdb_stream.seek(pos); // Seek previous position in stream to read next name offset in the next iteration of this loop
174
175 _named_streams.insert({ name, stream_index });
176 }
177}
178
179void blink::pdb_reader::read_symbol_table(uint8_t *image_base, std::unordered_map<std::string, void *> &symbols)
180{

Callers

nothing calls this directly

Calls 7

sizeMethod · 0.80
skipMethod · 0.80
readMethod · 0.80
dataMethod · 0.80
tellMethod · 0.80
seekMethod · 0.80
read_stringMethod · 0.80

Tested by

no test coverage detected