Home | History | Annotate | Download | only in util
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the w64 mingw-runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef _DBGHELP_
      7 #define _DBGHELP_
      8 
      9 #ifdef _WIN64
     10 #ifndef _IMAGEHLP64
     11 #define _IMAGEHLP64
     12 #endif
     13 #endif
     14 
     15 #ifdef __cplusplus
     16 extern "C" {
     17 #endif
     18 
     19 #define IMAGEAPI DECLSPEC_IMPORT WINAPI
     20 #define DBHLP_DEPRECIATED __declspec(deprecated)
     21 
     22 #define DBHLPAPI IMAGEAPI
     23 
     24 #define IMAGE_SEPARATION (64*1024)
     25 
     26   typedef struct _LOADED_IMAGE {
     27     PSTR ModuleName;
     28     HANDLE hFile;
     29     PUCHAR MappedAddress;
     30 #ifdef _IMAGEHLP64
     31     PIMAGE_NT_HEADERS64 FileHeader;
     32 #else
     33     PIMAGE_NT_HEADERS32 FileHeader;
     34 #endif
     35     PIMAGE_SECTION_HEADER LastRvaSection;
     36     ULONG NumberOfSections;
     37     PIMAGE_SECTION_HEADER Sections;
     38     ULONG Characteristics;
     39     BOOLEAN fSystemImage;
     40     BOOLEAN fDOSImage;
     41     LIST_ENTRY Links;
     42     ULONG SizeOfImage;
     43   } LOADED_IMAGE,*PLOADED_IMAGE;
     44 
     45 #define MAX_SYM_NAME 2000
     46 
     47   typedef BOOL (CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(HANDLE FileHandle,PSTR FileName,PVOID CallerData);
     48   typedef BOOL (CALLBACK *PFINDFILEINPATHCALLBACK)(PSTR filename,PVOID context);
     49   typedef BOOL (CALLBACK *PFIND_EXE_FILE_CALLBACK)(HANDLE FileHandle,PSTR FileName,PVOID CallerData);
     50 
     51   typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(LPCSTR,LPCSTR,PVOID,DWORD,DWORD,LPSTR);
     52   typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID);
     53   typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID);
     54   typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR,ULONG64);
     55   typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action,ULONG64 data,ULONG64 context);
     56   typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)();
     57   typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(LPCSTR);
     58 
     59   HANDLE IMAGEAPI FindDebugInfoFile(PSTR FileName,PSTR SymbolPath,PSTR DebugFilePath);
     60   HANDLE IMAGEAPI FindDebugInfoFileEx(PSTR FileName,PSTR SymbolPath,PSTR DebugFilePath,PFIND_DEBUG_FILE_CALLBACK Callback,PVOID CallerData);
     61   BOOL IMAGEAPI SymFindFileInPath(HANDLE hprocess,LPSTR SearchPath,LPSTR FileName,PVOID id,DWORD two,DWORD three,DWORD flags,LPSTR FoundFile,PFINDFILEINPATHCALLBACK callback,PVOID context);
     62   HANDLE IMAGEAPI FindExecutableImage(PSTR FileName,PSTR SymbolPath,PSTR ImageFilePath);
     63   HANDLE IMAGEAPI FindExecutableImageEx(PSTR FileName,PSTR SymbolPath,PSTR ImageFilePath,PFIND_EXE_FILE_CALLBACK Callback,PVOID CallerData);
     64   PIMAGE_NT_HEADERS IMAGEAPI ImageNtHeader(PVOID Base);
     65   PVOID IMAGEAPI ImageDirectoryEntryToDataEx(PVOID Base,BOOLEAN MappedAsImage,USHORT DirectoryEntry,PULONG Size,PIMAGE_SECTION_HEADER *FoundHeader);
     66   PVOID IMAGEAPI ImageDirectoryEntryToData(PVOID Base,BOOLEAN MappedAsImage,USHORT DirectoryEntry,PULONG Size);
     67   PIMAGE_SECTION_HEADER IMAGEAPI ImageRvaToSection(PIMAGE_NT_HEADERS NtHeaders,PVOID Base,ULONG Rva);
     68   PVOID IMAGEAPI ImageRvaToVa(PIMAGE_NT_HEADERS NtHeaders,PVOID Base,ULONG Rva,PIMAGE_SECTION_HEADER *LastRvaSection);
     69 
     70 #define SSRVOPT_CALLBACK 0x0001
     71 #define SSRVOPT_DWORD 0x0002
     72 #define SSRVOPT_DWORDPTR 0x0004
     73 #define SSRVOPT_GUIDPTR 0x0008
     74 #define SSRVOPT_OLDGUIDPTR 0x0010
     75 #define SSRVOPT_UNATTENDED 0x0020
     76 #define SSRVOPT_NOCOPY 0x0040
     77 #define SSRVOPT_PARENTWIN 0x0080
     78 #define SSRVOPT_PARAMTYPE 0x0100
     79 #define SSRVOPT_SECURE 0x0200
     80 #define SSRVOPT_TRACE 0x0400
     81 #define SSRVOPT_SETCONTEXT 0x0800
     82 #define SSRVOPT_PROXY 0x1000
     83 #define SSRVOPT_DOWNSTREAM_STORE 0x2000
     84 #define SSRVOPT_RESET ((ULONG_PTR)-1)
     85 
     86 #define SSRVACTION_TRACE 1
     87 #define SSRVACTION_QUERYCANCEL 2
     88 #define SSRVACTION_EVENT 3
     89 
     90 #ifndef _WIN64
     91 
     92   typedef struct _IMAGE_DEBUG_INFORMATION {
     93     LIST_ENTRY List;
     94     DWORD ReservedSize;
     95     PVOID ReservedMappedBase;
     96     USHORT ReservedMachine;
     97     USHORT ReservedCharacteristics;
     98     DWORD ReservedCheckSum;
     99     DWORD ImageBase;
    100     DWORD SizeOfImage;
    101     DWORD ReservedNumberOfSections;
    102     PIMAGE_SECTION_HEADER ReservedSections;
    103     DWORD ReservedExportedNamesSize;
    104     PSTR ReservedExportedNames;
    105     DWORD ReservedNumberOfFunctionTableEntries;
    106     PIMAGE_FUNCTION_ENTRY ReservedFunctionTableEntries;
    107     DWORD ReservedLowestFunctionStartingAddress;
    108     DWORD ReservedHighestFunctionEndingAddress;
    109     DWORD ReservedNumberOfFpoTableEntries;
    110     PFPO_DATA ReservedFpoTableEntries;
    111     DWORD SizeOfCoffSymbols;
    112     PIMAGE_COFF_SYMBOLS_HEADER CoffSymbols;
    113     DWORD ReservedSizeOfCodeViewSymbols;
    114     PVOID ReservedCodeViewSymbols;
    115     PSTR ImageFilePath;
    116     PSTR ImageFileName;
    117     PSTR ReservedDebugFilePath;
    118     DWORD ReservedTimeDateStamp;
    119     BOOL ReservedRomImage;
    120     PIMAGE_DEBUG_DIRECTORY ReservedDebugDirectory;
    121     DWORD ReservedNumberOfDebugDirectories;
    122     DWORD ReservedOriginalFunctionTableBaseAddress;
    123     DWORD Reserved[2 ];
    124   } IMAGE_DEBUG_INFORMATION,*PIMAGE_DEBUG_INFORMATION;
    125 
    126   PIMAGE_DEBUG_INFORMATION IMAGEAPI MapDebugInformation(HANDLE FileHandle,PSTR FileName,PSTR SymbolPath,DWORD ImageBase);
    127   BOOL IMAGEAPI UnmapDebugInformation(PIMAGE_DEBUG_INFORMATION DebugInfo);
    128 #endif
    129 
    130   typedef BOOL (CALLBACK *PENUMDIRTREE_CALLBACK)(LPCSTR FilePath,PVOID CallerData);
    131 
    132   BOOL IMAGEAPI SearchTreeForFile(PSTR RootPath,PSTR InputPathName,PSTR OutputPathBuffer);
    133   BOOL IMAGEAPI EnumDirTree(HANDLE hProcess,PSTR RootPath,PSTR InputPathName,PSTR OutputPathBuffer,PENUMDIRTREE_CALLBACK Callback,PVOID CallbackData);
    134   BOOL IMAGEAPI MakeSureDirectoryPathExists(PCSTR DirPath);
    135 
    136 #define UNDNAME_COMPLETE (0x0000)
    137 #define UNDNAME_NO_LEADING_UNDERSCORES (0x0001)
    138 #define UNDNAME_NO_MS_KEYWORDS (0x0002)
    139 #define UNDNAME_NO_FUNCTION_RETURNS (0x0004)
    140 #define UNDNAME_NO_ALLOCATION_MODEL (0x0008)
    141 #define UNDNAME_NO_ALLOCATION_LANGUAGE (0x0010)
    142 #define UNDNAME_NO_MS_THISTYPE (0x0020)
    143 #define UNDNAME_NO_CV_THISTYPE (0x0040)
    144 #define UNDNAME_NO_THISTYPE (0x0060)
    145 #define UNDNAME_NO_ACCESS_SPECIFIERS (0x0080)
    146 #define UNDNAME_NO_THROW_SIGNATURES (0x0100)
    147 #define UNDNAME_NO_MEMBER_TYPE (0x0200)
    148 #define UNDNAME_NO_RETURN_UDT_MODEL (0x0400)
    149 #define UNDNAME_32_BIT_DECODE (0x0800)
    150 #define UNDNAME_NAME_ONLY (0x1000)
    151 #define UNDNAME_NO_ARGUMENTS (0x2000)
    152 #define UNDNAME_NO_SPECIAL_SYMS (0x4000)
    153 
    154   DWORD IMAGEAPI WINAPI UnDecorateSymbolName(PCSTR DecoratedName,PSTR UnDecoratedName,DWORD UndecoratedLength,DWORD Flags);
    155 
    156 #define DBHHEADER_DEBUGDIRS 0x1
    157 
    158   typedef struct _MODLOAD_DATA {
    159     DWORD ssize;
    160     DWORD ssig;
    161     PVOID data;
    162     DWORD size;
    163     DWORD flags;
    164   } MODLOAD_DATA,*PMODLOAD_DATA;
    165 
    166   typedef enum {
    167     AddrMode1616,AddrMode1632,AddrModeReal,AddrModeFlat
    168   } ADDRESS_MODE;
    169 
    170   typedef struct _tagADDRESS64 {
    171     DWORD64 Offset;
    172     WORD Segment;
    173     ADDRESS_MODE Mode;
    174   } ADDRESS64,*LPADDRESS64;
    175 
    176 #ifdef _IMAGEHLP64
    177 #define ADDRESS ADDRESS64
    178 #define LPADDRESS LPADDRESS64
    179 #else
    180   typedef struct _tagADDRESS {
    181     DWORD Offset;
    182     WORD Segment;
    183     ADDRESS_MODE Mode;
    184   } ADDRESS,*LPADDRESS;
    185 
    186   static __inline void Address32To64(LPADDRESS a32,LPADDRESS64 a64) {
    187     a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset;
    188     a64->Segment = a32->Segment;
    189     a64->Mode = a32->Mode;
    190   }
    191 
    192   static __inline void Address64To32(LPADDRESS64 a64,LPADDRESS a32) {
    193     a32->Offset = (ULONG)a64->Offset;
    194     a32->Segment = a64->Segment;
    195     a32->Mode = a64->Mode;
    196   }
    197 #endif
    198 
    199   typedef struct _KDHELP64 {
    200     DWORD64 Thread;
    201     DWORD ThCallbackStack;
    202     DWORD ThCallbackBStore;
    203     DWORD NextCallback;
    204     DWORD FramePointer;
    205     DWORD64 KiCallUserMode;
    206     DWORD64 KeUserCallbackDispatcher;
    207     DWORD64 SystemRangeStart;
    208     DWORD64 Reserved[8];
    209   } KDHELP64,*PKDHELP64;
    210 
    211 #ifdef _IMAGEHLP64
    212 #define KDHELP KDHELP64
    213 #define PKDHELP PKDHELP64
    214 #else
    215   typedef struct _KDHELP {
    216     DWORD Thread;
    217     DWORD ThCallbackStack;
    218     DWORD NextCallback;
    219     DWORD FramePointer;
    220     DWORD KiCallUserMode;
    221     DWORD KeUserCallbackDispatcher;
    222     DWORD SystemRangeStart;
    223     DWORD ThCallbackBStore;
    224     DWORD Reserved[8];
    225   } KDHELP,*PKDHELP;
    226 
    227   static __inline void KdHelp32To64(PKDHELP p32,PKDHELP64 p64) {
    228     p64->Thread = p32->Thread;
    229     p64->ThCallbackStack = p32->ThCallbackStack;
    230     p64->NextCallback = p32->NextCallback;
    231     p64->FramePointer = p32->FramePointer;
    232     p64->KiCallUserMode = p32->KiCallUserMode;
    233     p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher;
    234     p64->SystemRangeStart = p32->SystemRangeStart;
    235   }
    236 #endif
    237 
    238   typedef struct _tagSTACKFRAME64 {
    239     ADDRESS64 AddrPC;
    240     ADDRESS64 AddrReturn;
    241     ADDRESS64 AddrFrame;
    242     ADDRESS64 AddrStack;
    243     ADDRESS64 AddrBStore;
    244     PVOID FuncTableEntry;
    245     DWORD64 Params[4];
    246     BOOL Far;
    247     BOOL Virtual;
    248     DWORD64 Reserved[3];
    249     KDHELP64 KdHelp;
    250   } STACKFRAME64,*LPSTACKFRAME64;
    251 
    252 #ifdef _IMAGEHLP64
    253 #define STACKFRAME STACKFRAME64
    254 #define LPSTACKFRAME LPSTACKFRAME64
    255 #else
    256   typedef struct _tagSTACKFRAME {
    257     ADDRESS AddrPC;
    258     ADDRESS AddrReturn;
    259     ADDRESS AddrFrame;
    260     ADDRESS AddrStack;
    261     PVOID FuncTableEntry;
    262     DWORD Params[4];
    263     BOOL Far;
    264     BOOL Virtual;
    265     DWORD Reserved[3];
    266     KDHELP KdHelp;
    267     ADDRESS AddrBStore;
    268   } STACKFRAME,*LPSTACKFRAME;
    269 #endif
    270 
    271   typedef BOOL (WINAPI *PREAD_PROCESS_MEMORY_ROUTINE64)(HANDLE hProcess,DWORD64 qwBaseAddress,PVOID lpBuffer,DWORD nSize,LPDWORD lpNumberOfBytesRead);
    272   typedef PVOID (WINAPI *PFUNCTION_TABLE_ACCESS_ROUTINE64)(HANDLE hProcess,DWORD64 AddrBase);
    273   typedef DWORD64 (WINAPI *PGET_MODULE_BASE_ROUTINE64)(HANDLE hProcess,DWORD64 Address);
    274   typedef DWORD64 (WINAPI *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE hProcess,HANDLE hThread,LPADDRESS64 lpaddr);
    275 
    276   BOOL IMAGEAPI StackWalk64(DWORD MachineType,HANDLE hProcess,HANDLE hThread,LPSTACKFRAME64 StackFrame,PVOID ContextRecord,PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
    277 
    278 #ifdef _IMAGEHLP64
    279 #define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64
    280 #define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64
    281 #define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64
    282 #define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64
    283 #define StackWalk StackWalk64
    284 #else
    285   typedef BOOL (WINAPI *PREAD_PROCESS_MEMORY_ROUTINE)(HANDLE hProcess,DWORD lpBaseAddress,PVOID lpBuffer,DWORD nSize,PDWORD lpNumberOfBytesRead);
    286   typedef PVOID (WINAPI *PFUNCTION_TABLE_ACCESS_ROUTINE)(HANDLE hProcess,DWORD AddrBase);
    287   typedef DWORD (WINAPI *PGET_MODULE_BASE_ROUTINE)(HANDLE hProcess,DWORD Address);
    288   typedef DWORD (WINAPI *PTRANSLATE_ADDRESS_ROUTINE)(HANDLE hProcess,HANDLE hThread,LPADDRESS lpaddr);
    289 
    290   BOOL IMAGEAPI StackWalk(DWORD MachineType,HANDLE hProcess,HANDLE hThread,LPSTACKFRAME StackFrame,PVOID ContextRecord,PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine,PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine,PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine,PTRANSLATE_ADDRESS_ROUTINE TranslateAddress);
    291 #endif
    292 
    293 #define API_VERSION_NUMBER 9
    294 
    295   typedef struct API_VERSION {
    296     USHORT MajorVersion;
    297     USHORT MinorVersion;
    298     USHORT Revision;
    299     USHORT Reserved;
    300   } API_VERSION,*LPAPI_VERSION;
    301 
    302   LPAPI_VERSION IMAGEAPI ImagehlpApiVersion(VOID);
    303   LPAPI_VERSION IMAGEAPI ImagehlpApiVersionEx(LPAPI_VERSION AppVersion);
    304   DWORD IMAGEAPI GetTimestampForLoadedLibrary(HMODULE Module);
    305 
    306   typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(PSTR ModuleName,DWORD64 BaseOfDll,PVOID UserContext);
    307   typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(PSTR SymbolName,DWORD64 SymbolAddress,ULONG SymbolSize,PVOID UserContext);
    308   typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(PWSTR SymbolName,DWORD64 SymbolAddress,ULONG SymbolSize,PVOID UserContext);
    309   typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(PSTR ModuleName,DWORD64 ModuleBase,ULONG ModuleSize,PVOID UserContext);
    310   typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(HANDLE hProcess,ULONG ActionCode,ULONG64 CallbackData,ULONG64 UserContext);
    311   typedef PVOID (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(HANDLE hProcess,DWORD AddrBase,PVOID UserContext);
    312   typedef PVOID (CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(HANDLE hProcess,ULONG64 AddrBase,ULONG64 UserContext);
    313 
    314 #ifdef _IMAGEHLP64
    315 #define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64
    316 #define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64
    317 #define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W
    318 #define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64
    319 #define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64
    320 #define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64
    321 #else
    322   typedef BOOL (CALLBACK *PSYM_ENUMMODULES_CALLBACK)(PSTR ModuleName,ULONG BaseOfDll,PVOID UserContext);
    323   typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(PSTR SymbolName,ULONG SymbolAddress,ULONG SymbolSize,PVOID UserContext);
    324   typedef BOOL (CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(PWSTR SymbolName,ULONG SymbolAddress,ULONG SymbolSize,PVOID UserContext);
    325   typedef BOOL (CALLBACK *PENUMLOADED_MODULES_CALLBACK)(PSTR ModuleName,ULONG ModuleBase,ULONG ModuleSize,PVOID UserContext);
    326   typedef BOOL (CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(HANDLE hProcess,ULONG ActionCode,PVOID CallbackData,PVOID UserContext);
    327 #endif
    328 
    329 #define SYMFLAG_VALUEPRESENT 0x00000001
    330 #define SYMFLAG_REGISTER 0x00000008
    331 #define SYMFLAG_REGREL 0x00000010
    332 #define SYMFLAG_FRAMEREL 0x00000020
    333 #define SYMFLAG_PARAMETER 0x00000040
    334 #define SYMFLAG_LOCAL 0x00000080
    335 #define SYMFLAG_CONSTANT 0x00000100
    336 #define SYMFLAG_EXPORT 0x00000200
    337 #define SYMFLAG_FORWARDER 0x00000400
    338 #define SYMFLAG_FUNCTION 0x00000800
    339 #define SYMFLAG_VIRTUAL 0x00001000
    340 #define SYMFLAG_THUNK 0x00002000
    341 #define SYMFLAG_TLSREL 0x00004000
    342 
    343   typedef enum {
    344     SymNone = 0,SymCoff,SymCv,SymPdb,SymExport,SymDeferred,SymSym,SymDia,SymVirtual,NumSymTypes
    345   } SYM_TYPE;
    346 
    347   typedef struct _IMAGEHLP_SYMBOL64 {
    348     DWORD SizeOfStruct;
    349     DWORD64 Address;
    350     DWORD Size;
    351     DWORD Flags;
    352     DWORD MaxNameLength;
    353     CHAR Name[1];
    354   } IMAGEHLP_SYMBOL64,*PIMAGEHLP_SYMBOL64;
    355 
    356   typedef struct _IMAGEHLP_SYMBOL64_PACKAGE {
    357     IMAGEHLP_SYMBOL64 sym;
    358     CHAR name[MAX_SYM_NAME + 1];
    359   } IMAGEHLP_SYMBOL64_PACKAGE,*PIMAGEHLP_SYMBOL64_PACKAGE;
    360 
    361 #ifdef _IMAGEHLP64
    362 
    363 #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
    364 #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
    365 #define IMAGEHLP_SYMBOL_PACKAGE IMAGEHLP_SYMBOL64_PACKAGE
    366 #define PIMAGEHLP_SYMBOL_PACKAGE PIMAGEHLP_SYMBOL64_PACKAGE
    367 #else
    368 
    369   typedef struct _IMAGEHLP_SYMBOL {
    370     DWORD SizeOfStruct;
    371     DWORD Address;
    372     DWORD Size;
    373     DWORD Flags;
    374     DWORD MaxNameLength;
    375     CHAR Name[1];
    376   } IMAGEHLP_SYMBOL,*PIMAGEHLP_SYMBOL;
    377 
    378   typedef struct _IMAGEHLP_SYMBOL_PACKAGE {
    379     IMAGEHLP_SYMBOL sym;
    380     CHAR name[MAX_SYM_NAME + 1];
    381   } IMAGEHLP_SYMBOL_PACKAGE,*PIMAGEHLP_SYMBOL_PACKAGE;
    382 #endif
    383 
    384   typedef struct _IMAGEHLP_MODULE64 {
    385     DWORD SizeOfStruct;
    386     DWORD64 BaseOfImage;
    387     DWORD ImageSize;
    388     DWORD TimeDateStamp;
    389     DWORD CheckSum;
    390     DWORD NumSyms;
    391     SYM_TYPE SymType;
    392     CHAR ModuleName[32];
    393     CHAR ImageName[256];
    394     CHAR LoadedImageName[256];
    395     CHAR LoadedPdbName[256];
    396     DWORD CVSig;
    397     CHAR CVData[MAX_PATH*3];
    398     DWORD PdbSig;
    399     GUID PdbSig70;
    400     DWORD PdbAge;
    401     BOOL PdbUnmatched;
    402     BOOL DbgUnmatched;
    403     BOOL LineNumbers;
    404     BOOL GlobalSymbols;
    405     BOOL TypeInfo;
    406   } IMAGEHLP_MODULE64,*PIMAGEHLP_MODULE64;
    407 
    408   typedef struct _IMAGEHLP_MODULE64W {
    409     DWORD SizeOfStruct;
    410     DWORD64 BaseOfImage;
    411     DWORD ImageSize;
    412     DWORD TimeDateStamp;
    413     DWORD CheckSum;
    414     DWORD NumSyms;
    415     SYM_TYPE SymType;
    416     WCHAR ModuleName[32];
    417     WCHAR ImageName[256];
    418     WCHAR LoadedImageName[256];
    419     WCHAR LoadedPdbName[256];
    420     DWORD CVSig;
    421     WCHAR CVData[MAX_PATH*3];
    422     DWORD PdbSig;
    423     GUID PdbSig70;
    424     DWORD PdbAge;
    425     BOOL PdbUnmatched;
    426     BOOL DbgUnmatched;
    427     BOOL LineNumbers;
    428     BOOL GlobalSymbols;
    429     BOOL TypeInfo;
    430   } IMAGEHLP_MODULEW64,*PIMAGEHLP_MODULEW64;
    431 
    432 #ifdef _IMAGEHLP64
    433 #define IMAGEHLP_MODULE IMAGEHLP_MODULE64
    434 #define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64
    435 #define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64
    436 #define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64
    437 #else
    438   typedef struct _IMAGEHLP_MODULE {
    439     DWORD SizeOfStruct;
    440     DWORD BaseOfImage;
    441     DWORD ImageSize;
    442     DWORD TimeDateStamp;
    443     DWORD CheckSum;
    444     DWORD NumSyms;
    445     SYM_TYPE SymType;
    446     CHAR ModuleName[32];
    447     CHAR ImageName[256];
    448     CHAR LoadedImageName[256];
    449   } IMAGEHLP_MODULE,*PIMAGEHLP_MODULE;
    450 
    451   typedef struct _IMAGEHLP_MODULEW {
    452     DWORD SizeOfStruct;
    453     DWORD BaseOfImage;
    454     DWORD ImageSize;
    455     DWORD TimeDateStamp;
    456     DWORD CheckSum;
    457     DWORD NumSyms;
    458     SYM_TYPE SymType;
    459     WCHAR ModuleName[32];
    460     WCHAR ImageName[256];
    461     WCHAR LoadedImageName[256];
    462   } IMAGEHLP_MODULEW,*PIMAGEHLP_MODULEW;
    463 #endif
    464 
    465   typedef struct _IMAGEHLP_LINE64 {
    466     DWORD SizeOfStruct;
    467     PVOID Key;
    468     DWORD LineNumber;
    469     PCHAR FileName;
    470     DWORD64 Address;
    471   } IMAGEHLP_LINE64,*PIMAGEHLP_LINE64;
    472 
    473 #ifdef _IMAGEHLP64
    474 #define IMAGEHLP_LINE IMAGEHLP_LINE64
    475 #define PIMAGEHLP_LINE PIMAGEHLP_LINE64
    476 #else
    477   typedef struct _IMAGEHLP_LINE {
    478     DWORD SizeOfStruct;
    479     PVOID Key;
    480     DWORD LineNumber;
    481     PCHAR FileName;
    482     DWORD Address;
    483   } IMAGEHLP_LINE,*PIMAGEHLP_LINE;
    484 #endif
    485 
    486   typedef struct _SOURCEFILE {
    487     DWORD64 ModBase;
    488     PCHAR FileName;
    489   } SOURCEFILE,*PSOURCEFILE;
    490 
    491 #define CBA_DEFERRED_SYMBOL_LOAD_START 0x00000001
    492 #define CBA_DEFERRED_SYMBOL_LOAD_COMPLETE 0x00000002
    493 #define CBA_DEFERRED_SYMBOL_LOAD_FAILURE 0x00000003
    494 #define CBA_SYMBOLS_UNLOADED 0x00000004
    495 #define CBA_DUPLICATE_SYMBOL 0x00000005
    496 #define CBA_READ_MEMORY 0x00000006
    497 #define CBA_DEFERRED_SYMBOL_LOAD_CANCEL 0x00000007
    498 #define CBA_SET_OPTIONS 0x00000008
    499 #define CBA_EVENT 0x00000010
    500 #define CBA_DEFERRED_SYMBOL_LOAD_PARTIAL 0x00000020
    501 #define CBA_DEBUG_INFO 0x10000000
    502 
    503   typedef struct _IMAGEHLP_CBA_READ_MEMORY {
    504     DWORD64 addr;
    505     PVOID buf;
    506     DWORD bytes;
    507     DWORD *bytesread;
    508   } IMAGEHLP_CBA_READ_MEMORY,*PIMAGEHLP_CBA_READ_MEMORY;
    509 
    510   enum {
    511     sevInfo = 0,sevProblem,sevAttn,sevFatal,sevMax
    512   };
    513 
    514   typedef struct _IMAGEHLP_CBA_EVENT {
    515     DWORD severity;
    516     DWORD code;
    517     PCHAR desc;
    518     PVOID object;
    519   } IMAGEHLP_CBA_EVENT,*PIMAGEHLP_CBA_EVENT;
    520 
    521   typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 {
    522     DWORD SizeOfStruct;
    523     DWORD64 BaseOfImage;
    524     DWORD CheckSum;
    525     DWORD TimeDateStamp;
    526     CHAR FileName[MAX_PATH];
    527     BOOLEAN Reparse;
    528     HANDLE hFile;
    529     DWORD Flags;
    530   } IMAGEHLP_DEFERRED_SYMBOL_LOAD64,*PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
    531 
    532 #define DSLFLAG_MISMATCHED_PDB 0x1
    533 #define DSLFLAG_MISMATCHED_DBG 0x2
    534 
    535 #ifdef _IMAGEHLP64
    536 #define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
    537 #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
    538 #else
    539   typedef struct _IMAGEHLP_DEFERRED_SYMBOL_LOAD {
    540     DWORD SizeOfStruct;
    541     DWORD BaseOfImage;
    542     DWORD CheckSum;
    543     DWORD TimeDateStamp;
    544     CHAR FileName[MAX_PATH];
    545     BOOLEAN Reparse;
    546     HANDLE hFile;
    547   } IMAGEHLP_DEFERRED_SYMBOL_LOAD,*PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
    548 #endif
    549 
    550   typedef struct _IMAGEHLP_DUPLICATE_SYMBOL64 {
    551     DWORD SizeOfStruct;
    552     DWORD NumberOfDups;
    553     PIMAGEHLP_SYMBOL64 Symbol;
    554     DWORD SelectedSymbol;
    555   } IMAGEHLP_DUPLICATE_SYMBOL64,*PIMAGEHLP_DUPLICATE_SYMBOL64;
    556 
    557 #ifdef _IMAGEHLP64
    558 #define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64
    559 #define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64
    560 #else
    561   typedef struct _IMAGEHLP_DUPLICATE_SYMBOL {
    562     DWORD SizeOfStruct;
    563     DWORD NumberOfDups;
    564     PIMAGEHLP_SYMBOL Symbol;
    565     DWORD SelectedSymbol;
    566   } IMAGEHLP_DUPLICATE_SYMBOL,*PIMAGEHLP_DUPLICATE_SYMBOL;
    567 #endif
    568 
    569   BOOL IMAGEAPI SymSetParentWindow(HWND hwnd);
    570   PCHAR IMAGEAPI SymSetHomeDirectory(PCSTR dir);
    571   PCHAR IMAGEAPI SymGetHomeDirectory(DWORD type,PSTR dir,size_t size);
    572 
    573   enum {
    574     hdBase = 0,hdSym,hdSrc,hdMax
    575   };
    576 
    577 #define SYMOPT_CASE_INSENSITIVE 0x00000001
    578 #define SYMOPT_UNDNAME 0x00000002
    579 #define SYMOPT_DEFERRED_LOADS 0x00000004
    580 #define SYMOPT_NO_CPP 0x00000008
    581 #define SYMOPT_LOAD_LINES 0x00000010
    582 #define SYMOPT_OMAP_FIND_NEAREST 0x00000020
    583 #define SYMOPT_LOAD_ANYTHING 0x00000040
    584 #define SYMOPT_IGNORE_CVREC 0x00000080
    585 #define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100
    586 #define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
    587 #define SYMOPT_EXACT_SYMBOLS 0x00000400
    588 #define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS 0x00000800
    589 #define SYMOPT_IGNORE_NT_SYMPATH 0x00001000
    590 #define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000
    591 #define SYMOPT_PUBLICS_ONLY 0x00004000
    592 #define SYMOPT_NO_PUBLICS 0x00008000
    593 #define SYMOPT_AUTO_PUBLICS 0x00010000
    594 #define SYMOPT_NO_IMAGE_SEARCH 0x00020000
    595 #define SYMOPT_SECURE 0x00040000
    596 #define SYMOPT_NO_PROMPTS 0x00080000
    597 
    598 #define SYMOPT_DEBUG 0x80000000
    599 
    600   DWORD IMAGEAPI SymSetOptions(DWORD SymOptions);
    601   DWORD IMAGEAPI SymGetOptions(VOID);
    602   BOOL IMAGEAPI SymCleanup(HANDLE hProcess);
    603   BOOL IMAGEAPI SymMatchString(LPSTR string,LPSTR expression,BOOL fCase);
    604 
    605   typedef BOOL (CALLBACK *PSYM_ENUMSOURCFILES_CALLBACK)(PSOURCEFILE pSourceFile,PVOID UserContext);
    606 
    607   BOOL IMAGEAPI SymEnumSourceFiles(HANDLE hProcess,ULONG64 ModBase,LPSTR Mask,PSYM_ENUMSOURCFILES_CALLBACK cbSrcFiles,PVOID UserContext);
    608   BOOL IMAGEAPI SymEnumerateModules64(HANDLE hProcess,PSYM_ENUMMODULES_CALLBACK64 EnumModulesCallback,PVOID UserContext);
    609 
    610 #ifdef _IMAGEHLP64
    611 #define SymEnumerateModules SymEnumerateModules64
    612 #else
    613   BOOL IMAGEAPI SymEnumerateModules(HANDLE hProcess,PSYM_ENUMMODULES_CALLBACK EnumModulesCallback,PVOID UserContext);
    614 #endif
    615 
    616   BOOL IMAGEAPI SymEnumerateSymbols64(HANDLE hProcess,DWORD64 BaseOfDll,PSYM_ENUMSYMBOLS_CALLBACK64 EnumSymbolsCallback,PVOID UserContext);
    617   BOOL IMAGEAPI SymEnumerateSymbolsW64(HANDLE hProcess,DWORD64 BaseOfDll,PSYM_ENUMSYMBOLS_CALLBACK64W EnumSymbolsCallback,PVOID UserContext);
    618 
    619 #ifdef _IMAGEHLP64
    620 #define SymEnumerateSymbols SymEnumerateSymbols64
    621 #define SymEnumerateSymbolsW SymEnumerateSymbolsW64
    622 #else
    623   BOOL IMAGEAPI SymEnumerateSymbols(HANDLE hProcess,DWORD BaseOfDll,PSYM_ENUMSYMBOLS_CALLBACK EnumSymbolsCallback,PVOID UserContext);
    624   BOOL IMAGEAPI SymEnumerateSymbolsW(HANDLE hProcess,DWORD BaseOfDll,PSYM_ENUMSYMBOLS_CALLBACKW EnumSymbolsCallback,PVOID UserContext);
    625 #endif
    626 
    627   BOOL IMAGEAPI EnumerateLoadedModules64(HANDLE hProcess,PENUMLOADED_MODULES_CALLBACK64 EnumLoadedModulesCallback,PVOID UserContext);
    628 #ifdef _IMAGEHLP64
    629 #define EnumerateLoadedModules EnumerateLoadedModules64
    630 #else
    631   BOOL IMAGEAPI EnumerateLoadedModules(HANDLE hProcess,PENUMLOADED_MODULES_CALLBACK EnumLoadedModulesCallback,PVOID UserContext);
    632 #endif
    633 
    634   PVOID IMAGEAPI SymFunctionTableAccess64(HANDLE hProcess,DWORD64 AddrBase);
    635 
    636 #ifdef _IMAGEHLP64
    637 #define SymFunctionTableAccess SymFunctionTableAccess64
    638 #else
    639   PVOID IMAGEAPI SymFunctionTableAccess(HANDLE hProcess,DWORD AddrBase);
    640 #endif
    641 
    642   BOOL IMAGEAPI SymGetModuleInfo64(HANDLE hProcess,DWORD64 qwAddr,PIMAGEHLP_MODULE64 ModuleInfo);
    643   BOOL IMAGEAPI SymGetModuleInfoW64(HANDLE hProcess,DWORD64 qwAddr,PIMAGEHLP_MODULEW64 ModuleInfo);
    644 
    645 #ifdef _IMAGEHLP64
    646 #define SymGetModuleInfo SymGetModuleInfo64
    647 #define SymGetModuleInfoW SymGetModuleInfoW64
    648 #else
    649   BOOL IMAGEAPI SymGetModuleInfo(HANDLE hProcess,DWORD dwAddr,PIMAGEHLP_MODULE ModuleInfo);
    650   BOOL IMAGEAPI SymGetModuleInfoW(HANDLE hProcess,DWORD dwAddr,PIMAGEHLP_MODULEW ModuleInfo);
    651 #endif
    652 
    653   DWORD64 IMAGEAPI SymGetModuleBase64(HANDLE hProcess,DWORD64 qwAddr);
    654 
    655 #ifdef _IMAGEHLP64
    656 #define SymGetModuleBase SymGetModuleBase64
    657 #else
    658   DWORD IMAGEAPI SymGetModuleBase(HANDLE hProcess,DWORD dwAddr);
    659 #endif
    660 
    661   BOOL IMAGEAPI SymGetSymNext64(HANDLE hProcess,PIMAGEHLP_SYMBOL64 Symbol);
    662 
    663 #ifdef _IMAGEHLP64
    664 #define SymGetSymNext SymGetSymNext64
    665 #else
    666   BOOL IMAGEAPI SymGetSymNext(HANDLE hProcess,PIMAGEHLP_SYMBOL Symbol);
    667 #endif
    668 
    669   BOOL IMAGEAPI SymGetSymPrev64(HANDLE hProcess,PIMAGEHLP_SYMBOL64 Symbol);
    670 
    671 #ifdef _IMAGEHLP64
    672 #define SymGetSymPrev SymGetSymPrev64
    673 #else
    674   BOOL IMAGEAPI SymGetSymPrev(HANDLE hProcess,PIMAGEHLP_SYMBOL Symbol);
    675 #endif
    676 
    677   typedef struct _SRCCODEINFO {
    678     DWORD SizeOfStruct;
    679     PVOID Key;
    680     DWORD64 ModBase;
    681     CHAR Obj[MAX_PATH + 1];
    682     CHAR FileName[MAX_PATH + 1];
    683     DWORD LineNumber;
    684     DWORD64 Address;
    685   } SRCCODEINFO,*PSRCCODEINFO;
    686 
    687   typedef BOOL (CALLBACK *PSYM_ENUMLINES_CALLBACK)(PSRCCODEINFO LineInfo,PVOID UserContext);
    688 
    689   BOOL IMAGEAPI SymEnumLines(HANDLE hProcess,ULONG64 Base,PCSTR Obj,PCSTR File,PSYM_ENUMLINES_CALLBACK EnumLinesCallback,PVOID UserContext);
    690   BOOL IMAGEAPI SymGetLineFromAddr64(HANDLE hProcess,DWORD64 qwAddr,PDWORD pdwDisplacement,PIMAGEHLP_LINE64 Line64);
    691 
    692 #ifdef _IMAGEHLP64
    693 #define SymGetLineFromAddr SymGetLineFromAddr64
    694 #else
    695   BOOL IMAGEAPI SymGetLineFromAddr(HANDLE hProcess,DWORD dwAddr,PDWORD pdwDisplacement,PIMAGEHLP_LINE Line);
    696 #endif
    697 
    698   BOOL IMAGEAPI SymGetLineFromName64(HANDLE hProcess,PSTR ModuleName,PSTR FileName,DWORD dwLineNumber,PLONG plDisplacement,PIMAGEHLP_LINE64 Line);
    699 
    700 #ifdef _IMAGEHLP64
    701 #define SymGetLineFromName SymGetLineFromName64
    702 #else
    703   BOOL IMAGEAPI SymGetLineFromName(HANDLE hProcess,PSTR ModuleName,PSTR FileName,DWORD dwLineNumber,PLONG plDisplacement,PIMAGEHLP_LINE Line);
    704 #endif
    705 
    706   BOOL IMAGEAPI SymGetLineNext64(HANDLE hProcess,PIMAGEHLP_LINE64 Line);
    707 
    708 #ifdef _IMAGEHLP64
    709 #define SymGetLineNext SymGetLineNext64
    710 #else
    711   BOOL IMAGEAPI SymGetLineNext(HANDLE hProcess,PIMAGEHLP_LINE Line);
    712 #endif
    713 
    714   BOOL IMAGEAPI SymGetLinePrev64(HANDLE hProcess,PIMAGEHLP_LINE64 Line);
    715 
    716 #ifdef _IMAGEHLP64
    717 #define SymGetLinePrev SymGetLinePrev64
    718 #else
    719   BOOL IMAGEAPI SymGetLinePrev(HANDLE hProcess,PIMAGEHLP_LINE Line);
    720 #endif
    721 
    722   BOOL IMAGEAPI SymMatchFileName(PSTR FileName,PSTR Match,PSTR *FileNameStop,PSTR *MatchStop);
    723   BOOL IMAGEAPI SymInitialize(HANDLE hProcess,PSTR UserSearchPath,BOOL fInvadeProcess);
    724   BOOL IMAGEAPI SymGetSearchPath(HANDLE hProcess,PSTR SearchPath,DWORD SearchPathLength);
    725   BOOL IMAGEAPI SymSetSearchPath(HANDLE hProcess,PSTR SearchPath);
    726   DWORD64 IMAGEAPI SymLoadModule64(HANDLE hProcess,HANDLE hFile,PSTR ImageName,PSTR ModuleName,DWORD64 BaseOfDll,DWORD SizeOfDll);
    727 
    728 #define SLMFLAG_VIRTUAL 0x1
    729 
    730   DWORD64 IMAGEAPI SymLoadModuleEx(HANDLE hProcess,HANDLE hFile,PSTR ImageName,PSTR ModuleName,DWORD64 BaseOfDll,DWORD DllSize,PMODLOAD_DATA Data,DWORD Flags);
    731 
    732 #ifdef _IMAGEHLP64
    733 #define SymLoadModule SymLoadModule64
    734 #else
    735   DWORD IMAGEAPI SymLoadModule(HANDLE hProcess,HANDLE hFile,PSTR ImageName,PSTR ModuleName,DWORD BaseOfDll,DWORD SizeOfDll);
    736 #endif
    737 
    738   BOOL IMAGEAPI SymUnloadModule64(HANDLE hProcess,DWORD64 BaseOfDll);
    739 
    740 #ifdef _IMAGEHLP64
    741 #define SymUnloadModule SymUnloadModule64
    742 #else
    743   BOOL IMAGEAPI SymUnloadModule(HANDLE hProcess,DWORD BaseOfDll);
    744 #endif
    745 
    746   BOOL IMAGEAPI SymUnDName64(PIMAGEHLP_SYMBOL64 sym,PSTR UnDecName,DWORD UnDecNameLength);
    747 
    748 #ifdef _IMAGEHLP64
    749 #define SymUnDName SymUnDName64
    750 #else
    751   BOOL IMAGEAPI SymUnDName(PIMAGEHLP_SYMBOL sym,PSTR UnDecName,DWORD UnDecNameLength);
    752 #endif
    753 
    754   BOOL IMAGEAPI SymRegisterCallback64(HANDLE hProcess,PSYMBOL_REGISTERED_CALLBACK64 CallbackFunction,ULONG64 UserContext);
    755 
    756   BOOL IMAGEAPI SymRegisterFunctionEntryCallback64(HANDLE hProcess,PSYMBOL_FUNCENTRY_CALLBACK64 CallbackFunction,ULONG64 UserContext);
    757 
    758 #ifdef _IMAGEHLP64
    759 #define SymRegisterCallback SymRegisterCallback64
    760 #define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64
    761 #else
    762   BOOL IMAGEAPI SymRegisterCallback(HANDLE hProcess,PSYMBOL_REGISTERED_CALLBACK CallbackFunction,PVOID UserContext);
    763   BOOL IMAGEAPI SymRegisterFunctionEntryCallback(HANDLE hProcess,PSYMBOL_FUNCENTRY_CALLBACK CallbackFunction,PVOID UserContext);
    764 #endif
    765 
    766   typedef struct _IMAGEHLP_SYMBOL_SRC {
    767     DWORD sizeofstruct;
    768     DWORD type;
    769     char file[MAX_PATH];
    770   } IMAGEHLP_SYMBOL_SRC,*PIMAGEHLP_SYMBOL_SRC;
    771 
    772   typedef struct _MODULE_TYPE_INFO {
    773     USHORT dataLength;
    774     USHORT leaf;
    775     BYTE data[1];
    776   } MODULE_TYPE_INFO,*PMODULE_TYPE_INFO;
    777 
    778   typedef struct _SYMBOL_INFO {
    779     ULONG SizeOfStruct;
    780     ULONG TypeIndex;
    781     ULONG64 Reserved[2];
    782     ULONG info;
    783     ULONG Size;
    784     ULONG64 ModBase;
    785     ULONG Flags;
    786     ULONG64 Value;
    787     ULONG64 Address;
    788     ULONG Register;
    789     ULONG Scope;
    790     ULONG Tag;
    791     ULONG NameLen;
    792     ULONG MaxNameLen;
    793     CHAR Name[1];
    794   } SYMBOL_INFO,*PSYMBOL_INFO;
    795 
    796   typedef struct _SYMBOL_INFO_PACKAGE {
    797     SYMBOL_INFO si;
    798     CHAR name[MAX_SYM_NAME + 1];
    799   } SYMBOL_INFO_PACKAGE,*PSYMBOL_INFO_PACKAGE;
    800 
    801   typedef struct _IMAGEHLP_STACK_FRAME
    802   {
    803     ULONG64 InstructionOffset;
    804     ULONG64 ReturnOffset;
    805     ULONG64 FrameOffset;
    806     ULONG64 StackOffset;
    807     ULONG64 BackingStoreOffset;
    808     ULONG64 FuncTableEntry;
    809     ULONG64 Params[4];
    810     ULONG64 Reserved[5];
    811     BOOL Virtual;
    812     ULONG Reserved2;
    813   } IMAGEHLP_STACK_FRAME,*PIMAGEHLP_STACK_FRAME;
    814 
    815   typedef VOID IMAGEHLP_CONTEXT,*PIMAGEHLP_CONTEXT;
    816 
    817   BOOL IMAGEAPI SymSetContext(HANDLE hProcess,PIMAGEHLP_STACK_FRAME StackFrame,PIMAGEHLP_CONTEXT Context);
    818   BOOL IMAGEAPI SymFromAddr(HANDLE hProcess,DWORD64 Address,PDWORD64 Displacement,PSYMBOL_INFO Symbol);
    819   BOOL IMAGEAPI SymFromToken(HANDLE hProcess,DWORD64 Base,DWORD Token,PSYMBOL_INFO Symbol);
    820   BOOL IMAGEAPI SymFromName(HANDLE hProcess,LPSTR Name,PSYMBOL_INFO Symbol);
    821 
    822   typedef BOOL (CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(PSYMBOL_INFO pSymInfo,ULONG SymbolSize,PVOID UserContext);
    823 
    824   BOOL IMAGEAPI SymEnumSymbols(HANDLE hProcess,ULONG64 BaseOfDll,PCSTR Mask,PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,PVOID UserContext);
    825   BOOL IMAGEAPI SymEnumSymbolsForAddr(HANDLE hProcess,DWORD64 Address,PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,PVOID UserContext);
    826 
    827 #define SYMENUMFLAG_FULLSRCH 1
    828 #define SYMENUMFLAG_SPEEDSRCH 2
    829 
    830   typedef enum _IMAGEHLP_SYMBOL_TYPE_INFO {
    831     TI_GET_SYMTAG,TI_GET_SYMNAME,TI_GET_LENGTH,TI_GET_TYPE,TI_GET_TYPEID,TI_GET_BASETYPE,TI_GET_ARRAYINDEXTYPEID,TI_FINDCHILDREN,
    832     TI_GET_DATAKIND,TI_GET_ADDRESSOFFSET,TI_GET_OFFSET,TI_GET_VALUE,TI_GET_COUNT,TI_GET_CHILDRENCOUNT,TI_GET_BITPOSITION,TI_GET_VIRTUALBASECLASS,
    833     TI_GET_VIRTUALTABLESHAPEID,TI_GET_VIRTUALBASEPOINTEROFFSET,TI_GET_CLASSPARENTID,TI_GET_NESTED,TI_GET_SYMINDEX,TI_GET_LEXICALPARENT,
    834     TI_GET_ADDRESS,TI_GET_THISADJUST,TI_GET_UDTKIND,TI_IS_EQUIV_TO,TI_GET_CALLING_CONVENTION
    835   } IMAGEHLP_SYMBOL_TYPE_INFO;
    836 
    837   typedef struct _TI_FINDCHILDREN_PARAMS {
    838     ULONG Count;
    839     ULONG Start;
    840     ULONG ChildId[1];
    841   } TI_FINDCHILDREN_PARAMS;
    842 
    843   BOOL IMAGEAPI SymGetTypeInfo(HANDLE hProcess,DWORD64 ModBase,ULONG TypeId,IMAGEHLP_SYMBOL_TYPE_INFO GetType,PVOID pInfo);
    844   BOOL IMAGEAPI SymEnumTypes(HANDLE hProcess,ULONG64 BaseOfDll,PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,PVOID UserContext);
    845   BOOL IMAGEAPI SymGetTypeFromName(HANDLE hProcess,ULONG64 BaseOfDll,LPSTR Name,PSYMBOL_INFO Symbol);
    846   BOOL IMAGEAPI SymAddSymbol(HANDLE hProcess,ULONG64 BaseOfDll,PCSTR Name,DWORD64 Address,DWORD Size,DWORD Flags);
    847   BOOL IMAGEAPI SymDeleteSymbol(HANDLE hProcess,ULONG64 BaseOfDll,PCSTR Name,DWORD64 Address,DWORD Flags);
    848 
    849   typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(DWORD DataType,PVOID *Data,LPDWORD DataLength,PVOID UserData);
    850 
    851   BOOL WINAPI DbgHelpCreateUserDump(LPSTR FileName,PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,PVOID UserData);
    852   BOOL WINAPI DbgHelpCreateUserDumpW(LPWSTR FileName,PDBGHELP_CREATE_USER_DUMP_CALLBACK Callback,PVOID UserData);
    853   BOOL IMAGEAPI SymGetSymFromAddr64(HANDLE hProcess,DWORD64 qwAddr,PDWORD64 pdwDisplacement,PIMAGEHLP_SYMBOL64 Symbol);
    854 
    855 #ifdef _IMAGEHLP64
    856 #define SymGetSymFromAddr SymGetSymFromAddr64
    857 #else
    858   BOOL IMAGEAPI SymGetSymFromAddr(HANDLE hProcess,DWORD dwAddr,PDWORD pdwDisplacement,PIMAGEHLP_SYMBOL Symbol);
    859 #endif
    860 
    861   BOOL IMAGEAPI SymGetSymFromName64(HANDLE hProcess,PSTR Name,PIMAGEHLP_SYMBOL64 Symbol);
    862 
    863 #ifdef _IMAGEHLP64
    864 #define SymGetSymFromName SymGetSymFromName64
    865 #else
    866   BOOL IMAGEAPI SymGetSymFromName(HANDLE hProcess,PSTR Name,PIMAGEHLP_SYMBOL Symbol);
    867 #endif
    868 
    869   DBHLP_DEPRECIATED BOOL IMAGEAPI FindFileInPath(HANDLE hprocess,LPSTR SearchPath,LPSTR FileName,PVOID id,DWORD two,DWORD three,DWORD flags,LPSTR FilePath);
    870   DBHLP_DEPRECIATED BOOL IMAGEAPI FindFileInSearchPath(HANDLE hprocess,LPSTR SearchPath,LPSTR FileName,DWORD one,DWORD two,DWORD three,LPSTR FilePath);
    871   DBHLP_DEPRECIATED BOOL IMAGEAPI SymEnumSym(HANDLE hProcess,ULONG64 BaseOfDll,PSYM_ENUMERATESYMBOLS_CALLBACK EnumSymbolsCallback,PVOID UserContext);
    872 
    873 #define SYMF_OMAP_GENERATED 0x00000001
    874 #define SYMF_OMAP_MODIFIED 0x00000002
    875 #define SYMF_REGISTER 0x00000008
    876 #define SYMF_REGREL 0x00000010
    877 #define SYMF_FRAMEREL 0x00000020
    878 #define SYMF_PARAMETER 0x00000040
    879 #define SYMF_LOCAL 0x00000080
    880 #define SYMF_CONSTANT 0x00000100
    881 #define SYMF_EXPORT 0x00000200
    882 #define SYMF_FORWARDER 0x00000400
    883 #define SYMF_FUNCTION 0x00000800
    884 #define SYMF_VIRTUAL 0x00001000
    885 #define SYMF_THUNK 0x00002000
    886 #define SYMF_TLSREL 0x00004000
    887 
    888 #define IMAGEHLP_SYMBOL_INFO_VALUEPRESENT 1
    889 #define IMAGEHLP_SYMBOL_INFO_REGISTER SYMF_REGISTER
    890 #define IMAGEHLP_SYMBOL_INFO_REGRELATIVE SYMF_REGREL
    891 #define IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE SYMF_FRAMEREL
    892 #define IMAGEHLP_SYMBOL_INFO_PARAMETER SYMF_PARAMETER
    893 #define IMAGEHLP_SYMBOL_INFO_LOCAL SYMF_LOCAL
    894 #define IMAGEHLP_SYMBOL_INFO_CONSTANT SYMF_CONSTANT
    895 #define IMAGEHLP_SYMBOL_FUNCTION SYMF_FUNCTION
    896 #define IMAGEHLP_SYMBOL_VIRTUAL SYMF_VIRTUAL
    897 #define IMAGEHLP_SYMBOL_THUNK SYMF_THUNK
    898 #define IMAGEHLP_SYMBOL_INFO_TLSRELATIVE SYMF_TLSREL
    899 
    900 #include <pshpack4.h>
    901 
    902 #define MINIDUMP_SIGNATURE ('PMDM')
    903 #define MINIDUMP_VERSION (42899)
    904   typedef DWORD RVA;
    905   typedef ULONG64 RVA64;
    906 
    907   typedef struct _MINIDUMP_LOCATION_DESCRIPTOR {
    908     ULONG32 DataSize;
    909     RVA Rva;
    910   } MINIDUMP_LOCATION_DESCRIPTOR;
    911 
    912   typedef struct _MINIDUMP_LOCATION_DESCRIPTOR64 {
    913     ULONG64 DataSize;
    914     RVA64 Rva;
    915   } MINIDUMP_LOCATION_DESCRIPTOR64;
    916 
    917   typedef struct _MINIDUMP_MEMORY_DESCRIPTOR {
    918     ULONG64 StartOfMemoryRange;
    919     MINIDUMP_LOCATION_DESCRIPTOR Memory;
    920   } MINIDUMP_MEMORY_DESCRIPTOR,*PMINIDUMP_MEMORY_DESCRIPTOR;
    921 
    922   typedef struct _MINIDUMP_MEMORY_DESCRIPTOR64 {
    923     ULONG64 StartOfMemoryRange;
    924     ULONG64 DataSize;
    925   } MINIDUMP_MEMORY_DESCRIPTOR64,*PMINIDUMP_MEMORY_DESCRIPTOR64;
    926 
    927   typedef struct _MINIDUMP_HEADER {
    928     ULONG32 Signature;
    929     ULONG32 Version;
    930     ULONG32 NumberOfStreams;
    931     RVA StreamDirectoryRva;
    932     ULONG32 CheckSum;
    933     union {
    934       ULONG32 Reserved;
    935       ULONG32 TimeDateStamp;
    936     } DUMMYUNIONNAME;
    937     ULONG64 Flags;
    938   } MINIDUMP_HEADER,*PMINIDUMP_HEADER;
    939 
    940   typedef struct _MINIDUMP_DIRECTORY {
    941     ULONG32 StreamType;
    942     MINIDUMP_LOCATION_DESCRIPTOR Location;
    943   } MINIDUMP_DIRECTORY,*PMINIDUMP_DIRECTORY;
    944 
    945   typedef struct _MINIDUMP_STRING {
    946     ULONG32 Length;
    947     WCHAR Buffer [0];
    948   } MINIDUMP_STRING,*PMINIDUMP_STRING;
    949 
    950   typedef enum _MINIDUMP_STREAM_TYPE {
    951     UnusedStream = 0,ReservedStream0 = 1,ReservedStream1 = 2,ThreadListStream = 3,ModuleListStream = 4,MemoryListStream = 5,
    952     ExceptionStream = 6,SystemInfoStream = 7,ThreadExListStream = 8,Memory64ListStream = 9,CommentStreamA = 10,CommentStreamW = 11,
    953     HandleDataStream = 12,FunctionTableStream = 13,UnloadedModuleListStream = 14,MiscInfoStream = 15,LastReservedStream = 0xffff
    954   } MINIDUMP_STREAM_TYPE;
    955 
    956   typedef union _CPU_INFORMATION {
    957     struct {
    958       ULONG32 VendorId [3 ];
    959       ULONG32 VersionInformation;
    960       ULONG32 FeatureInformation;
    961       ULONG32 AMDExtendedCpuFeatures;
    962     } X86CpuInfo;
    963     struct {
    964       ULONG64 ProcessorFeatures [2 ];
    965     } OtherCpuInfo;
    966   } CPU_INFORMATION,*PCPU_INFORMATION;
    967 
    968   typedef struct _MINIDUMP_SYSTEM_INFO {
    969     USHORT ProcessorArchitecture;
    970     USHORT ProcessorLevel;
    971     USHORT ProcessorRevision;
    972     union {
    973       USHORT Reserved0;
    974       struct {
    975 	UCHAR NumberOfProcessors;
    976 	UCHAR ProductType;
    977       } DUMMYSTRUCTNAME;
    978     } DUMMYUNIONNAME;
    979     ULONG32 MajorVersion;
    980     ULONG32 MinorVersion;
    981     ULONG32 BuildNumber;
    982     ULONG32 PlatformId;
    983     RVA CSDVersionRva;
    984     union {
    985       ULONG32 Reserved1;
    986       struct {
    987 	USHORT SuiteMask;
    988 	USHORT Reserved2;
    989       } DUMMYSTRUCTNAME;
    990     } DUMMYUNIONNAME1;
    991     CPU_INFORMATION Cpu;
    992   } MINIDUMP_SYSTEM_INFO,*PMINIDUMP_SYSTEM_INFO;
    993 
    994   C_ASSERT (sizeof (((PPROCESS_INFORMATION)0)->dwThreadId)==4);
    995 
    996   typedef struct _MINIDUMP_THREAD {
    997     ULONG32 ThreadId;
    998     ULONG32 SuspendCount;
    999     ULONG32 PriorityClass;
   1000     ULONG32 Priority;
   1001     ULONG64 Teb;
   1002     MINIDUMP_MEMORY_DESCRIPTOR Stack;
   1003     MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
   1004   } MINIDUMP_THREAD,*PMINIDUMP_THREAD;
   1005 
   1006   typedef struct _MINIDUMP_THREAD_LIST {
   1007     ULONG32 NumberOfThreads;
   1008     MINIDUMP_THREAD Threads [0];
   1009   } MINIDUMP_THREAD_LIST,*PMINIDUMP_THREAD_LIST;
   1010 
   1011   typedef struct _MINIDUMP_THREAD_EX {
   1012     ULONG32 ThreadId;
   1013     ULONG32 SuspendCount;
   1014     ULONG32 PriorityClass;
   1015     ULONG32 Priority;
   1016     ULONG64 Teb;
   1017     MINIDUMP_MEMORY_DESCRIPTOR Stack;
   1018     MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
   1019     MINIDUMP_MEMORY_DESCRIPTOR BackingStore;
   1020   } MINIDUMP_THREAD_EX,*PMINIDUMP_THREAD_EX;
   1021 
   1022   typedef struct _MINIDUMP_THREAD_EX_LIST {
   1023     ULONG32 NumberOfThreads;
   1024     MINIDUMP_THREAD_EX Threads [0];
   1025   } MINIDUMP_THREAD_EX_LIST,*PMINIDUMP_THREAD_EX_LIST;
   1026 
   1027   typedef struct _MINIDUMP_EXCEPTION {
   1028     ULONG32 ExceptionCode;
   1029     ULONG32 ExceptionFlags;
   1030     ULONG64 ExceptionRecord;
   1031     ULONG64 ExceptionAddress;
   1032     ULONG32 NumberParameters;
   1033     ULONG32 __unusedAlignment;
   1034     ULONG64 ExceptionInformation [EXCEPTION_MAXIMUM_PARAMETERS ];
   1035   } MINIDUMP_EXCEPTION,*PMINIDUMP_EXCEPTION;
   1036 
   1037   typedef struct MINIDUMP_EXCEPTION_STREAM {
   1038     ULONG32 ThreadId;
   1039     ULONG32 __alignment;
   1040     MINIDUMP_EXCEPTION ExceptionRecord;
   1041     MINIDUMP_LOCATION_DESCRIPTOR ThreadContext;
   1042   } MINIDUMP_EXCEPTION_STREAM,*PMINIDUMP_EXCEPTION_STREAM;
   1043 
   1044   typedef struct _MINIDUMP_MODULE {
   1045     ULONG64 BaseOfImage;
   1046     ULONG32 SizeOfImage;
   1047     ULONG32 CheckSum;
   1048     ULONG32 TimeDateStamp;
   1049     RVA ModuleNameRva;
   1050     VS_FIXEDFILEINFO VersionInfo;
   1051     MINIDUMP_LOCATION_DESCRIPTOR CvRecord;
   1052     MINIDUMP_LOCATION_DESCRIPTOR MiscRecord;
   1053     ULONG64 Reserved0;
   1054     ULONG64 Reserved1;
   1055   } MINIDUMP_MODULE,*PMINIDUMP_MODULE;
   1056 
   1057   typedef struct _MINIDUMP_MODULE_LIST {
   1058     ULONG32 NumberOfModules;
   1059     MINIDUMP_MODULE Modules [0 ];
   1060   } MINIDUMP_MODULE_LIST,*PMINIDUMP_MODULE_LIST;
   1061 
   1062   typedef struct _MINIDUMP_MEMORY_LIST {
   1063     ULONG32 NumberOfMemoryRanges;
   1064     MINIDUMP_MEMORY_DESCRIPTOR MemoryRanges [0];
   1065   } MINIDUMP_MEMORY_LIST,*PMINIDUMP_MEMORY_LIST;
   1066 
   1067   typedef struct _MINIDUMP_MEMORY64_LIST {
   1068     ULONG64 NumberOfMemoryRanges;
   1069     RVA64 BaseRva;
   1070     MINIDUMP_MEMORY_DESCRIPTOR64 MemoryRanges [0];
   1071   } MINIDUMP_MEMORY64_LIST,*PMINIDUMP_MEMORY64_LIST;
   1072 
   1073   typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
   1074     DWORD ThreadId;
   1075     PEXCEPTION_POINTERS ExceptionPointers;
   1076     BOOL ClientPointers;
   1077   } MINIDUMP_EXCEPTION_INFORMATION,*PMINIDUMP_EXCEPTION_INFORMATION;
   1078 
   1079   typedef struct _MINIDUMP_EXCEPTION_INFORMATION64 {
   1080     DWORD ThreadId;
   1081     ULONG64 ExceptionRecord;
   1082     ULONG64 ContextRecord;
   1083     BOOL ClientPointers;
   1084   } MINIDUMP_EXCEPTION_INFORMATION64,*PMINIDUMP_EXCEPTION_INFORMATION64;
   1085 
   1086   typedef struct _MINIDUMP_HANDLE_DESCRIPTOR {
   1087     ULONG64 Handle;
   1088     RVA TypeNameRva;
   1089     RVA ObjectNameRva;
   1090     ULONG32 Attributes;
   1091     ULONG32 GrantedAccess;
   1092     ULONG32 HandleCount;
   1093     ULONG32 PointerCount;
   1094   } MINIDUMP_HANDLE_DESCRIPTOR,*PMINIDUMP_HANDLE_DESCRIPTOR;
   1095 
   1096   typedef struct _MINIDUMP_HANDLE_DATA_STREAM {
   1097     ULONG32 SizeOfHeader;
   1098     ULONG32 SizeOfDescriptor;
   1099     ULONG32 NumberOfDescriptors;
   1100     ULONG32 Reserved;
   1101   } MINIDUMP_HANDLE_DATA_STREAM,*PMINIDUMP_HANDLE_DATA_STREAM;
   1102 
   1103   typedef struct _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR {
   1104     ULONG64 MinimumAddress;
   1105     ULONG64 MaximumAddress;
   1106     ULONG64 BaseAddress;
   1107     ULONG32 EntryCount;
   1108     ULONG32 SizeOfAlignPad;
   1109   } MINIDUMP_FUNCTION_TABLE_DESCRIPTOR,*PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
   1110 
   1111   typedef struct _MINIDUMP_FUNCTION_TABLE_STREAM {
   1112     ULONG32 SizeOfHeader;
   1113     ULONG32 SizeOfDescriptor;
   1114     ULONG32 SizeOfNativeDescriptor;
   1115     ULONG32 SizeOfFunctionEntry;
   1116     ULONG32 NumberOfDescriptors;
   1117     ULONG32 SizeOfAlignPad;
   1118   } MINIDUMP_FUNCTION_TABLE_STREAM,*PMINIDUMP_FUNCTION_TABLE_STREAM;
   1119 
   1120   typedef struct _MINIDUMP_UNLOADED_MODULE {
   1121     ULONG64 BaseOfImage;
   1122     ULONG32 SizeOfImage;
   1123     ULONG32 CheckSum;
   1124     ULONG32 TimeDateStamp;
   1125     RVA ModuleNameRva;
   1126   } MINIDUMP_UNLOADED_MODULE,*PMINIDUMP_UNLOADED_MODULE;
   1127 
   1128   typedef struct _MINIDUMP_UNLOADED_MODULE_LIST {
   1129     ULONG32 SizeOfHeader;
   1130     ULONG32 SizeOfEntry;
   1131     ULONG32 NumberOfEntries;
   1132   } MINIDUMP_UNLOADED_MODULE_LIST,*PMINIDUMP_UNLOADED_MODULE_LIST;
   1133 
   1134 #define MINIDUMP_MISC1_PROCESS_ID 0x00000001
   1135 #define MINIDUMP_MISC1_PROCESS_TIMES 0x00000002
   1136 
   1137   typedef struct _MINIDUMP_MISC_INFO {
   1138     ULONG32 SizeOfInfo;
   1139     ULONG32 Flags1;
   1140     ULONG32 ProcessId;
   1141     ULONG32 ProcessCreateTime;
   1142     ULONG32 ProcessUserTime;
   1143     ULONG32 ProcessKernelTime;
   1144   } MINIDUMP_MISC_INFO,*PMINIDUMP_MISC_INFO;
   1145 
   1146   typedef struct _MINIDUMP_USER_RECORD {
   1147     ULONG32 Type;
   1148     MINIDUMP_LOCATION_DESCRIPTOR Memory;
   1149   } MINIDUMP_USER_RECORD,*PMINIDUMP_USER_RECORD;
   1150 
   1151   typedef struct _MINIDUMP_USER_STREAM {
   1152     ULONG32 Type;
   1153     ULONG BufferSize;
   1154     PVOID Buffer;
   1155   } MINIDUMP_USER_STREAM,*PMINIDUMP_USER_STREAM;
   1156 
   1157   typedef struct _MINIDUMP_USER_STREAM_INFORMATION {
   1158     ULONG UserStreamCount;
   1159     PMINIDUMP_USER_STREAM UserStreamArray;
   1160   } MINIDUMP_USER_STREAM_INFORMATION,*PMINIDUMP_USER_STREAM_INFORMATION;
   1161 
   1162   typedef enum _MINIDUMP_CALLBACK_TYPE {
   1163     ModuleCallback,ThreadCallback,ThreadExCallback,IncludeThreadCallback,IncludeModuleCallback,MemoryCallback
   1164   } MINIDUMP_CALLBACK_TYPE;
   1165 
   1166   typedef struct _MINIDUMP_THREAD_CALLBACK {
   1167     ULONG ThreadId;
   1168     HANDLE ThreadHandle;
   1169     CONTEXT Context;
   1170     ULONG SizeOfContext;
   1171     ULONG64 StackBase;
   1172     ULONG64 StackEnd;
   1173   } MINIDUMP_THREAD_CALLBACK,*PMINIDUMP_THREAD_CALLBACK;
   1174 
   1175   typedef struct _MINIDUMP_THREAD_EX_CALLBACK {
   1176     ULONG ThreadId;
   1177     HANDLE ThreadHandle;
   1178     CONTEXT Context;
   1179     ULONG SizeOfContext;
   1180     ULONG64 StackBase;
   1181     ULONG64 StackEnd;
   1182     ULONG64 BackingStoreBase;
   1183     ULONG64 BackingStoreEnd;
   1184   } MINIDUMP_THREAD_EX_CALLBACK,*PMINIDUMP_THREAD_EX_CALLBACK;
   1185 
   1186   typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK {
   1187     ULONG ThreadId;
   1188   } MINIDUMP_INCLUDE_THREAD_CALLBACK,*PMINIDUMP_INCLUDE_THREAD_CALLBACK;
   1189 
   1190   typedef enum _THREAD_WRITE_FLAGS {
   1191     ThreadWriteThread = 0x0001,ThreadWriteStack = 0x0002,ThreadWriteContext = 0x0004,ThreadWriteBackingStore = 0x0008,
   1192     ThreadWriteInstructionWindow = 0x0010,ThreadWriteThreadData = 0x0020
   1193   } THREAD_WRITE_FLAGS;
   1194 
   1195   typedef struct _MINIDUMP_MODULE_CALLBACK {
   1196     PWCHAR FullPath;
   1197     ULONG64 BaseOfImage;
   1198     ULONG SizeOfImage;
   1199     ULONG CheckSum;
   1200     ULONG TimeDateStamp;
   1201     VS_FIXEDFILEINFO VersionInfo;
   1202     PVOID CvRecord;
   1203     ULONG SizeOfCvRecord;
   1204     PVOID MiscRecord;
   1205     ULONG SizeOfMiscRecord;
   1206   } MINIDUMP_MODULE_CALLBACK,*PMINIDUMP_MODULE_CALLBACK;
   1207 
   1208   typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK {
   1209     ULONG64 BaseOfImage;
   1210   } MINIDUMP_INCLUDE_MODULE_CALLBACK,*PMINIDUMP_INCLUDE_MODULE_CALLBACK;
   1211 
   1212   typedef enum _MODULE_WRITE_FLAGS {
   1213     ModuleWriteModule = 0x0001,ModuleWriteDataSeg = 0x0002,ModuleWriteMiscRecord = 0x0004,ModuleWriteCvRecord = 0x0008,
   1214     ModuleReferencedByMemory = 0x0010
   1215   } MODULE_WRITE_FLAGS;
   1216 
   1217   typedef struct _MINIDUMP_CALLBACK_INPUT {
   1218     ULONG ProcessId;
   1219     HANDLE ProcessHandle;
   1220     ULONG CallbackType;
   1221     union {
   1222       MINIDUMP_THREAD_CALLBACK Thread;
   1223       MINIDUMP_THREAD_EX_CALLBACK ThreadEx;
   1224       MINIDUMP_MODULE_CALLBACK Module;
   1225       MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
   1226       MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
   1227     } DUMMYUNIONNAME;
   1228   } MINIDUMP_CALLBACK_INPUT,*PMINIDUMP_CALLBACK_INPUT;
   1229 
   1230   typedef struct _MINIDUMP_CALLBACK_OUTPUT {
   1231     union {
   1232       ULONG ModuleWriteFlags;
   1233       ULONG ThreadWriteFlags;
   1234       struct {
   1235 	ULONG64 MemoryBase;
   1236 	ULONG MemorySize;
   1237       } DUMMYSTRUCTNAME;
   1238     } DUMMYUNIONNAME;
   1239   } MINIDUMP_CALLBACK_OUTPUT,*PMINIDUMP_CALLBACK_OUTPUT;
   1240 
   1241   typedef enum _MINIDUMP_TYPE {
   1242     MiniDumpNormal = 0x0000,MiniDumpWithDataSegs = 0x0001,MiniDumpWithFullMemory = 0x0002,MiniDumpWithHandleData = 0x0004,
   1243     MiniDumpFilterMemory = 0x0008,MiniDumpScanMemory = 0x0010,MiniDumpWithUnloadedModules = 0x0020,MiniDumpWithIndirectlyReferencedMemory = 0x0040,
   1244     MiniDumpFilterModulePaths = 0x0080,MiniDumpWithProcessThreadData = 0x0100,MiniDumpWithPrivateReadWriteMemory = 0x0200,
   1245     MiniDumpWithoutOptionalData = 0x0400
   1246   } MINIDUMP_TYPE;
   1247 
   1248   typedef BOOL (WINAPI *MINIDUMP_CALLBACK_ROUTINE)(PVOID CallbackParam,CONST PMINIDUMP_CALLBACK_INPUT CallbackInput,PMINIDUMP_CALLBACK_OUTPUT CallbackOutput);
   1249 
   1250   typedef struct _MINIDUMP_CALLBACK_INFORMATION {
   1251     MINIDUMP_CALLBACK_ROUTINE CallbackRoutine;
   1252     PVOID CallbackParam;
   1253   } MINIDUMP_CALLBACK_INFORMATION,*PMINIDUMP_CALLBACK_INFORMATION;
   1254 
   1255 #define RVA_TO_ADDR(Mapping,Rva) ((PVOID)(((ULONG_PTR) (Mapping)) + (Rva)))
   1256 
   1257   BOOL WINAPI MiniDumpWriteDump(HANDLE hProcess,DWORD ProcessId,HANDLE hFile,MINIDUMP_TYPE DumpType,CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
   1258   BOOL WINAPI MiniDumpReadDumpStream(PVOID BaseOfDump,ULONG StreamNumber,PMINIDUMP_DIRECTORY *Dir,PVOID *StreamPointer,ULONG *StreamSize);
   1259 
   1260 #include <poppack.h>
   1261 
   1262 #ifdef __cplusplus
   1263 }
   1264 #endif
   1265 #endif
   1266