' ########################################################################################
' Microsoft Windows
' File: DbgHelp.inc
' Contents: Prototypes and constants required for the image help routines.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
' Make sure ImageHelp.inc is not included.
#IF NOT %DEF(%IMAGEHLP_INC)
#IF NOT %DEF(%DBGHELP_INC)
 %DBGHELP_INC = 1
'// As a general principal always call the 64 bit version
'// of every API, if a choice exists. The 64 bit version
'// works great on 32 bit platforms, and is forward
'// compatible to 64 bit platforms.
'#ifdef _WIN64
'#ifndef _IMAGEHLP64
'#define _IMAGEHLP64
'#endif
'#endif
#INCLUDE ONCE "Legacy/Platform/WinTrust.inc"
'#include <pshpack8.h>
%EQUATE `IMAGE_SEPARATION = 64*1024
'// Observant readers may notice that 2 new fields,
'// 'fReadOnly' and 'Version' have been added to
'// the LOADED_IMAGE structure after 'fDOSImage'.
'// This does not change the size of the structure
'// from previous headers. That is because while
'// 'fDOSImage' is a byte, it is padded by the
'// compiler to 4 bytes. So the 2 new fields are
'// slipped into the extra space.
'typedef struct _LOADED_IMAGE {
' PSTR ModuleName;
' HANDLE hFile;
' PUCHAR MappedAddress;
'#ifdef _IMAGEHLP64
' PIMAGE_NT_HEADERS64 FileHeader;
'#else
' PIMAGE_NT_HEADERS32 FileHeader;
'#endif
' PIMAGE_SECTION_HEADER LastRvaSection;
' ULONG NumberOfSections;
' PIMAGE_SECTION_HEADER Sections;
' ULONG Characteristics;
' BOOLEAN fSystemImage;
' BOOLEAN fDOSImage;
' BOOLEAN fReadOnly;
' UCHAR Version;
' LIST_ENTRY Links;
' ULONG SizeOfImage;
'} LOADED_IMAGE, *PLOADED_IMAGE;
' // Size = 48 bytes
TYPE LOADED_IMAGE BYTE
 ModuleName AS ASCIIZ PTR
 hFile AS DWORD
 MappedAddress AS BYTE PTR
 FileHeader AS IMAGE_NT_HEADERS PTR ' PIMAGE_NT_HEADERS32
 LastRvaSection AS IMAGE_SECTION_HEADER PTR ' PIMAGE_SECTION_HEADER
 NumberOfSections AS DWORD ' ULONG
 Sections AS IMAGE_SECTION_HEADER PTR ' PIMAGE_SECTION_HEADER
 Characteristics AS DWORD ' ULONG
 fSystemImage AS BYTE ' BOOLEAN
 fDOSImage AS BYTE ' BOOLEAN
 fReadOnly AS BYTE ' BOOLEAN
 Version AS BYTE ' UCHAR
 Links AS LIST_ENTRY ' LIST_ENTRY
 SizeOfImage AS DWORD ' ULONG
END TYPE
%EQUATE `MAX_SYM_NAME = 2000
'// Error codes set by dbghelp functions. Call GetLastError
'// to see them.
'// Dbghelp also sets error codes found in winerror.h
%EQUATE `ERROR_IMAGE_NOT_STRIPPED = &H8800& ' // the image is not stripped. No dbg file available.
%EQUATE `ERROR_NO_DBG_POINTER = &H8801& ' // image is stripped but there is no pointer to a dbg file
%EQUATE `ERROR_NO_PDB_POINTER = &H8802& ' // image does not point to a pdb file
'typedef BOOL
'(CALLBACK *PFIND_DEBUG_FILE_CALLBACK)(
' );
'FUNCTION FIND_DEBUG_FILE_CALLBACK ( ' BYVAL FileHandle AS DWORD
' , BYREF szFileName AS ASCIIZ
' , BYVAL CallerData AS DWORD
' ) AS LONG
DECLARE FUNCTION SymFindDebugInfoFileA LIB "dbghelp.dll" ALIAS "SymFindDebugInfoFile" ( BYVAL hProcess AS DWORD
 , BYREF FileName AS ASCIIZ
 , BYREF DebugFilePath AS ASCIIZ
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
'typedef BOOL
'(CALLBACK *PFIND_DEBUG_FILE_CALLBACKW)(
' );
'FUNCTION FIND_DEBUG_FILE_CALLBACKW ( ' BYREF FileHandle AS WSTRINGZ
' , BYREF szFileName AS WSTRINGZ
' , BYREF CallerData AS WSTRINGZ
' ) AS LONG
DECLARE FUNCTION SymFindDebugInfoFileW LIB "dbghelp.dll" ALIAS "SymFindDebugInfoFileW" ( BYVAL hProcess AS DWORD
 , BYREF FileName AS WSTRINGZ
 , BYREF DebugFilePath AS DWORD
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymFindDebugInfoFile = SymFindDebugInfoFileW
#ELSE
 MACRO SymFindDebugInfoFile = SymFindDebugInfoFileA
#ENDIF
DECLARE FUNCTION FindDebugInfoFile LIB "dbghelp.dll" ALIAS "FindDebugInfoFile" ( BYREF FileName AS ASCIIZ , BYREF SymbolPath AS ASCIIZ , BYREF DebugFilePath AS ASCIIZ ) AS QUAD
DECLARE FUNCTION FindDebugInfoFileExA LIB "dbghelp.dll" ALIAS "FindDebugInfoFileEx" ( BYREF FileName AS ASCIIZ
 , BYREF SymbolPath AS ASCIIZ
 , BYREF DebugFilePath AS ASCIIZ
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
DECLARE FUNCTION FindDebugInfoFileExW LIB "dbghelp.dll" ALIAS "FindDebugInfoFileExW" ( BYREF FileName AS WSTRINGZ
 , BYREF SymbolPath AS WSTRINGZ
 , BYREF DebugFilePath AS DWORD
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindDebugInfoFileEx = FindDebugInfoFileExW
#ELSE
 MACRO FindDebugInfoFileEx = FindDebugInfoFileExA
#ENDIF
'typedef BOOL
'(CALLBACK *PFINDFILEINPATHCALLBACK)(
' );
'FUNCTION FINDFILEINPATHCALLBACK ( ' BYREF szFileName AS ASCIIZ ' PCSTR filename
' , BYVAL context AS DWORD ' PVOID context
' ) AS LONG
DECLARE FUNCTION SymFindFileInPathA LIB "dbghelp.dll" ALIAS "SymFindFileInPath" ( BYVAL hprocess AS DWORD
 , BYREF SearchPath AS ASCIIZ
 , BYREF FileName AS ASCIIZ
 , BYVAL id AS DWORD
 , BYVAL two AS DWORD
 , BYVAL three AS DWORD
 , BYVAL flags AS DWORD
 , BYREF FoundFile AS ASCIIZ
 , BYVAL callback AS DWORD
 , BYVAL context AS DWORD
 ) AS LONG
'typedef BOOL
'(CALLBACK *PFINDFILEINPATHCALLBACKW)(
' );
'FUNCTION FINDFILEINPATHCALLBACKW ( ' BYREF szFileName AS WSTRINGZ ' PCWSTR filename
' , BYVAL context AS DWORD ' PVOID context
' ) AS LONG
DECLARE FUNCTION SymFindFileInPathW LIB "dbghelp.dll" ALIAS "SymFindFileInPathW" ( BYVAL hprocess AS DWORD
 , BYREF SearchPath AS WSTRINGZ
 , BYREF FileName AS WSTRINGZ
 , BYVAL id AS DWORD
 , BYVAL two AS DWORD
 , BYVAL three AS DWORD
 , BYVAL flags AS DWORD
 , BYREF FoundFile AS WSTRINGZ
 , BYVAL callback AS DWORD
 , BYVAL context AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymFindFileInPath = SymFindFileInPathW
#ELSE
 MACRO SymFindFileInPath = SymFindFileInPathA
#ENDIF
'typedef BOOL
'(CALLBACK *PFIND_EXE_FILE_CALLBACK)(
' );
'FUNCTION FIND_EXE_FILE_CALLBACK ( ' BYVAL FileHandle AS DWORD
' , BYREF szFileName AS ASCIIZ
' , BYVAL CallerData AS DWORD
' ) AS LONG
DECLARE FUNCTION SymFindExecutableImageA LIB "dbghelp.dll" ALIAS "SymFindExecutableImage" ( BYVAL hprocess AS DWORD
 , BYREF FileName AS ASCIIZ
 , BYREF ImageFilePath AS ASCIIZ
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
'typedef BOOL
'(CALLBACK *PFIND_EXE_FILE_CALLBACKW)(
' );
'FUNCTION FIND_EXE_FILE_CALLBACKW ( ' BYREF FileHandle AS WSTRINGZ
' , BYREF szFileName AS WSTRINGZ
' , BYVAL CallerData AS DWORD
' ) AS LONG
DECLARE FUNCTION SymFindExecutableImageW LIB "dbghelp.dll" ALIAS "SymFindExecutableImageW" ( BYVAL hprocess AS DWORD
 , BYREF FileName AS WSTRINGZ
 , BYREF ImageFilePath AS WSTRINGZ
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymFindExecutableImage = SymFindExecutableImageW
#ELSE
 MACRO SymFindExecutableImage = SymFindExecutableImageA
#ENDIF
DECLARE FUNCTION FindExecutableImage LIB "dbghelp.dll" ALIAS "FindExecutableImage" ( BYREF FileName AS ASCIIZ , BYREF SymbolPath AS ASCIIZ , BYREF ImageFilePath AS ASCIIZ ) AS QUAD
DECLARE FUNCTION FindExecutableImageExA LIB "dbghelp.dll" ALIAS "FindExecutableImageEx" ( BYREF FileName AS ASCIIZ
 , BYREF SymbolPath AS ASCIIZ
 , BYREF ImageFilePath AS ASCIIZ
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
DECLARE FUNCTION FindExecutableImageExW LIB "dbghelp.dll" ALIAS "FindExecutableImageExW" ( BYREF FileName AS WSTRINGZ
 , BYREF SymbolPath AS WSTRINGZ
 , BYREF ImageFilePath AS WSTRINGZ
 , BYVAL Callback AS DWORD
 , BYVAL CallerData AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO FindExecutableImageEx = FindExecutableImageExW
#ELSE
 MACRO FindExecutableImageEx = FindExecutableImageExA
#ENDIF
DECLARE FUNCTION ImageNtHeader LIB "dbghelp.dll" ALIAS "ImageNtHeader" ( BYVAL Base AS QUAD ) AS QUAD ' PIMAGE_NT_HEADERS
DECLARE FUNCTION ImageDirectoryEntryToDataEx LIB "dbghelp.dll" ALIAS "ImageDirectoryEntryToDataEx" ( BYVAL Base AS QUAD , BYVAL MappedAsImage AS BYTE , BYVAL DirectoryEntry AS WORD , BYREF Size AS QUAD , BYREF FoundHeader AS IMAGE_SECTION_HEADER ) AS QUAD
DECLARE FUNCTION ImageDirectoryEntryToData LIB "dbghelp.dll" ALIAS "ImageDirectoryEntryToData" ( BYVAL Base AS QUAD
 , BYVAL MappedAsImage AS BYTE
 , BYVAL DirectoryEntry AS WORD
 , BYREF Size AS DWORD
 ) AS DWORD
DECLARE FUNCTION ImageRvaToSection LIB "dbghelp.dll" ALIAS "ImageRvaToSection" ( BYREF NtHeaders AS IMAGE_NT_HEADERS
 , BYVAL Base AS DWORD
 , BYVAL Rva AS DWORD
 ) AS DWORD ' PIMAGE_SECTION_HEADER
DECLARE FUNCTION ImageRvaToVa LIB "dbghelp.dll" ALIAS "ImageRvaToVa" ( BYREF NtHeaders AS IMAGE_NT_HEADERS , BYVAL Base AS QUAD , BYVAL Rva AS QUAD , BYREF LastRvaSection AS IMAGE_SECTION_HEADER ) AS QUAD
'#ifndef _WIN64
'// This api won't be ported to Win64 - Fix your code.
' // Size: 128 bytes
TYPE IMAGE_DEBUG_INFORMATION WORD
 List AS LIST_ENTRY ' LIST_ENTRY
 ReservedSize AS DWORD
 ReservedMappedBase AS DWORD
 ReservedMachine AS WORD ' USHORT
 ReservedCharacteristics AS WORD ' USHORT
 ReservedCheckSum AS DWORD
 ImageBase AS DWORD
 SizeOfImage AS DWORD
 ReservedNumberOfSections AS DWORD
 ReservedSections AS IMAGE_SECTION_HEADER PTR ' PIMAGE_SECTION_HEADER
 ReservedExportedNamesSize AS DWORD
 ReservedExportedNames AS ASCIIZ PTR
 ReservedNumberOfFunctionTableEntries AS DWORD
 ReservedFunctionTableEntries AS IMAGE_FUNCTION_ENTRY PTR ' PIMAGE_FUNCTION_ENTRY
 ReservedLowestFunctionStartingAddress AS DWORD
 ReservedHighestFunctionEndingAddress AS DWORD
 ReservedNumberOfFpoTableEntries AS DWORD
 ReservedFpoTableEntries AS FPO_DATA PTR ' PFPO_DATA
 SizeOfCoffSymbols AS DWORD
 CoffSymbols AS IMAGE_COFF_SYMBOLS_HEADER PTR ' PIMAGE_COFF_SYMBOLS_HEADER
 ReservedSizeOfCodeViewSymbols AS DWORD
 ReservedCodeViewSymbols AS DWORD
 ImageFilePath AS ASCIIZ PTR
 ImageFileName AS ASCIIZ PTR
 ReservedDebugFilePath AS ASCIIZ PTR
 ReservedTimeDateStamp AS DWORD
 ReservedRomImage AS LONG
 ReservedDebugDirectory AS IMAGE_DEBUG_DIRECTORY PTR ' PIMAGE_DEBUG_DIRECTORY
 ReservedNumberOfDebugDirectories AS DWORD
 ReservedOriginalFunctionTableBaseAddress AS DWORD
 Reserved(1) AS DWORD
END TYPE
DECLARE FUNCTION MapDebugInformation LIB "dbghelp.dll" ALIAS "MapDebugInformation" ( BYVAL FileHandle AS QUAD , BYREF FileName AS ASCIIZ , BYREF SymbolPath AS ASCIIZ , BYVAL ImageBase AS QUAD ) AS QUAD ' PIMAGE_DEBUG_INFORMATION
DECLARE FUNCTION UnmapDebugInformation LIB "dbghelp.dll" ALIAS "UnmapDebugInformation" ( BYREF DebugInfo AS IMAGE_DEBUG_INFORMATION ) AS LONG
'#endif
DECLARE FUNCTION SearchTreeForFileA LIB "dbghelp.dll" ALIAS "SearchTreeForFile" ( BYREF RootPath AS ASCIIZ , BYREF InputPathName AS ASCIIZ , BYREF OutputPathBuffer AS ASCIIZ ) AS LONG
DECLARE FUNCTION SearchTreeForFileW LIB "dbghelp.dll" ALIAS "SearchTreeForFileW" ( BYREF RootPath AS WSTRINGZ
 , BYREF InputPathName AS WSTRINGZ
 , BYREF OutputPathBuffer AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SearchTreeForFile = SearchTreeForFileW
#ELSE
 MACRO SearchTreeForFile = SearchTreeForFileA
#ENDIF
'typedef BOOL
'(CALLBACK *PENUMDIRTREE_CALLBACK)(
' );
'FUNCTION ENUMDIRTREE_CALLBACK ( ' BYREF szFilePath AS ASCIIZ
' , BYVAL CallerData AS DWORD
' ) AS LONG
' Requries version 6.0 or later.
DECLARE FUNCTION EnumDirTreeA LIB "dbghelp.dll" ALIAS "EnumDirTree" ( BYVAL hProcess AS QUAD , BYREF RootPath AS ASCIIZ , BYREF InputPathName AS ASCIIZ , BYREF OutputPathBuffer AS ASCIIZ , BYVAL cb AS QUAD , BYVAL data AS QUAD ) AS LONG
'typedef BOOL
'(CALLBACK *PENUMDIRTREE_CALLBACKW)(
' );
'FUNCTION ENUMDIRTREE_CALLBACKW ( ' BYREF szFilePath AS WSTRINGZ
' , BYVAL CallerData AS DWORD
' ) AS LONG
' Requries version 6.0 or later.
DECLARE FUNCTION EnumDirTreeW LIB "dbghelp.dll" ALIAS "EnumDirTreeW" ( BYVAL hProcess AS QUAD , BYREF RootPath AS WSTRINGZ , BYREF InputPathName AS WSTRINGZ , BYREF OutputPathBuffer AS QUAD , BYVAL cb AS QUAD , BYVAL data AS QUAD ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumDirTree = EnumDirTreeW
#ELSE
 MACRO EnumDirTree = EnumDirTreeA
#ENDIF
DECLARE FUNCTION MakeSureDirectoryPathExists LIB "dbghelp.dll" ALIAS "MakeSureDirectoryPathExists" ( BYREF DirPath AS ASCIIZ ) AS LONG
'//
'// UnDecorateSymbolName Flags
'//
%EQUATE `UNDNAME_COMPLETE = &H0000 ' // Enable full undecoration
%EQUATE `UNDNAME_NO_LEADING_UNDERSCORES = &H0001 ' // Remove leading underscores from MS extended keywords
%EQUATE `UNDNAME_NO_MS_KEYWORDS = &H0002 ' // Disable expansion of MS extended keywords
%EQUATE `UNDNAME_NO_FUNCTION_RETURNS = &H0004 ' // Disable expansion of return type for primary declaration
%EQUATE `UNDNAME_NO_ALLOCATION_MODEL = &H0008 ' // Disable expansion of the declaration model
%EQUATE `UNDNAME_NO_ALLOCATION_LANGUAGE = &H0010 ' // Disable expansion of the declaration language specifier
%EQUATE `UNDNAME_NO_MS_THISTYPE = &H0020 ' // NYI Disable expansion of MS keywords on the 'this' type for primary declaration
%EQUATE `UNDNAME_NO_CV_THISTYPE = &H0040 ' // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration
%EQUATE `UNDNAME_NO_THISTYPE = &H0060 ' // Disable all modifiers on the 'this' type
%EQUATE `UNDNAME_NO_ACCESS_SPECIFIERS = &H0080 ' // Disable expansion of access specifiers for members
%EQUATE `UNDNAME_NO_THROW_SIGNATURES = &H0100 ' // Disable expansion of 'throw-signatures' for functions and pointers to functions
%EQUATE `UNDNAME_NO_MEMBER_TYPE = &H0200 ' // Disable expansion of 'static' or 'virtual'ness of members
%EQUATE `UNDNAME_NO_RETURN_UDT_MODEL = &H0400 ' // Disable expansion of MS model for UDT returns
%EQUATE `UNDNAME_32_BIT_DECODE = &H0800 ' // Undecorate 32-bit decorated names
%EQUATE `UNDNAME_NAME_ONLY = &H1000 ' // Crack only the name for primary declaration;
 ' // return just [scope::]name. Does expand template params
%EQUATE `UNDNAME_NO_ARGUMENTS = &H2000 ' // Don't undecorate arguments to function
%EQUATE `UNDNAME_NO_SPECIAL_SYMS = &H4000 ' // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc???
DECLARE FUNCTION UnDecorateSymbolNameA LIB "dbghelp.dll" ALIAS "UnDecorateSymbolName" ( BYREF name AS ASCIIZ , BYREF outputString AS ASCIIZ , BYVAL maxStringLength AS QUAD , BYVAL flags AS QUAD ) AS QUAD
DECLARE FUNCTION UnDecorateSymbolNameW LIB "dbghelp.dll" ALIAS "UnDecorateSymbolNameW" ( BYREF name AS WSTRINGZ
 , BYREF outputString AS WSTRINGZ
 , BYVAL maxStringLength AS DWORD
 , BYVAL flags AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO UnDecorateSymbolName = UnDecorateSymbolNameW
#ELSE
 MACRO UnDecorateSymbolName = UnDecorateSymbolNameA
#ENDIF
'//
'// these values are used for synthesized file types
'// that can be passed in as image headers instead of
'// the standard ones from ntimage.h
'//
%EQUATE `DBHHEADER_DEBUGDIRS = &H1
%EQUATE `DBHHEADER_CVMISC = &H2
%EQUATE `DBHHEADER_PDBGUID = &H3
' // Size = 20 bytes
TYPE MODLOAD_DATA DWORD
 ssize AS DWORD ' DWORD // size of this struct
 ssig AS DWORD ' DWORD // signature identifying the passed data
 data AS DWORD ' PVOID // pointer to passed data
 size AS DWORD ' DWORD // size of passed data
 flags AS DWORD ' DWORD // options
END TYPE
' // Size = 24 bytes
TYPE MODLOAD_CVMISC DWORD
 oCV AS DWORD ' DWORD // ofset to the codeview record
 cCV AS DWORD ' size_t // size of the codeview record
 oMisc AS DWORD ' DWORD // offset to the misc record
 cMisc AS DWORD ' size_t // size of the misc record
 dtImage AS DWORD ' DWORD // datetime stamp of the image
 cImage AS DWORD ' DWORD // size of the image
END TYPE
' // Size = 20 bytes
TYPE MODLOAD_PDBGUID_PDBAGE DWORD
 PdbGuid AS GUID ' GUID // Pdb Guid
 PdbAge AS DWORD ' DWORD // Pdb Age
END TYPE
'//
'// StackWalking API
'//
' enum ADDRESS_MODE
%EQUATE `AddrMode1616 = 0
%EQUATE `AddrMode1632 = 1
%EQUATE `AddrModeReal = 2
%EQUATE `AddrModeFlat = 3
' // Size = 16 bytes
TYPE ADDRESS64 DWORD
 Offset AS QUAD ' DWORD64
 Segment AS WORD ' WORD
 Mode AS WORD ' ADDRESS_MODE
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define ADDRESS ADDRESS64
'#define LPADDRESS LPADDRESS64
'#else
'typedef struct _tagADDRESS {
' DWORD Offset;
' WORD Segment;
' ADDRESS_MODE Mode;
'} ADDRESS, *LPADDRESS;
' // Size = 12 bytes
TYPE ADDRESS DWORD
 Offset AS DWORD
 Segment AS WORD ' WORD
 Mode AS WORD ' ADDRESS_MODE
END TYPE
'void
'Address32To64(
' )
'{
' a64->Offset = (ULONG64)(LONG64)(LONG)a32->Offset;
' a64->Segment = a32->Segment;
' a64->Mode = a32->Mode;
'}
MACRO Address32To64 (a32, a64)
 a64.Offset = a32.Offset
 a64.Segment = a32.Segment
 a64.Mode = a32.Mode
END MACRO
'void
'Address64To32(
' )
'{
' a32->Offset = (ULONG)a64->Offset;
' a32->Segment = a64->Segment;
' a32->Mode = a64->Mode;
'}
MACRO Address64To32 (a64, a32)
 a32.Offset = a64.Offset
 a32.Segment = a64.Segment
 a32.Mode = a64.Mode
END MACRO
'#endif
'//
'// This structure is included in the STACKFRAME structure,
'// and is used to trace through usermode callbacks in a thread's
'// kernel stack. The values must be copied by the kernel debugger
'// from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets.
'//
'//
'// New KDHELP structure for 64 bit system support.
'// This structure is preferred in new code.
'//
'typedef struct _KDHELP64 {
' //
' // address of kernel thread object, as provided in the
' // WAIT_STATE_CHANGE packet.
' //
' DWORD64 Thread;
' //
' // offset in thread object to pointer to the current callback frame
' // in kernel stack.
' //
' DWORD ThCallbackStack;
' //
' // offset in thread object to pointer to the current callback backing
' // store frame in kernel stack.
' //
' DWORD ThCallbackBStore;
' //
' // offsets to values in frame:
' //
' // address of next callback frame
' DWORD NextCallback;
' // address of saved frame pointer (if applicable)
' DWORD FramePointer;
' //
' // Address of the kernel function that calls out to user mode
' //
' DWORD64 KiCallUserMode;
' //
' // Address of the user mode dispatcher function
' //
' DWORD64 KeUserCallbackDispatcher;
' //
' // Lowest kernel mode address
' //
' DWORD64 SystemRangeStart;
' //
' // Address of the user mode exception dispatcher function.
' // Added in API version 10.
' //
' DWORD64 KiUserExceptionDispatcher;
' //
' // Stack bounds, added in API version 11.
' //
' DWORD64 StackBase;
' DWORD64 StackLimit;
' DWORD64 Reserved[5];
'} KDHELP64, *PKDHELP64;
' // Size = 112 bytes
TYPE KDHELP64 DWORD
 Thread AS QUAD ' DWORD64
 ThCallbackStack AS DWORD
 ThCallbackBStore AS DWORD
 NextCallback AS DWORD
 FramePointer AS DWORD
 KiCallUserMode AS QUAD ' DWORD64
 KeUserCallbackDispatcher AS QUAD ' DWORD64
 SystemRangeStart AS QUAD ' DWORD64
 KiUserExceptionDispatcher AS QUAD ' DWORD64
 StackBase AS QUAD ' DWORD64
 StackLimit AS QUAD ' DWORD64
 Reserved(4) AS QUAD ' DWORD64
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define KDHELP KDHELP64
'#define PKDHELP PKDHELP64
'#else
'typedef struct _KDHELP {
' //
' // address of kernel thread object, as provided in the
' // WAIT_STATE_CHANGE packet.
' //
' DWORD Thread;
' //
' // offset in thread object to pointer to the current callback frame
' // in kernel stack.
' //
' DWORD ThCallbackStack;
' //
' // offsets to values in frame:
' //
' // address of next callback frame
' DWORD NextCallback;
' // address of saved frame pointer (if applicable)
' DWORD FramePointer;
' //
' // Address of the kernel function that calls out to user mode
' //
' DWORD KiCallUserMode;
' //
' // Address of the user mode dispatcher function
' //
' DWORD KeUserCallbackDispatcher;
' //
' // Lowest kernel mode address
' //
' DWORD SystemRangeStart;
' //
' // offset in thread object to pointer to the current callback backing
' // store frame in kernel stack.
' //
' DWORD ThCallbackBStore;
' //
' // Address of the user mode exception dispatcher function.
' // Added in API version 10.
' //
' DWORD KiUserExceptionDispatcher;
' //
' // Stack bounds, added in API version 11.
' //
' DWORD StackBase;
' DWORD StackLimit;
' DWORD Reserved[5];
'} KDHELP, *PKDHELP;
' // Size = 64 bytes
TYPE KDHELP DWORD
 Thread AS DWORD
 ThCallbackStack AS DWORD
 ThCallbackBStore AS DWORD
 NextCallback AS DWORD
 FramePointer AS DWORD
 KiCallUserMode AS DWORD
 KeUserCallbackDispatcher AS DWORD
 SystemRangeStart AS DWORD
 KiUserExceptionDispatcher AS DWORD
 StackBase AS DWORD
 StackLimit AS DWORD
 Reserved(4) AS DWORD
END TYPE
'void
'KdHelp32To64(
' )
'{
' p64->Thread = p32->Thread;
' p64->ThCallbackStack = p32->ThCallbackStack;
' p64->NextCallback = p32->NextCallback;
' p64->FramePointer = p32->FramePointer;
' p64->KiCallUserMode = p32->KiCallUserMode;
' p64->KeUserCallbackDispatcher = p32->KeUserCallbackDispatcher;
' p64->SystemRangeStart = p32->SystemRangeStart;
' p64->KiUserExceptionDispatcher = p32->KiUserExceptionDispatcher;
' p64->StackBase = p32->StackBase;
' p64->StackLimit = p32->StackLimit;
'}
MACRO KdHelp32To64 (p32, p64)
 p64.Thread = p32.Thread
 p64.ThCallbackStack = p32.ThCallbackStack
 p64.NextCallback = p32.NextCallback
 p64.FramePointer = p32.FramePointer
 p64.KiCallUserMode = p32.KiCallUserMode
 p64.KeUserCallbackDispatcher = p32.KeUserCallbackDispatcher
 p64.SystemRangeStart = p32.SystemRangeStart
 p64.KiUserExceptionDispatcher = p32.KiUserExceptionDispatcher
 p64.StackBase = p32.StackBase
 p64.StackLimit = p32.StackLimit
END MACRO
'#endif
' // Size = 264 bytes
TYPE STACKFRAME64 ' Must be 8 bytes aligned
 AddrPC AS ADDRESS64 'ADDRESS64 // program counter
 AddrReturn AS ADDRESS64 ' ADDRESS64 // return address
 AddrFrame AS ADDRESS64 ' ADDRESS64 // frame pointer
 AddrStack AS ADDRESS64 ' ADDRESS64 // stack pointer
 AddrBStore AS ADDRESS64 ' ADDRESS64 // backing store pointer
 FuncTableEntry AS DWORD ' PVOID // pointer to pdata/fpo or NULL
 alignment__ AS DWORD ' // To keep 8 bytes alignment
 Params(3) AS QUAD ' DWORD64 // possible arguments to the function
 Far AS LONG ' BOOL // WOW far call
 Virtual AS LONG ' BOOL // is this a virtual frame?
 Reserved(2) AS QUAD ' DWORD64
 KdHelp AS KDHELP64 ' KDHELP64
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define STACKFRAME STACKFRAME64
'#define LPSTACKFRAME LPSTACKFRAME64
'#else
' // Size = 164 bytes
TYPE STACKFRAME DWORD
 AddrPC AS ADDRESS ' ADDRESS // program counter
 AddrReturn AS ADDRESS ' ADDRESS // return address
 AddrFrame AS ADDRESS ' ADDRESS // frame pointer
 AddrStack AS ADDRESS ' ADDRESS // stack pointer
 FuncTableEntry AS DWORD ' PVOID // pointer to pdata/fpo or NULL
 Params(3) AS DWORD ' DWORD // possible arguments to the function
 Far AS LONG ' BOOL // WOW far call
 Virtual AS LONG ' BOOL // is this a virtual frame?
 Reserved(2) AS DWORD
 KdHelp AS KDHELP ' KDHELP
 AddrBStore AS ADDRESS ' ADDRESS // backing store pointer
END TYPE
'#endif
'typedef
'(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(
' );
'FUNCTION READ_PROCESS_MEMORY_ROUTINE64 ( ' BYVAL hProcess AS DWORD
' , BYVAL qwBaseAddress AS QUAD
' , BYREF lpBuffer AS DWORD
' , BYVAL nSize AS DWORD
' , BYREF lpNumberOfBytesRead AS DWORD
' ) AS LONG
'typedef
'(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)(
' );
'FUNCTION FUNCTION_TABLE_ACCESS_ROUTINE64 ( ' BYVAL ahProcess AS DWORD
' , BYVAL AddrBase AS QUAD
' ) AS DWORD
'typedef
'DWORD64
'(__stdcall *PGET_MODULE_BASE_ROUTINE64)(
' );
'FUNCTION GET_MODULE_BASE_ROUTINE64 ( ' BYVAL hProcess AS DWORD
' , BYVAL Address AS QUAD
' ) AS QUAD ' DWORD64
'typedef
'DWORD64
'(__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(
' );
'FUNCTION TRANSLATE_ADDRESS_ROUTINE64 ( ' BYVAL hProcess AS DWORD
' , BYVAL hThread AS DWORD
' , BYREF lpaddr AS ADDRESS64
' ) AS QUAD ' DWORD64
DECLARE FUNCTION StackWalk64 LIB "dbghelp.dll" ALIAS "StackWalk64" ( BYVAL MachineType AS QUAD , BYVAL hProcess AS QUAD , BYVAL hThread AS QUAD , BYREF StackFrame AS STACKFRAME64 , BYREF ContextRecord AS ANY , BYVAL ReadMemoryRoutine AS QUAD , BYVAL FunctionTableAccessRoutine AS QUAD , BYVAL GetModuleBaseRoutine AS QUAD , BYVAL TranslateAddress AS QUAD ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define PREAD_PROCESS_MEMORY_ROUTINE PREAD_PROCESS_MEMORY_ROUTINE64
'#define PFUNCTION_TABLE_ACCESS_ROUTINE PFUNCTION_TABLE_ACCESS_ROUTINE64
'#define PGET_MODULE_BASE_ROUTINE PGET_MODULE_BASE_ROUTINE64
'#define PTRANSLATE_ADDRESS_ROUTINE PTRANSLATE_ADDRESS_ROUTINE64
'#define StackWalk StackWalk64
'#else
'typedef
'(__stdcall *PREAD_PROCESS_MEMORY_ROUTINE)(
' );
'FUNCTION READ_PROCESS_MEMORY_ROUTINE ( ' BYVAL hProcess AS DWORD
' , BYVAL qwBaseAddress AS DWORD
' , BYREF lpBuffer AS DWORD
' , BYVAL nSize AS DWORD
' , BYREF lpNumberOfBytesRead AS DWORD
' ) AS LONG
'typedef
'(__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE)(
' );
'FUNCTION FUNCTION_TABLE_ACCESS_ROUTINE ( ' BYVAL ahProcess AS DWORD
' , BYVAL AddrBase AS DWORD
' ) AS DWORD
'typedef
'(__stdcall *PGET_MODULE_BASE_ROUTINE)(
' );
'FUNCTION GET_MODULE_BASE_ROUTINE ( ' BYVAL hProcess AS DWORD
' , BYVAL Address AS DWORD
' ) AS DWORD
'typedef
'(__stdcall *PTRANSLATE_ADDRESS_ROUTINE)(
' );
'FUNCTION TRANSLATE_ADDRESS_ROUTINE ( ' BYVAL hProcess AS DWORD
' , BYVAL hThread AS DWORD
' , BYREF lpaddr AS ADDRESS
' ) AS DWORD
'IMAGEAPI
'StackWalk(
' DWORD MachineType,
' );
DECLARE FUNCTION StackWalk LIB "dbghelp.dll" ALIAS "StackWalk" ( BYVAL MachineType AS QUAD , BYVAL hProcess AS QUAD , BYVAL hThread AS QUAD , BYREF StackFrame AS STACKFRAME , BYREF ContextRecord AS ANY , BYVAL ReadMemoryRoutine AS QUAD , BYVAL FunctionTableAccessRoutine AS QUAD , BYVAL GetModuleBaseRoutine AS QUAD , BYVAL TranslateAddress AS QUAD ) AS LONG
'#endif
%EQUATE `PI_VERSION_NUMBER = 11
' // Size = 8 bytes
TYPE API_VERSION WORD
 MajorVersion AS WORD ' USHORT
 MinorVersion AS WORD ' USHORT
 Revision AS WORD ' USHORT
 Reserved AS WORD ' USHORT
END TYPE
DECLARE FUNCTION ImagehlpApiVersion LIB "dbghelp.dll" ALIAS "ImagehlpApiVersion" ( ) AS QUAD ' LPAPI_VERSION
DECLARE FUNCTION ImagehlpApiVersionEx LIB "dbghelp.dll" ALIAS "ImagehlpApiVersionEx" ( BYREF AppVersion AS API_VERSION ) AS QUAD ' LPAPI_VERSION
DECLARE FUNCTION GetTimestampForLoadedLibrary LIB "dbghelp.dll" ALIAS "GetTimestampForLoadedLibrary" ( BYVAL Module AS QUAD ) AS QUAD
'//
'// typedefs for function pointers
'//
'typedef BOOL
'(CALLBACK *PSYM_ENUMMODULES_CALLBACK64)(
' );
'FUNCTION SYM_ENUMMODULES_CALLBACK64 ( ' BYREF ModuleName AS ASCIIZ
' , BYVAL BaseOfDll AS QUAD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMMODULES_CALLBACKW64)(
' );
'FUNCTION SYM_ENUMMODULES_CALLBACKW64 ( ' BYREF ModuleName AS WSTRINGZ
' , BYVAL BaseOfDll AS QUAD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PENUMLOADED_MODULES_CALLBACK64)(
' );
'FUNCTION ENUMLOADED_MODULES_CALLBACK64 ( ' BYREF ModuleName AS ASCIIZ
' , BYVAL BaseOfDll AS QUAD
' , BYVAL ModuleSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PENUMLOADED_MODULES_CALLBACKW64)(
' );
'FUNCTION ENUMLOADED_MODULES_CALLBACKW64 ( ' BYREF ModuleName AS WSTRINGZ
' , BYVAL ModuleBase AS QUAD
' , BYVAL ModuleSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64)(
' );
'FUNCTION SYM_ENUMSYMBOLS_CALLBACK64 ( ' BYREF SymbolName AS ASCIIZ
' , BYVAL SymbolAddress AS QUAD
' , BYVAL SymbolSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK64W)(
' );
'FUNCTION SYM_ENUMSYMBOLS_CALLBACK64W ( ' BYREF SymbolName AS WSTRINGZ
' , BYVAL SymbolAddress AS QUAD
' , BYVAL SymbolSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYMBOL_REGISTERED_CALLBACK64)(
' );
'FUNCTION SYMBOL_REGISTERED_CALLBACK64 ( ' BYVAL hProcess AS DWORD
' , BYVAL ActionCode AS DWORD
' , BYVAL CallbackData AS QUAD
' , BYVAL UserContext AS QUAD
' ) AS LONG
'typedef
'(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK)(
' );
'FUNCTION SYMBOL_FUNCENTRY_CALLBACK ( ' BYVAL hProcess AS DWORD
' , BYVAL AddrBase AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS DWORD
'typedef
'(CALLBACK *PSYMBOL_FUNCENTRY_CALLBACK64)(
' );
'FUNCTION SYMBOL_FUNCENTRY_CALLBACK64 ( ' BYVAL hProcess AS DWORD
' , BYVAL AddrBase AS QUAD
' , BYVAL UserContext AS QUAD
' ) AS DWORD
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define PSYM_ENUMMODULES_CALLBACK PSYM_ENUMMODULES_CALLBACK64
'#define PSYM_ENUMSYMBOLS_CALLBACK PSYM_ENUMSYMBOLS_CALLBACK64
'#define PSYM_ENUMSYMBOLS_CALLBACKW PSYM_ENUMSYMBOLS_CALLBACK64W
'#define PENUMLOADED_MODULES_CALLBACK PENUMLOADED_MODULES_CALLBACK64
'#define PSYMBOL_REGISTERED_CALLBACK PSYMBOL_REGISTERED_CALLBACK64
'#define PSYMBOL_FUNCENTRY_CALLBACK PSYMBOL_FUNCENTRY_CALLBACK64
'#else
'typedef BOOL
'(CALLBACK *PSYM_ENUMMODULES_CALLBACK)(
' );
'FUNCTION SYM_ENUMMODULES_CALLBACK ( ' BYREF ModuleName AS ASCIIZ
' , BYVAL BaseOfDll AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACK)(
' );
'FUNCTION SYM_ENUMSYMBOLS_CALLBACK ( ' BYREF SymbolName AS ASCIIZ
' , BYVAL SymbolAddress AS DWORD
' , BYVAL SymbolSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMSYMBOLS_CALLBACKW)(
' );
'FUNCTION SYM_ENUMSYMBOLS_CALLBACKW ( ' BYREF SymbolName AS WSTRINGZ
' , BYVAL SymbolAddress AS DWORD
' , BYVAL SymbolSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PENUMLOADED_MODULES_CALLBACK)(
' );
'FUNCTION ENUMLOADED_MODULES_CALLBACK ( ' BYREF ModuleName AS ASCIIZ
' , BYVAL BaseOfDll AS DWORD
' , BYVAL ModuleSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
'typedef BOOL
'(CALLBACK *PSYMBOL_REGISTERED_CALLBACK)(
' );
'FUNCTION SYMBOL_REGISTERED_CALLBACK ( ' BYVAL hProcess AS DWORD
' , BYVAL ActionCode AS DWORD
' , BYVAL CallbackData AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
''#endif
'// values found in SYMBOL_INFO.Tag
'//
'// This was taken from cvconst.h and should
'// not override any values found there.
'//
'// #define _NO_CVCONST_H_ if you don't
'// have access to that file...
'#ifdef _NO_CVCONST_H
'// DIA enums
' enum SymTagEnum
%EQUATE `SymTagNull = 0
%EQUATE `SymTagExe = 1
%EQUATE `SymTagCompiland = 2
%EQUATE `SymTagCompilandDetails = 3
%EQUATE `SymTagCompilandEnv = 4
%EQUATE `SymTagFunction = 5
%EQUATE `SymTagBlock = 6
%EQUATE `SymTagData = 7
%EQUATE `SymTagAnnotation = 8
%EQUATE `SymTagLabel = 9
%EQUATE `SymTagPublicSymbol = 10
%EQUATE `SymTagUDT = 11
%EQUATE `SymTagEnum = 12
%EQUATE `SymTagFunctionType = 13
%EQUATE `SymTagPointerType = 14
%EQUATE `SymTagArrayType = 15
%EQUATE `SymTagBaseType = 16
%EQUATE `SymTagTypedef = 17
%EQUATE `SymTagBaseClass = 18
%EQUATE `SymTagFriend = 19
%EQUATE `SymTagFunctionArgType = 20
%EQUATE `SymTagFuncDebugStart = 21
%EQUATE `SymTagFuncDebugEnd = 22
%EQUATE `SymTagUsingNamespace = 23
%EQUATE `SymTagVTableShape = 24
%EQUATE `SymTagVTable = 25
%EQUATE `SymTagCustom = 26
%EQUATE `SymTagThunk = 27
%EQUATE `SymTagCustomType = 28
%EQUATE `SymTagManagedType = 29
%EQUATE `SymTagDimension = 30
%EQUATE `SymTagMax = 31
'#endif
'//
'// flags found in SYMBOL_INFO.Flags
'//
%EQUATE `SYMFLAG_VALUEPRESENT = &H00000001
%EQUATE `SYMFLAG_REGISTER = &H00000008
%EQUATE `SYMFLAG_REGREL = &H00000010
%EQUATE `SYMFLAG_FRAMEREL = &H00000020
%EQUATE `SYMFLAG_PARAMETER = &H00000040
%EQUATE `SYMFLAG_LOCAL = &H00000080
%EQUATE `SYMFLAG_CONSTANT = &H00000100
%EQUATE `SYMFLAG_EXPORT = &H00000200
%EQUATE `SYMFLAG_FORWARDER = &H00000400
%EQUATE `SYMFLAG_FUNCTION = &H00000800
%EQUATE `SYMFLAG_VIRTUAL = &H00001000
%EQUATE `SYMFLAG_THUNK = &H00002000
%EQUATE `SYMFLAG_TLSREL = &H00004000
%EQUATE `SYMFLAG_SLOT = &H00008000
%EQUATE `SYMFLAG_ILREL = &H00010000
%EQUATE `SYMFLAG_METADATA = &H00020000
%EQUATE `SYMFLAG_CLR_TOKEN = &H00040000
'// this resets SymNext/Prev to the beginning
'// of the module passed in the address field
%EQUATE `SYMFLAG_RESET = &H80000000
'//
'// symbol type enumeration
'//
' enum SYM_TYPE
%EQUATE `SymNone = 0
%EQUATE `SymCoff = 1
%EQUATE `SymCv = 2
%EQUATE `SymPdb = 3
%EQUATE `SymExport = 4
%EQUATE `SymDeferred = 5
%EQUATE `SymSym = 6 ' // .sym file
%EQUATE `SymDia = 7
%EQUATE `SymVirtual = 8
%EQUATE `NumSymTypes = 9
'//
'// symbol data structure
'//
' // Size in C++ = 32 bytes
TYPE IMAGEHLP_SYMBOL64 QWORD FILL
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_SYMBOL64)
 Address AS QUAD ' DWORD64 // virtual address including dll base address
 Size AS DWORD ' DWORD // estimated size of symbol, can be zero
 Flags AS DWORD ' DWORD // info about the symbols, see the SYMF defines
 MaxNameLength AS DWORD ' DWORD // maximum size of symbol name in 'Name'
 Name AS ASCIIZ * 1 ' CHAR // symbol name (null terminated string)
END TYPE
' // Size in C++ = 32 bytes
TYPE IMAGEHLP_SYMBOLW64 QWORD FILL
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_SYMBOLW64)
 Address AS QUAD ' DWORD64 // virtual address including dll base address
 Size AS DWORD ' DWORD // estimated size of symbol, can be zero
 Flags AS DWORD ' DWORD // info about the symbols, see the SYMF defines
 MaxNameLength AS DWORD ' DWORD // maximum size of symbol name in 'Name'
 Name AS WSTRINGZ * 1 ' WCHAR // symbol name (null terminated string)
END TYPE
' // Size in C++ = 2040 bytes
TYPE IMAGEHLP_SYMBOL64_PACKAGE QWORD FILL
 sym AS IMAGEHLP_SYMBOL64
 name AS ASCIIZ * (%MAX_SYM_NAME + 1) ' CHAR name[MAX_SYM_NAME + 1];
END TYPE
' // Size in C++ = 4040 bytes
TYPE IMAGEHLP_SYMBOLW64_PACKAGE QWORD FILL
 sym AS IMAGEHLP_SYMBOLW64
 name AS WSTRINGZ * %MAX_SYM_NAME + 1 ' WCHAR name[MAX_SYM_NAME + 1];
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
' #define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
' #define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
' #define IMAGEHLP_SYMBOL_PACKAGE IMAGEHLP_SYMBOL64_PACKAGE
' #define PIMAGEHLP_SYMBOL_PACKAGE PIMAGEHLP_SYMBOL64_PACKAGE
' #define IMAGEHLP_SYMBOLW IMAGEHLP_SYMBOLW64
' #define PIMAGEHLP_SYMBOLW PIMAGEHLP_SYMBOLW64
' #define IMAGEHLP_SYMBOLW_PACKAGE IMAGEHLP_SYMBOLW64_PACKAGE
' #define PIMAGEHLP_SYMBOLW_PACKAGE PIMAGEHLP_SYMBOLW64_PACKAGE
'#else
' // Size in C++ = 24 bytes
TYPE IMAGEHLP_SYMBOL DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_SYMBOL64)
 Address AS DWORD ' DWORD // virtual address including dll base address
 Size AS DWORD ' DWORD // estimated size of symbol, can be zero
 Flags AS DWORD ' DWORD // info about the symbols, see the SYMF defines
 MaxNameLength AS DWORD ' DWORD // maximum size of symbol name in 'Name'
 Name AS ASCIIZ * 1 ' CHAR // symbol name (null terminated string)
END TYPE
' // Size in C++ = 24 bytes
TYPE IMAGEHLP_SYMBOLW DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_SYMBOLW64)
 Address AS DWORD ' DWORD // virtual address including dll base address
 Size AS DWORD ' DWORD // estimated size of symbol, can be zero
 Flags AS DWORD ' DWORD // info about the symbols, see the SYMF defines
 MaxNameLength AS DWORD ' DWORD // maximum size of symbol name in 'Name'
 Name AS WSTRINGZ * 1 ' WCHAR // symbol name (null terminated string)
END TYPE
' // Size in C++ = 2028 bytes
TYPE IMAGEHLP_SYMBOL_PACKAGE DWORD
 sym AS IMAGEHLP_SYMBOL
 name AS ASCIIZ * (%MAX_SYM_NAME + 1) ' CHAR name[MAX_SYM_NAME + 1];
END TYPE
' // Size in C++ = 4028 bytes
TYPE IMAGEHLP_SYMBOLW_PACKAGE DWORD
 sym AS IMAGEHLP_SYMBOLW
 name AS WSTRINGZ * (%MAX_SYM_NAME + 1) ' WCHAR name[MAX_SYM_NAME + 1];
END TYPE
'#endif
'//
'// module data structure
'//
' // Size = 1672 bytes
TYPE IMAGEHLP_MODULE64 ' Must be 8 bytes aligned
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_MODULE64)
 alignment__ AS DWORD ' // To keep 8 bytes alignment
 BaseOfImage AS QUAD ' DWORD64 // base load address of module
 ImageSize AS DWORD ' DWORD // virtual size of the loaded module
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 NumSyms AS DWORD ' DWORD // number of symbols in the symbol table
 SymType AS DWORD ' SYM_TYPE // type of symbols loaded
 ModuleName AS ASCIIZ * 32 ' CHAR // module name
 ImageName AS ASCIIZ * 256 ' CHAR // image name
 LoadedImageName AS ASCIIZ * 256 ' CHAR // symbol file name
 ' // new elements: 07-Jun-2002
 LoadedPdbName AS ASCIIZ * 256 ' CHAR // pdb file name
 CVSig AS DWORD ' DWORD // Signature of the CV record in the debug directories
 CVData AS ASCIIZ * (%MAX_PATH * 3) ' CHAR // Contents of the CV record
 PdbSig AS DWORD ' DWORD // Signature of PDB
 PdbSig70 AS GUID ' GUID // Signature of PDB (VC 7 and up)
 PdbAge AS DWORD ' DWORD // DBI age of pdb
 PdbUnmatched AS LONG ' BOOL // loaded an unmatched pdb
 DbgUnmatched AS LONG ' BOOL // loaded an unmatched dbg
 LineNumbers AS LONG ' BOOL // we have line number information
 GlobalSymbols AS LONG ' BOOL // we have internal symbol information
 TypeInfo AS LONG ' BOOL// we have type information
 ' // new elements: 17-Dec-2003
 SourceIndexed AS LONG ' BOOL // pdb supports source server
 Publics AS LONG ' BOOL // contains public symbols
END TYPE
' // Size = 3256 bytes
TYPE IMAGEHLP_MODULEW64
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_MODULE64)
 alignment1__ AS DWORD ' // To keep 8 bytes alignment
 BaseOfImage AS QUAD ' DWORD64 // base load address of module
 ImageSize AS DWORD ' DWORD // virtual size of the loaded module
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 NumSyms AS DWORD ' DWORD // number of symbols in the symbol table
 SymType AS DWORD ' SYM_TYPE // type of symbols loaded
 ModuleName AS WSTRINGZ * 32 ' WCHAR // module name
 ImageName AS WSTRINGZ * 256 ' WCHAR // image name
 LoadedImageName AS WSTRINGZ * 256 ' WCHAR // symbol file name
 ' // new elements: 07-Jun-2002
 LoadedPdbName AS WSTRINGZ * 256 ' WCHAR // pdb file name
 CVSig AS DWORD ' DWORD // Signature of the CV record in the debug directories
 CVData AS WSTRINGZ * (%MAX_PATH * 3) ' WCHAR // Contents of the CV record
 PdbSig AS DWORD ' DWORD // Signature of PDB
 alignment2__ AS DWORD ' // To keep 8 bytes alignment
 PdbSig70 AS GUID ' GUID // Signature of PDB (VC 7 and up)
 PdbAge AS DWORD ' DWORD // DBI age of pdb
 PdbUnmatched AS LONG ' BOOL // loaded an unmatched pdb
 DbgUnmatched AS LONG ' BOOL // loaded an unmatched dbg
 LineNumbers AS LONG ' BOOL // we have line number information
 GlobalSymbols AS LONG ' BOOL // we have internal symbol information
 TypeInfo AS LONG ' BOOL// we have type information
 ' // new elements: 17-Dec-2003
 SourceIndexed AS LONG ' BOOL // pdb supports source server
 Publics AS LONG ' BOOL // contains public symbols
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define IMAGEHLP_MODULE IMAGEHLP_MODULE64
'#define PIMAGEHLP_MODULE PIMAGEHLP_MODULE64
'#define IMAGEHLP_MODULEW IMAGEHLP_MODULEW64
'#define PIMAGEHLP_MODULEW PIMAGEHLP_MODULEW64
'#else
' // Size = 572 bytes
TYPE IMAGEHLP_MODULE DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_MODULE64)
 BaseOfImage AS DWORD ' DWORD // base load address of module
 ImageSize AS DWORD ' DWORD // virtual size of the loaded module
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 NumSyms AS DWORD ' DWORD // number of symbols in the symbol table
 SymType AS DWORD ' SYM_TYPE // type of symbols loaded
 ModuleName AS ASCIIZ * 32 ' CHAR // module name
 ImageName AS ASCIIZ * 256 ' CHAR // image name
 LoadedImageName AS ASCIIZ * 256 ' CHAR // symbol file name
END TYPE
' // Size = 1116 bytes
TYPE IMAGEHLP_MODULEW DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_MODULE64)
 BaseOfImage AS DWORD ' DWORD // base load address of module
 ImageSize AS DWORD ' DWORD // virtual size of the loaded module
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 NumSyms AS DWORD ' DWORD // number of symbols in the symbol table
 SymType AS DWORD ' SYM_TYPE // type of symbols loaded
 ModuleName AS WSTRINGZ * 32 ' WCHAR // module name
 ImageName AS WSTRINGZ * 256 ' WCHAR // image name
 LoadedImageName AS WSTRINGZ * 256 ' WCHAR // symbol file name
END TYPE
'#endif
'//
'// source file line data structure
'//
' // Size = 24 bytes
TYPE IMAGEHLP_LINE64 DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_LINE64)
 Key AS DWORD ' PVOID // internal
 LineNumber AS DWORD ' DWORD // line number in file
 FileName AS ASCIIZ PTR ' PCHAR // full filename
 Address AS QUAD ' DWORD64 // first instruction of line
END TYPE
' // Size = 24 bytes
TYPE IMAGEHLP_LINEW64 DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_LINE64)
 Key AS DWORD ' PVOID // internal
 LineNumber AS DWORD ' DWORD // line number in file
 FileName AS WSTRINGZ PTR ' PWSTR // full filename
 Address AS QUAD ' DWORD64 // first instruction of line
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define IMAGEHLP_LINE IMAGEHLP_LINE64
'#define PIMAGEHLP_LINE PIMAGEHLP_LINE64
'#else
' // Size = 20 bytes
TYPE IMAGEHLP_LINE DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_LINE64)
 Key AS DWORD ' PVOID // internal
 LineNumber AS DWORD ' DWORD // line number in file
 FileName AS ASCIIZ PTR ' PCHAR // full filename
 Address AS DWORD ' DWORD // first instruction of line
END TYPE
'typedef struct _IMAGEHLP_LINEW {
' DWORD SizeOfStruct; // set to sizeof(IMAGEHLP_LINE64)
' PVOID Key; // internal
' DWORD LineNumber; // line number in file
' PCHAR FileName; // full filename *** wrong ***
' DWORD64 Address; // first instruction of line *** wrong ***
'} IMAGEHLP_LINEW, *PIMAGEHLP_LINEW;
' // Size = 24 bytes
TYPE IMAGEHLP_LINEW DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_LINE64)
 Key AS DWORD ' PVOID // internal
 LineNumber AS DWORD ' DWORD // line number in file
 FileName AS WSTRINGZ PTR ' PWSTR // full filename
 Address AS QUAD ' DWORD64 // first instruction of line
END TYPE
'#endif
'//
'// source file structure
'//
' // Size = 16 bytes
TYPE SOURCEFILE QWORD
 ModBase AS QUAD ' DWORD64 // base address of loaded module
 FileName AS ASCIIZ PTR ' PCHAR // full filename of source
END TYPE
' // Size = 16 bytes
TYPE SOURCEFILEW QWORD
 ModBase AS QUAD ' DWORD64 // base address of loaded module
 FileName AS WSTRINGZ PTR ' PWSTR // full filename of source
END TYPE
'//
'// data structures used for registered symbol callbacks
'//
%EQUATE `CBA_DEFERRED_SYMBOL_LOAD_START = &H00000001
%EQUATE `CBA_DEFERRED_SYMBOL_LOAD_COMPLETE = &H00000002
%EQUATE `CBA_DEFERRED_SYMBOL_LOAD_FAILURE = &H00000003
%EQUATE `CBA_SYMBOLS_UNLOADED = &H00000004
%EQUATE `CBA_DUPLICATE_SYMBOL = &H00000005
%EQUATE `CBA_READ_MEMORY = &H00000006
%EQUATE `CBA_DEFERRED_SYMBOL_LOAD_CANCEL = &H00000007
%EQUATE `CBA_SET_OPTIONS = &H00000008
%EQUATE `CBA_EVENT = &H00000010
%EQUATE `CBA_DEFERRED_SYMBOL_LOAD_PARTIAL = &H00000020
%EQUATE `CBA_DEBUG_INFO = &H10000000
%EQUATE `CBA_SRCSRV_INFO = &H20000000
%EQUATE `CBA_SRCSRV_EVENT = &H40000000
' // Size = 24 bytes
TYPE IMAGEHLP_CBA_READ_MEMORY ' Must be 8 bytes aligned
 addr AS QUAD ' DWORD64 // address to read from
 buf AS DWORD ' PVOID // buffer to read to
 bytes AS DWORD ' DWORD // amount of bytes to read
 bytesread AS DWORD PTR ' DWORD* // pointer to store amount of bytes read
 alignment__ AS DWORD ' // To keep 8 bytes alignment
END TYPE
' enum
%EQUATE `sevInfo = 0
%EQUATE `sevProblem = 1
%EQUATE `sevAttn = 2
%EQUATE `sevFatal = 3
'sevMax // unused
%EQUATE `EVENT_SRCSPEW_START = 100
%EQUATE `EVENT_SRCSPEW = 100
%EQUATE `EVENT_SRCSPEW_END = 199
' // Size = 16 bytes
TYPE IMAGEHLP_CBA_EVENT DWORD
 severity AS DWORD ' DWORD // values from sevInfo to sevFatal
 code AS DWORD ' DWORD // numerical code IDs the error
 desc AS ASCIIZ PTR ' PCHAR // may contain a text description of the error
 object AS DWORD ' PVOID // value dependant upon the error code
END TYPE
' // Size = 16 bytes
TYPE IMAGEHLP_CBA_EVENTW DWORD
 severity AS DWORD ' DWORD // values from sevInfo to sevFatal
 code AS DWORD ' DWORD // numerical code IDs the error
 desc AS WSTRINGZ PTR ' PCWSTR // may contain a text description of the error
 object AS DWORD ' PVOID // value dependant upon the error code
END TYPE
' // Size = 296 bytes
TYPE IMAGEHLP_DEFERRED_SYMBOL_LOAD64 QWORD FILL
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
 BaseOfImage AS QUAD ' DWORD64 // base load address of module
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 FileName AS ASCIIZ * %MAX_PATH ' CHAR // symbols file or image name
 Reparse AS BYTE ' BOOLEAN // load failure reparse
 hFile AS DWORD ' HANDLE // file handle, if passed
 Flags AS DWORD
END TYPE
' // Size = 560 bytes
TYPE IMAGEHLP_DEFERRED_SYMBOL_LOADW64 QWORD FILL
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
 BaseOfImage AS QUAD ' DWORD64 // base load address of module
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 FileName AS WSTRINGZ * %MAX_PATH ' WCHAR // symbols file or image name
 Reparse AS BYTE ' BOOLEAN // load failure reparse
 hFile AS DWORD ' HANDLE // file handle, if passed
 Flags AS DWORD
 alignment__ AS DWORD ' // To keep 8 bytes alignment
END TYPE
%EQUATE `DSLFLAG_MISMATCHED_PDB = &H1
%EQUATE `DSLFLAG_MISMATCHED_DBG = &H2
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define IMAGEHLP_DEFERRED_SYMBOL_LOAD IMAGEHLP_DEFERRED_SYMBOL_LOAD64
'#define PIMAGEHLP_DEFERRED_SYMBOL_LOAD PIMAGEHLP_DEFERRED_SYMBOL_LOAD64
'#else
' // Size = 284 bytes
TYPE IMAGEHLP_DEFERRED_SYMBOL_LOAD DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
 BaseOfImage AS DWORD ' DWORD // base load address of module
 CheckSum AS DWORD ' DWORD // checksum from the pe header
 TimeDateStamp AS DWORD ' DWORD // date/time stamp from pe header
 FileName AS ASCIIZ * %MAX_PATH ' CHAR // symbols file or image name
 Reparse AS BYTE ' BOOLEAN // load failure reparse
 hFile AS DWORD ' HANDLE // file handle, if passed
END TYPE
'#endif
' // Size = 16 bytes
TYPE IMAGEHLP_DUPLICATE_SYMBOL64 DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64)
 NumberOfDups AS DWORD ' DWORD // number of duplicates in the Symbol array
 Symbol AS IMAGEHLP_SYMBOL64 PTR ' PIMAGEHLP_SYMBOL64 // array of duplicate symbols
 SelectedSymbol AS DWORD ' DWORD // symbol selected (-1 to start)
END TYPE
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define IMAGEHLP_DUPLICATE_SYMBOL IMAGEHLP_DUPLICATE_SYMBOL64
'#define PIMAGEHLP_DUPLICATE_SYMBOL PIMAGEHLP_DUPLICATE_SYMBOL64
'#else
' // Size = 16 bytes
TYPE IMAGEHLP_DUPLICATE_SYMBOL DWORD
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64)
 NumberOfDups AS DWORD ' DWORD // number of duplicates in the Symbol array
 Symbol AS IMAGEHLP_SYMBOL PTR ' PIMAGEHLP_SYMBOL // array of duplicate symbols
 SelectedSymbol AS DWORD ' DWORD // symbol selected (-1 to start)
END TYPE
'#endif
'// If dbghelp ever needs to display graphical UI, it will use this as the parent window.
DECLARE FUNCTION SymSetParentWindowA LIB "dbghelp.dll" ALIAS "SymSetParentWindow" ( BYVAL hwnd AS QUAD ) AS LONG
DECLARE FUNCTION SymSetHomeDirectoryA LIB "dbghelp.dll" ALIAS "SymSetHomeDirectory" ( BYVAL hProcess AS QUAD
 , BYREF dir AS ASCIIZ
 ) AS DWORD
DECLARE FUNCTION SymSetHomeDirectoryW LIB "dbghelp.dll" ALIAS "SymSetHomeDirectoryW" ( BYVAL hProcess AS DWORD
 , BYREF dir AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymSetHomeDirectory = SymSetHomeDirectoryW
#ELSE
 MACRO SymSetHomeDirectory = SymSetHomeDirectoryA
#ENDIF
DECLARE FUNCTION SymGetHomeDirectoryA LIB "dbghelp.dll" ALIAS "SymGetHomeDirectory" ( BYVAL type AS QUAD , BYREF dir AS ASCIIZ , BYVAL size AS QUAD ) AS QUAD
DECLARE FUNCTION SymGetHomeDirectoryW LIB "dbghelp.dll" ALIAS "SymGetHomeDirectoryW" ( BYVAL type AS QUAD
 , BYREF dir AS DWORD
 , BYVAL size AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymGetHomeDirectory = SymGetHomeDirectoryW
#ELSE
 MACRO SymGetHomeDirectory = SymGetHomeDirectoryA
#ENDIF
' enum
%EQUATE `hdBase = 0 ' // root directory for dbghelp
%EQUATE `hdSym = 1 ' // where symbols are stored
%EQUATE `hdSrc = 2 ' // where source is stored
%EQUATE `hdMax = 3 ' // end marker
' // Size = 8 bytes
TYPE OMAP DWORD
 rva AS DWORD ' ULONG
 rvaTo AS DWORD ' ULONG
END TYPE
DECLARE FUNCTION SymGetOmaps LIB "dbghelp.dll" ALIAS "SymGetOmaps" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYREF OmapTo AS OMAP , BYREF cOmapTo AS QUAD , BYREF OmapFrom AS OMAP , BYREF cOmapFrom AS QUAD ) AS LONG
'//
'// options that are set/returned by SymSetOptions() & SymGetOptions()
'// these are used as a mask
'//
%EQUATE `SYMOPT_CASE_INSENSITIVE = &H00000001
%EQUATE `SYMOPT_UNDNAME = &H00000002
%EQUATE `SYMOPT_DEFERRED_LOADS = &H00000004
%EQUATE `SYMOPT_NO_CPP = &H00000008
%EQUATE `SYMOPT_LOAD_LINES = &H00000010
%EQUATE `SYMOPT_OMAP_FIND_NEAREST = &H00000020
%EQUATE `SYMOPT_LOAD_ANYTHING = &H00000040
%EQUATE `SYMOPT_IGNORE_CVREC = &H00000080
%EQUATE `SYMOPT_NO_UNQUALIFIED_LOADS = &H00000100
%EQUATE `SYMOPT_FAIL_CRITICAL_ERRORS = &H00000200
%EQUATE `SYMOPT_EXACT_SYMBOLS = &H00000400
%EQUATE `SYMOPT_ALLOW_ABSOLUTE_SYMBOLS = &H00000800
%EQUATE `SYMOPT_IGNORE_NT_SYMPATH = &H00001000
%EQUATE `SYMOPT_INCLUDE_32BIT_MODULES = &H00002000
%EQUATE `SYMOPT_PUBLICS_ONLY = &H00004000
%EQUATE `SYMOPT_NO_PUBLICS = &H00008000
%EQUATE `SYMOPT_AUTO_PUBLICS = &H00010000
%EQUATE `SYMOPT_NO_IMAGE_SEARCH = &H00020000
%EQUATE `SYMOPT_SECURE = &H00040000
%EQUATE `SYMOPT_NO_PROMPTS = &H00080000
%EQUATE `SYMOPT_OVERWRITE = &H00100000
%EQUATE `SYMOPT_IGNORE_IMAGEDIR = &H00200000
%EQUATE `SYMOPT_FLAT_DIRECTORY = &H00400000
%EQUATE `SYMOPT_FAVOR_COMPRESSED = &H00800000
%EQUATE `SYMOPT_ALLOW_ZERO_ADDRESS = &H01000000
%EQUATE `SYMOPT_DISABLE_SYMSRV_AUTODETECT = &H02000000
%EQUATE `SYMOPT_DEBUG = &H80000000
DECLARE FUNCTION SymSetOptions LIB "dbghelp.dll" ALIAS "SymSetOptions" ( BYVAL SymOptions AS QUAD ) AS QUAD
DECLARE FUNCTION SymGetOptions LIB "dbghelp.dll" ALIAS "SymGetOptions" ( ) AS QUAD
DECLARE FUNCTION SymCleanup LIB "dbghelp.dll" ALIAS "SymCleanup" ( BYVAL hProcess AS QUAD
 ) AS LONG
'DECLARE FUNCTION SymMatchString LIB "dbghelp.dll" ALIAS "SymMatchString" ( ' BYREF string AS ASCIIZ
' , BYREF expression AS ASCIIZ
' , BYVAL fCase AS LONG
' ) AS LONG
DECLARE FUNCTION SymMatchStringA LIB "dbghelp.dll" ALIAS "SymMatchStringA" ( BYREF string AS ASCIIZ
 , BYREF expression AS ASCIIZ
 , BYVAL fCase AS LONG
 ) AS LONG
DECLARE FUNCTION SymMatchStringW LIB "dbghelp.dll" ALIAS "SymMatchStringW" ( BYREF string AS WSTRINGZ
 , BYREF expression AS WSTRINGZ
 , BYVAL fCase AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymMatchString = SymMatchStringW
#ELSE
 MACRO SymMatchString = SymMatchStringA
#ENDIF
'typedef BOOL
'(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACK)(
' );
'FUNCTION SYM_ENUMSOURCEFILES_CALLBACK ( ' BYREF pSourceFile AS SOURCEFILE
' , BYVAL UserContext AS DWORD
' ) AS LONG
'// for backwards compatibility - don't use this
'#define PSYM_ENUMSOURCFILES_CALLBACK PSYM_ENUMSOURCEFILES_CALLBACK
DECLARE FUNCTION SymEnumSourceFilesA LIB "dbghelp.dll" ALIAS "SymEnumSourceFiles" ( BYVAL hProcess AS QUAD , BYVAL ModBase AS QUAD , BYREF Mask AS ASCIIZ , BYVAL cbSrcFiles AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMSOURCEFILES_CALLBACKW)(
' );
'FUNCTION SYM_ENUMSOURCEFILES_CALLBACKW ( ' BYREF pSourceFile AS SOURCEFILEW
' , BYVAL UserContext AS DWORD
' ) AS LONG
DECLARE FUNCTION SymEnumSourceFilesW LIB "dbghelp.dll" ALIAS "SymEnumSourceFilesW" ( BYVAL hProcess AS DWORD
 , BYVAL ModBase AS QUAD
 , BYREF Mask AS WSTRINGZ
 , BYVAL cbSrcFiles AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumSourceFiles = SymEnumSourceFilesW
#ELSE
 MACRO SymEnumSourceFiles = SymEnumSourceFilesA
#ENDIF
DECLARE FUNCTION SymEnumerateModulesA64 LIB "dbghelp.dll" ALIAS "SymEnumerateModules64" ( BYVAL hProcess AS QUAD , BYVAL EnumModulesCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymEnumerateModulesW64 LIB "dbghelp.dll" ALIAS "SymEnumerateModulesW64" ( BYVAL hProcess AS QUAD
 , BYVAL EnumModulesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumerateModules64 = SymEnumerateModulesW64
#ELSE
 MACRO SymEnumerateModules64 = SymEnumerateModulesA64
#ENDIF
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymEnumerateModules SymEnumerateModules64
'#else
DECLARE FUNCTION SymEnumerateModules LIB "dbghelp.dll" ALIAS "SymEnumerateModules" ( BYVAL hProcess AS QUAD , BYVAL EnumModulesCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
'#endif
DECLARE FUNCTION EnumerateLoadedModulesExA LIB "dbghelp.dll" ALIAS "EnumerateLoadedModulesEx" ( BYVAL hProcess AS QUAD , BYVAL EnumLoadedModulesCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION EnumerateLoadedModulesExW LIB "dbghelp.dll" ALIAS "EnumerateLoadedModulesExW" ( BYVAL hProcess AS QUAD
 , BYVAL EnumLoadedModulesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumerateLoadedModulesEx = EnumerateLoadedModulesExW
#ELSE
 MACRO EnumerateLoadedModulesEx = EnumerateLoadedModulesExA
#ENDIF
DECLARE FUNCTION EnumerateLoadedModulesA64 LIB "dbghelp.dll" ALIAS "EnumerateLoadedModules64" ( BYVAL hProcess AS QUAD , BYVAL EnumModulesCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION EnumerateLoadedModulesW64 LIB "dbghelp.dll" ALIAS "EnumerateLoadedModulesW64" ( BYVAL hProcess AS QUAD
 , BYVAL EnumModulesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO EnumerateLoadedModules64 = EnumerateLoadedModulesW64
#ELSE
 MACRO EnumerateLoadedModules64 = EnumerateLoadedModulesA64
#ENDIF
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define EnumerateLoadedModules EnumerateLoadedModules64
'#else
DECLARE FUNCTION EnumerateLoadedModules LIB "dbghelp.dll" ALIAS "EnumerateLoadedModules" ( BYVAL hProcess AS QUAD , BYVAL EnumModulesCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
'#endif
DECLARE FUNCTION SymFunctionTableAccess64 LIB "dbghelp.dll" ALIAS "SymFunctionTableAccess64" ( BYVAL hProcess AS QUAD , BYVAL AddrBase AS QUAD ) AS QUAD
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymFunctionTableAccess SymFunctionTableAccess64
'#else
DECLARE FUNCTION SymFunctionTableAccess LIB "dbghelp.dll" ALIAS "SymFunctionTableAccess" ( BYVAL hProcess AS QUAD , BYVAL AddrBase AS QUAD ) AS QUAD
'#endif
DECLARE FUNCTION SymGetUnwindInfo LIB "dbghelp.dll" ALIAS "SymGetUnwindInfo" ( BYVAL hProcess AS QUAD , BYVAL Address AS QUAD , BYREF Buffer AS ANY , BYREF Size AS QUAD ) AS LONG
DECLARE FUNCTION SymGetModuleInfo64 LIB "dbghelp.dll" ALIAS "SymGetModuleInfo64" ( BYVAL hProcess AS QUAD
 , BYVAL qwAddr AS QUAD
 , BYREF ModuleInfo AS IMAGEHLP_MODULE64
 ) AS LONG
DECLARE FUNCTION SymGetModuleInfoW64 LIB "dbghelp.dll" ALIAS "SymGetModuleInfoW64" ( BYVAL hProcess AS DWORD
 , BYVAL qwAddr AS QUAD
 , BYREF ModuleInfo AS IMAGEHLP_MODULEW64
 ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetModuleInfo SymGetModuleInfo64
'#define SymGetModuleInfoW SymGetModuleInfoW64
'#else
DECLARE FUNCTION SymGetModuleInfoA LIB "dbghelp.dll" ALIAS "SymGetModuleInfo" ( BYVAL hProcess AS QUAD , BYVAL qwAddr AS QUAD , BYREF ModuleInfo AS IMAGEHLP_MODULE ) AS LONG
DECLARE FUNCTION SymGetModuleInfoW LIB "dbghelp.dll" ALIAS "SymGetModuleInfoW" ( BYVAL hProcess AS QUAD
 , BYVAL qwAddr AS DWORD
 , BYREF ModuleInfo AS IMAGEHLP_MODULEW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetModuleInfo = SymGetModuleInfoW
#ELSE
 MACRO SymGetModuleInfo = SymGetModuleInfoA
#ENDIF
'#endif
DECLARE FUNCTION SymGetModuleBase64 LIB "dbghelp.dll" ALIAS "SymGetModuleBase64" ( BYVAL hProcess AS QUAD , BYVAL qwAddr AS QUAD ) AS QUAD ' DWORD64
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetModuleBase SymGetModuleBase64
'#else
DECLARE FUNCTION SymGetModuleBase LIB "dbghelp.dll" ALIAS "SymGetModuleBase" ( BYVAL hProcess AS QUAD , BYVAL qwAddr AS QUAD ) AS QUAD
'#endif
' // Size = 552 bytes
TYPE SRCCODEINFO QWORD FILL
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(SRCCODEINFO)
 Key AS DWORD ' PVOID // not used
 ModBase AS QUAD ' DWORD64 // base address of module this applies to
 Obj AS ASCIIZ * %MAX_PATH + 1 ' CHAR // the object file within the module
 FileName AS ASCIIZ * %MAX_PATH + 1 ' CHAR // full filename
 LineNumber AS DWORD ' DWORD // line number in file
 Address AS QUAD ' DWORD64 // first instruction of line
END TYPE
' // Size = 1072 bytes
TYPE SRCCODEINFOW QWORD FILL
 SizeOfStruct AS DWORD ' DWORD // set to sizeof(SRCCODEINFO)
 Key AS DWORD ' PVOID // not used
 ModBase AS QUAD ' DWORD64 // base address of module this applies to
 Obj AS WSTRINGZ * (%MAX_PATH + 1) ' WCHAR // the object file within the module
 FileName AS WSTRINGZ * (%MAX_PATH + 1) ' WCHAR // full filename
 LineNumber AS DWORD ' DWORD // line number in file
 Address AS QUAD ' DWORD64 // first instruction of line
END TYPE
'typedef BOOL
'(CALLBACK *PSYM_ENUMLINES_CALLBACK)(
' );
'FUNCTION SYM_ENUMLINES_CALLBACK ( ' BYREF LineInfo AS SRCCODEINFO
' , BYVAL UserContext AS DWORD
' ) AS LONG
DECLARE FUNCTION SymEnumLinesA LIB "dbghelp.dll" ALIAS "SymEnumLines" ( BYVAL hProcess AS DWORD
 , BYVAL Base AS QUAD
 , BYREF Obj AS ASCIIZ
 , BYREF File AS ASCIIZ
 , BYVAL EnumLinesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMLINES_CALLBACKW)(
' );
'FUNCTION SYM_ENUMLINES_CALLBACKW ( ' BYREF LineInfo AS SRCCODEINFOW
' , BYVAL UserContext AS DWORD
' ) AS LONG
DECLARE FUNCTION SymEnumLinesW LIB "dbghelp.dll" ALIAS "SymEnumLinesW" ( BYVAL hProcess AS DWORD
 , BYVAL Base AS QUAD
 , BYREF Obj AS WSTRINGZ
 , BYREF File AS WSTRINGZ
 , BYVAL EnumLinesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumLines = SymEnumLinesW
#ELSE
 MACRO SymEnumLines = SymEnumLinesA
#ENDIF
DECLARE FUNCTION SymGetLineFromAddrA64 LIB "dbghelp.dll" ALIAS "SymGetLineFromAddr64" ( BYVAL hProcess AS QUAD , BYVAL qwAddr AS QUAD , BYREF pdwDisplacement AS QUAD , BYREF Line64 AS IMAGEHLP_LINE64 ) AS LONG
DECLARE FUNCTION SymGetLineFromAddrW64 LIB "dbghelp.dll" ALIAS "SymGetLineFromAddrW64" ( BYVAL hProcess AS QUAD
 , BYVAL qwAddr AS QUAD
 , BYREF pdwDisplacement AS DWORD
 , BYREF Line AS IMAGEHLP_LINEW64
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLineFromAddr64 = SymGetLineFromAddrW64
#ELSE
 MACRO SymGetLineFromAddr64 = SymGetLineFromAddrA64
#ENDIF
DECLARE FUNCTION SymEnumSourceLinesA LIB "dbghelp.dll" ALIAS "SymEnumSourceLines" ( BYVAL hProcess AS QUAD , BYVAL Base AS QUAD , BYREF Obj AS ASCIIZ , BYREF File AS ASCIIZ , BYVAL Line AS QUAD , BYVAL Flags AS QUAD , BYVAL EnumLinesCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymEnumSourceLinesW LIB "dbghelp.dll" ALIAS "SymEnumSourceLinesW" ( BYVAL hProcess AS QUAD
 , BYVAL Base AS QUAD
 , BYREF Obj AS WSTRINGZ
 , BYREF File AS WSTRINGZ
 , BYREF Line AS DWORD
 , BYVAL Flags AS DWORD
 , BYVAL EnumLinesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumSourceLines = SymEnumSourceLinesW
#ELSE
 MACRO SymEnumSourceLines = SymEnumSourceLinesA
#ENDIF
'// flags for SymEnumSourceLines
%EQUATE `ESLFLAG_FULLPATH = &H1
%EQUATE `ESLFLAG_NEAREST = &H2
%EQUATE `ESLFLAG_PREV = &H4
%EQUATE `ESLFLAG_NEXT = &H8
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetLineFromAddr SymGetLineFromAddr64
'#define SymGetLineFromAddrW SymGetLineFromAddrW64
'#else
DECLARE FUNCTION SymGetLineFromAddrA LIB "dbghelp.dll" ALIAS "SymGetLineFromAddr" ( BYVAL hProcess AS QUAD , BYVAL dwAddr AS QUAD , BYREF pdwDisplacement AS QUAD , BYREF Line AS IMAGEHLP_LINE ) AS LONG
DECLARE FUNCTION SymGetLineFromAddrW LIB "dbghelp.dll" ALIAS "SymGetLineFromAddrW" ( BYVAL hProcess AS QUAD
 , BYVAL dwAddr AS DWORD
 , BYREF pdwDisplacement AS DWORD
 , BYREF Line AS IMAGEHLP_LINEW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLineFromAddr = SymGetLineFromAddrW
#ELSE
 MACRO SymGetLineFromAddr = SymGetLineFromAddrA
#ENDIF
'#endif
DECLARE FUNCTION SymGetLineFromNameA64 LIB "dbghelp.dll" ALIAS "SymGetLineFromName64" ( BYVAL hProcess AS QUAD , BYREF ModuleName AS ASCIIZ , BYREF FileName AS ASCIIZ , BYVAL dwLineNumber AS QUAD , BYREF plDisplacement AS LONG , BYREF Line AS IMAGEHLP_LINE64 ) AS LONG
DECLARE FUNCTION SymGetLineFromNameW64 LIB "dbghelp.dll" ALIAS "SymGetLineFromNameW64" ( BYVAL hProcess AS QUAD
 , BYREF ModuleName AS WSTRINGZ
 , BYREF FileName AS WSTRINGZ
 , BYVAL dwLineNumber AS DWORD
 , BYREF plDisplacement AS LONG
 , BYREF Line AS IMAGEHLP_LINEW64
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLineFromName64 = SymGetLineFromNameW64
#ELSE
 MACRO SymGetLineFromName64 = SymGetLineFromNameA64
#ENDIF
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetLineFromName SymGetLineFromName64
'#else
DECLARE FUNCTION SymGetLineFromName LIB "dbghelp.dll" ALIAS "SymGetLineFromName" ( BYVAL hProcess AS QUAD , BYREF ModuleName AS ASCIIZ , BYREF FileName AS ASCIIZ , BYVAL dwLineNumber AS QUAD , BYREF plDisplacement AS LONG , BYREF Line AS IMAGEHLP_LINE ) AS LONG
'#endif
DECLARE FUNCTION SymGetLineNextA64 LIB "dbghelp.dll" ALIAS "SymGetLineNext64" ( BYVAL hProcess AS QUAD , BYREF Line AS IMAGEHLP_LINE64 ) AS LONG
DECLARE FUNCTION SymGetLineNextW64 LIB "dbghelp.dll" ALIAS "SymGetLineNextW64" ( BYVAL hProcess AS QUAD
 , BYREF Line AS IMAGEHLP_LINEW64
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLineNext64 = SymGetLineNextW64
#ELSE
 MACRO SymGetLineNext64 = SymGetLineNextA64
#ENDIF
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetLineNext SymGetLineNext64
'#else
DECLARE FUNCTION SymGetLineNextA LIB "dbghelp.dll" ALIAS "SymGetLineNext" ( BYVAL hProcess AS QUAD , BYREF Line AS IMAGEHLP_LINE ) AS LONG
DECLARE FUNCTION SymGetLineNextW LIB "dbghelp.dll" ALIAS "SymGetLineNextW" ( BYVAL hProcess AS QUAD
 , BYREF Line AS IMAGEHLP_LINEW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLineNext = SymGetLineNextW
#ELSE
 MACRO SymGetLineNext = SymGetLineNextA
#ENDIF
'#endif
DECLARE FUNCTION SymGetLinePrevA64 LIB "dbghelp.dll" ALIAS "SymGetLinePrev64" ( BYVAL hProcess AS QUAD , BYREF Line AS IMAGEHLP_LINE64 ) AS LONG
DECLARE FUNCTION SymGetLinePrevW64 LIB "dbghelp.dll" ALIAS "SymGetLinePrevW64" ( BYVAL hProcess AS QUAD
 , BYREF Line AS IMAGEHLP_LINEW64
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLinePrev64 = SymGetLinePrevW64
#ELSE
 MACRO SymGetLinePrev64 = SymGetLinePrevA64
#ENDIF
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetLinePrev SymGetLinePrev64
'#else
DECLARE FUNCTION SymGetLinePrevA LIB "dbghelp.dll" ALIAS "SymGetLinePrev" ( BYVAL hProcess AS QUAD , BYREF Line AS IMAGEHLP_LINE ) AS LONG
DECLARE FUNCTION SymGetLinePrevW LIB "dbghelp.dll" ALIAS "SymGetLinePrevW" ( BYVAL hProcess AS QUAD
 , BYREF Line AS IMAGEHLP_LINEW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetLinePrev = SymGetLinePrevW
#ELSE
 MACRO SymGetLinePrev = SymGetLinePrevA
#ENDIF
'#endif
DECLARE FUNCTION SymGetFileLineOffsets64 LIB "dbghelp.dll" ALIAS "SymGetFileLineOffsets64" ( BYVAL hProcess AS QUAD , BYREF ModuleName AS ASCIIZ , BYREF FileName AS ASCIIZ , BYREF Buffer AS QUAD , BYVAL BufferLines AS QUAD ) AS QUAD ' ULONG
DECLARE FUNCTION SymMatchFileNameA LIB "dbghelp.dll" ALIAS "SymMatchFileName" ( BYREF FileName AS ASCIIZ , BYREF Match AS ASCIIZ , BYREF FileNameStop AS QUAD , BYREF MatchStop AS QUAD ) AS LONG
DECLARE FUNCTION SymMatchFileNameW LIB "dbghelp.dll" ALIAS "SymMatchFileNameW" ( BYREF FileName AS WSTRINGZ
 , BYREF Match AS WSTRINGZ
 , BYREF FileNameStop AS DWORD
 , BYREF MatchStop AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymMatchFileName = SymMatchFileNameW
#ELSE
 MACRO SymMatchFileName = SymMatchFileNameA
#ENDIF
DECLARE FUNCTION SymGetSourceFileA LIB "dbghelp.dll" ALIAS "SymGetSourceFile" ( BYVAL hProcess AS QUAD , BYVAL Base AS QUAD , BYREF Params AS ASCIIZ , BYREF FileSpec AS ASCIIZ , BYREF FilePath AS ASCIIZ , BYVAL Size AS QUAD ) AS LONG
DECLARE FUNCTION SymGetSourceFileW LIB "dbghelp.dll" ALIAS "SymGetSourceFileW" ( BYVAL hProcess AS QUAD
 , BYVAL Base AS QUAD
 , BYREF Params AS WSTRINGZ
 , BYREF FileSpec AS WSTRINGZ
 , BYREF FilePath AS WSTRINGZ
 , BYVAL Size AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSourceFile = SymGetSourceFileW
#ELSE
 MACRO SymGetSourceFile = SymGetSourceFileA
#ENDIF
DECLARE FUNCTION SymGetSourceFileTokenA LIB "dbghelp.dll" ALIAS "SymGetSourceFileToken" ( BYVAL hProcess AS QUAD , BYVAL Base AS QUAD , BYREF FileSpec AS ASCIIZ , BYREF Token AS ANY , BYREF Size AS QUAD ) AS LONG
DECLARE FUNCTION SymGetSourceFileTokenW LIB "dbghelp.dll" ALIAS "SymGetSourceFileTokenW" ( BYVAL hProcess AS QUAD
 , BYVAL Base AS QUAD
 , BYREF FileSpec AS WSTRINGZ
 , BYREF Token AS ANY
 , BYREF Size AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSourceFileToken = SymGetSourceFileTokenW
#ELSE
 MACRO SymGetSourceFileToken = SymGetSourceFileTokenA
#ENDIF
DECLARE FUNCTION SymGetSourceFileFromTokenA LIB "dbghelp.dll" ALIAS "SymGetSourceFileFromToken" ( BYVAL hProcess AS QUAD , BYVAL Token AS QUAD , BYREF Params AS ASCIIZ , BYREF FilePath AS ASCIIZ , BYVAL Size AS QUAD ) AS LONG
DECLARE FUNCTION SymGetSourceFileFromTokenW LIB "dbghelp.dll" ALIAS "SymGetSourceFileFromTokenW" ( BYVAL hProcess AS QUAD
 , BYVAL Token AS DWORD
 , BYREF Params AS WSTRINGZ
 , BYREF FilePath AS WSTRINGZ
 , BYVAL Size AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSourceFileFromToken = SymGetSourceFileFromTokenW
#ELSE
 MACRO SymGetSourceFileFromToken = SymGetSourceFileFromTokenA
#ENDIF
DECLARE FUNCTION SymGetSourceVarFromTokenA LIB "dbghelp.dll" ALIAS "SymGetSourceVarFromToken" ( BYVAL hProcess AS QUAD , BYVAL Token AS QUAD , BYREF Params AS ASCIIZ , BYREF VarName AS ASCIIZ , BYREF Value AS ASCIIZ , BYVAL Size AS QUAD ) AS LONG
DECLARE FUNCTION SymGetSourceVarFromTokenW LIB "dbghelp.dll" ALIAS "SymGetSourceVarFromTokenW" ( BYVAL hProcess AS QUAD
 , BYVAL Token AS DWORD
 , BYREF Params AS WSTRINGZ
 , BYREF VarName AS WSTRINGZ
 , BYREF Value AS WSTRINGZ
 , BYVAL Size AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSourceVarFromToken = SymGetSourceVarFromTokenW
#ELSE
 MACRO SymGetSourceVarFromToken = SymGetSourceVarFromTokenA
#ENDIF
'typedef BOOL (CALLBACK *PENUMSOURCEFILETOKENSCALLBACK)(__in PVOID token, __in size_t size);
'FUNCTION ENUMSOURCEFILETOKENSCALLBACK (BYVAL token AS DWORD, BYVAL nsize AS DWORD) AS LONG
DECLARE FUNCTION SymEnumSourceFileTokens LIB "dbghelp.dll" ALIAS "SymEnumSourceFileTokens" ( BYVAL hProcess AS QUAD , BYVAL Base AS QUAD , BYVAL Callback AS QUAD ) AS LONG
DECLARE FUNCTION SymInitializeA LIB "dbghelp.dll" ALIAS "SymInitialize" ( BYVAL hProcess AS QUAD
 , BYREF UserSearchPath AS ASCIIZ
 , BYVAL fInvadeProcess AS LONG
 ) AS LONG
DECLARE FUNCTION SymInitializeW LIB "dbghelp.dll" ALIAS "SymInitializeW" ( BYVAL hProcess AS DWORD
 , BYREF UserSearchPath AS WSTRINGZ
 , BYVAL fInvadeProcess AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymInitialize = SymInitializeW
#ELSE
 MACRO SymInitialize = SymInitializeA
#ENDIF
DECLARE FUNCTION SymGetSearchPathA LIB "dbghelp.dll" ALIAS "SymGetSearchPath" ( BYVAL hProcess AS QUAD , BYREF SearchPath AS ASCIIZ , BYVAL SearchPathLength AS QUAD ) AS LONG
DECLARE FUNCTION SymGetSearchPathW LIB "dbghelp.dll" ALIAS "SymGetSearchPathW" ( BYVAL hProcess AS QUAD
 , BYREF SearchPath AS WSTRINGZ
 , BYVAL SearchPathLength AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSearchPath = SymGetSearchPathW
#ELSE
 MACRO SymGetSearchPath = SymGetSearchPathA
#ENDIF
DECLARE FUNCTION SymSetSearchPathA LIB "dbghelp.dll" ALIAS "SymSetSearchPath" ( BYVAL hProcess AS QUAD , BYREF SearchPath AS ASCIIZ ) AS LONG
DECLARE FUNCTION SymSetSearchPathW LIB "dbghelp.dll" ALIAS "SymSetSearchPathW" ( BYVAL hProcess AS QUAD
 , BYREF SearchPath AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymSetSearchPath = SymSetSearchPathW
#ELSE
 MACRO SymSetSearchPath = SymSetSearchPathA
#ENDIF
%EQUATE `SLMFLAG_VIRTUAL = &H1
%EQUATE `SLMFLAG_ALT_INDEX = &H2
%EQUATE `SLMFLAG_NO_SYMBOLS = &H4
DECLARE FUNCTION SymLoadModuleExA LIB "dbghelp.dll" ALIAS "SymLoadModuleEx" ( BYVAL hProcess AS QUAD , BYVAL hFile AS QUAD , BYREF ImageName AS ASCIIZ , BYREF ModuleName AS ASCIIZ , BYVAL BaseOfDll AS QUAD , BYVAL DllSize AS QUAD , BYREF Data AS MODLOAD_DATA , BYVAL Flags AS QUAD ) AS QUAD ' DWORD64
DECLARE FUNCTION SymLoadModuleExW LIB "dbghelp.dll" ALIAS "SymLoadModuleExW" ( BYVAL hProcess AS QUAD , BYVAL hFile AS QUAD , BYREF ImageName AS WSTRINGZ , BYREF ModuleName AS WSTRINGZ , BYVAL BaseOfDll AS QUAD , BYVAL DllSize AS QUAD , BYREF Data AS MODLOAD_DATA , BYVAL Flags AS QUAD ) AS QUAD ' DWORD64
#IF %DEF(%UNICODE)
 MACRO SymLoadModuleEx = SymLoadModuleExW
#ELSE
 MACRO SymLoadModuleEx = SymLoadModuleExA
#ENDIF
DECLARE FUNCTION SymUnloadModule64 LIB "dbghelp.dll" ALIAS "SymUnloadModule64" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymUnloadModule SymUnloadModule64
'#else
DECLARE FUNCTION SymUnloadModule LIB "dbghelp.dll" ALIAS "SymUnloadModule" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD ) AS LONG
'#endif
DECLARE FUNCTION SymUnDName64 LIB "dbghelp.dll" ALIAS "SymUnDName64" ( BYREF sym AS IMAGEHLP_SYMBOL64 , BYREF UnDecName AS ASCIIZ , BYVAL UnDecNameLength AS QUAD ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymUnDName SymUnDName64
'#else
DECLARE FUNCTION SymUnDName LIB "dbghelp.dll" ALIAS "SymUnDName" ( BYREF sym AS IMAGEHLP_SYMBOL , BYREF UnDecName AS ASCIIZ , BYVAL UnDecNameLength AS QUAD ) AS LONG
'#endif
DECLARE FUNCTION SymRegisterCallback64 LIB "dbghelp.dll" ALIAS "SymRegisterCallback64" ( BYVAL hProcess AS QUAD , BYVAL CallbackFunction AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymRegisterCallbackW64 LIB "dbghelp.dll" ALIAS "SymRegisterCallbackW64" ( BYVAL hProcess AS QUAD
 , BYVAL CallbackFunction AS DWORD
 , BYVAL UserContext AS QUAD
 ) AS LONG
DECLARE FUNCTION SymRegisterFunctionEntryCallback64 LIB "dbghelp.dll" ALIAS "SymRegisterFunctionEntryCallback64" ( BYVAL hProcess AS DWORD
 , BYVAL CallbackFunction AS DWORD
 , BYVAL UserContext AS QUAD
 ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymRegisterCallback SymRegisterCallback64
'#define SymRegisterFunctionEntryCallback SymRegisterFunctionEntryCallback64
'#else
DECLARE FUNCTION SymRegisterCallback LIB "dbghelp.dll" ALIAS "SymRegisterCallback" ( BYVAL hProcess AS QUAD , BYVAL CallbackFunction AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymRegisterFunctionEntryCallback LIB "dbghelp.dll" ALIAS "SymRegisterFunctionEntryCallback" ( BYVAL hProcess AS QUAD
 , BYVAL CallbackFunction AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
'#endif
' // Size = 258 bytes
TYPE IMAGEHLP_SYMBOL_SRC DWORD
 sizeofstruct AS DWORD
 type AS DWORD
 file AS ASCIIZ * %MAX_PATH ' char
END TYPE
' // Size = 6 bytes
TYPE MODULE_TYPE_INFO WORD
 dataLength AS WORD ' USHORT
 leaf AS WORD ' USHORT
 data(0) AS BYTE ' BYTE
END TYPE
' // Size in C++ = 88 bytes
TYPE SYMBOL_INFO QWORD FILL
 SizeOfStruct AS DWORD ' ULONG
 TypeIndex AS DWORD ' ULONG // Type Index of symbol
 Reserved(1) AS QUAD ' ULONG64
 Index AS DWORD ' ULONG
 Size AS DWORD ' ULONG
 ModBase AS QUAD ' ULONG64 // Base Address of module comtaining this symbol
 Flags AS DWORD ' ULONG
 Value AS QUAD ' ULONG64 // Value of symbol, ValuePresent should be 1
 Address AS QUAD ' ULONG64 // Address of symbol including base address of module
 Register AS DWORD ' ULONG // register holding value or pointer to value
 Scope AS DWORD ' ULONG // scope of the symbol
 Tag AS DWORD ' ULONG // pdb classification
 NameLen AS DWORD ' ULONG // Actual length of name
 MaxNameLen AS DWORD ' ULONG
 Name AS ASCIIZ * 1 ' CHAR // Name of symbol
END TYPE
' // Size in C++ = 2096 bytes
TYPE SYMBOL_INFO_PACKAGE QWORD FILL
 si AS SYMBOL_INFO
 name AS ASCIIZ * (%MAX_SYM_NAME + 1) ' CHAR name[MAX_SYM_NAME + 1]
END TYPE
' // Size in C++ = 88 bytes
TYPE SYMBOL_INFOW QWORD FILL
 SizeOfStruct AS DWORD ' ULONG
 TypeIndex AS DWORD ' ULONG // Type Index of symbol
 Reserved(1) AS QUAD ' ULONG64
 Index AS DWORD ' ULONG
 Size AS DWORD ' ULONG
 ModBase AS QUAD ' ULONG64 // Base Address of module comtaining this symbol
 Flags AS DWORD ' ULONG
 Value AS QUAD ' ULONG64 // Value of symbol, ValuePresent should be 1
 Address AS QUAD ' ULONG64 // Address of symbol including base address of module
 Register AS DWORD ' ULONG // register holding value or pointer to value
 Scope AS DWORD ' ULONG // scope of the symbol
 Tag AS DWORD ' ULONG // pdb classification
 NameLen AS DWORD ' ULONG // Actual length of name
 MaxNameLen AS DWORD ' ULONG
 Name AS WSTRINGZ * 1 ' WCHAR // Name of symbol
END TYPE
' // Size in C++ = 4096 bytes
TYPE SYMBOL_INFO_PACKAGEW QWORD FILL
 si AS SYMBOL_INFOW
 name AS WSTRINGZ * (%MAX_SYM_NAME + 1) ' WCHAR name[MAX_SYM_NAME + 1]
END TYPE
' // Size = 128 bytes
TYPE IMAGEHLP_STACK_FRAME DWORD
 InstructionOffset AS QUAD ' ULONG64
 ReturnOffset AS QUAD ' ULONG64
 FrameOffset AS QUAD ' ULONG64
 StackOffset AS QUAD ' ULONG64
 BackingStoreOffset AS QUAD ' ULONG64
 FuncTableEntry AS QUAD ' ULONG64
 Params(3) AS QUAD ' ULONG64
 Reserved(4) AS QUAD ' ULONG64
 Virtual AS LONG
 Reserved2 AS DWORD ' ULONG
END TYPE
'typedef VOID IMAGEHLP_CONTEXT, *PIMAGEHLP_CONTEXT;
DECLARE FUNCTION SymSetContext LIB "dbghelp.dll" ALIAS "SymSetContext" ( BYVAL hProcess AS QUAD , BYREF StackFrame AS IMAGEHLP_STACK_FRAME , BYVAL Context AS QUAD ) AS LONG
DECLARE FUNCTION SymSetScopeFromAddr LIB "dbghelp.dll" ALIAS "SymSetScopeFromAddr" ( BYVAL hProcess AS QUAD
 , BYVAL Address AS QUAD
 ) AS LONG
DECLARE FUNCTION SymSetScopeFromIndex LIB "dbghelp.dll" ALIAS "SymSetScopeFromIndex" ( BYVAL hProcess AS DWORD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL Index AS DWORD
 ) AS LONG
'typedef BOOL
'(CALLBACK *PSYM_ENUMPROCESSES_CALLBACK)(
' );
'FUNCTION SYM_ENUMPROCESSES_CALLBACK ( ' BYVAL hProcess AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
DECLARE FUNCTION SymEnumProcesses LIB "dbghelp.dll" ALIAS "SymEnumProcesses" ( BYVAL EnumProcessesCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
DECLARE FUNCTION SymFromAddrA LIB "dbghelp.dll" ALIAS "SymFromAddr" ( BYVAL hProcess AS DWORD
 , BYVAL Address AS QUAD
 , BYREF Displacement AS QUAD
 , BYREF Symbol AS SYMBOL_INFO
 ) AS LONG
DECLARE FUNCTION SymFromAddrW LIB "dbghelp.dll" ALIAS "SymFromAddrW" ( BYVAL hProcess AS DWORD
 , BYVAL Address AS QUAD
 , BYREF Displacement AS QUAD
 , BYREF Symbol AS SYMBOL_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymFromAddr = SymFromAddrW
#ELSE
 MACRO SymFromAddr = SymFromAddrA
#ENDIF
DECLARE FUNCTION SymFromTokenA LIB "dbghelp.dll" ALIAS "SymFromToken" ( BYVAL hProcess AS QUAD , BYVAL Base AS QUAD , BYVAL Token AS QUAD , BYREF Symbol AS SYMBOL_INFO ) AS LONG
DECLARE FUNCTION SymFromTokenW LIB "dbghelp.dll" ALIAS "SymFromTokenW" ( BYVAL hProcess AS QUAD
 , BYVAL Base AS QUAD
 , BYVAL Token AS DWORD
 , BYREF Symbol AS SYMBOL_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymFromToken = SymFromTokenW
#ELSE
 MACRO SymFromToken = SymFromTokenA
#ENDIF
' Requries version 6.2 or later.
DECLARE FUNCTION SymNextA LIB "dbghelp.dll" ALIAS "SymNext" ( BYVAL hProcess AS QUAD , BYREF si AS SYMBOL_INFO ) AS LONG
' Requries version 6.2 or later.
DECLARE FUNCTION SymNextW LIB "dbghelp.dll" ALIAS "SymNextW" ( BYVAL hProcess AS QUAD , BYREF siw AS SYMBOL_INFOW ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymNext = SymNextW
#ELSE
 MACRO SymNext = SymNextA
#ENDIF
' Requries version 6.2 or later.
DECLARE FUNCTION SymPrevA LIB "dbghelp.dll" ALIAS "SymPrev" ( BYVAL hProcess AS QUAD , BYREF si AS SYMBOL_INFO ) AS LONG
' Requries version 6.2 or later.
DECLARE FUNCTION SymPrevW LIB "dbghelp.dll" ALIAS "SymPrevW" ( BYVAL hProcess AS QUAD , BYREF siw AS SYMBOL_INFOW ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymPrev = SymPrevW
#ELSE
 MACRO SymPrev = SymPrevA
#ENDIF
'// While SymFromName will provide a symbol from a name,
'// SymEnumSymbols can provide the same matching information
'// for ALL symbols with a matching name, even regular
'// expressions. That way you can search across modules
'// and differentiate between identically named symbols.
DECLARE FUNCTION SymFromNameA LIB "dbghelp.dll" ALIAS "SymFromName" ( BYVAL hProcess AS QUAD , BYREF Name AS ASCIIZ , BYREF Symbol AS SYMBOL_INFO ) AS LONG
DECLARE FUNCTION SymFromNameW LIB "dbghelp.dll" ALIAS "SymFromNameW" ( BYVAL hProcess AS QUAD
 , BYREF Name AS WSTRINGZ
 , BYREF Symbol AS SYMBOL_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymFromName = SymFromNameW
#ELSE
 MACRO SymFromName = SymFromNameA
#ENDIF
'typedef BOOL
'(CALLBACK *PSYM_ENUMERATESYMBOLS_CALLBACK)(
' );
'FUNCTION SYM_ENUMERATESYMBOLS_CALLBACK ( ' BYREF pSymInfo AS SYMBOL_INFO
' , BYVAL SymbolSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
DECLARE FUNCTION SymEnumSymbolsA LIB "dbghelp.dll" ALIAS "SymEnumSymbols" ( BYVAL hProcess AS DWORD
 , BYVAL BaseOfDll AS QUAD
 , BYREF Mask AS ASCIIZ
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
'FUNCTION SYM_ENUMERATESYMBOLS_CALLBACKW ( ' BYREF pSymInfo AS SYMBOL_INFOW
' , BYVAL SymbolSize AS DWORD
' , BYVAL UserContext AS DWORD
' ) AS LONG
DECLARE FUNCTION SymEnumSymbolsW LIB "dbghelp.dll" ALIAS "SymEnumSymbolsW" ( BYVAL hProcess AS DWORD
 , BYVAL BaseOfDll AS QUAD
 , BYREF Mask AS ASCIIZ
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumSymbols = SymEnumSymbolsW
#ELSE
 MACRO SymEnumSymbols = SymEnumSymbolsA
#ENDIF
DECLARE FUNCTION SymEnumSymbolsForAddrA LIB "dbghelp.dll" ALIAS "SymEnumSymbolsForAddr" ( BYVAL hProcess AS QUAD , BYVAL Address AS QUAD , BYVAL EnumSymbolsCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymEnumSymbolsForAddrW LIB "dbghelp.dll" ALIAS "SymEnumSymbolsForAddrW" ( BYVAL hProcess AS QUAD
 , BYVAL Address AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumSymbolsForAddr = SymEnumSymbolsForAddrW
#ELSE
 MACRO SymEnumSymbolsForAddr = SymEnumSymbolsForAddrA
#ENDIF
%EQUATE `SYMSEARCH_MASKOBJS = &H01 ' // used internally to implement other APIs
%EQUATE `SYMSEARCH_RECURSE = &H02 ' // recurse scopes
%EQUATE `SYMSEARCH_GLOBALSONLY = &H04 ' // search only for global symbols
%EQUATE `SYMSEARCH_ALLITEMS = &H08 ' // search for everything in the pdb, not just normal scoped symbols
DECLARE FUNCTION SymSearchA LIB "dbghelp.dll" ALIAS "SymSearch" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYVAL Index AS QUAD , BYVAL SymTag AS QUAD , BYREF Mask AS ASCIIZ , BYVAL Address AS QUAD , BYVAL EnumSymbolsCallback AS QUAD , BYVAL UserContext AS QUAD , BYVAL Options AS QUAD ) AS LONG
DECLARE FUNCTION SymSearchW LIB "dbghelp.dll" ALIAS "SymSearchW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL Index AS DWORD
 , BYVAL SymTag AS DWORD
 , BYREF Mask AS WSTRINGZ
 , BYVAL Address AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 , BYVAL Options AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymSearch = SymSearchW
#ELSE
 MACRO SymSearch = SymSearchA
#ENDIF
DECLARE FUNCTION SymGetScopeA LIB "dbghelp.dll" ALIAS "SymGetScope" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYVAL Index AS QUAD , BYREF Symbol AS SYMBOL_INFO ) AS LONG
DECLARE FUNCTION SymGetScopeW LIB "dbghelp.dll" ALIAS "SymGetScopeW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL Index AS DWORD
 , BYREF Symbol AS SYMBOL_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetScope = SymGetScopeW
#ELSE
 MACRO SymGetScope = SymGetScopeA
#ENDIF
DECLARE FUNCTION SymFromIndexA LIB "dbghelp.dll" ALIAS "SymFromIndex" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYVAL Index AS QUAD , BYREF Symbol AS SYMBOL_INFO ) AS LONG
DECLARE FUNCTION SymFromIndexW LIB "dbghelp.dll" ALIAS "SymFromIndexW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL Index AS DWORD
 , BYREF Symbol AS SYMBOL_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymFromIndex = SymFromIndexW
#ELSE
 MACRO SymFromIndex = SymFromIndexA
#ENDIF
' enum IMAGEHLP_SYMBOL_TYPE_INFO
%EQUATE `TI_GET_SYMTAG = 0
%EQUATE `TI_GET_SYMNAME = 1
%EQUATE `TI_GET_LENGTH = 2
%EQUATE `TI_GET_TYPE = 3
%EQUATE `TI_GET_TYPEID = 4
%EQUATE `TI_GET_BASETYPE = 5
%EQUATE `TI_GET_ARRAYINDEXTYPEID = 6
%EQUATE `TI_FINDCHILDREN = 7
%EQUATE `TI_GET_DATAKIND = 8
%EQUATE `TI_GET_ADDRESSOFFSET = 9
%EQUATE `TI_GET_OFFSET = 10
%EQUATE `TI_GET_VALUE = 11
%EQUATE `TI_GET_COUNT = 12
%EQUATE `TI_GET_CHILDRENCOUNT = 13
%EQUATE `TI_GET_BITPOSITION = 14
%EQUATE `TI_GET_VIRTUALBASECLASS = 15
%EQUATE `TI_GET_VIRTUALTABLESHAPEID = 16
%EQUATE `TI_GET_VIRTUALBASEPOINTEROFFSET = 17
%EQUATE `TI_GET_CLASSPARENTID = 18
%EQUATE `TI_GET_NESTED = 19
%EQUATE `TI_GET_SYMINDEX = 20
%EQUATE `TI_GET_LEXICALPARENT = 21
%EQUATE `TI_GET_ADDRESS = 22
%EQUATE `TI_GET_THISADJUST = 23
%EQUATE `TI_GET_UDTKIND = 24
%EQUATE `TI_IS_EQUIV_TO = 25
%EQUATE `TI_GET_CALLING_CONVENTION = 26
%EQUATE `TI_IS_CLOSE_EQUIV_TO = 27
%EQUATE `TI_GTIEX_REQS_VALID = 28
%EQUATE `TI_GET_VIRTUALBASEOFFSET = 29
%EQUATE `TI_GET_VIRTUALBASEDISPINDEX = 30
%EQUATE `TI_GET_IS_REFERENCE = 31
%EQUATE `TI_GET_INDIRECTVIRTUALBASECLASS = 32
%EQUATE `IMAGEHLP_SYMBOL_TYPE_INFO_MAX = 33
' // Size = 12 bytes
TYPE TI_FINDCHILDREN_PARAMS DWORD
 Count AS DWORD ' ULONG
 Start AS DWORD ' ULONG
 ChildId(0) AS DWORD ' ULONG
END TYPE
DECLARE FUNCTION SymGetTypeInfo LIB "dbghelp.dll" ALIAS "SymGetTypeInfo" ( BYVAL hProcess AS QUAD , BYVAL ModBase AS QUAD , BYVAL TypeId AS QUAD , BYVAL GetType AS QUAD , BYREF pInfo AS ANY ) AS LONG
%EQUATE `IMAGEHLP_GET_TYPE_INFO_UNCACHED = &H00000001
%EQUATE `IMAGEHLP_GET_TYPE_INFO_CHILDREN = &H00000002
' // Size = 88 bytes
TYPE IMAGEHLP_GET_TYPE_INFO_PARAMS ' Must be 8 bytes aligned
 SizeOfStruct AS DWORD ' ULONG
 Flags AS DWORD ' ULONG
 NumIds AS DWORD ' ULONG
 TypeIds AS DWORD PTR
 TagFilter AS QUAD ' ULONG64
 NumReqs AS DWORD ' ULONG
 ReqKinds AS DWORD PTR ' IMAGEHLP_SYMBOL_TYPE_INFO*
 ReqOffsets AS DWORD PTR ' PULONG_PTR
 ReqSizes AS DWORD PTR
 ReqStride AS DWORD ' ULONG_PTR
 BufferSize AS DWORD ' ULONG_PTR
 Buffer AS DWORD
 EntriesMatched AS DWORD ' ULONG
 EntriesFilled AS DWORD ' ULONG
 alignment__ AS DWORD ' // To keep 8 bytes alignment
 TagsFound AS QUAD ' ULONG64
 AllReqsValid AS QUAD ' ULONG64
 NumReqsValid AS DWORD ' ULONG
 ReqsValid AS QUAD PTR ' PULONG64
END TYPE
DECLARE FUNCTION SymGetTypeInfoEx LIB "dbghelp.dll" ALIAS "SymGetTypeInfoEx" ( BYVAL hProcess AS QUAD , BYVAL ModBase AS QUAD , BYREF Params AS IMAGEHLP_GET_TYPE_INFO_PARAMS ) AS LONG
DECLARE FUNCTION SymEnumTypesA LIB "dbghelp.dll" ALIAS "SymEnumTypes" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
DECLARE FUNCTION SymEnumTypesW LIB "dbghelp.dll" ALIAS "SymEnumTypesW" ( BYVAL hProcess AS DWORD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumTypes = SymEnumTypesW
#ELSE
 MACRO SymEnumTypes = SymEnumTypesA
#ENDIF
DECLARE FUNCTION SymEnumTypesByNameA LIB "dbghelp.dll" ALIAS "SymEnumTypesByName" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYREF mask AS ASCIIZ , BYVAL EnumSymbolsCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymEnumTypesByNameW LIB "dbghelp.dll" ALIAS "SymEnumTypesByNameW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYREF mask AS WSTRINGZ
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumTypesByName = SymEnumTypesByNameW
#ELSE
 MACRO SymEnumTypesByName = SymEnumTypesByNameA
#ENDIF
DECLARE FUNCTION SymGetTypeFromNameA LIB "dbghelp.dll" ALIAS "SymGetTypeFromName" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYREF Name AS ASCIIZ , BYREF Symbol AS SYMBOL_INFO ) AS LONG
DECLARE FUNCTION SymGetTypeFromNameW LIB "dbghelp.dll" ALIAS "SymGetTypeFromNameW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYREF Name AS WSTRINGZ
 , BYREF Symbol AS SYMBOL_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetTypeFromName = SymGetTypeFromNameW
#ELSE
 MACRO SymGetTypeFromName = SymGetTypeFromNameA
#ENDIF
DECLARE FUNCTION SymAddSymbolA LIB "dbghelp.dll" ALIAS "SymAddSymbol" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYREF Name AS ASCIIZ , BYVAL Address AS QUAD , BYVAL Size AS QUAD , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION SymAddSymbolW LIB "dbghelp.dll" ALIAS "SymAddSymbolW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYREF Name AS WSTRINGZ
 , BYVAL Address AS QUAD
 , BYVAL Size AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymAddSymbol = SymAddSymbolW
#ELSE
 MACRO SymAddSymbol = SymAddSymbolA
#ENDIF
DECLARE FUNCTION SymDeleteSymbolA LIB "dbghelp.dll" ALIAS "SymDeleteSymbol" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYREF Name AS ASCIIZ , BYVAL Address AS QUAD , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION SymDeleteSymbolW LIB "dbghelp.dll" ALIAS "SymDeleteSymbolW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYREF Name AS WSTRINGZ
 , BYVAL Address AS QUAD
 , BYVAL Flags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymDeleteSymbol = SymDeleteSymbolW
#ELSE
 MACRO SymDeleteSymbol = SymDeleteSymbolA
#ENDIF
DECLARE FUNCTION SymRefreshModuleList LIB "dbghelp.dll" ALIAS "SymRefreshModuleList" ( BYVAL hProcess AS QUAD ) AS LONG
'DECLARE FUNCTION SymAddSourceStream LIB "dbghelp.dll" ALIAS "SymAddSourceStream" ( ' BYVAL hProcess AS QUAD
' , BYVAL Base AS QUAD
' , BYREF StreamFile AS ASCIIZ
' , BYVAL Buffer AS BYTE PTR
' , BYVAL Size AS DWORD
' ) AS LONG
DECLARE FUNCTION SymAddSourceStreamA LIB "dbghelp.dll" ALIAS "SymAddSourceStreamA" ( BYVAL hProcess AS DWORD
 , BYVAL Base AS QUAD
 , BYREF StreamFile AS ASCIIZ
 , BYVAL Buffer AS BYTE PTR
 , BYVAL Size AS DWORD
 ) AS LONG
DECLARE FUNCTION SymAddSourceStreamW LIB "dbghelp.dll" ALIAS "SymAddSourceStreamW" ( BYVAL hProcess AS DWORD
 , BYVAL Base AS QUAD
 , BYREF StreamFile AS WSTRINGZ
 , BYVAL Buffer AS BYTE PTR
 , BYVAL Size AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymAddSourceStream = SymAddSourceStreamW
#ELSE
 MACRO SymAddSourceStream = SymAddSourceStreamA
#ENDIF
DECLARE FUNCTION SymSrvIsStoreW LIB "dbghelp.dll" ALIAS "SymSrvIsStoreW" ( BYVAL hProcess AS QUAD , BYREF path AS WSTRINGZ ) AS LONG
DECLARE FUNCTION SymSrvIsStoreA LIB "dbghelp.dll" ALIAS "SymSrvIsStore" ( BYVAL hProcess AS QUAD
 , BYREF path AS ASCIIZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymSrvIsStore = SymSrvIsStoreW
#ELSE
 MACRO SymSrvIsStore = SymSrvIsStoreA
#ENDIF
DECLARE FUNCTION SymSrvDeltaNameA LIB "dbghelp.dll" ALIAS "SymSrvDeltaName" ( BYVAL hProcess AS QUAD , BYREF SymPath AS ASCIIZ , BYREF Type AS ASCIIZ , BYREF File1 AS ASCIIZ , BYREF File2 AS ASCIIZ ) AS QUAD
DECLARE FUNCTION SymSrvDeltaNameW LIB "dbghelp.dll" ALIAS "SymSrvDeltaNameW" ( BYVAL hProcess AS QUAD
 , BYREF SymPath AS WSTRINGZ
 , BYREF Type AS WSTRINGZ
 , BYREF File1 AS WSTRINGZ
 , BYREF File2 AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymSrvDeltaName = SymSrvDeltaNameW
#ELSE
 MACRO SymSrvDeltaName = SymSrvDeltaNameA
#ENDIF
DECLARE FUNCTION SymSrvGetSupplementA LIB "dbghelp.dll" ALIAS "SymSrvGetSupplement" ( BYVAL hProcess AS QUAD , BYREF SymPath AS ASCIIZ , BYREF Node AS ASCIIZ , BYREF File AS ASCIIZ ) AS QUAD
DECLARE FUNCTION SymSrvGetSupplementW LIB "dbghelp.dll" ALIAS "SymSrvGetSupplementW" ( BYVAL hProcess AS QUAD
 , BYREF SymPath AS WSTRINGZ
 , BYREF Node AS WSTRINGZ
 , BYREF File AS WSTRINGZ
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymSrvGetSupplement = SymSrvGetSupplementW
#ELSE
 MACRO SymSrvGetSupplement = SymSrvGetSupplementA
#ENDIF
DECLARE FUNCTION SymSrvGetFileIndexesA LIB "dbghelp.dll" ALIAS "SymSrvGetFileIndexes" ( BYREF File AS ASCIIZ , BYREF Id AS GUID , BYREF Val1 AS QUAD , BYREF Val2 AS QUAD , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION SymSrvGetFileIndexesW LIB "dbghelp.dll" ALIAS "SymSrvGetFileIndexesW" ( BYREF File AS WSTRINGZ
 , BYREF Id AS GUID
 , BYREF Val1 AS DWORD
 , BYREF Val2 AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymSrvGetFileIndexes = SymSrvGetFileIndexesW
#ELSE
 MACRO SymSrvGetFileIndexes = SymSrvGetFileIndexesA
#ENDIF
DECLARE FUNCTION SymSrvGetFileIndexStringW LIB "dbghelp.dll" ALIAS "SymSrvGetFileIndexStringW" ( BYVAL hProcess AS QUAD , BYREF SrvPath AS WSTRINGZ , BYREF File AS WSTRINGZ , BYREF Index AS WSTRINGZ , BYVAL Size AS QUAD , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION SymSrvGetFileIndexStringA LIB "dbghelp.dll" ALIAS "SymSrvGetFileIndexString" ( BYVAL hProcess AS QUAD
 , BYREF SrvPath AS ASCIIZ
 , BYREF File AS ASCIIZ
 , BYREF Index AS ASCIIZ
 , BYVAL Size AS DWORD
 , BYVAL Flags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymSrvGetFileIndexString = SymSrvGetFileIndexStringW
#ELSE
 MACRO SymSrvGetFileIndexString = SymSrvGetFileIndexStringA
#ENDIF
' // Size = 828 bytes
TYPE SYMSRV_INDEX_INFO BYTE
 sizeofstruct AS DWORD
 file AS ASCIIZ * %MAX_PATH + 1 ' char
 filller1_(2) AS BYTE ' // To keep alignment
 stripped AS LONG
 timestamp AS DWORD
 size AS DWORD
 dbgfile AS ASCIIZ * %MAX_PATH + 1 ' char
 filller2_(1) AS BYTE ' // To keep alignment
 pdbfile AS ASCIIZ * %MAX_PATH + 1 ' char
 guid AS GUID ' GUID
 sig AS DWORD
 age AS DWORD
END TYPE
' // Size = 1608 bytes
TYPE SYMSRV_INDEX_INFOW
 sizeofstruct AS DWORD
 file AS WSTRINGZ * (%MAX_PATH + 1) ' WCHAR
 filller1_(1) AS BYTE ' // To keep alignment
 stripped AS LONG
 timestamp AS DWORD
 size AS DWORD
 dbgfile AS WSTRINGZ * (%MAX_PATH + 1) ' WCHAR
 pdbfile AS WSTRINGZ * (%MAX_PATH + 1) ' WCHAR
 guid AS GUID ' GUID
 sig AS DWORD
 age AS DWORD
END TYPE
DECLARE FUNCTION SymSrvGetFileIndexInfoA LIB "dbghelp.dll" ALIAS "SymSrvGetFileIndexInfo" ( BYREF File AS ASCIIZ , BYREF Info AS SYMSRV_INDEX_INFO , BYVAL Flags AS QUAD ) AS LONG
DECLARE FUNCTION SymSrvGetFileIndexInfoW LIB "dbghelp.dll" ALIAS "SymSrvGetFileIndexInfoW" ( BYREF File AS WSTRINGZ
 , BYREF Info AS SYMSRV_INDEX_INFOW
 , BYVAL Flags AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymSrvGetFileIndexInfo = SymSrvGetFileIndexInfoW
#ELSE
 MACRO SymSrvGetFileIndexInfo = SymSrvGetFileIndexInfoA
#ENDIF
DECLARE FUNCTION SymSrvStoreSupplementA LIB "dbghelp.dll" ALIAS "SymSrvStoreSupplement" ( BYVAL hProcess AS QUAD , BYREF SrvPath AS ASCIIZ , BYREF Node AS ASCIIZ , BYREF File AS ASCIIZ , BYVAL Flags AS QUAD ) AS QUAD
DECLARE FUNCTION SymSrvStoreSupplementW LIB "dbghelp.dll" ALIAS "SymSrvStoreSupplementW" ( BYVAL hProcess AS QUAD
 , BYREF SrvPath AS WSTRINGZ
 , BYREF Node AS WSTRINGZ
 , BYREF File AS WSTRINGZ
 , BYVAL Flags AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymSrvStoreSupplement = SymSrvStoreSupplementW
#ELSE
 MACRO SymSrvStoreSupplement = SymSrvStoreSupplementA
#ENDIF
DECLARE FUNCTION SymSrvStoreFileA LIB "dbghelp.dll" ALIAS "SymSrvStoreFile" ( BYVAL hProcess AS QUAD , BYREF SrvPath AS ASCIIZ , BYREF File AS ASCIIZ , BYVAL Flags AS QUAD ) AS QUAD
DECLARE FUNCTION SymSrvStoreFileW LIB "dbghelp.dll" ALIAS "SymSrvStoreFileW" ( BYVAL hProcess AS QUAD
 , BYREF SrvPath AS WSTRINGZ
 , BYREF File AS WSTRINGZ
 , BYVAL Flags AS DWORD
 ) AS DWORD
#IF %DEF(%UNICODE)
 MACRO SymSrvStoreFile = SymSrvStoreFileW
#ELSE
 MACRO SymSrvStoreFile = SymSrvStoreFileA
#ENDIF
'// used by SymGetSymbolFile's "Type" parameter
' enum
%EQUATE `sfImage = 0
%EQUATE `sfDbg = 1
%EQUATE `sfPdb = 2
%EQUATE `sfMpd = 3
%EQUATE `sfMax = 4
DECLARE FUNCTION SymGetSymbolFileA LIB "dbghelp.dll" ALIAS "SymGetSymbolFile" ( BYVAL DhProcess AS WORD , BYREF SymPath AS ASCIIZ , BYREF ImageFile AS ASCIIZ , BYVAL Type AS QUAD , BYREF SymbolFile AS ASCIIZ , BYVAL cSymbolFile AS QUAD , BYREF DbgFile AS ASCIIZ , BYVAL cDbgFile AS QUAD ) AS LONG
DECLARE FUNCTION SymGetSymbolFileW LIB "dbghelp.dll" ALIAS "SymGetSymbolFileW" ( BYVAL hProcess AS QUAD
 , BYREF SymPath AS WSTRINGZ
 , BYREF ImageFile AS WSTRINGZ
 , BYVAL Type AS DWORD
 , BYREF SymbolFile AS WSTRINGZ
 , BYVAL cSymbolFile AS DWORD
 , BYREF DbgFile AS WSTRINGZ
 , BYVAL cDbgFile AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSymbolFile = SymGetSymbolFileW
#ELSE
 MACRO SymGetSymbolFile = SymGetSymbolFileA
#ENDIF
'//
'// Full user-mode dump creation.
'//
'typedef BOOL (WINAPI *PDBGHELP_CREATE_USER_DUMP_CALLBACK)(
' );
'FUNCTION DBGHELP_CREATE_USER_DUMP_CALLBACK ( ' BYVAL DataType AS DWORD
' , BYVAL Data AS DWORD
' , BYREF DataLength AS DWORD
' , BYVAL UserData AS DWORD
' ) AS LONG
DECLARE FUNCTION DbgHelpCreateUserDumpA LIB "dbghelp.dll" ALIAS "DbgHelpCreateUserDump" ( BYREF FileName AS ASCIIZ
 , BYVAL Callback AS DWORD
 , BYVAL UserData AS DWORD
 ) AS LONG
DECLARE FUNCTION DbgHelpCreateUserDumpW LIB "dbghelp.dll" ALIAS "DbgHelpCreateUserDumpW" ( BYREF FileName AS WSTRINGZ
 , BYVAL Callback AS DWORD
 , BYVAL UserData AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO DbgHelpCreateUserDump = DbgHelpCreateUserDumpW
#ELSE
 MACRO DbgHelpCreateUserDump = DbgHelpCreateUserDumpA
#ENDIF
'// -----------------------------------------------------------------
'// The following 4 legacy APIs are fully supported, but newer
'// ones are recommended. SymFromName and SymFromAddr provide
'// much more detailed info on the returned symbol.
DECLARE FUNCTION SymGetSymFromAddr64 LIB "dbghelp.dll" ALIAS "SymGetSymFromAddr64" ( BYVAL hProcess AS QUAD , BYVAL qwAddr AS QUAD , BYREF pdwDisplacement AS QUAD , BYREF Symbol AS IMAGEHLP_SYMBOL64 ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetSymFromAddr SymGetSymFromAddr64
'#else
DECLARE FUNCTION SymGetSymFromAddr LIB "dbghelp.dll" ALIAS "SymGetSymFromAddr" ( BYVAL hProcess AS QUAD , BYVAL qwAddr AS QUAD , BYREF pdwDisplacement AS QUAD , BYREF Symbol AS IMAGEHLP_SYMBOL ) AS LONG
'#endif
'// While following two APIs will provide a symbol from a name,
'// SymEnumSymbols can provide the same matching information
'// for ALL symbols with a matching name, even regular
'// expressions. That way you can search across modules
'// and differentiate between identically named symbols.
DECLARE FUNCTION SymGetSymFromName64 LIB "dbghelp.dll" ALIAS "SymGetSymFromName64" ( BYVAL hProcess AS QUAD , BYREF Name AS ASCIIZ , BYREF Symbol AS IMAGEHLP_SYMBOL64 ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetSymFromName SymGetSymFromName64
'#else
DECLARE FUNCTION SymGetSymFromName LIB "dbghelp.dll" ALIAS "SymGetSymFromName" ( BYVAL hProcess AS QUAD , BYREF Name AS ASCIIZ , BYREF Symbol AS IMAGEHLP_SYMBOL ) AS LONG
'#endif
'// Symbol server exports
'typedef BOOL (WINAPI *PSYMBOLSERVERPROC)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERPROCA)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERPROCW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROC)(PCSTR, PCSTR, PCSTR, PSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCA)(PCSTR, PCSTR, PCSTR, PSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERBYINDEXPROCW)(PCWSTR, PCWSTR, PCWSTR, PWSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVEROPENPROC)(VOID);
'typedef BOOL (WINAPI *PSYMBOLSERVERCLOSEPROC)(VOID);
'typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSPROC)(UINT_PTR, ULONG64);
'typedef BOOL (WINAPI *PSYMBOLSERVERSETOPTIONSWPROC)(UINT_PTR, ULONG64);
'typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERCALLBACKPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
'typedef UINT_PTR (WINAPI *PSYMBOLSERVERGETOPTIONSPROC)();
'typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROC)(PCSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCA)(PCSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERPINGPROCW)(PCWSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERGETVERSION)(LPAPI_VERSION);
'typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAME)(PCSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PSTR, size_t);
'typedef BOOL (WINAPI *PSYMBOLSERVERDELTANAMEW)(PCWSTR, PVOID, DWORD, DWORD, PVOID, DWORD, DWORD, PWSTR, size_t);
'typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t);
'typedef BOOL (WINAPI *PSYMBOLSERVERGETSUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t);
'typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENT)(PCSTR, PCSTR, PCSTR, PSTR, size_t, DWORD);
'typedef BOOL (WINAPI *PSYMBOLSERVERSTORESUPPLEMENTW)(PCWSTR, PCWSTR, PCWSTR, PWSTR, size_t, DWORD);
'typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRING)(PVOID, DWORD, DWORD, PSTR, size_t);
'typedef BOOL (WINAPI *PSYMBOLSERVERGETINDEXSTRINGW)(PVOID, DWORD, DWORD, PWSTR, size_t);
'typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILE)(PCSTR, PCSTR, PVOID, DWORD, DWORD, PSTR, size_t, DWORD);
'typedef BOOL (WINAPI *PSYMBOLSERVERSTOREFILEW)(PCWSTR, PCWSTR, PVOID, DWORD, DWORD, PWSTR, size_t, DWORD);
'typedef BOOL (WINAPI *PSYMBOLSERVERISSTORE)(PCSTR);
'typedef BOOL (WINAPI *PSYMBOLSERVERISSTOREW)(PCWSTR);
'typedef DWORD (WINAPI *PSYMBOLSERVERVERSION)();
'typedef BOOL (CALLBACK WINAPI *PSYMBOLSERVERMESSAGEPROC)(UINT_PTR action, ULONG64 data, ULONG64 context);
%EQUATE `SYMSRV_VERSION = 2
%EQUATE `SSRVOPT_CALLBACK = &H00000001
%EQUATE `SSRVOPT_DWORD = &H00000002
%EQUATE `SSRVOPT_DWORDPTR = &H00000004
%EQUATE `SSRVOPT_GUIDPTR = &H00000008
%EQUATE `SSRVOPT_OLDGUIDPTR = &H00000010
%EQUATE `SSRVOPT_UNATTENDED = &H00000020
%EQUATE `SSRVOPT_NOCOPY = &H00000040
%EQUATE `SSRVOPT_GETPATH = &H00000040
%EQUATE `SSRVOPT_PARENTWIN = &H00000080
%EQUATE `SSRVOPT_PARAMTYPE = &H00000100
%EQUATE `SSRVOPT_SECURE = &H00000200
%EQUATE `SSRVOPT_TRACE = &H00000400
%EQUATE `SSRVOPT_SETCONTEXT = &H00000800
%EQUATE `SSRVOPT_PROXY = &H00001000
%EQUATE `SSRVOPT_DOWNSTREAM_STORE = &H00002000
%EQUATE `SSRVOPT_OVERWRITE = &H00004000
%EQUATE `SSRVOPT_RESETTOU = &H00008000
%EQUATE `SSRVOPT_CALLBACKW = &H00010000
%EQUATE `SSRVOPT_FLAT_DEFAULT_STORE = &H00020000
%EQUATE `SSRVOPT_PROXYW = &H00040000
%EQUATE `SSRVOPT_MESSAGE = &H00080000
%EQUATE `SSRVOPT_SERVICE = &H00100000 ' // deprecated
%EQUATE `SSRVOPT_FAVOR_COMPRESSED = &H00200000
%EQUATE `SSRVOPT_STRING = &H00400000
%EQUATE `SSRVOPT_WINHTTP = &H00800000
%EQUATE `SSRVOPT_WININET = &H01000000
%EQUATE `SSRVOPT_MAX = &H01000000
%EQUATE `SSRVOPT_RESET = &HFFFFFFFF ' ((ULONG_PTR)-1)
%EQUATE `NUM_SSRVOPTS = 30
%EQUATE `SSRVACTION_TRACE = 1
%EQUATE `SSRVACTION_QUERYCANCEL = 2
%EQUATE `SSRVACTION_EVENT = 3
%EQUATE `SSRVACTION_EVENTW = 4
%EQUATE `SSRVACTION_SIZE = 5
%EQUATE `SYMSTOREOPT_COMPRESS = &H01
%EQUATE `SYMSTOREOPT_OVERWRITE = &H02
%EQUATE `SYMSTOREOPT_RETURNINDEX = &H04
%EQUATE `SYMSTOREOPT_POINTER = &H08
%EQUATE `SYMSTOREOPT_ALT_INDEX = &H10
%EQUATE `SYMSTOREOPT_UNICODE = &H20
%EQUATE `SYMSTOREOPT_PASS_IF_EXISTS = &H40
'#ifdef DBGHELP_TRANSLATE_TCHAR
' #define SymInitialize SymInitializeW
' #define SymAddSymbol SymAddSymbolW
' #define SymDeleteSymbol SymDeleteSymbolW
' #define SearchTreeForFile SearchTreeForFileW
' #define UnDecorateSymbolName UnDecorateSymbolNameW
' #define SymGetLineFromName64 SymGetLineFromNameW64
' #define SymGetLineFromAddr64 SymGetLineFromAddrW64
' #define SymGetLineNext64 SymGetLineNextW64
' #define SymGetLinePrev64 SymGetLinePrevW64
' #define SymFromName SymFromNameW
' #define SymFindExecutableImage SymFindExecutableImageW
' #define FindExecutableImageEx FindExecutableImageExW
' #define SymSearch SymSearchW
' #define SymEnumLines SymEnumLinesW
' #define SymEnumSourceLines SymEnumSourceLinesW
' #define SymGetTypeFromName SymGetTypeFromNameW
' #define SymEnumSymbolsForAddr SymEnumSymbolsForAddrW
' #define SymFromAddr SymFromAddrW
' #define SymMatchString SymMatchStringW
' #define SymEnumSourceFiles SymEnumSourceFilesW
' #define SymEnumSymbols SymEnumSymbolsW
' #define SymLoadModuleEx SymLoadModuleExW
' #define SymSetSearchPath SymSetSearchPathW
' #define SymGetSearchPath SymGetSearchPathW
' #define EnumDirTree EnumDirTreeW
' #define SymFromToken SymFromTokenW
' #define SymFromIndex SymFromIndexW
' #define SymGetScope SymGetScopeW
' #define SymNext SymNextW
' #define SymPrev SymPrevW
' #define SymEnumTypes SymEnumTypesW
' #define SymEnumTypesByName SymEnumTypesByNameW
' #define SymRegisterCallback64 SymRegisterCallbackW64
' #define SymFindDebugInfoFile SymFindDebugInfoFileW
' #define FindDebugInfoFileEx FindDebugInfoFileExW
' #define SymFindFileInPath SymFindFileInPathW
' #define SymEnumerateModules64 SymEnumerateModulesW64
' #define SymSetHomeDirectory SymSetHomeDirectoryW
' #define SymGetHomeDirectory SymGetHomeDirectoryW
' #define SymGetSourceFile SymGetSourceFileW
' #define SymGetSourceFileToken SymGetSourceFileTokenW
' #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW
' #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW
' #define SymGetSourceFileToken SymGetSourceFileTokenW
' #define SymGetFileLineOffsets64 SymGetFileLineOffsetsW64
' #define SymFindFileInPath SymFindFileInPathW
' #define SymMatchFileName SymMatchFileNameW
' #define SymGetSourceFileFromToken SymGetSourceFileFromTokenW
' #define SymGetSourceVarFromToken SymGetSourceVarFromTokenW
' #define SymGetModuleInfo64 SymGetModuleInfoW64
' #define SymSrvIsStore SymSrvIsStoreW
' #define SymSrvDeltaName SymSrvDeltaNameW
' #define SymSrvGetSupplement SymSrvGetSupplementW
' #define SymSrvStoreSupplement SymSrvStoreSupplementW
' #define SymSrvGetFileIndexes SymSrvGetFileIndexes
' #define SymSrvGetFileIndexString SymSrvGetFileIndexStringW
' #define SymSrvStoreFile SymSrvStoreFileW
' #define SymGetSymbolFile SymGetSymbolFileW
' #define EnumerateLoadedModules64 EnumerateLoadedModulesW64
' #define EnumerateLoadedModulesEx EnumerateLoadedModulesExW
' #define SymSrvGetFileIndexInfo SymSrvGetFileIndexInfoW
' #define IMAGEHLP_LINE64 IMAGEHLP_LINEW64
' #define PIMAGEHLP_LINE64 PIMAGEHLP_LINEW64
' #define SYMBOL_INFO SYMBOL_INFOW
' #define PSYMBOL_INFO PSYMBOL_INFOW
' #define SYMBOL_INFO_PACKAGE SYMBOL_INFO_PACKAGEW
' #define PSYMBOL_INFO_PACKAGE PSYMBOL_INFO_PACKAGEW
' #define FIND_EXE_FILE_CALLBACK FIND_EXE_FILE_CALLBACKW
' #define PFIND_EXE_FILE_CALLBACK PFIND_EXE_FILE_CALLBACKW
' #define SYM_ENUMERATESYMBOLS_CALLBACK SYM_ENUMERATESYMBOLS_CALLBACKW
' #define PSYM_ENUMERATESYMBOLS_CALLBACK PSYM_ENUMERATESYMBOLS_CALLBACKW
' #define SRCCODEINFO SRCCODEINFOW
' #define PSRCCODEINFO PSRCCODEINFOW
' #define SOURCEFILE SOURCEFILEW
' #define PSOURCEFILE PSOURCEFILEW
' #define SYM_ENUMSOURECFILES_CALLBACK SYM_ENUMSOURCEFILES_CALLBACKW
' #define PSYM_ENUMSOURCEFILES_CALLBACK PSYM_ENUMSOURECFILES_CALLBACKW
' #define IMAGEHLP_CBA_EVENT IMAGEHLP_CBA_EVENTW
' #define PIMAGEHLP_CBA_EVENT PIMAGEHLP_CBA_EVENTW
' #define PENUMDIRTREE_CALLBACK PENUMDIRTREE_CALLBACKW
' #define IMAGEHLP_DEFERRED_SYMBOL_LOAD64 IMAGEHLP_DEFERRED_SYMBOL_LOADW64
' #define PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 PIMAGEHLP_DEFERRED_SYMBOL_LOADW64
' #define PFIND_DEBUG_FILE_CALLBACK PFIND_DEBUG_FILE_CALLBACKW
' #define PFINDFILEINPATHCALLBACK PFINDFILEINPATHCALLBACKW
' #define IMAGEHLP_MODULE64 IMAGEHLP_MODULEW64
' #define PIMAGEHLP_MODULE64 PIMAGEHLP_MODULEW64
' #define SYMSRV_INDEX_INFO SYMSRV_INDEX_INFOW
' #define PSYMSRV_INDEX_INFO PSYMSRV_INDEX_INFOW
' #define PSYMBOLSERVERPROC PSYMBOLSERVERPROCW
' #define PSYMBOLSERVERPINGPROC PSYMBOLSERVERPINGPROCW
'#endif
'// -----------------------------------------------------------------
'// The following APIs exist only for backwards compatibility
'// with a pre-release version documented in an MSDN release.
'// You should use SymFindFileInPath if you want to maintain
'// future compatibility.
DECLARE FUNCTION FindFileInPath LIB "dbghelp.dll" ALIAS "FindFileInPath" ( BYVAL hProcess AS QUAD , BYREF SearchPath AS ASCIIZ , BYREF FileName AS ASCIIZ , BYVAL id AS QUAD , BYVAL two AS QUAD , BYVAL three AS QUAD , BYVAL flags AS QUAD , BYREF FilePath AS ASCIIZ ) AS LONG
'// You should use SymFindFileInPath if you want to maintain
'// future compatibility.
DECLARE FUNCTION FindFileInSearchPath LIB "dbghelp.dll" ALIAS "FindFileInSearchPath" ( BYVAL hProcess AS QUAD , BYREF SearchPath AS ASCIIZ , BYREF FileName AS ASCIIZ , BYVAL id AS QUAD , BYVAL two AS QUAD , BYVAL three AS QUAD , BYREF FilePath AS ASCIIZ ) AS LONG
DECLARE FUNCTION SymEnumSym LIB "dbghelp.dll" ALIAS "SymEnumSym" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
DECLARE FUNCTION SymEnumerateSymbols64 LIB "dbghelp.dll" ALIAS "SymEnumerateSymbols64" ( BYVAL hProcess AS DWORD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
DECLARE FUNCTION SymEnumerateSymbolsW64 LIB "dbghelp.dll" ALIAS "SymEnumerateSymbolsW64" ( BYVAL hProcess AS DWORD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymEnumerateSymbols SymEnumerateSymbols64
'#define SymEnumerateSymbolsW SymEnumerateSymbolsW64
'#else
DECLARE FUNCTION SymEnumerateSymbolsA LIB "dbghelp.dll" ALIAS "SymEnumerateSymbols" ( BYVAL hProcess AS QUAD , BYVAL BaseOfDll AS QUAD , BYVAL EnumSymbolsCallback AS QUAD , BYVAL UserContext AS QUAD ) AS LONG
DECLARE FUNCTION SymEnumerateSymbolsW LIB "dbghelp.dll" ALIAS "SymEnumerateSymbolsW" ( BYVAL hProcess AS QUAD
 , BYVAL BaseOfDll AS QUAD
 , BYVAL EnumSymbolsCallback AS DWORD
 , BYVAL UserContext AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymEnumerateSymbols = SymEnumerateSymbolsW
#ELSE
 MACRO SymEnumerateSymbols = SymEnumerateSymbolsA
#ENDIF
'#endif
'// use SymLoadModuleEx
DECLARE FUNCTION SymLoadModule64 LIB "dbghelp.dll" ALIAS "SymLoadModule64" ( BYVAL hProcess AS QUAD , BYVAL hFile AS QUAD , BYREF ImageName AS ASCIIZ , BYREF ModuleName AS ASCIIZ , BYVAL BaseOfDll AS QUAD , BYVAL SizeOfDll AS QUAD ) AS QUAD ' DWORD64
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymLoadModule SymLoadModule64
'#else
DECLARE FUNCTION SymLoadModule LIB "dbghelp.dll" ALIAS "SymLoadModule" ( BYVAL hProcess AS QUAD , BYVAL hFile AS QUAD , BYREF ImageName AS ASCIIZ , BYREF ModuleName AS ASCIIZ , BYVAL BaseOfDll AS QUAD , BYVAL SizeOfDll AS QUAD ) AS QUAD ' DWORD64
'#endif
DECLARE FUNCTION SymGetSymNext64 LIB "dbghelp.dll" ALIAS "SymGetSymNext64" ( BYVAL hProcess AS QUAD , BYREF Symbol AS IMAGEHLP_SYMBOL64 ) AS LONG
DECLARE FUNCTION SymGetSymNextW64 LIB "dbghelp.dll" ALIAS "SymGetSymNextW64" ( BYVAL hProcess AS QUAD
 , BYREF Symbol AS IMAGEHLP_SYMBOLW64
 ) AS LONG
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetSymNext SymGetSymNext64
'#define SymGetSymNextW SymGetSymNextW64
'#else
DECLARE FUNCTION SymGetSymNextA LIB "dbghelp.dll" ALIAS "SymGetSymNext" ( BYVAL hProcess AS QUAD , BYREF Symbol AS IMAGEHLP_SYMBOL ) AS LONG
DECLARE FUNCTION SymGetSymNextW LIB "dbghelp.dll" ALIAS "SymGetSymNextW" ( BYVAL hProcess AS QUAD
 , BYREF Symbol AS IMAGEHLP_SYMBOLW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSymNext = SymGetSymNextW
#ELSE
 MACRO SymGetSymNext = SymGetSymNextA
#ENDIF
'#endif
DECLARE FUNCTION SymGetSymPrevA64 LIB "dbghelp.dll" ALIAS "SymGetSymPrev64" ( BYVAL hProcess AS QUAD , BYREF Symbol AS IMAGEHLP_SYMBOL64 ) AS LONG
DECLARE FUNCTION SymGetSymPrevW64 LIB "dbghelp.dll" ALIAS "SymGetSymPrevW64" ( BYVAL hProcess AS QUAD
 , BYREF Symbol AS IMAGEHLP_SYMBOLW64
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSymPrev64 = SymGetSymPrevW64
#ELSE
 MACRO SymGetSymPrev64 = SymGetSymPrevA64
#ENDIF
'#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
'#define SymGetSymPrev SymGetSymPrev64
'#define SymGetSymPrevW SymGetSymPrevW64
'#else
DECLARE FUNCTION SymGetSymPrevA LIB "dbghelp.dll" ALIAS "SymGetSymPrev" ( BYVAL hProcess AS QUAD , BYREF Symbol AS IMAGEHLP_SYMBOL ) AS LONG
DECLARE FUNCTION SymGetSymPrevW LIB "dbghelp.dll" ALIAS "SymGetSymPrevW" ( BYVAL hProcess AS QUAD
 , BYREF Symbol AS IMAGEHLP_SYMBOLW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO SymGetSymPrev = SymGetSymPrevW
#ELSE
 MACRO SymGetSymPrev = SymGetSymPrevA
#ENDIF
'#endif
'// These values should not be used.
'// They have been replaced by SYMFLAG_ values.
%EQUATE `SYMF_OMAP_GENERATED = &H00000001
%EQUATE `SYMF_OMAP_MODIFIED = &H00000002
%EQUATE `SYMF_REGISTER = &H00000008
%EQUATE `SYMF_REGREL = &H00000010
%EQUATE `SYMF_FRAMEREL = &H00000020
%EQUATE `SYMF_PARAMETER = &H00000040
%EQUATE `SYMF_LOCAL = &H00000080
%EQUATE `SYMF_CONSTANT = &H00000100
%EQUATE `SYMF_EXPORT = &H00000200
%EQUATE `SYMF_FORWARDER = &H00000400
%EQUATE `SYMF_FUNCTION = &H00000800
%EQUATE `SYMF_VIRTUAL = &H00001000
%EQUATE `SYMF_THUNK = &H00002000
%EQUATE `SYMF_TLSREL = &H00004000
'// These values should also not be used.
'// They have been replaced by SYMFLAG_ values.
%EQUATE `IMAGEHLP_SYMBOL_INFO_VALUEPRESENT = 1
%EQUATE `IMAGEHLP_SYMBOL_INFO_REGISTER = %SYMF_REGISTER ' // 0x0008
%EQUATE `IMAGEHLP_SYMBOL_INFO_REGRELATIVE = %SYMF_REGREL ' // 0x0010
%EQUATE `IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE = %SYMF_FRAMEREL ' // 0x0020
%EQUATE `IMAGEHLP_SYMBOL_INFO_PARAMETER = %SYMF_PARAMETER ' // 0x0040
%EQUATE `IMAGEHLP_SYMBOL_INFO_LOCAL = %SYMF_LOCAL ' // 0x0080
%EQUATE `IMAGEHLP_SYMBOL_INFO_CONSTANT = %SYMF_CONSTANT ' // 0x0100
%EQUATE `IMAGEHLP_SYMBOL_FUNCTION = %SYMF_FUNCTION ' // 0x0800
%EQUATE `IMAGEHLP_SYMBOL_VIRTUAL = %SYMF_VIRTUAL ' // 0x1000
%EQUATE `IMAGEHLP_SYMBOL_THUNK = %SYMF_THUNK ' // 0x2000
%EQUATE `IMAGEHLP_SYMBOL_INFO_TLSRELATIVE = %SYMF_TLSREL ' // 0x4000
'#include <poppack.h>
'#include <pshpack4.h>
'#if defined(_MSC_VER)
'#if _MSC_VER >= 800
'#if _MSC_VER >= 1200
'#pragma warning(push)
'#endif
'#pragma warning(disable:4200) /* Zero length array */
'#pragma warning(disable:4201) /* Nameless struct/union */
'#endif
'#endif
'#define MINIDUMP_SIGNATURE ('PMDM')
'#define MINIDUMP_VERSION (42899)
%EQUATE `MINIDUMP_SIGNATURE = 1296321872 ' 'PMDM'
%EQUATE `MINIDUMP_VERSION = 42899
'typedef DWORD RVA;
'typedef ULONG64 RVA64;
' // Size = 8 bytes
TYPE MINIDUMP_LOCATION_DESCRIPTOR DWORD
 DataSize AS DWORD ' ULONG32
 Rva AS DWORD ' RVA
END TYPE
' // Size = 16 bytes
TYPE MINIDUMP_LOCATION_DESCRIPTOR64 QWORD
 DataSize AS QUAD ' ULONG64
 Rva AS DWORD ' RVA
END TYPE
' // Size = 16 bytes
TYPE MINIDUMP_MEMORY_DESCRIPTOR
 StartOfMemoryRange AS QUAD ' ULONG64
 Memory AS MINIDUMP_LOCATION_DESCRIPTOR
END TYPE
'// DESCRIPTOR64 is used for full-memory minidumps where
'// all of the raw memory is laid out sequentially at the
'// end of the dump. There is no need for individual RVAs
'// as the RVA is the base RVA plus the sum of the preceeding
'// data blocks.
' // Size = 16 bytes
TYPE MINIDUMP_MEMORY_DESCRIPTOR64 QWORD
 StartOfMemoryRange AS QUAD ' ULONG64
 DataSize AS QUAD ' ULONG64
END TYPE
' // Size = 4 bytes
UNION MINIDUMP_HEADER_UNION DWORD
 Reserved AS DWORD ' ULONG32
 TimeDateStamp AS DWORD ' ULONG32
END UNION
' // Size = 32 bytes
TYPE MINIDUMP_HEADER DWORD
 Signature AS DWORD ' ULONG32
 Version AS DWORD ' ULONG32
 NumberOfStreams AS DWORD ' ULONG32
 StreamDirectoryRva AS DWORD ' RVA
 CheckSum AS DWORD ' ULONG32
 MINIDUMP_HEADER_UNION
 Flags AS QUAD ' ULONG64
END TYPE
'//
'// The MINIDUMP_HEADER field StreamDirectoryRva points to
'// an array of MINIDUMP_DIRECTORY structures.
'//
' // Size = 12 bytes
TYPE MINIDUMP_DIRECTORY DWORD
 StreamType AS DWORD ' ULONG32
 Location AS MINIDUMP_LOCATION_DESCRIPTOR
END TYPE
' // Size = 4 bytes
TYPE MINIDUMP_STRING DWORD
 Length AS DWORD ' ULONG32 // Length in bytes of the string
 ' Buffer() AS WSTRINGZ ' WCHAR // Variable size buffer
END TYPE
'//
'// The MINIDUMP_DIRECTORY field StreamType may be one of the following types.
'// Types will be added in the future, so if a program reading the minidump
'// header encounters a stream type it does not understand it should ignore
'// the data altogether. Any tag above LastReservedStream will not be used by
'// the system and is reserved for program-specific information.
'//
' enum MINIDUMP_STREAM_TYPE
%EQUATE `UnusedStream = 0
%EQUATE `ReservedStream0 = 1
%EQUATE `ReservedStream1 = 2
%EQUATE `ThreadListStream = 3
%EQUATE `ModuleListStream = 4
%EQUATE `MemoryListStream = 5
%EQUATE `ExceptionStream = 6
%EQUATE `SystemInfoStream = 7
%EQUATE `ThreadExListStream = 8
%EQUATE `Memory64ListStream = 9
%EQUATE `CommentStreamA = 10
%EQUATE `CommentStreamW = 11
%EQUATE `HandleDataStream = 12
%EQUATE `FunctionTableStream = 13
%EQUATE `UnloadedModuleListStream = 14
%EQUATE `MiscInfoStream = 15
%EQUATE `MemoryInfoListStream = 16
%EQUATE `ThreadInfoListStream = 17
%EQUATE `HandleOperationListStream = 18
%EQUATE `TokenStream = 19
%EQUATE `ceStreamNull = &H8000
%EQUATE `ceStreamSystemInfo = &H8001
%EQUATE `ceStreamException = &H8002
%EQUATE `ceStreamModuleList = &H8003
%EQUATE `ceStreamProcessList = &H8004
%EQUATE `ceStreamThreadList = &H8005
%EQUATE `ceStreamThreadContextList = &H8006
%EQUATE `ceStreamThreadCallStackList = &H8007
%EQUATE `ceStreamMemoryVirtualList = &H8008
%EQUATE `ceStreamMemoryPhysicalList = &H8009
%EQUATE `ceStreamBucketParameters = &H800A
%EQUATE `ceStreamProcessModuleMap = &H800B
%EQUATE `ceStreamDiagnosisList = &H800C
%EQUATE `LastReservedStream = &Hffff
'//
'// The minidump system information contains processor and
'// Operating System specific information.
'//
'//
'// CPU information is obtained from one of two places.
'//
'// 1) On x86 computers, CPU_INFORMATION is obtained from the CPUID
'// instruction. You must use the X86 portion of the union for X86
'// computers.
'//
'// 2) On non-x86 architectures, CPU_INFORMATION is obtained by calling
'// IsProcessorFeatureSupported().
'//
'typedef union _CPU_INFORMATION {
' //
' // X86 platforms use CPUID function to obtain processor information.
' //
' struct {
' //
' // CPUID Subfunction 0, register EAX (VendorId [0]),
' // EBX (VendorId [1]) and ECX (VendorId [2]).
' //
' ULONG32 VendorId [ 3 ];
' //
' // CPUID Subfunction 1, register EAX
' //
' ULONG32 VersionInformation;
' //
' // CPUID Subfunction 1, register EDX
' //
' ULONG32 FeatureInformation;
' //
' // CPUID, Subfunction 80000001, register EBX. This will only
' // be obtained if the vendor id is "AuthenticAMD".
' //
' ULONG32 AMDExtendedCpuFeatures;
' } X86CpuInfo;
' //
' // Non-x86 platforms use processor feature flags.
' //
' struct {
' ULONG64 ProcessorFeatures [ 2 ];
' } OtherCpuInfo;
'} CPU_INFORMATION, *PCPU_INFORMATION;
' // Size = 24 bytes
TYPE CPU_INFORMATION_X86CpuInfo DWORD
 VendorId(2) AS DWORD ' ULONG32
 VersionInformation AS DWORD ' ULONG32
 FeatureInformation AS DWORD ' ULONG32
 AMDExtendedCpuFeatures AS DWORD ' ULONG32
END TYPE
' // Size = 16 bytes
TYPE CPU_INFORMATION_OtherCpuInfo QWORD
 ProcessorFeatures(1) AS QUAD ' ULONG64
END TYPE
' // Size = 24 bytes
UNION CPU_INFORMATION
 CPU_INFORMATION_X86CpuInfo
 CPU_INFORMATION_OtherCpuInfo
END UNION
'typedef struct _MINIDUMP_SYSTEM_INFO {
' //
' // ProcessorArchitecture, ProcessorLevel and ProcessorRevision are all
' // taken from the SYSTEM_INFO structure obtained by GetSystemInfo( ).
' //
' USHORT ProcessorArchitecture;
' USHORT ProcessorLevel;
' USHORT ProcessorRevision;
' union {
' USHORT Reserved0;
' struct {
' UCHAR NumberOfProcessors;
' UCHAR ProductType;
' };
' };
' //
' // MajorVersion, MinorVersion, BuildNumber, PlatformId and
' // CSDVersion are all taken from the OSVERSIONINFO structure
' // returned by GetVersionEx( ).
' //
' ULONG32 MajorVersion;
' ULONG32 MinorVersion;
' ULONG32 BuildNumber;
' ULONG32 PlatformId;
' //
' // RVA to a CSDVersion string in the string table.
' //
' RVA CSDVersionRva;
' union {
' ULONG32 Reserved1;
' struct {
' USHORT SuiteMask;
' USHORT Reserved2;
' };
' };
' CPU_INFORMATION Cpu;
'} MINIDUMP_SYSTEM_INFO, *PMINIDUMP_SYSTEM_INFO;
' // Size = 2 bytes
TYPE MINIDUMP_SYSTEM_INFO_UNION_1_STRUCT BYTE
 NumberOfProcessors AS BYTE ' UCHAR
 ProductType AS BYTE ' UCHAR
END TYPE
' // Size = 2 bytes
UNION MINIDUMP_SYSTEM_INFO_UNION_1 WORD FILL
 Reserved0 AS WORD ' USHORT
 MINIDUMP_SYSTEM_INFO_UNION_1_STRUCT
END UNION
' // Size = 4 bytes
TYPE MINIDUMP_SYSTEM_INFO_UNION_2_STRUCT WORD
 SuiteMask AS WORD ' USHORT
 Reserved2 AS WORD ' USHORT
END TYPE
' // Size = 4 bytes
UNION MINIDUMP_SYSTEM_INFO_UNION_2 WORD
 Reserved1 AS DWORD ' ULONG32
 MINIDUMP_SYSTEM_INFO_UNION_2_STRUCT
END UNION
' // Size = 56 bytes
TYPE MINIDUMP_SYSTEM_INFO WORD
 ProcessorArchitecture AS WORD ' USHORT
 ProcessorLevel AS WORD ' USHORT
 ProcessorRevision AS WORD ' USHORT
 MINIDUMP_SYSTEM_INFO_UNION_1
 MajorVersion AS DWORD ' ULONG32
 MinorVersion AS DWORD ' ULONG32
 BuildNumber AS DWORD ' ULONG32
 PlatformId AS DWORD ' ULONG32
 CSDVersionRva AS DWORD ' RVA
 MINIDUMP_SYSTEM_INFO_UNION_2
 Cpu AS CPU_INFORMATION
END TYPE
'//
'// The minidump thread contains standard thread
'// information plus an RVA to the memory for this
'// thread and an RVA to the CONTEXT structure for
'// this thread.
'//
'//
'// ThreadId must be 4 bytes on all architectures.
'//
'C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
' // Size = 48 bytes
TYPE MINIDUMP_THREAD DWORD
 ThreadId AS DWORD ' ULONG32
 SuspendCount AS DWORD ' ULONG32
 PriorityClass AS DWORD ' ULONG32
 Priority AS DWORD ' ULONG32
 Teb AS QUAD ' ULONG64
 Stack AS MINIDUMP_MEMORY_DESCRIPTOR
 ThreadContext AS MINIDUMP_LOCATION_DESCRIPTOR
END TYPE
'//
'// The thread list is a container of threads.
'//
' // Size = 4 bytes
TYPE MINIDUMP_THREAD_LIST DWORD
 NumberOfThreads AS DWORD ' ULONG32
 ' Threads() AS MINIDUMP_THREAD
END TYPE
' // Size = 64 bytes
TYPE MINIDUMP_THREAD_EX DWORD
 ThreadId AS DWORD ' ULONG32
 SuspendCount AS DWORD ' ULONG32
 PriorityClass AS DWORD ' ULONG32
 Priority AS DWORD ' ULONG32
 Teb AS QUAD ' ULONG64
 Stack AS MINIDUMP_MEMORY_DESCRIPTOR
 ThreadContext AS MINIDUMP_LOCATION_DESCRIPTOR
 BackingStore AS MINIDUMP_MEMORY_DESCRIPTOR
END TYPE
'//
'// The thread list is a container of threads.
'//
' // Size = 4 bytes
TYPE MINIDUMP_THREAD_EX_LIST DWORD
 NumberOfThreads AS DWORD ' ULONG32
 ' Threads() AS MINIDUMP_THREAD_EX
END TYPE
'//
'// The MINIDUMP_EXCEPTION is the same as EXCEPTION on Win64.
'//
' // Size = 152 bytes
TYPE MINIDUMP_EXCEPTION DWORD
 ExceptionCode AS DWORD ' ULONG32
 ExceptionFlags AS DWORD ' ULONG32
 ExceptionRecord AS QUAD ' ULONG64
 ExceptionAddress AS QUAD ' ULONG64
 NumberParameters AS DWORD ' ULONG32
 unusedAlignment__ AS DWORD ' ULONG32
 ExceptionInformation(%EXCEPTION_MAXIMUM_PARAMETERS - 1) AS QUAD ' ULONG64
END TYPE
'//
'// The exception information stream contains the id of the thread that caused
'// the exception (ThreadId), the exception record for the exception
'// (ExceptionRecord) and an RVA to the thread context where the exception
'// occured.
'//
' // Size = 168 bytes
TYPE MINIDUMP_EXCEPTION_STREAM DWORD
 ThreadId AS DWORD ' ULONG32
 alignment__ AS DWORD ' ULONG32
 ExceptionRecord AS MINIDUMP_EXCEPTION
 ThreadContext AS MINIDUMP_LOCATION_DESCRIPTOR
END TYPE
'//
'// The MINIDUMP_MODULE contains information about a
'// a specific module. It includes the CheckSum and
'// the TimeDateStamp for the module so the module
'// can be reloaded during the analysis phase.
'//
' // Size = 108 bytes
TYPE MINIDUMP_MODULE DWORD
 BaseOfImage AS QUAD ' ULONG64
 SizeOfImage AS DWORD ' ULONG32
 CheckSum AS DWORD ' ULONG32
 TimeDateStamp AS DWORD ' ULONG32
 ModuleNameRva AS DWORD ' RVA
 VersionInfo AS VS_FIXEDFILEINFO
 CvRecord AS MINIDUMP_LOCATION_DESCRIPTOR
 MiscRecord AS MINIDUMP_LOCATION_DESCRIPTOR
 Reserved0 AS QUAD ' ULONG64 // Reserved for future use.
 Reserved1 AS QUAD ' ULONG64 // Reserved for future use.
END TYPE
'//
'// The minidump module list is a container for modules.
'//
' // Size = 4 bytes
TYPE MINIDUMP_MODULE_LIST DWORD
 NumberOfModules AS DWORD ' ULONG32
 ' Modules() AS MINIDUMP_MODULE
END TYPE
'//
'// Memory Ranges
'//
' // Size = 4 bytes
TYPE MINIDUMP_MEMORY_LIST DWORD
 NumberOfMemoryRanges AS DWORD ' ULONG32
 ' MemoryRanges(0) AS MINIDUMP_MEMORY_DESCRIPTOR
END TYPE
' // Size = 16 bytes
TYPE MINIDUMP_MEMORY64_LIST QWORD
 NumberOfMemoryRanges AS QUAD ' ULONG64
 BaseRva AS QUAD ' RVA64
 ' MemoryRanges() AS MINIDUMP_MEMORY_DESCRIPTOR64
END TYPE
'//
'// Support for user supplied exception information.
'//
' // Size = 12 bytes
TYPE MINIDUMP_EXCEPTION_INFORMATION DWORD
 ThreadId AS DWORD
 ExceptionPointers AS EXCEPTION_POINTERS PTR
 ClientPointers AS LONG
END TYPE
' // Size = 24 bytes
TYPE MINIDUMP_EXCEPTION_INFORMATION64 DWORD
 ThreadId AS DWORD
 ExceptionRecord AS QUAD ' ULONG64
 ContextRecord AS QUAD ' ULONG64
 ClientPointers AS LONG
END TYPE
'//
'// Support for capturing system handle state at the time of the dump.
'//
'// Per-handle object information varies according to
'// the OS, the OS version, the processor type and
'// so on. The minidump gives a minidump identifier
'// to each possible data format for identification
'// purposes but does not control nor describe the actual data.
' enum MINIDUMP_HANDLE_OBJECT_INFORMATION_TYPE
%EQUATE `MiniHandleObjectInformationNone = 0
%EQUATE `MiniThreadInformation1 = 1
%EQUATE `MiniMutantInformation1 = 2
%EQUATE `MiniMutantInformation2 = 3
%EQUATE `MiniProcessInformation1 = 4
%EQUATE `MiniProcessInformation2 = 5
%EQUATE `MiniHandleObjectInformationTypeMax = 6
' // Size = 12 bytes
TYPE MINIDUMP_HANDLE_OBJECT_INFORMATION DWORD
 NextInfoRva AS DWORD ' RVA
 InfoType AS DWORD ' ULONG32
 SizeOfInfo AS DWORD ' ULONG32
 ' // Raw information follows.
END TYPE
' // Size = 32 bytes
TYPE MINIDUMP_HANDLE_DESCRIPTOR DWORD
 Handle AS QUAD ' ULONG64
 TypeNameRva AS DWORD ' RVA
 ObjectNameRva AS DWORD ' RVA
 Attributes AS DWORD ' ULONG32
 GrantedAccess AS DWORD ' ULONG32
 HandleCount AS DWORD ' ULONG32
 PointerCount AS DWORD ' ULONG32
END TYPE
' // Size = 40 bytes
TYPE MINIDUMP_HANDLE_DESCRIPTOR_2 DWORD
 Handle AS QUAD ' ULONG64
 TypeNameRva AS DWORD ' RVA
 ObjectNameRva AS DWORD ' RVA
 Attributes AS DWORD ' ULONG32
 GrantedAccess AS DWORD ' ULONG32
 HandleCount AS DWORD ' ULONG32
 PointerCount AS DWORD ' ULONG32
 ObjectInfoRva AS DWORD ' RVA
 Reserved0 AS DWORD ' ULONG32
END TYPE
'// The latest MINIDUMP_HANDLE_DESCRIPTOR definition.
'typedef MINIDUMP_HANDLE_DESCRIPTOR_2 MINIDUMP_HANDLE_DESCRIPTOR_N;
'typedef MINIDUMP_HANDLE_DESCRIPTOR_N *PMINIDUMP_HANDLE_DESCRIPTOR_N;
' // Size = 16 bytes
TYPE MINIDUMP_HANDLE_DATA_STREAM DWORD
 SizeOfHeader AS DWORD ' ULONG32
 SizeOfDescriptor AS DWORD ' ULONG32
 NumberOfDescriptors AS DWORD ' ULONG32
 Reserved AS DWORD ' ULONG32
END TYPE
'// Some operating systems can track the last operations
'// performed on a handle. For example, Application Verifier
'// can enable this for some versions of Windows. The
'// handle operation list collects handle operations
'// known for the dump target.
'// Each entry is an AVRF_HANDLE_OPERATION.
' // Size = 16 bytes
TYPE MINIDUMP_HANDLE_OPERATION_LIST DWORD
 SizeOfHeader AS DWORD ' ULONG32
 SizeOfEntry AS DWORD ' ULONG32
 NumberOfEntries AS DWORD ' ULONG32
 Reserved AS DWORD ' ULONG32
END TYPE
'//
'// Support for capturing dynamic function table state at the time of the dump.
'//
' // Size = 32 bytes
TYPE MINIDUMP_FUNCTION_TABLE_DESCRIPTOR DWORD
 MinimumAddress AS QUAD ' ULONG64
 MaximumAddress AS QUAD ' ULONG64
 BaseAddress AS QUAD ' ULONG64
 EntryCount AS DWORD ' ULONG32
 SizeOfAlignPad AS DWORD ' ULONG32
END TYPE
' // Size = 24 bytes
TYPE MINIDUMP_FUNCTION_TABLE_STREAM DWORD
 SizeOfHeader AS DWORD ' ULONG32
 SizeOfDescriptor AS DWORD ' ULONG32
 SizeOfNativeDescriptor AS DWORD ' ULONG32
 SizeOfFunctionEntry AS DWORD ' ULONG32
 NumberOfDescriptors AS DWORD ' ULONG32
 SizeOfAlignPad AS DWORD ' ULONG32
END TYPE
'//
'// The MINIDUMP_UNLOADED_MODULE contains information about a
'// a specific module that was previously loaded but no
'// longer is. This can help with diagnosing problems where
'// callers attempt to call code that is no longer loaded.
'//
' // Size = 24 bytes
TYPE MINIDUMP_UNLOADED_MODULE DWORD
 BaseOfImage AS QUAD ' ULONG64
 SizeOfImage AS DWORD ' ULONG32
 CheckSum AS DWORD ' ULONG32
 TimeDateStamp AS DWORD ' ULONG32
 ModuleNameRva AS DWORD ' RVA
END TYPE
'//
'// The minidump unloaded module list is a container for unloaded modules.
'//
' // Size = 12 bytes
TYPE MINIDUMP_UNLOADED_MODULE_LIST DWORD
 SizeOfHeader AS DWORD ' ULONG32
 SizeOfEntry AS DWORD ' ULONG32
 NumberOfEntries AS DWORD ' ULONG32
END TYPE
'//
'// The miscellaneous information stream contains a variety
'// of small pieces of information. A member is valid if
'// it's within the available size and its corresponding
'// bit is set.
'//
%EQUATE `MINIDUMP_MISC1_PROCESS_ID = &H00000001
%EQUATE `MINIDUMP_MISC1_PROCESS_TIMES = &H00000002
%EQUATE `MINIDUMP_MISC1_PROCESSOR_POWER_INFO = &H00000004
%EQUATE `MINIDUMP_MISC3_PROCESS_INTEGRITY = &H00000010
%EQUATE `MINIDUMP_MISC3_PROCESS_EXECUTE_FLAGS = &H00000020
%EQUATE `MINIDUMP_MISC3_TIMEZONE = &H00000040
%EQUATE `MINIDUMP_MISC3_PROTECTED_PROCESS = &H00000080
' // Size = 24 bytes
TYPE MINIDUMP_MISC_INFO DWORD
 SizeOfInfo AS DWORD ' ULONG32
 Flags1 AS DWORD ' ULONG32
 ProcessId AS DWORD ' ULONG32
 ProcessCreateTime AS DWORD ' ULONG32
 ProcessUserTime AS DWORD ' ULONG32
 ProcessKernelTime AS DWORD ' ULONG32
END TYPE
' // Size = 44 bytes
TYPE MINIDUMP_MISC_INFO_2 DWORD
 SizeOfInfo AS DWORD ' ULONG32
 Flags1 AS DWORD ' ULONG32
 ProcessId AS DWORD ' ULONG32
 ProcessCreateTime AS DWORD ' ULONG32
 ProcessUserTime AS DWORD ' ULONG32
 ProcessKernelTime AS DWORD ' ULONG32
 ProcessorMaxMhz AS DWORD ' ULONG32
 ProcessorCurrentMhz AS DWORD ' ULONG32
 ProcessorMhzLimit AS DWORD ' ULONG32
 ProcessorMaxIdleState AS DWORD ' ULONG32
 ProcessorCurrentIdleState AS DWORD ' ULONG32
END TYPE
' // Size = 232 bytes
TYPE MINIDUMP_MISC_INFO_3 DWORD
 SizeOfInfo AS DWORD ' ULONG32
 Flags1 AS DWORD ' ULONG32
 ProcessId AS DWORD ' ULONG32
 ProcessCreateTime AS DWORD ' ULONG32
 ProcessUserTime AS DWORD ' ULONG32
 ProcessKernelTime AS DWORD ' ULONG32
 ProcessorMaxMhz AS DWORD ' ULONG32
 ProcessorCurrentMhz AS DWORD ' ULONG32
 ProcessorMhzLimit AS DWORD ' ULONG32
 ProcessorMaxIdleState AS DWORD ' ULONG32
 ProcessorCurrentIdleState AS DWORD ' ULONG32
 ProcessIntegrityLevel AS DWORD ' ULONG32
 ProcessExecuteFlags AS DWORD ' ULONG32
 ProtectedProcess AS DWORD ' ULONG32
 TimeZoneId AS DWORD ' ULONG32
 TimeZone AS TIME_ZONE_INFORMATION
END TYPE
'// The latest MINIDUMP_MISC_INFO definition.
'typedef MINIDUMP_MISC_INFO_3 MINIDUMP_MISC_INFO_N;
'typedef MINIDUMP_MISC_INFO_N* PMINIDUMP_MISC_INFO_N;
'//
'// The memory information stream contains memory region
'// description information. This stream corresponds to
'// what VirtualQuery would return for the process the
'// dump was created for.
'//
TYPE MINIDUMP_MEMORY_INFO
 BaseAddress AS QUAD ' ULONG64
 AllocationBase AS QUAD ' ULONG64
 AllocationProtect AS DWORD ' ULONG32
 alignment1__ AS DWORD ' ULONG32
 RegionSize AS QUAD ' ULONG64
 State AS DWORD ' ULONG32
 Protect AS DWORD ' ULONG32
 Type AS DWORD ' ULONG32
 alignment2__ AS DWORD ' ULONG32
END TYPE
TYPE MINIDUMP_MEMORY_INFO_LIST
 SizeOfHeader AS DWORD ' ULONG
 SizeOfEntry AS DWORD ' ULONG
 NumberOfEntries AS QUAD ' ULONG64
END TYPE
'//
'// The memory information stream contains memory region
'// description information. This stream corresponds to
'// what VirtualQuery would return for the process the
'// dump was created for.
'//
'// Thread dump writer status flags.
%EQUATE `MINIDUMP_THREAD_INFO_ERROR_THREAD = &H00000001
%EQUATE `MINIDUMP_THREAD_INFO_WRITING_THREAD = &H00000002
%EQUATE `MINIDUMP_THREAD_INFO_EXITED_THREAD = &H00000004
%EQUATE `MINIDUMP_THREAD_INFO_INVALID_INFO = &H00000008
%EQUATE `MINIDUMP_THREAD_INFO_INVALID_CONTEXT = &H00000010
%EQUATE `MINIDUMP_THREAD_INFO_INVALID_TEB = &H00000020
' // Size = 64 bytes
TYPE MINIDUMP_THREAD_INFO QWORD FILL
 ThreadId AS DWORD ' ULONG32
 DumpFlags AS DWORD ' ULONG32
 DumpError AS DWORD ' ULONG32
 ExitStatus AS DWORD ' ULONG32
 CreateTime AS QUAD ' ULONG64
 ExitTime AS QUAD ' ULONG64
 KernelTime AS QUAD ' ULONG64
 UserTime AS QUAD ' ULONG64
 StartAddress AS QUAD ' ULONG64
 Affinity AS QUAD ' ULONG64
END TYPE
' // Size = 12 bytes
TYPE MINIDUMP_THREAD_INFO_LIST DWORD
 SizeOfHeader AS DWORD ' ULONG
 SizeOfEntry AS DWORD ' ULONG
 NumberOfEntries AS DWORD ' ULONG
END TYPE
'//
'// Support for token information.
'//
' // Size = 16 bytes
TYPE MINIDUMP_TOKEN_INFO_HEADER QWORD FILL
 TokenSize AS DWORD ' ULONG // The size of the token structure.
 TokenId AS DWORD ' ULONG // The PID in NtOpenProcessToken() call or TID in NtOpenThreadToken() call.
 TokenHandle AS QUAD ' ULONG64 // The handle value returned.
END TYPE
' // Size = 16 bytes
TYPE MINIDUMP_TOKEN_INFO_LIST DWORD
 TokenListSize AS DWORD ' ULONG
 TokenListEntries AS DWORD ' ULONG
 ListHeaderSize AS DWORD ' ULONG
 ElementHeaderSize AS DWORD ' ULONG
END TYPE
'//
'// Support for arbitrary user-defined information.
'//
' // Size = 12 bytes
TYPE MINIDUMP_USER_RECORD DWORD
 Type AS DWORD ' ULONG32
 Memory AS MINIDUMP_LOCATION_DESCRIPTOR
END TYPE
' // Size = 12 bytes
TYPE MINIDUMP_USER_STREAM DWORD
 Type AS DWORD ' ULONG32
 BufferSize AS DWORD ' ULONG
 Buffer AS DWORD
END TYPE
' // Size = 8 bytes
TYPE MINIDUMP_USER_STREAM_INFORMATION DWORD
 UserStreamCount AS DWORD ' ULONG
 UserStreamArray AS MINIDUMP_USER_STREAM PTR ' PMINIDUMP_USER_STREAM
END TYPE
'//
'// Callback support.
'//
' enum MINIDUMP_CALLBACK_TYPE
%EQUATE `ModuleCallback = 0
%EQUATE `ThreadCallback = 1
%EQUATE `ThreadExCallback = 2
%EQUATE `IncludeThreadCallback = 3
%EQUATE `IncludeModuleCallback = 4
%EQUATE `MemoryCallback = 5
%EQUATE `CancelCallback = 6
%EQUATE `WriteKernelMinidumpCallback = 7
%EQUATE `KernelMinidumpStatusCallback = 8
%EQUATE `RemoveMemoryCallback = 9
%EQUATE `IncludeVmRegionCallback = 10
%EQUATE `IoStartCallback = 11
%EQUATE `IoWriteAllCallback = 12
%EQUATE `IoFinishCallback = 13
%EQUATE `ReadMemoryFailureCallback = 14
%EQUATE `SecondaryFlagsCallback = 15
' // Size = 744 bytes
TYPE MINIDUMP_THREAD_CALLBACK DWORD
 ThreadId AS DWORD ' ULONG
 ThreadHandle AS DWORD
 Context AS CONTEXT
 SizeOfContext AS DWORD ' ULONG
 StackBase AS QUAD ' ULONG64
 StackEnd AS QUAD ' ULONG64
END TYPE
' // Size = 760 bytes
TYPE MINIDUMP_THREAD_EX_CALLBACK DWORD
 ThreadId AS DWORD ' ULONG
 ThreadHandle AS DWORD
 Context AS CONTEXT
 SizeOfContext AS DWORD ' ULONG
 StackBase AS QUAD ' ULONG64
 StackEnd AS QUAD ' ULONG64
 BackingStoreBase AS QUAD ' ULONG64
 BackingStoreEnd AS QUAD ' ULONG64
END TYPE
' // Size = 4 bytes
TYPE MINIDUMP_INCLUDE_THREAD_CALLBACK DWORD
 ThreadId AS DWORD ' ULONG
END TYPE
' enum THREAD_WRITE_FLAGS
%EQUATE `ThreadWriteThread = &H0001
%EQUATE `ThreadWriteStack = &H0002
%EQUATE `ThreadWriteContext = &H0004
%EQUATE `ThreadWriteBackingStore = &H0008
%EQUATE `ThreadWriteInstructionWindow = &H0010
%EQUATE `ThreadWriteThreadData = &H0020
%EQUATE `ThreadWriteThreadInfo = &H0040
' // Size = 92 bytes
TYPE MINIDUMP_MODULE_CALLBACK DWORD
 FullPath AS WSTRINGZ PTR
 BaseOfImage AS QUAD ' ULONG64
 SizeOfImage AS DWORD ' ULONG
 CheckSum AS DWORD ' ULONG
 TimeDateStamp AS DWORD ' ULONG
 VersionInfo AS VS_FIXEDFILEINFO
 CvRecord AS DWORD
 SizeOfCvRecord AS DWORD ' ULONG
 MiscRecord AS DWORD
 SizeOfMiscRecord AS DWORD ' ULONG
END TYPE
' // Size = 8 bytes
TYPE MINIDUMP_INCLUDE_MODULE_CALLBACK QWORD
 BaseOfImage AS QUAD ' ULONG64
END TYPE
' enum MODULE_WRITE_FLAGS
%EQUATE `ModuleWriteModule = &H0001
%EQUATE `ModuleWriteDataSeg = &H0002
%EQUATE `ModuleWriteMiscRecord = &H0004
%EQUATE `ModuleWriteCvRecord = &H0008
%EQUATE `ModuleReferencedByMemory = &H0010
%EQUATE `ModuleWriteTlsData = &H0020
%EQUATE `ModuleWriteCodeSegs = &H0040
' // Size = 20 bytes
TYPE MINIDUMP_IO_CALLBACK DWORD
 Handle AS DWORD
 Offset AS QUAD ' ULONG64
 Buffer AS DWORD
 BufferBytes AS DWORD ' ULONG
END TYPE
' // Size = 16 bytes
TYPE MINIDUMP_READ_MEMORY_FAILURE_CALLBACK
 Offset AS QUAD ' ULONG64
 Bytes AS DWORD ' ULONG
 FailureStatus AS LONG
END TYPE
'typedef struct _MINIDUMP_CALLBACK_INPUT {
' ULONG ProcessId;
' HANDLE ProcessHandle;
' ULONG CallbackType;
' union {
' HRESULT Status;
' MINIDUMP_THREAD_CALLBACK Thread;
' MINIDUMP_THREAD_EX_CALLBACK ThreadEx;
' MINIDUMP_MODULE_CALLBACK Module;
' MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
' MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
' MINIDUMP_IO_CALLBACK Io;
' MINIDUMP_READ_MEMORY_FAILURE_CALLBACK ReadMemoryFailure;
' ULONG SecondaryFlags;
' };
'} MINIDUMP_CALLBACK_INPUT, *PMINIDUMP_CALLBACK_INPUT;
' // Size = 760 bytes bytes
UNION MINIDUMP_CALLBACK_INPUT_UNION DWORD
 Status AS LONG
 Thread AS MINIDUMP_THREAD_CALLBACK
 ThreadEx AS MINIDUMP_THREAD_EX_CALLBACK
 Module AS MINIDUMP_MODULE_CALLBACK
 IncludeThread AS MINIDUMP_INCLUDE_THREAD_CALLBACK
 IncludeModule AS MINIDUMP_INCLUDE_MODULE_CALLBACK
 Io AS MINIDUMP_IO_CALLBACK
 ReadMemoryFailure AS MINIDUMP_READ_MEMORY_FAILURE_CALLBACK
 SecondaryFlags AS DWORD ' ULONG
END UNION
' // Size = 772 bytes bytes
TYPE MINIDUMP_CALLBACK_INPUT DWORD
 ProcessId AS DWORD ' ULONG
 ProcessHandle AS DWORD
 CallbackType AS DWORD ' ULONG
 MINIDUMP_CALLBACK_INPUT_UNION
END TYPE
' // Size = 12 bytes bytes
TYPE INIDUMP_CALLBACK_OUTPUT_UNION_STRUCT_1 DWORD
 MemoryBase AS QUAD ' ULONG64
 MemorySize AS DWORD ' ULONG
END TYPE
' // Size = 8 bytes bytes
TYPE INIDUMP_CALLBACK_OUTPUT_UNION_STRUCT_2 DWORD
 CheckCancel AS LONG
 Cancel AS LONG
END TYPE
' // Size = 52 bytes bytes
TYPE INIDUMP_CALLBACK_OUTPUT_UNION_STRUCT_3 DWORD
 VmRegion AS MINIDUMP_MEMORY_INFO
 Continue AS LONG
END TYPE
' // Size = 52 bytes bytes
UNION INIDUMP_CALLBACK_OUTPUT_UNION DWORD
 ModuleWriteFlags AS DWORD ' ULONG
 ThreadWriteFlags AS DWORD ' ULONG
 SecondaryFlags AS DWORD ' ULONG
 INIDUMP_CALLBACK_OUTPUT_UNION_STRUCT_1
 INIDUMP_CALLBACK_OUTPUT_UNION_STRUCT_2
 Handle AS DWORD
 INIDUMP_CALLBACK_OUTPUT_UNION_STRUCT_3
 Status AS LONG
END UNION
' // Size = 52 bytes bytes
TYPE MINIDUMP_CALLBACK_OUTPUT DWORD
 INIDUMP_CALLBACK_OUTPUT_UNION
END TYPE
'//
'// Stack and backing store memory can be filtered to remove
'// data unnecessary for stack walking. This can improve
'// compression of stacks and also deletes data that may
'// be private and should not be stored in a dump.
'// Memory can also be scanned to see what modules are
'// referenced by stack and backing store memory to allow
'// omission of other modules to reduce dump size.
'// In either of these modes the ModuleReferencedByMemory flag
'// is set for all modules referenced before the base
'// module callbacks occur.
'//
'// On some operating systems a list of modules that were
'// recently unloaded is kept in addition to the currently
'// loaded module list. This information can be saved in
'// the dump if desired.
'//
'// Stack and backing store memory can be scanned for referenced
'// pages in order to pick up data referenced by locals or other
'// stack memory. This can increase the size of a dump significantly.
'//
'// Module paths may contain undesired information such as user names
'// or other important directory names so they can be stripped. This
'// option reduces the ability to locate the proper image later
'// and should only be used in certain situations.
'//
'// Complete operating system per-process and per-thread information can
'// be gathered and stored in the dump.
'//
'// The virtual address space can be scanned for various types
'// of memory to be included in the dump.
'//
'// Code which is concerned with potentially private information
'// getting into the minidump can set a flag that automatically
'// modifies all existing and future flags to avoid placing
'// unnecessary data in the dump. Basic data, such as stack
'// information, will still be included but optional data, such
'// as indirect memory, will not.
'//
'// When doing a full memory dump it's possible to store all
'// of the enumerated memory region descriptive information
'// in a memory information stream.
'//
'// Additional thread information beyond the basic thread
'// structure can be collected if desired.
'//
'// A minidump with code segments includes all of the code
'// and code-related sections from loaded modules in order
'// to capture executable content.
'//
'// MiniDumpWithoutAuxiliaryState turns off any secondary,
'// auxiliary-supported memory gathering.
'//
'// MiniDumpWithFullAuxiliaryState asks any present auxiliary
'// data providers to include all of their state in the dump.
'// The exact set of what is provided depends on the auxiliary.
'// This can be quite large.
'//
' enum MINIDUMP_TYPE
%EQUATE `MiniDumpNormal = &H00000000
%EQUATE `MiniDumpWithDataSegs = &H00000001
%EQUATE `MiniDumpWithFullMemory = &H00000002
%EQUATE `MiniDumpWithHandleData = &H00000004
%EQUATE `MiniDumpFilterMemory = &H00000008
%EQUATE `MiniDumpScanMemory = &H00000010
%EQUATE `MiniDumpWithUnloadedModules = &H00000020
%EQUATE `MiniDumpWithIndirectlyReferencedMemory = &H00000040
%EQUATE `MiniDumpFilterModulePaths = &H00000080
%EQUATE `MiniDumpWithProcessThreadData = &H00000100
%EQUATE `MiniDumpWithPrivateReadWriteMemory = &H00000200
%EQUATE `MiniDumpWithoutOptionalData = &H00000400
%EQUATE `MiniDumpWithFullMemoryInfo = &H00000800
%EQUATE `MiniDumpWithThreadInfo = &H00001000
%EQUATE `MiniDumpWithCodeSegs = &H00002000
%EQUATE `MiniDumpWithoutAuxiliaryState = &H00004000
%EQUATE `MiniDumpWithFullAuxiliaryState = &H00008000
%EQUATE `MiniDumpWithPrivateWriteCopyMemory = &H00010000
%EQUATE `MiniDumpIgnoreInaccessibleMemory = &H00020000
%EQUATE `MiniDumpWithTokenInformation = &H00040000
%EQUATE `MiniDumpValidTypeFlags = &H0000ffff
'//
'// In addition to the primary flags provided to
'// MiniDumpWriteDump there are additional, less
'// frequently used options queried via the secondary
'// flags callback.
'//
'// MiniSecondaryWithoutPowerInfo suppresses the minidump
'// query that retrieves processor power information for
'// MINIDUMP_MISC_INFO.
'//
' enum MINIDUMP_SECONDARY_FLAGS
%EQUATE `MiniSecondaryWithoutPowerInfo = &H00000001
%EQUATE `MiniSecondaryValidFlags = &H00000001
'//
'// The minidump callback should modify the FieldsToWrite parameter to reflect
'// what portions of the specified thread or module should be written to the
'// file.
'//
'typedef
'(WINAPI * MINIDUMP_CALLBACK_ROUTINE) (
' );
'FUNCTION MINIDUMP_CALLBACK_ROUTINE ( ' BYVAL CallbackParam AS DWORD
' , BYVAL CallbackInput AS DWORD
' , BYREF CallbackOutput AS DWORD
' ) AS LONG
' // Size = 8 bytes bytes
TYPE MINIDUMP_CALLBACK_INFORMATION DWORD
 CallbackRoutine AS DWORD ' MINIDUMP_CALLBACK_ROUTINE
 CallbackParam AS DWORD
END TYPE
'//++
'//
'// PVOID
'// RVA_TO_ADDR(
'// PVOID Mapping,
'// ULONG Rva
'// )
'//
'// Routine Description:
'//
'// Map an RVA that is contained within a mapped file to it's associated
'// flat address.
'//
'// Arguments:
'//
'// Mapping - Base address of mapped file containing the RVA.
'//
'// Rva - An Rva to fixup.
'//
'// Return Values:
'//
'// A pointer to the desired data.
'//
'//--
'#define RVA_TO_ADDR(Mapping,Rva) ((PVOID)(((ULONG_PTR) (Mapping)) + (Rva)))
DECLARE FUNCTION MiniDumpWriteDump LIB "dbghelp.dll" ALIAS "MiniDumpWriteDump" ( BYVAL hProcess AS QUAD , BYVAL ProcessId AS QUAD , BYVAL hFile AS QUAD , BYVAL DumpType AS QUAD , BYREF ExceptionParam AS MINIDUMP_EXCEPTION_INFORMATION , BYREF UserStreamParam AS MINIDUMP_USER_STREAM_INFORMATION , BYREF CallbackParam AS MINIDUMP_CALLBACK_INFORMATION ) AS LONG
DECLARE FUNCTION MiniDumpReadDumpStream LIB "dbghelp.dll" ALIAS "MiniDumpReadDumpStream" ( BYVAL BaseOfDump AS QUAD
 , BYVAL StreamNumber AS DWORD
 , BYREF Dir AS MINIDUMP_DIRECTORY
 , BYREF StreamPointer AS ANY
 , BYREF StreamSize AS DWORD
 ) AS LONG
'#if defined(_MSC_VER)
'#if _MSC_VER >= 800
'#if _MSC_VER >= 1200
'#pragma warning(pop)
'#else
'#pragma warning(default:4200) /* Zero length array */
'#pragma warning(default:4201) /* Nameless struct/union */
'#endif
'#endif
'#endif
'#include <poppack.h>
'#ifdef __cplusplus
'}
'#endif
#ENDIF ' #IF NOT %DEF(%DBGHELP_INC)
#ENDIF ' #IF NOT %DEF(%IMAGEHLP_INC)