VirtualBox

source: vbox/trunk/include/iprt/formats/pdb.h@ 106061

Last change on this file since 106061 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 16.4 KB
Line 
1/* $Id: pdb.h 106061 2024-09-16 14:03:52Z vboxsync $ */
2/** @file
3 * IPRT - Microsoft Program Database (PDB) Structures and Constants.
4 */
5
6/*
7 * Copyright (C) 2023-2024 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_formats_pdb_h
38#define IPRT_INCLUDED_formats_pdb_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/types.h>
44#include <iprt/assertcompile.h>
45
46
47/** @defgroup grp_rt_formats_pdbg Microsoft Program Database (PDB) structures and definitions.
48 * @ingroup grp_rt_formats
49 * @{
50 */
51
52/** @name PDB 1.0
53 *
54 * This is just a type info database, rather than an abstract streams container
55 * like in version 2.0 and later.
56 *
57 * @note Seen in EX04.PDB shipping with Visual C++ 1.5.
58 * @{ */
59/** The PDB 1.00 signature. */
60#define RTPDB_SIGNATURE_100 "Microsoft C/C++ program database 1.00\r\n\x1A" "JG\0"
61
62/**
63 * The PDB 1.0 header.
64 */
65typedef struct RTPDB10HDR
66{
67 /** The signature string. */
68 uint8_t szSignature[sizeof(RTPDB_SIGNATURE_100)];
69 /** The compiler version (RTDBG10HDR_VERSION_XXX). */
70 uint32_t uVersion;
71 /** PDB timestamp/signature. */
72 uint32_t uTimestamp;
73 /** PDB age. */
74 uint32_t uAge;
75 /** The index of the first TI record. */
76 uint16_t idxTypeInfoFirst;
77 /** The index of the last TI records + 1. */
78 uint16_t idxTypeInfoEnd;
79 /** The size of the hashed type info records following this header. */
80 uint32_t cbTypeInfo;
81 /* Following are cbTypeInfo bytes worth of hashed type info (RTPDB10HASHEDTI). */
82} RTPDB10HDR;
83AssertCompileSize(RTPDB10HDR, 64);
84typedef RTPDB10HDR *PRTPDB10HDR;
85typedef RTPDB10HDR const *PCRTPDB10HDR;
86
87/** Typical RTPDB10HDR::uVersion value. */
88#define RTDBG10HDR_VERSION_VC10 UINT32_C(920924) /* 0x000e0d5c */
89
90/** PDB 1.0 hashed type info records. */
91typedef struct RTPDB10HASHEDTI
92{
93 uint16_t uHash;
94 uint8_t cbInfo;
95 RT_FLEXIBLE_ARRAY_EXTENSION
96 uint8_t abData[RT_FLEXIBLE_ARRAY];
97} RTPDB10HASHEDTI;
98typedef RTPDB10HASHEDTI *PRTPDB10HASHEDTI;
99typedef RTPDB10HASHEDTI const *PCRTPDB10HASHEDTI;
100
101/** @} */
102
103
104/** @name PDB 2.0
105 *
106 * This was presumably introduced with Visual C++ v2.0.
107 *
108 * @{ */
109/** A PDB 2.0 Page number. */
110typedef uint16_t RTPDB20PAGE;
111/** Pointer to a PDB 2.0 Page number. */
112typedef RTPDB20PAGE *PRTPDB20PAGE;
113/** Pointer to a const PDB 2.0 Page number. */
114typedef RTPDB20PAGE const *PCRTPDB20PAGE;
115
116/**
117 * A PDB 2.0 stream.
118 */
119typedef struct RTPDB20STREAM
120{
121 /** The size of the stream. */
122 uint32_t cbStream;
123 /** Some unknown value. */
124 uint32_t u32Unknown;
125} RTPDB20STREAM;
126typedef RTPDB20STREAM *PRTPDB20STREAM;
127
128/** The PDB 2.00 signature. */
129#define RTPDB_SIGNATURE_200 "Microsoft C/C++ program database 2.00\r\n\x1A" "JG\0"
130/**
131 * The PDB 2.0 header.
132 */
133typedef struct RTPDB20HDR
134{
135 /** The signature string. */
136 uint8_t szSignature[sizeof(RTPDB_SIGNATURE_200)];
137 /** The page size. */
138 uint32_t cbPage;
139 /** The start page - whatever that is... */
140 RTPDB20PAGE iStartPage;
141 /** The number of pages in the file. */
142 RTPDB20PAGE cPages;
143 /** The root stream directory. */
144 RTPDB20STREAM RootStream;
145 /** The root page table. */
146 RT_FLEXIBLE_ARRAY_EXTENSION
147 RTPDB20PAGE aiRootPageMap[RT_FLEXIBLE_ARRAY];
148} RTPDB20HDR;
149AssertCompileMemberOffset(RTPDB20HDR, aiRootPageMap, 60);
150typedef RTPDB20HDR *PRTPDB20HDR;
151typedef RTPDB20HDR const *PCRTPDB20HDR;
152
153/**
154 * The PDB 2.0 root directory.
155 */
156typedef struct RTPDB20ROOT
157{
158 /** The number of streams */
159 uint16_t cStreams;
160 /** Reserved or high part of cStreams. */
161 uint16_t u16Reserved;
162 /** Array of streams. */
163 RT_FLEXIBLE_ARRAY_EXTENSION
164 RTPDB20STREAM aStreams[RT_FLEXIBLE_ARRAY];
165} RTPDB20ROOT;
166typedef RTPDB20ROOT *PRTPDB20ROOT;
167typedef RTPDB20ROOT const *PCRTPDB20ROOT;
168
169/**
170 * The PDB 2.0 name stream (#1) header.
171 */
172typedef struct RTPDB20NAMES
173{
174 /** The structure version (RTPDB20NAMES_VERSION_XXX). */
175 uint32_t uVersion;
176 /** Timestamp or similar to help uniquely identify the PDB. */
177 uint32_t uTimestamp;
178 /** PDB file age. */
179 uint32_t uAge;
180 /** The size of the following name table. */
181 uint32_t cbNames;
182#if 0
183 /** The name table. */
184 RT_FLEXIBLE_ARRAY_EXTENSION
185 char szzNames[RT_FLEXIBLE_ARRAY];
186 /* Followed by ID to string table mappings. */
187 uint32_t cbIdMap;
188#endif
189} RTPDB20NAMES;
190AssertCompileSize(RTPDB20NAMES, 16);
191typedef RTPDB20NAMES *PRTPDB20NAMES;
192typedef RTPDB20NAMES const *PCRTPDB20NAMES;
193
194/** The version / magic of the names structure for Visual C++ v2.0. */
195#define RTPDB20NAMES_VERSION_VC20 UINT32_C(19941610)
196/** The version / magic of the names structure for Visual C++ v4.0. */
197#define RTPDB20NAMES_VERSION_VC40 UINT32_C(19950623)
198/** The version / magic of the names structure for Visual C++ v4.1. */
199#define RTPDB20NAMES_VERSION_VC41 UINT32_C(19950814)
200/** The version / magic of the names structure for Visual C++ v5.0. */
201#define RTPDB20NAMES_VERSION_VC50 UINT32_C(19960307)
202
203/** The version / magic of the names structure for Visual C++ v6.0.
204 * @note This is the only one tested. */
205#define RTPDB20NAMES_VERSION_VC60 UINT32_C(19970604)
206
207/** @} */
208
209
210/** @name PDB 7.0
211 * @{ */
212
213/** A PDB 7.0 Page number. */
214typedef uint32_t RTPDB70PAGE;
215/** Pointer to a PDB 7.0 Page number. */
216typedef RTPDB70PAGE *PRTPDB70PAGE;
217/** Pointer to a const PDB 7.0 Page number. */
218typedef RTPDB70PAGE const *PCRTPDB70PAGE;
219
220/**
221 * A PDB 7.0 stream.
222 */
223typedef struct RTPDB70STREAM
224{
225 /** The size of the stream. */
226 uint32_t cbStream;
227} RTPDB70STREAM;
228typedef RTPDB70STREAM *PRTPDB70STREAM;
229
230
231/** The PDB 7.00 signature. */
232#define RTPDB_SIGNATURE_700 "Microsoft C/C++ MSF 7.00\r\n\x1A" "DS\0\0"
233/**
234 * The PDB 7.0 header.
235 */
236typedef struct RTPDB70HDR
237{
238 /** The signature string. */
239 uint8_t szSignature[sizeof(RTPDB_SIGNATURE_700)];
240 /** The page size. */
241 uint32_t cbPage;
242 /** The start page. */
243 RTPDB70PAGE iStartPage;
244 /** The number of pages in the file. */
245 RTPDB70PAGE cPages;
246 /** The root stream directory. */
247 uint32_t cbRoot;
248 /** Unknown function, always 0. */
249 uint32_t u32Reserved;
250 /** The page index of the root page table. */
251 RTPDB70PAGE iRootPages;
252} RTPDB70HDR;
253AssertCompileSize(RTPDB70HDR, 56);
254typedef RTPDB70HDR *PRTPDB70HDR;
255typedef RTPDB70HDR const *PCRTPDB70HDR;
256
257/**
258 * The PDB 7.0 root directory.
259 */
260typedef struct RTPDB70ROOT
261{
262 /** The number of streams */
263 uint32_t cStreams;
264 /** Array of streams. */
265 RT_FLEXIBLE_ARRAY_EXTENSION
266 RTPDB70STREAM aStreams[RT_FLEXIBLE_ARRAY];
267 /* RTPDB70PAGE aiPages[] */
268} RTPDB70ROOT;
269AssertCompileMemberOffset(RTPDB70ROOT, aStreams, 4);
270typedef RTPDB70ROOT *PRTPDB70ROOT;
271typedef RTPDB70ROOT const *PCRTPDB70ROOT;
272
273/**
274 * The PDB 7.0 name stream (#1) header.
275 */
276#pragma pack(4)
277typedef struct RTPDB70NAMES
278{
279 /** The structure version (typically RTPDB70NAMES_VERSION). */
280 uint32_t uVersion;
281 /** PDB creation timestamp. */
282 uint32_t uTimestamp;
283 /** PDB age. */
284 uint32_t uAge;
285 /** PDB unique identifier. */
286 RTUUID Uuid;
287
288 /** The size of the following name table. */
289 uint32_t cbNames;
290#if 0
291 /** The name table. */
292 RT_FLEXIBLE_ARRAY_EXTENSION
293 char szzNames[RT_FLEXIBLE_ARRAY];
294 /* Followed by ID to string table mappings. */
295 uint32_t cbIdMap;
296 /* ... */
297#endif
298} RTPDB70NAMES;
299#pragma pack()
300AssertCompileSize(RTPDB70NAMES, 12 + 16 + 4);
301typedef RTPDB70NAMES *PRTPDB70NAMES;
302typedef RTPDB70NAMES const *PCRTPDB70NAMES;
303
304/** The version / magic of the names structure.
305 * This is for VC++ v7.0. It's technically possible it may have other values,
306 * like 19990604 (v7.0 dep), 20030901 (v8.0), 20091201 (v11.0), or 20140508
307 * (v14.0), but these haven't been encountered yet. */
308#define RTPDB70NAMES_VERSION UINT32_C(20000404)
309
310/** @} */
311
312/**
313 * Helper for converting a stream size to a page count.
314 *
315 * @returns Number of pages.
316 * @param cbStream The stream size.
317 * @param cbPage The page size (must not be zero).
318 */
319DECLINLINE(uint32_t) RTPdbSizeToPages(uint32_t cbStream, uint32_t cbPage)
320{
321 if (cbStream == UINT32_MAX || !cbStream)
322 return 0;
323 return (uint32_t)(((uint64_t)cbStream + cbPage - 1) / cbPage);
324}
325
326
327/**
328 * This is the old DBI stream header.
329 *
330 * @note Haven't found any examples of this yet, as it must predate VC60, quite
331 * likely VC40 was the last to use it. It may need padding adjusting as
332 * well as a reality check...
333 */
334typedef struct RTPDBDBIHDROLD
335{
336 /** The global symbol records stream number. */
337 uint16_t idxGlobalStream;
338 /** The public symbol records stream number. */
339 uint16_t idxPublicStream;
340 /** The symbol records stream. */
341 uint16_t idxSymRecStream;
342 /** Haven't seen the real thing yet... The struct could be misaligned by
343 * pragma pack(1)... */
344 uint16_t uUnusedPadding;
345 /** Size of the module info substream. */
346 uint32_t cbModInfoSubstream;
347 /** Size of the section contribution substream. */
348 uint32_t cbSectContribSubstream;
349 /** Size of the source info substream. */
350 uint32_t cbSrcInfoSubstream;
351} RTPDBDBIHDROLD;
352
353
354/**
355 * The new DBI stream header.
356 */
357typedef struct RTPDBDBIHDR
358{
359 /** 0x00: Header signature, RTPDBDBIHDR_SIGNATURE.
360 * This has the value UINT32_MAX which probably to make sure it can be
361 * distinguished from the start of the old header, assuming the global and/or
362 * public stream indexes won't both be NIL (UINT16_MAX). */
363 uint32_t uSignature;
364 /** 0x04: The header version signature, RTPDBDBIHDR_VCVER_XXX.
365 * This should be RTPDBDBIHDR_VCVER_50 or higher, even if Visual C++ 4.1 in
366 * the RTPDBDBIHDR_VCVER_XXX collection. */
367 uint32_t uVcVersion;
368 /** 0x08: Same (copy) of RTPDB70NAMES::uAge / RTPDB20NAMES::uAge. */
369 uint32_t uAge;
370 /** 0x0c: The global symbol records stream number. */
371 uint16_t idxGlobalStream;
372 /** 0x0e: The MSPDB*.DLL version.
373 * This is a bitfield with two different layout. If the new format is used,
374 * the RBuild is stored separately as uPdbDllRBuild
375 *
376 * @note In the w2ksp4 PDBs this is all zeros. So, was presumably added
377 * after VC60. Ditto for the two other version/build fields.
378 *
379 * In a random 32-bit xp rtm kernel it's set to 0x8800 (8.0, new format),
380 * and with uPdbDllBuild=0xc627 (50727) and uPdbDllRBuild=0x0048 (72).
381 *
382 * For a VBoxRT.dll built with VC 2010 this is set to 0x8a00 (10.0, new
383 * format), uPdbDllBuild=0x6f76 (28534) and uPdbDllRBuild=0x0001. */
384 union
385 {
386 uint16_t u16;
387 struct
388 {
389 RT_GCC_EXTENSION
390 uint16_t uMinor : 8;
391 RT_GCC_EXTENSION
392 uint16_t uMajor : 7;
393 RT_GCC_EXTENSION
394 uint16_t fNewVerFmt : 1;
395 } New;
396 struct
397 {
398 RT_GCC_EXTENSION
399 uint16_t uRBuild : 4;
400 RT_GCC_EXTENSION
401 uint16_t uMinor : 7;
402 RT_GCC_EXTENSION
403 uint16_t uMajor : 5;
404 } Old;
405 } PdbDllVer;
406 /** 0x10: The public symbol records stream number. */
407 uint16_t idxPublicStream;
408 /** 0x12: The MSPDB*.DLL build number. */
409 uint16_t uPdbDllBuild;
410 /** 0x14: The symbol records stream. */
411 uint16_t idxSymRecStream;
412 /** 0x16: The MSPDB*.DLL rbuild number, whatever that is... (Release build
413 * number, perhaps?) */
414 uint16_t uPdbDllRBuild;
415 /** 0x18: Size of the module info substream. */
416 uint32_t cbModInfoSubstream;
417 /** 0x1c: Size of the section contribution substream. */
418 uint32_t cbSectContribSubstream;
419 /** 0x20: Size of the section map substream. */
420 uint32_t cbSectionMapSubstream;
421 /** 0x24: Size of the source info substream. */
422 uint32_t cbSrcInfoSubstream;
423 /** 0x28: Size of the type server map substream. */
424 uint32_t cbTypeServerMapSubstream;
425 /** 0x2c: Index of the MFC type server in the type server map substream. */
426 uint32_t idxMFC;
427 /** 0x30: Size of the optional debug header at the end of the stream. */
428 uint32_t cbOptDbgHdr;
429 /** 0x34: Size of the edit & continue substream. Added in VC60, can contain
430 * garbage when uVcVersion is older. */
431 uint32_t cbEditContinueSubstream;
432 /** 0x38: Flat, combination of RTPDBDBIHDR_F_XXX. */
433 uint16_t fFlags;
434 /** 0x3a: The machine type (IMAGE_FILE_MACHINE_XXX from pecoff). */
435 uint16_t uMachine;
436 /** 0x3c: Currently unused field. */
437 uint32_t uReserved;
438} RTPDBDBIHDR;
439AssertCompileSize(RTPDBDBIHDR,64);
440
441/** The value of RTPDBDBIHDR::uSignature. */
442#define RTPDBDBIHDR_SIGNATURE UINT32_MAX
443
444/** @name RTPDBDBIHDR_VCVER_XXX - Possible RTPDBDBIHDR::uVcVersion values.
445 * @{ */
446#define RTPDBDBIHDR_VCVER RTPDBDBIHDR_VCVER_70
447#define RTPDBDBIHDR_VCVER_41 UINT32_C( 930803) /**< Apparently too old for the new header. Go figure. */
448#define RTPDBDBIHDR_VCVER_50 UINT32_C(19960307)
449#define RTPDBDBIHDR_VCVER_60 UINT32_C(19970606) /**< Used by Windows 2000 SP4 PDBs.*/
450#define RTPDBDBIHDR_VCVER_70 UINT32_C(19990903)
451#define RTPDBDBIHDR_VCVER_110 UINT32_C(20091201)
452/** @} */
453
454/** @name RTPDBDBIHDR_F_XXX - DBI Header Flags.
455 * @{ */
456#define RTPDBDBIHDR_F_INCREMENTAL_LINK UINT16_C(0x0001)
457#define RTPDBDBIHDR_F_PRIVATE_SYMS_STRIPPED UINT16_C(0x0002)
458#define RTPDBDBIHDR_F_CONFLICTING_TYPES UINT16_C(0x0004)
459#define RTPDBDBIHDR_F_RESERVED UINT16_C(0xfff8)
460/** @} */
461
462
463/** @name RTPDBDBIOPT_IDX_XXX - DBI Optional Header Indexes.
464 *
465 * The optional DBI header follows after the edit & continue substream and
466 * consists of an array of 16-bit stream indexes (uint16_t) that helps
467 * identifying streams in the PDB.
468 *
469 * @{ */
470/** Frame pointer optimization sections ('.debug$F' from MASM, apparently). */
471#define RTPDBDBIOPT_IDX_FPO_MASM 0
472/** Exception data - IMAGE_DEBUG_TYPE_EXCEPTION. */
473#define RTPDBDBIOPT_IDX_EXCEPTION 1
474/** Fixup data - IMAGE_DEBUG_TYPE_FIXUP. */
475#define RTPDBDBIOPT_IDX_FIXUP 2
476/** OMAP to source - IMAGE_DEBUG_TYPE_OMAP_TO_SRC. */
477#define RTPDBDBIOPT_IDX_OMAP_TO_SRC 3
478/** OMAP from source - IMAGE_DEBUG_TYPE_OMAP_FROM_SRC. */
479#define RTPDBDBIOPT_IDX_OMAP_FROM_SRC 4
480/** Section headers from the executable (array of IMAGE_SECTION_HEADER). */
481#define RTPDBDBIOPT_IDX_SECTION_HEADERS 5
482/** Something related to mapping CLR tokens to CLR record IDs. */
483#define RTPDBDBIOPT_IDX_CLR_TOKEN_ID_MAP 6
484/** Copy of the '.xdata' section. */
485#define RTPDBDBIOPT_IDX_XDATA 7
486/** Copy of the '.pdata' section. (Same purpose as RTPDBDBIOPT_IDX_EXCEPTION?) */
487#define RTPDBDBIOPT_IDX_PDATA 8
488/** Frame pointer optimization info - IMAGE_DEBUG_TYPE_FPO. */
489#define RTPDBDBIOPT_IDX_FPO 9
490/** Original section headers from the executable (array of IMAGE_SECTION_HEADER). */
491#define RTPDBDBIOPT_IDX_ORG_SECTION_HEADERS 10
492
493/** End of known indexes. */
494#define RTPDBDBIOPT_IDX_END 11
495/** @} */
496
497/** @} */
498
499#endif /* !IPRT_INCLUDED_formats_pdb_h */
500
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette