This repository has been archived by the owner on Apr 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 271
/
pdb.h
1733 lines (1495 loc) · 68.2 KB
/
pdb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Debug Information API
// Copyright (C) Microsoft Corporation. All Rights Reserved.
#pragma once
#ifndef _VC_VER_INC
#include "vcver.h"
#endif
#pragma warning(push)
#pragma warning(disable:4201)
#ifndef __PDB_INCLUDED__
#define __PDB_INCLUDED__
typedef int BOOL;
typedef unsigned UINT;
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned __int64 DWORDLONG;
typedef unsigned short USHORT;
typedef unsigned long ULONG;
typedef ULONG INTV; // interface version number
typedef ULONG IMPV; // implementation version number
typedef ULONG SIG; // unique (across PDB instances) signature
typedef ULONG AGE; // no. of times this instance has been updated
typedef const char* SZ_CONST; // const string
typedef void * PV;
typedef const void * PCV;
#if defined(__midl)
cpp_quote("#ifndef GUID_DEFINED")
cpp_quote("#define GUID_DEFINED")
typedef struct _GUID { // size is 16
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[8];
} GUID;
cpp_quote("#endif")
#else // defined(__midl)
#ifndef GUID_DEFINED
#define GUID_DEFINED
typedef struct _GUID { // size is 16
DWORD Data1;
WORD Data2;
WORD Data3;
BYTE Data4[8];
} GUID;
#endif // !GUID_DEFINED
#endif // defined(__midl)
#ifndef _HRESULT_DEFINED
#define _HRESULT_DEFINED
typedef long HRESULT;
#endif // !_HRESULT_DEFINED
typedef GUID SIG70; // new to 7.0 are 16-byte guid-like signatures
typedef SIG70 * PSIG70;
typedef const SIG70 * PCSIG70;
#if defined(__midl)
cpp_quote("#ifndef _WCHAR_T_DEFINED")
typedef unsigned short wchar_t;
cpp_quote("#define _WCHAR_T_DEFINED")
cpp_quote("#endif")
#else
#ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
#define _WCHAR_T_DEFINED
#endif
#endif
#if !defined(__midl)
enum PDBINTV {
PDBIntv110 = 20091201,
PDBIntv80 = 20030901,
PDBIntv70 = 20001102,
PDBIntv70Dep = 20000406,
PDBIntv69 = 19990511,
PDBIntv61 = 19980914,
PDBIntv50a = 19970116,
PDBIntv60 = PDBIntv50a,
PDBIntv50 = 19960502,
PDBIntv41 = 920924,
PDBIntv = PDBIntv110,
};
enum PDBIMPV {
PDBImpvVC2 = 19941610,
PDBImpvVC4 = 19950623,
PDBImpvVC41 = 19950814,
PDBImpvVC50 = 19960307,
PDBImpvVC98 = 19970604,
PDBImpvVC70 = 20000404,
PDBImpvVC70Dep = 19990604, // deprecated vc70 implementation version
PDBImpvVC80 = 20030901,
PDBImpvVC110 = 20091201,
PDBImpvVC140 = 20140508,
PDBImpv = PDBImpvVC110,
};
enum PDBConsts {
niNil = 0,
PDB_MAX_PATH = 260,
cbErrMax = 1024,
};
#endif
// cvinfo.h type index, intentionally typedef'ed here to check equivalence.
typedef unsigned short CV_typ16_t;
typedef unsigned long CV_typ_t;
typedef unsigned long CV_pubsymflag_t; // must be same as CV_typ_t.
typedef CV_typ_t TI; // PDB name for type index
typedef CV_typ16_t TI16; // 16-bit version
typedef unsigned long NI; // name index
typedef TI * PTi;
typedef TI16 * PTi16;
typedef BYTE ITSM; // type server map index
typedef ITSM* PITSM;
typedef BOOL (__stdcall *PFNVALIDATEDEBUGINFOFILE) (const char * szFile, ULONG * errcode );
#if !defined(__midl)
typedef struct _tagSEARCHDEBUGINFO {
DWORD cb; // doubles as version detection
BOOL fMainDebugFile; // indicates "core" or "ancilliary" file
// eg: main.exe has main.pdb and foo.lib->foo.pdb
char * szMod; // exe/dll
char * szLib; // lib if appropriate
char * szObj; // object file
char * *rgszTriedThese; // list of ones that were tried,
// NULL terminated list of LSZ's
char szValidatedFile[PDB_MAX_PATH];// output of validated filename,
PFNVALIDATEDEBUGINFOFILE
pfnValidateDebugInfoFile; // validation function
char * szExe; // exe/dll
} SEARCHDEBUGINFO, *PSEARCHDEBUGINFO;
typedef BOOL ( __stdcall * PfnFindDebugInfoFile) ( PSEARCHDEBUGINFO );
#endif
#define PdbInterface struct
PdbInterface PDB; // program database
PdbInterface DBI; // debug information within the PDB
PdbInterface Mod; // a module within the DBI
PdbInterface TPI; // type info within the DBI
PdbInterface GSI; // global symbol info
PdbInterface SO;
PdbInterface Stream; // some named bytestream in the PDB
PdbInterface StreamImage; // some memory mapped stream
PdbInterface NameMap; // name mapping
PdbInterface Enum; // generic enumerator
PdbInterface EnumNameMap; // enumerate names within a NameMap
PdbInterface EnumContrib; // enumerate contributions
PdbInterface Dbg; // misc debug data (FPO, OMAP, etc)
PdbInterface Src; // Src file data
PdbInterface EnumSrc; // Src file enumerator
PdbInterface SrcHash; // Src file hasher
PdbInterface EnumLines;
PdbInterface EnumThunk;
PdbInterface EnumSyms;
#if !defined(__midl)
typedef PdbInterface PDB PDB;
typedef PdbInterface DBI DBI;
typedef PdbInterface Mod Mod;
typedef PdbInterface TPI TPI;
typedef PdbInterface GSI GSI;
typedef PdbInterface SO SO;
typedef PdbInterface Stream Stream;
typedef PdbInterface StreamImage StreamImage;
typedef PdbInterface NameMap NameMap;
typedef PdbInterface Enum Enum;
typedef PdbInterface EnumStreamNames EnumStreamNames;
typedef PdbInterface EnumNameMap EnumNameMap;
typedef PdbInterface EnumContrib EnumContrib;
typedef PdbInterface EnumSyms EnumSyms;
typedef PdbInterface WidenTi WidenTi;
typedef PdbInterface Dbg Dbg;
typedef PdbInterface EnumThunk EnumThunk;
typedef PdbInterface Src Src;
typedef PdbInterface EnumSrc EnumSrc;
typedef PdbInterface SrcHash SrcHash;
typedef PdbInterface EnumLines EnumLines;
typedef PdbInterface EnumThunk EnumThunk;
typedef PdbInterface EnumSyms EnumSyms;
#endif // !__midl
typedef PdbInterface SrcHash * PSrcHash;
typedef long EC; // error code
#if !defined(__midl)
enum PDBErrors {
EC_OK, // no problem
EC_USAGE, // invalid parameter or call order
EC_OUT_OF_MEMORY, // out of heap
EC_FILE_SYSTEM, // "pdb name", can't write file, out of disk, etc.
EC_NOT_FOUND, // "pdb name", PDB file not found
EC_INVALID_SIG, // "pdb name", PDB::OpenValidate() and its clients only
EC_INVALID_AGE, // "pdb name", PDB::OpenValidate() and its clients only
EC_PRECOMP_REQUIRED, // "obj name", Mod::AddTypes() only
EC_OUT_OF_TI, // "pdb name", TPI::QueryTiForCVRecord() only
EC_NOT_IMPLEMENTED, // -
EC_V1_PDB, // "pdb name", PDB::Open* only (obsolete)
EC_UNKNOWN_FORMAT = EC_V1_PDB, // pdb can't be opened because it has newer versions of stuff
EC_FORMAT, // accessing pdb with obsolete format
EC_LIMIT,
EC_CORRUPT, // cv info corrupt, recompile mod
EC_TI16, // no 16-bit type interface present
EC_ACCESS_DENIED, // "pdb name", PDB file read-only
EC_ILLEGAL_TYPE_EDIT, // trying to edit types in read-only mode
EC_INVALID_EXECUTABLE, // not recogized as a valid executable
EC_DBG_NOT_FOUND, // A required .DBG file was not found
EC_NO_DEBUG_INFO, // No recognized debug info found
EC_INVALID_EXE_TIMESTAMP, // Invalid timestamp on Openvalidate of exe
EC_CORRUPT_TYPEPOOL, // A corrupted type record was found in a PDB
EC_DEBUG_INFO_NOT_IN_PDB, // returned by OpenValidateX
EC_RPC, // Error occured during RPC
EC_UNKNOWN, // Unknown error
EC_BAD_CACHE_PATH, // bad cache location specified with symsrv
EC_CACHE_FULL, // symsrv cache is full
EC_TOO_MANY_MOD_ADDTYPE, // Addtype is called more then once per mod
EC_MAX
};
#endif
#if !defined(pure)
#define pure = 0
#endif
#ifndef PDBCALL
#define PDBCALL __cdecl
#endif
#ifdef PDB_SERVER
#define PDB_IMPORT_EXPORT(RTYPE) __declspec(dllexport) RTYPE PDBCALL
#elif defined(PDB_LIBRARY)
#define PDB_IMPORT_EXPORT(RTYPE) RTYPE PDBCALL
#else
#define PDB_IMPORT_EXPORT(RTYPE) __declspec(dllimport) RTYPE PDBCALL
#endif
#define PDBAPI PDB_IMPORT_EXPORT
#ifndef IN
#define IN /* in parameter, parameters are IN by default */
#endif
#ifndef OUT
#define OUT /* out parameter */
#endif
// Type of callback arg to PDB::OpenValidate5
#if !defined(__midl)
enum POVC
{
povcNotifyDebugDir,
povcNotifyOpenDBG,
povcNotifyOpenPDB,
povcReserved,
povcReadExecutableAt,
povcReadExecutableAtRVA,
povcRestrictRegistry,
povcRestrictSymsrv,
povcRestrictSystemRoot,
povcNotifyMiscPath,
povcReadMiscDebugData,
povcReadCodeViewDebugData,
povcRestrictOriginalPath,
povcRestrictReferencePath,
povcRestrictDBG
};
typedef int (PDBCALL *PDBCALLBACK)();
typedef PDBCALLBACK (PDBCALL *PfnPDBQueryCallback)(void *pvClient, enum POVC povc);
typedef void (PDBCALL *PfnPDBNotifyDebugDir)(void *pvClient, BOOL fExecutable, const struct _IMAGE_DEBUG_DIRECTORY *pdbgdir);
typedef void (PDBCALL *PfnPDBNotifyOpenDBG)(void *pvClient, const wchar_t *wszDbgPath, EC ec, const wchar_t *wszError);
typedef void (PDBCALL *PfnPDBNotifyOpenPDB)(void *pvClient, const wchar_t *wszPdbPath, EC ec, const wchar_t *wszError);
typedef HRESULT (PDBCALL *PfnPDBReadExecutableAt)(void *pvClient, DWORDLONG fo, DWORD cb, void *pv);
typedef HRESULT (PDBCALL *PfnPDBReadExecutableAtRVA)(void *pvClient, DWORD rva, DWORD cb, void *pv);
typedef HRESULT (PDBCALL *PfnPDBRestrictRegistry)(void *pvClient);
typedef HRESULT (PDBCALL *PfnPDBRestrictSymsrv)(void *pvClient);
typedef HRESULT (PDBCALL *PfnPDBRestrictSystemRoot)(void *pvClient);
typedef void (PDBCALL *PfnPDBNotifyMiscPath)(void *pvClient, const wchar_t *wszMiscPath);
typedef HRESULT (PDBCALL *PfnPDBReadCodeViewDebugData)(void *pvClient, DWORD *pcb, void *pv);
typedef HRESULT (PDBCALL *PfnPDBReadMiscDebugData)(void *pvClient, DWORD *pdwTimeStampExe, DWORD *pdwTimeStampDbg, DWORD *pdwSizeOfImage, DWORD *pcb, void *pv);
typedef HRESULT (PDBCALL *PfnPdbRestrictOriginalPath)(void *pvClient);
typedef HRESULT (PDBCALL *PfnPdbRestrictReferencePath)(void *pvClient);
typedef HRESULT (PDBCALL *PfnPdbRestrictDBG) (void *pvClient);
// type of callback arg to PDB::GetRawBytes
typedef BOOL (PDBCALL *PFNfReadPDBRawBytes)(const void *, long);
// type of callback arg to DBI::FSetPfn*
enum DOVC
{
dovcNotePdbUsed,
dovcNoteTypeMismatch,
dovcTmdTypeFilter,
};
typedef int (PDBCALL *DBICALLBACK)();
typedef DBICALLBACK (PDBCALL *PFNDBIQUERYCALLBACK)(void *pvContext, enum DOVC dovc);
typedef void (__cdecl *PFNNOTEPDBUSED)(
void * pvContext,
const wchar_t * szFile,
BOOL fRead,
BOOL fWrite);
typedef void (__cdecl *PFNNOTETYPEMISMATCH)(
void * pvContext,
const wchar_t * szTypeName,
const wchar_t * szInfo);
typedef BOOL (__cdecl *PFNTMDTYPEFILTER)(
void * pvContext,
const wchar_t * szUDT);
// interface for error reporting
typedef struct IPDBError
#if defined(__cplusplus)
{
virtual EC QueryLastError( _Out_opt_z_cap_(cchMax) wchar_t * szError, size_t cchMax) pure;
virtual void SetLastError(EC ec, const wchar_t * wszErr) pure;
virtual void Destroy() pure;
}
#endif
IPDBError;
typedef IPDBError * (PDBCALL *PfnPDBErrorCreate)(PDB *ppdb);
// WidenTi interface needs a couple of structures to communicate info back
// and forth.
struct OffMap {
ULONG offOld;
ULONG offNew;
};
typedef struct OffMap OffMap;
typedef OffMap * POffMap;
struct SymConvertInfo {
ULONG cbSyms; // size necessary for converting a block
ULONG cSyms; // count of symbols, necessary to allocate
// mpoffOldoffNew array.
BYTE * pbSyms; // block of symbols (output side)
OffMap * rgOffMap; // OffMap rgOffMap[cSyms]
};
typedef struct SymConvertInfo SymConvertInfo;
enum { wtiSymsNB09 = 0, wtiSymsNB10 = 1 };
// Filter values for PDBCopyTo
enum {
copyRemovePrivate = 0x00000001, // remove private debug information
copyCreateNewSig = 0x00000002, // create new signature for target pdb
copyKeepAnnotation = 0x00000004, // keep S_ANNOTATION symbols, filtering on the first string
copyKeepAnnotation2 = 0x00000008, // keep S_ANNOTATION symbols, filtering on both the first and last strings
copyRemoveNamedStream = 0x00000010, // remove named stream only
};
// PDBCopy callback signatures and function pointer types for PDB::CopyTo2 and CopyToW2
//
enum PCC {
pccFilterPublics,
pccFilterAnnotations,
pccFilterStreamNames,
};
#if !defined(__cplusplus)
typedef enum PCC PCC;
#endif // __cplusplus
typedef BOOL (PDBCALL *PDBCOPYCALLBACK)();
typedef PDBCOPYCALLBACK (PDBCALL *PfnPDBCopyQueryCallback)(void *pvClientContext, PCC pcc);
// Return (true, pszNewPublic==NULL) to keep the name as is,
// (true, pszNewPublic!=NULL) changes name to pszNewPublic,
// false to discard public entirely.
//
typedef BOOL (PDBCALL *PfnPDBCopyFilterPublics)(
void * pvClientContext,
DWORD dwFilterFlags,
unsigned int offPublic,
unsigned int sectPublic,
unsigned int grfPublic, // see cvinfo.h, definition of CV_PUBSYMFLAGS_e and
// CV_PUBSYMFLAGS give the format of this bitfield.
const wchar_t * szPublic,
wchar_t * szNewPublic,
unsigned int cchNewPublic
);
// Return true to keep the annotation, false to discard it.
//
typedef BOOL (PDBCALL *PfnPDBCopyFilterAnnotations)(
void * pvClientContext,
const wchar_t * szFirstAnnotation
);
// Return true to delete the named stream, false to keep it.
//
typedef BOOL (PDBCALL *PfnPDBCopyFilterStreamNames)(
void * pvClientContext,
const wchar_t * szStream
);
enum DBGTYPE {
dbgtypeFPO,
dbgtypeException, // deprecated
dbgtypeFixup,
dbgtypeOmapToSrc,
dbgtypeOmapFromSrc,
dbgtypeSectionHdr,
dbgtypeTokenRidMap,
dbgtypeXdata,
dbgtypePdata,
dbgtypeNewFPO,
dbgtypeSectionHdrOrig,
dbgtypeMax // must be last!
};
typedef enum DBGTYPE DBGTYPE;
// We add a slight bit of structure to dbg blobs so we can record extra
// relevant information there. Generally, the blobs are lifted right out
// of an image, and need some extra info anyway. In the case of Xdata, we
// store RVA base of the Xdata there. This is used to interpret the
// UnwindInfoAddress RVA in the IA64 Pdata entries.
//
enum VerDataBlob {
vdbOne = 1,
vdbXdataCur = vdbOne,
vdbPdataCur = vdbOne,
};
// default blob header
//
typedef struct DbgBlob {
ULONG ver;
ULONG cbHdr;
ULONG cbData;
//BYTE rgbDataBlob[]; // Data follows, but to enable simple embedding,
// don't use a zero-sized array here.
} DbgBlob;
// "store rva of the base and va of image base" blob header
//
typedef struct DbgRvaVaBlob {
ULONG ver;
ULONG cbHdr;
ULONG cbData;
ULONG rvaDataBase;
DWORDLONG vaImageBase;
ULONG ulReserved1; // reserved, must be 0
ULONG ulReserved2; // reserved, must be 0
//BYTE rgbDataBlob[]; // Data follows, but to enable simple embedding,
// don't use a zero-sized array here.
} DbgRvaVaBlob;
// Linker data necessary for relinking an image. Record contains two SZ strings
// off of the end of the record with two offsets from the base
//
enum VerLinkInfo {
vliOne = 1,
vliTwo = 2,
vliCur = vliTwo,
};
struct LinkInfo {
ULONG cb; // size of the whole record. computed as
// sizeof(LinkInfo) + strlen(szCwd) + 1 +
// strlen(szCommand) + 1
ULONG ver; // version of this record (VerLinkInfo)
ULONG offszCwd; // offset from base of this record to szCwd
ULONG offszCommand; // offset from base of this record
ULONG ichOutfile; // index of start of output file in szCommand
ULONG offszLibs; // offset from base of this record to szLibs
// The command includes the full path to the linker, the -re and -out:...
// swithches.
// A sample might look like the following:
// "c:\program files\msdev\bin\link.exe -re -out:debug\foo.exe"
// with ichOutfile being 48.
// the -out switch is guaranteed to be the last item in the command line.
#ifdef __cplusplus
VerLinkInfo Ver() const {
return VerLinkInfo(ver);
}
long Cb() const {
return cb;
}
char * SzCwd() const {
return (char *)((char *)(this) + offszCwd);
}
char * SzCommand() const {
return (char *)((char *)(this) + offszCommand);
}
char * SzOutFile() const {
return SzCommand() + ichOutfile;
}
LinkInfo() :
cb(0), ver(vliCur), offszCwd(0), offszCommand(0), ichOutfile(0)
{
}
char * SzLibs() const {
return (char *)((char *)(this) + offszLibs);
}
#endif
};
#ifdef __cplusplus
struct LinkInfoW : public LinkInfo
{
wchar_t* SzCwdW() const {
return (wchar_t *)((wchar_t *)(this) + offszCwd);
}
wchar_t* SzCommandW() const {
return (wchar_t *)((wchar_t *)(this) + offszCommand);
}
wchar_t* SzOutFileW() const {
return SzCommandW() + ichOutfile;
}
wchar_t* SzLibsW() const {
return (wchar_t *)((wchar_t *)(this) + offszLibs);
}
};
#else
typedef struct LinkInfo LinkInfoW;
#endif // __cplusplus
typedef LinkInfoW * PLinkInfoW;
typedef struct LinkInfo LinkInfo;
typedef LinkInfo * PLinkInfo;
//
// Source (Src) info
//
// This is the source file server for virtual and real source code.
// It is structured as an index on the object file name concatenated
// with
enum SrcVer {
srcverOne = 19980827,
};
enum SrcCompress {
srccompressNone,
srccompressRLE,
srccompressHuffman,
srccompressLZ,
};
struct SrcHeader {
unsigned long cb; // record length
unsigned long ver; // header version
unsigned long sig; // CRC of the data for uniqueness w/o full compare
unsigned long cbSource; // count of bytes of the resulting source
unsigned char srccompress;// compression algorithm used
union {
unsigned char grFlags;
struct {
unsigned char fVirtual : 1; // file is a virtual file (injected)
unsigned char pad : 7; // must be zero
};
};
unsigned char szNames[1]; // file names (szFile "\0" szObj "\0" szVirtual,
// as in: "f.cpp" "\0" "f.obj" "\0" "*inj:1:f.obj")
// in the case of non-virtual files, szVirtual is
// the same as szFile.
};
typedef struct SrcHeader SrcHeader;
typedef SrcHeader * PSrcHeader;
typedef const SrcHeader * PCSrcHeader;
struct SrcHeaderW {
unsigned long cb; // record length
unsigned long ver; // header version
unsigned long sig; // CRC of the data for uniqueness w/o full compare
unsigned long cbSource; // count of bytes of the resulting source
unsigned char srccompress;// compression algorithm used
union {
unsigned char grFlags;
struct {
unsigned char fVirtual : 1; // file is a virtual file (injected)
unsigned char pad : 7; // must be zero
};
};
wchar_t szNames[1]; // see comment above
};
typedef struct SrcHeaderW SrcHeaderW;
typedef SrcHeaderW * PSrcHeaderW;
typedef const SrcHeaderW * PCSrcHeaderW;
// cassert(offsetof(SrcHeader,szNames) == offsetof(SrcHeaderW,szNames));
// header used for storing the info and for output to clients who are reading
//
struct SrcHeaderOut {
unsigned long cb; // record length
unsigned long ver; // header version
unsigned long sig; // CRC of the data for uniqueness w/o full compare
unsigned long cbSource; // count of bytes of the resulting source
unsigned long niFile;
unsigned long niObj;
unsigned long niVirt;
unsigned char srccompress;// compression algorithm used
union {
unsigned char grFlags;
struct {
unsigned char fVirtual : 1; // file is a virtual file (injected)
unsigned char pad : 7; // must be zero
};
};
short sPad;
union {
void * pvReserved1;
__int64 pv64Reserved2;
};
};
typedef struct SrcHeaderOut SrcHeaderOut;
typedef SrcHeaderOut * PSrcHeaderOut;
typedef const SrcHeaderOut *PCSrcHeaderOut;
struct SrcHeaderBlock {
__int32 ver;
__int32 cb;
struct {
DWORD dwLowDateTime;
DWORD dwHighDateTime;
} ft;
__int32 age;
BYTE rgbPad[44];
};
typedef struct SrcHeaderBlock SrcHeaderBlock;
struct SO {
long off;
USHORT isect;
unsigned short pad;
};
#endif // !defined(__midl)
#ifdef __cplusplus
struct IStream;
// C++ Binding
PdbInterface PDB { // program database
enum {
intv = PDBIntv,
intvVC80 = PDBIntv80,
intvVC70 = PDBIntv70,
intvVC70Dep = PDBIntv70Dep, // deprecated
};
static PDBAPI(BOOL)
Open2W(
_In_z_ const wchar_t *wszPDB,
_In_z_ const char *szMode,
OUT EC *pec,
_Out_opt_cap_(cchErrMax) OUT wchar_t *wszError,
size_t cchErrMax,
OUT PDB **pppdb);
static PDBAPI(BOOL)
OpenEx2W(
_In_z_ const wchar_t *wszPDB,
_In_z_ const char *szMode,
long cbPage,
OUT EC *pec,
_Out_opt_cap_(cchErrMax) OUT wchar_t *wszError,
size_t cchErrMax,
OUT PDB **pppdb);
static PDBAPI(BOOL)
OpenValidate4(
_In_z_ const wchar_t *wszPDB,
_In_z_ const char *szMode,
PCSIG70 pcsig70,
SIG sig,
AGE age,
OUT EC *pec,
_Out_opt_cap_(cchErrMax) OUT wchar_t *wszError,
size_t cchErrMax,
OUT PDB **pppdb);
static PDBAPI(BOOL)
OpenValidate5(
_In_z_ const wchar_t *wszExecutable,
_In_z_ const wchar_t *wszSearchPath,
void *pvClient,
PfnPDBQueryCallback pfnQueryCallback,
OUT EC *pec,
_Out_opt_cap_(cchErrMax) OUT wchar_t *wszError,
size_t cchErrMax,
OUT PDB **pppdb);
static PDBAPI(BOOL) OpenInStream(
IStream *pIStream,
_In_z_ const char *szMode,
OUT EC *pec,
_Out_opt_cap_(cchErrMax) OUT wchar_t *wszError,
size_t cchErrMax,
OUT PDB **pppdb);
static PDBAPI(BOOL)
OpenNgenPdb(
_In_z_ const wchar_t *wszNgenImage,
_In_z_ const wchar_t *wszPdbPath,
OUT EC *pec,
_Out_opt_cap_(cchErrMax) OUT wchar_t *wszError,
size_t cchErrMax,
OUT PDB **pppdb);
static PDBAPI(BOOL) ExportValidateInterface(INTV intv);
static PDBAPI(BOOL) ExportValidateImplementation(IMPV impv);
static PDBAPI(IMPV) QueryImplementationVersionStatic();
static PDBAPI(INTV) QueryInterfaceVersionStatic();
static PDBAPI(BOOL) SetErrorHandlerAPI(PfnPDBErrorCreate pfn);
static PDBAPI(BOOL) SetPDBCloseTimeout(DWORDLONG t);
static PDBAPI(BOOL) ShutDownTimeoutManager( );
static PDBAPI(BOOL) CloseAllTimeoutPDB();
static PDBAPI(BOOL) RPC();
virtual INTV QueryInterfaceVersion() pure;
virtual IMPV QueryImplementationVersion() pure;
virtual EC QueryLastError(_Out_opt_cap_(cbErrMax) OUT char szError[cbErrMax]) pure;
virtual char*QueryPDBName(_Out_opt_z_cap_(PDB_MAX_PATH) OUT char szPDB[PDB_MAX_PATH]) pure;
virtual SIG QuerySignature() pure;
virtual AGE QueryAge() pure;
virtual BOOL CreateDBI(_In_z_ const char* szTarget, OUT DBI** ppdbi) pure;
virtual BOOL OpenDBI(_In_z_ const char* szTarget, _In_z_ const char* szMode, OUT DBI** ppdbi ) pure;
virtual BOOL OpenTpi(_In_z_ const char* szMode, OUT TPI** pptpi) pure;
virtual BOOL OpenIpi(_In_z_ const char* szMode, OUT TPI** pptpi) pure;
virtual BOOL Commit() pure;
virtual BOOL Close() pure;
virtual BOOL OpenStream(_In_z_ const char* szStream, OUT Stream** ppstream) pure;
virtual BOOL GetEnumStreamNameMap(OUT Enum** ppenum) pure;
virtual BOOL GetRawBytes(PFNfReadPDBRawBytes pfnfSnarfRawBytes) pure;
virtual IMPV QueryPdbImplementationVersion() pure;
virtual BOOL OpenDBIEx(_In_z_ const char* szTarget, _In_z_ const char* szMode, OUT DBI** ppdbi, PfnFindDebugInfoFile pfn=0) pure;
virtual BOOL CopyTo( _Pre_notnull_ _Post_z_ const char *szDst, DWORD dwCopyFilter, DWORD dwReserved) pure;
//
// support for source file data
//
virtual BOOL OpenSrc(OUT Src** ppsrc) pure;
virtual EC QueryLastErrorExW(_Out_opt_cap_(cchMax) OUT wchar_t *wszError, size_t cchMax) pure;
virtual wchar_t *QueryPDBNameExW(_Out_opt_cap_(cchMax) OUT wchar_t *wszPDB, size_t cchMax) pure;
virtual BOOL QuerySignature2(PSIG70 psig70) pure;
virtual BOOL CopyToW( _Pre_notnull_ _Post_z_ const wchar_t *szDst, DWORD dwCopyFilter, DWORD dwReserved) pure;
virtual BOOL fIsSZPDB() const pure;
// Implemented only on 7.0 and above versions.
//
virtual BOOL OpenStreamW(_In_z_ const wchar_t * szStream, OUT Stream** ppstream) pure;
// Implemented in both 6.0 and 7.0 builds
virtual BOOL CopyToW2(
_In_z_ const wchar_t * szDst,
DWORD dwCopyFilter,
PfnPDBCopyQueryCallback pfnCallBack,
void * pvClientContext
) pure;
inline BOOL ValidateInterface()
{
return ExportValidateInterface(intv);
}
virtual BOOL OpenStreamEx(_In_z_ const char * szStream, _In_z_ const char *szMode, Stream **ppStream) pure;
// Support for PDB mapping
virtual BOOL RegisterPDBMapping(_In_z_ const wchar_t *wszPDBFrom, _In_z_ const wchar_t *wszPDBTo) pure;
virtual BOOL EnablePrefetching() pure;
virtual BOOL FLazy() pure;
virtual BOOL FMinimal() pure;
virtual BOOL ResetGUID(BYTE *pb, DWORD cb) pure;
};
// Review: a stream directory service would be more appropriate
// than Stream::Delete, ...
PdbInterface Stream {
virtual long QueryCb() pure;
virtual BOOL Read(long off, void* pvBuf, long* pcbBuf) pure;
virtual BOOL Write(long off, void* pvBuf, long cbBuf) pure;
virtual BOOL Replace(void* pvBuf, long cbBuf) pure;
virtual BOOL Append(void* pvBuf, long cbBuf) pure;
virtual BOOL Delete() pure;
virtual BOOL Release() pure;
virtual BOOL Read2(long off, void* pvBuf, long cbBuf) pure;
virtual BOOL Truncate(long cb) pure;
};
PdbInterface StreamImage {
static PDBAPI(BOOL) open(Stream* pstream, long cb, OUT StreamImage** ppsi);
virtual long size() pure;
virtual void* base() pure;
virtual BOOL noteRead(long off, long cb, OUT void** ppv) pure;
virtual BOOL noteWrite(long off, long cb, OUT void** ppv) pure;
virtual BOOL writeBack() pure;
virtual BOOL release() pure;
};
PdbInterface DBI { // debug information
enum { intv = PDBIntv };
virtual IMPV QueryImplementationVersion() pure;
virtual INTV QueryInterfaceVersion() pure;
virtual BOOL OpenMod(_In_z_ const char* szModule, _In_z_ const char* szFile, OUT Mod** ppmod) pure;
virtual BOOL DeleteMod(_In_z_ const char* szModule) pure;
virtual BOOL QueryNextMod(Mod* pmod, Mod** ppmodNext) pure;
virtual BOOL OpenGlobals(OUT GSI **ppgsi) pure;
virtual BOOL OpenPublics(OUT GSI **ppgsi) pure;
virtual BOOL AddSec(USHORT isect, USHORT flags, long off, long cb) pure;
//__declspec(deprecated)
virtual BOOL QueryModFromAddr(USHORT isect, long off, OUT Mod** ppmod,
OUT USHORT* pisect, OUT long* poff, OUT long* pcb) pure;
virtual BOOL QuerySecMap(OUT BYTE* pb, long* pcb) pure;
virtual BOOL QueryFileInfo(OUT BYTE* pb, long* pcb) pure;
virtual void DumpMods() pure;
virtual void DumpSecContribs() pure;
virtual void DumpSecMap() pure;
virtual BOOL Close() pure;
virtual BOOL AddThunkMap(long* poffThunkMap, unsigned nThunks, long cbSizeOfThunk,
struct SO* psoSectMap, unsigned nSects,
USHORT isectThunkTable, long offThunkTable) pure;
virtual BOOL AddPublic(_In_z_ const char* szPublic, USHORT isect, long off) pure;
virtual BOOL getEnumContrib(OUT Enum** ppenum) pure;
virtual BOOL QueryTypeServer( ITSM itsm, OUT TPI** pptpi ) pure;
virtual BOOL QueryItsmForTi( TI ti, OUT ITSM* pitsm ) pure;
virtual BOOL QueryNextItsm( ITSM itsm, OUT ITSM *inext ) pure;
virtual BOOL QueryLazyTypes() pure;
virtual BOOL SetLazyTypes( BOOL fLazy ) pure; // lazy is default and can only be turned off
virtual BOOL FindTypeServers( OUT EC* pec, _Out_opt_cap_(cbErrMax) OUT char szError[cbErrMax] ) pure;
virtual void DumpTypeServers() pure;
virtual BOOL OpenDbg(DBGTYPE dbgtype, OUT Dbg **ppdbg) pure;
virtual BOOL QueryDbgTypes(OUT DBGTYPE *pdbgtype, OUT long* pcDbgtype) pure;
// apis to support EnC work
virtual BOOL QueryAddrForSec(OUT USHORT* pisect, OUT long* poff,
USHORT imod, long cb, DWORD dwDataCrc, DWORD dwRelocCrc) pure;
virtual BOOL QueryAddrForSecEx(OUT USHORT* pisect, OUT long* poff, USHORT imod,
long cb, DWORD dwDataCrc, DWORD dwRelocCrc, DWORD dwCharacteristics) pure;
virtual BOOL QuerySupportsEC() pure;
virtual BOOL QueryPdb( OUT PDB** pppdb ) pure;
virtual BOOL AddLinkInfo(IN PLinkInfo ) pure;
virtual BOOL QueryLinkInfo(PLinkInfo, OUT long * pcb) pure;
// new to vc6
virtual AGE QueryAge() const pure;
virtual void * QueryHeader() const pure;
virtual void FlushTypeServers() pure;
virtual BOOL QueryTypeServerByPdb(_In_z_ const char* szPdb, OUT ITSM* pitsm) pure;
// Long filename support
virtual BOOL OpenModW(_In_z_ const wchar_t* szModule, _In_z_ const wchar_t* szFile, OUT Mod** ppmod) pure;
virtual BOOL DeleteModW(_In_z_ const wchar_t* szModule) pure;
virtual BOOL AddPublicW(_In_z_ const wchar_t* szPublic, USHORT isect, long off, CV_pubsymflag_t cvpsf =0) pure;
virtual BOOL QueryTypeServerByPdbW(_In_z_ const wchar_t* szPdb, OUT ITSM* pitsm ) pure;
virtual BOOL AddLinkInfoW(IN PLinkInfoW ) pure;
virtual BOOL AddPublic2(_In_z_ const char* szPublic, USHORT isect, long off, CV_pubsymflag_t cvpsf =0) pure;
virtual USHORT QueryMachineType() const pure;
virtual void SetMachineType(USHORT wMachine) pure;
virtual void RemoveDataForRva( ULONG rva, ULONG cb ) pure;
virtual BOOL FStripped() pure;
virtual BOOL QueryModFromAddr2(USHORT isect, long off, OUT Mod** ppmod,
OUT USHORT* pisect, OUT long* poff, OUT long* pcb,
OUT ULONG * pdwCharacteristics) pure;
// Replacement for QueryNextMod() and QueryModFromAddr()
virtual BOOL QueryNoOfMods(long *cMods) pure;
virtual BOOL QueryMods(Mod **ppmodNext, long cMods) pure;
virtual BOOL QueryImodFromAddr(USHORT isect, long off, OUT USHORT* pimod,
OUT USHORT* pisect, OUT long* poff, OUT long* pcb,
OUT ULONG * pdwCharacteristics) pure;
virtual BOOL OpenModFromImod( USHORT imod, OUT Mod **ppmod ) pure;
virtual BOOL QueryHeader2(long cb, OUT BYTE * pb, OUT long * pcbOut) pure;
virtual BOOL FAddSourceMappingItem(
_In_z_ const wchar_t * szMapTo,
_In_z_ const wchar_t * szMapFrom,
ULONG grFlags // must be zero; no flags defn'ed as yet
) pure;
typedef ::PFNNOTEPDBUSED PFNNOTEPDBUSED;
virtual BOOL FSetPfnNotePdbUsed(void * pvContext, PFNNOTEPDBUSED) pure;
virtual BOOL FCTypes() pure;
virtual BOOL QueryFileInfo2(BYTE *pb, long *pcb) pure;
virtual BOOL FSetPfnQueryCallback(void *pvContext, PFNDBIQUERYCALLBACK) pure;
typedef ::PFNNOTETYPEMISMATCH PFNNOTETYPEMISMATCH;
virtual BOOL FSetPfnNoteTypeMismatch(void * pvContext, PFNNOTETYPEMISMATCH) pure;
typedef ::PFNTMDTYPEFILTER PFNTMDTYPEFILTER;
virtual BOOL FSetPfnTmdTypeFilter(void *pvContext, PFNTMDTYPEFILTER) pure;
virtual BOOL RemovePublic(_In_z_ const char* szPublic) pure;
virtual BOOL getEnumContrib2(OUT Enum** ppenum) pure;
virtual BOOL QueryModFromAddrEx(USHORT isect, ULONG off, OUT Mod** ppmod,
OUT USHORT* pisect, OUT ULONG *pisectCoff, OUT ULONG* poff, OUT ULONG* pcb,
OUT ULONG * pdwCharacteristics) pure;
virtual BOOL QueryImodFromAddrEx(USHORT isect, ULONG off, OUT USHORT* pimod,
OUT USHORT* pisect, OUT ULONG *pisectCoff, OUT ULONG* poff, OUT ULONG* pcb,
OUT ULONG * pdwCharacteristics) pure;
};
PdbInterface Mod { // info for one module within DBI
enum { intv = PDBIntv };
virtual INTV QueryInterfaceVersion() pure;
virtual IMPV QueryImplementationVersion() pure;
virtual BOOL AddTypes(BYTE* pbTypes, long cb) pure;
virtual BOOL AddSymbols(BYTE* pbSym, long cb) pure;
virtual BOOL AddPublic(_In_z_ const char* szPublic, USHORT isect, long off) pure;
virtual BOOL AddLines(_In_z_ const char* szSrc, USHORT isect, long offCon, long cbCon, long doff,
USHORT lineStart, BYTE* pbCoff, long cbCoff) pure;
virtual BOOL AddSecContrib(USHORT isect, long off, long cb, ULONG dwCharacteristics) pure;
virtual BOOL QueryCBName(OUT long* pcb) pure;
virtual BOOL QueryName(_Out_z_cap_(PDB_MAX_PATH) OUT char szName[PDB_MAX_PATH], OUT long* pcb) pure;
virtual BOOL QuerySymbols(BYTE* pbSym, long* pcb) pure;
virtual BOOL QueryLines(BYTE* pbLines, long* pcb) pure;
virtual BOOL SetPvClient(void *pvClient) pure;
virtual BOOL GetPvClient(OUT void** ppvClient) pure;
virtual BOOL QueryFirstCodeSecContrib(OUT USHORT* pisect, OUT long* poff, OUT long* pcb, OUT ULONG* pdwCharacteristics) pure;
//
// Make all users of this api use the real one, as this is exactly what it was
// supposed to query in the first place
//
#define QuerySecContrib QueryFirstCodeSecContrib
virtual BOOL QueryImod(OUT USHORT* pimod) pure;
virtual BOOL QueryDBI(OUT DBI** ppdbi) pure;
virtual BOOL Close() pure;
virtual BOOL QueryCBFile(OUT long* pcb) pure;
virtual BOOL QueryFile(_Out_z_cap_(PDB_MAX_PATH) OUT char szFile[PDB_MAX_PATH], OUT long* pcb) pure;
virtual BOOL QueryTpi(OUT TPI** pptpi) pure; // return this Mod's Tpi
// apis to support EnC work
virtual BOOL AddSecContribEx(USHORT isect, long off, long cb, ULONG dwCharacteristics, DWORD dwDataCrc, DWORD dwRelocCrc) pure;
virtual BOOL QueryItsm(OUT USHORT* pitsm) pure;
virtual BOOL QuerySrcFile(_Out_z_cap_(PDB_MAX_PATH) OUT char szFile[PDB_MAX_PATH], OUT long* pcb) pure;
virtual BOOL QuerySupportsEC() pure;