JwaImageHlp.pas
上传用户:davidchvip
上传日期:2009-07-28
资源大小:1749k
文件大小:143k
源码类别:

Windows编程

开发平台:

Delphi

  1. {******************************************************************************}
  2. {                                                                       }
  3. { Image Help API interface Unit for Object Pascal                              }
  4. {                                                                       }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft          }
  6. { Corporation. All Rights Reserved.                                            }
  7. {                 }
  8. { The original file is: imagehlp.h, released August 2001. The original Pascal  }
  9. { code is: ImageHelp.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm@chello.nl).                        }
  11. {                                                                              }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001            }
  13. { Marcel van Brakel. All Rights Reserved.                                      }
  14. {                 }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI)        }
  16. {                }
  17. { You may retrieve the latest version of this file at the Project JEDI home    }
  18. { page, located at http://delphi-jedi.org or my personal homepage located at   }
  19. { http://members.chello.nl/m.vanbrakel2                                        }
  20. {                }
  21. { The contents of this file are used with permission, subject to the Mozilla   }
  22. { Public License Version 1.1 (the "License"); you may not use this file except }
  23. { in compliance with the License. You may obtain a copy of the License at      }
  24. { http://www.mozilla.org/MPL/MPL-1.1.html                                      }
  25. {                                                                              }
  26. { Software distributed under the License is distributed on an "AS IS" basis,   }
  27. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  28. { the specific language governing rights and limitations under the License.    }
  29. {                                                                              }
  30. { Alternatively, the contents of this file may be used under the terms of the  }
  31. { GNU Lesser General Public License (the  "LGPL License"), in which case the   }
  32. { provisions of the LGPL License are applicable instead of those above.        }
  33. { If you wish to allow use of your version of this file only under the terms   }
  34. { of the LGPL License and not to allow others to use your version of this file }
  35. { under the MPL, indicate your decision by deleting  the provisions above and  }
  36. { replace  them with the notice and other provisions required by the LGPL      }
  37. { License.  If you do not delete the provisions above, a recipient may use     }
  38. { your version of this file under either the MPL or the LGPL License.          }
  39. {                 }
  40. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  41. {                 }
  42. {******************************************************************************}
  43. unit JwaImageHlp;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include "ImageHlp.h"'}
  47. {$HPPEMIT ''}
  48. {$I WINDEFINES.INC}
  49. interface
  50. uses
  51.   Windows, JwaWinBase, JwaWinNT, JwaWinType;
  52. const
  53.   IMAGE_SEPARATION = (64*1024);
  54.   {$EXTERNALSYM IMAGE_SEPARATION}
  55. type
  56.   PLOADED_IMAGE = ^LOADED_IMAGE;
  57.   {$EXTERNALSYM PLOADED_IMAGE}
  58.   _LOADED_IMAGE = record
  59.     ModuleName: PSTR;
  60.     hFile: HANDLE;
  61.     MappedAddress: PUCHAR;
  62.     FileHeader: PIMAGE_NT_HEADERS32;
  63.     LastRvaSection: PIMAGE_SECTION_HEADER;
  64.     NumberOfSections: ULONG;
  65.     Sections: PIMAGE_SECTION_HEADER;
  66.     Characteristics: ULONG;
  67.     fSystemImage: ByteBool;
  68.     fDOSImage: ByteBool;
  69.     Links: LIST_ENTRY;
  70.     SizeOfImage: ULONG;
  71.   end;
  72.   {$EXTERNALSYM _LOADED_IMAGE}
  73.   LOADED_IMAGE = _LOADED_IMAGE;
  74.   {$EXTERNALSYM LOADED_IMAGE}
  75.   TLoadedImage = LOADED_IMAGE;
  76.   PLoadedImage = PLOADED_IMAGE;
  77. const
  78.   MAX_SYM_NAME = 2000;
  79.   {$EXTERNALSYM MAX_SYM_NAME}
  80. function BindImage(ImageName, DllPath, SymbolPath: PSTR): BOOL; stdcall;
  81. {$EXTERNALSYM BindImage}
  82. type
  83.   _IMAGEHLP_STATUS_REASON = (
  84.     BindOutOfMemory,
  85.     BindRvaToVaFailed,
  86.     BindNoRoomInImage,
  87.     BindImportModuleFailed,
  88.     BindImportProcedureFailed,
  89.     BindImportModule,
  90.     BindImportProcedure,
  91.     BindForwarder,
  92.     BindForwarderNOT,
  93.     BindImageModified,
  94.     BindExpandFileHeaders,
  95.     BindImageComplete,
  96.     BindMismatchedSymbols,
  97.     BindSymbolsNotUpdated,
  98.     BindImportProcedure32,
  99.     BindImportProcedure64,
  100.     BindForwarder32,
  101.     BindForwarder64,
  102.     BindForwarderNOT32,
  103.     BindForwarderNOT64);
  104.   {$EXTERNALSYM _IMAGEHLP_STATUS_REASON}
  105.   IMAGEHLP_STATUS_REASON = _IMAGEHLP_STATUS_REASON;
  106.   {$EXTERNALSYM IMAGEHLP_STATUS_REASON}
  107.   TImageHlpStatusReason = IMAGEHLP_STATUS_REASON;
  108.   PIMAGEHLP_STATUS_ROUTINE = function (Reason: IMAGEHLP_STATUS_REASON;
  109.     ImageName, DllName: PSTR; Va, Parameter: ULONG_PTR): BOOL; stdcall;
  110.   {$EXTERNALSYM PIMAGEHLP_STATUS_ROUTINE}
  111.   PImageHlpStatusRoutine = PIMAGEHLP_STATUS_ROUTINE;
  112.   PIMAGEHLP_STATUS_ROUTINE32 = function (Reason: IMAGEHLP_STATUS_REASON; ImageName, DllName: PSTR;
  113.     Va: ULONG; Parameter: ULONG_PTR): BOOL; stdcall;
  114.   {$EXTERNALSYM PIMAGEHLP_STATUS_ROUTINE32}
  115.   PImageHlpStatusRoutine23 = PIMAGEHLP_STATUS_ROUTINE32;
  116.   PIMAGEHLP_STATUS_ROUTINE64 = function (Reason: IMAGEHLP_STATUS_REASON; ImageName, DllName: PSTR;
  117.     Va: ULONG64; Parameter: ULONG_PTR): BOOL; stdcall;
  118.   {$EXTERNALSYM PIMAGEHLP_STATUS_ROUTINE64}
  119.   PImageHlpStatusRoutine64 = PIMAGEHLP_STATUS_ROUTINE64;
  120. function BindImageEx(Flags: DWORD; ImageName, DllPath, SymbolPath: PSTR;
  121.   StatusRoutine: PIMAGEHLP_STATUS_ROUTINE): BOOL; stdcall;
  122. {$EXTERNALSYM BindImageEx}
  123. const
  124.   BIND_NO_BOUND_IMPORTS  = $00000001;
  125.   {$EXTERNALSYM BIND_NO_BOUND_IMPORTS}
  126.   BIND_NO_UPDATE         = $00000002;
  127.   {$EXTERNALSYM BIND_NO_UPDATE}
  128.   BIND_ALL_IMAGES        = $00000004;
  129.   {$EXTERNALSYM BIND_ALL_IMAGES}
  130.   BIND_CACHE_IMPORT_DLLS = $00000008; // Cache dll's across calls to BindImageEx (same as NT 3.1->NT 4.0)
  131.   {$EXTERNALSYM BIND_CACHE_IMPORT_DLLS}
  132.   BIND_REPORT_64BIT_VA   = $00000010;
  133.   {$EXTERNALSYM BIND_REPORT_64BIT_VA}
  134. function ReBaseImage(CurrentImageName: PSTR; SymbolPath: PSTR; fReBase: BOOL;
  135.   fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG;
  136.   var OldImageSize: ULONG; var OldImageBase: ULONG_PTR; var NewImageSize: ULONG;
  137.   var NewImageBase: ULONG_PTR; TimeStamp: ULONG): BOOL; stdcall;
  138. {$EXTERNALSYM ReBaseImage}
  139. function ReBaseImage64(CurrentImageName: PSTR; SymbolPath: PSTR; fReBase: BOOL;
  140.   fRebaseSysfileOk: BOOL; fGoingDown: BOOL; CheckImageSize: ULONG;
  141.   var OldImageSize: ULONG; var OldImageBase: ULONG64; var NewImageSize: ULONG;
  142.   var NewImageBase: ULONG64; TimeStamp: ULONG): BOOL; stdcall;
  143. {$EXTERNALSYM ReBaseImage64}
  144. //
  145. // Define checksum return codes.
  146. //
  147. const
  148.   CHECKSUM_SUCCESS         = 0;
  149.   {$EXTERNALSYM CHECKSUM_SUCCESS}
  150.   CHECKSUM_OPEN_FAILURE    = 1;
  151.   {$EXTERNALSYM CHECKSUM_OPEN_FAILURE}
  152.   CHECKSUM_MAP_FAILURE     = 2;
  153.   {$EXTERNALSYM CHECKSUM_MAP_FAILURE}
  154.   CHECKSUM_MAPVIEW_FAILURE = 3;
  155.   {$EXTERNALSYM CHECKSUM_MAPVIEW_FAILURE}
  156.   CHECKSUM_UNICODE_FAILURE = 4;
  157.   {$EXTERNALSYM CHECKSUM_UNICODE_FAILURE}
  158. // Define Splitsym flags.
  159.   SPLITSYM_REMOVE_PRIVATE = $00000001; // Remove CV types/symbols and Fixup debug
  160.   {$EXTERNALSYM SPLITSYM_REMOVE_PRIVATE}
  161.                                                     //  Used for creating .dbg files that ship
  162.                                                     //  as part of the product.
  163.   SPLITSYM_EXTRACT_ALL = $00000002; // Extract all debug info from image.
  164.   {$EXTERNALSYM SPLITSYM_EXTRACT_ALL}
  165.                                                     //  Normally, FPO is left in the image
  166.                                                     //  to allow stack traces through the code.
  167.                                                     //  Using this switch is similar to linking
  168.                                                     //  with -debug:none except the .dbg file
  169.                                                     //  exists...
  170.   SPLITSYM_SYMBOLPATH_IS_SRC = $00000004; // The SymbolFilePath contains an alternate
  171.   {$EXTERNALSYM SPLITSYM_SYMBOLPATH_IS_SRC}
  172.                                                     //  path to locate the pdb.
  173. //
  174. // Define checksum function prototypes.
  175. //
  176. function CheckSumMappedFile(BaseAddress: PVOID; FileLength: DWORD;
  177.   var HeaderSum, CheckSum: DWORD): PIMAGE_NT_HEADERS; stdcall;
  178. {$EXTERNALSYM CheckSumMappedFile}
  179. function MapFileAndCheckSumA(Filename: PSTR; var HeaderSum, CheckSum: DWORD): DWORD; stdcall;
  180. {$EXTERNALSYM MapFileAndCheckSumA}
  181. function MapFileAndCheckSumW(Filename: PWSTR; var HeaderSum, CheckSum: DWORD): DWORD; stdcall;
  182. {$EXTERNALSYM MapFileAndCheckSumW}
  183. {$IFDEF UNICODE}
  184. function MapFileAndCheckSum(Filename: PWSTR; var HeaderSum, CheckSum: DWORD): DWORD; stdcall;
  185. {$EXTERNALSYM MapFileAndCheckSum}
  186. {$ELSE}
  187. function MapFileAndCheckSum(Filename: PSTR; var HeaderSum, CheckSum: DWORD): DWORD; stdcall;
  188. {$EXTERNALSYM MapFileAndCheckSum}
  189. {$ENDIF}
  190. function GetImageConfigInformation(const LoadedImage: LOADED_IMAGE;
  191.   var ImageConfigInformation: IMAGE_LOAD_CONFIG_DIRECTORY): BOOL; stdcall;
  192. {$EXTERNALSYM GetImageConfigInformation}
  193. function GetImageUnusedHeaderBytes(const LoadedImage: LOADED_IMAGE;
  194.   var SizeUnusedHeaderBytes: DWORD): DWORD; stdcall;
  195. {$EXTERNALSYM GetImageUnusedHeaderBytes}
  196. function SetImageConfigInformation(const LoadedImage: LOADED_IMAGE;
  197.   const ImageConfigInformation: IMAGE_LOAD_CONFIG_DIRECTORY): BOOL; stdcall;
  198. {$EXTERNALSYM SetImageConfigInformation}
  199. // Image Integrity API's
  200. const
  201.   CERT_PE_IMAGE_DIGEST_DEBUG_INFO      = $01;
  202.   {$EXTERNALSYM CERT_PE_IMAGE_DIGEST_DEBUG_INFO}
  203.   CERT_PE_IMAGE_DIGEST_RESOURCES       = $02;
  204.   {$EXTERNALSYM CERT_PE_IMAGE_DIGEST_RESOURCES}
  205.   CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO = $04;
  206.   {$EXTERNALSYM CERT_PE_IMAGE_DIGEST_ALL_IMPORT_INFO}
  207.   CERT_PE_IMAGE_DIGEST_NON_PE_INFO     = $08; // include data outside the PE image
  208.   {$EXTERNALSYM CERT_PE_IMAGE_DIGEST_NON_PE_INFO}
  209.   CERT_SECTION_TYPE_ANY = $FF; // Any Certificate type
  210.   {$EXTERNALSYM CERT_SECTION_TYPE_ANY}
  211. type
  212.   DIGEST_HANDLE = PVOID;
  213.   {$EXTERNALSYM DIGEST_HANDLE}
  214.   TDigestHandle = DIGEST_HANDLE;
  215.   DIGEST_FUNCTION = function (refdata: DIGEST_HANDLE; pData: PBYTE; dwLength: DWORD): BOOL; stdcall;
  216.   {$EXTERNALSYM DIGEST_FUNCTION}
  217.   TDigestFunction = DIGEST_FUNCTION;
  218. function ImageGetDigestStream(FileHandle: HANDLE; DigestLevel: DWORD;
  219.   DigestFunction: DIGEST_FUNCTION; DigestHandle: DIGEST_HANDLE): BOOL; stdcall;
  220. {$EXTERNALSYM ImageGetDigestStream}
  221. function ImageAddCertificate(FileHandle: HANDLE; Certificate: PWinCertificate;
  222.   var Index: DWORD): BOOL; stdcall;
  223. {$EXTERNALSYM ImageAddCertificate}
  224. function ImageRemoveCertificate(FileHandle: HANDLE; Index: DWORD): BOOL; stdcall;
  225. {$EXTERNALSYM ImageRemoveCertificate}
  226. function ImageEnumerateCertificates(FileHandle: HANDLE; TypeFilter: WORD;
  227.   var CertificateCount: DWORD; Indices: PDWORD; IndexCount: DWORD): BOOL; stdcall;
  228. {$EXTERNALSYM ImageEnumerateCertificates}
  229. function ImageGetCertificateData(FileHandle: HANDLE; CertificateIndex: DWORD;
  230.   Certificate: PWinCertificate; var RequiredLength: DWORD): BOOL; stdcall;
  231. {$EXTERNALSYM ImageGetCertificateData}
  232. function ImageGetCertificateHeader(FileHandle: HANDLE; CertificateIndex: DWORD;
  233.   Certificateheader: PWinCertificate): BOOL; stdcall;
  234. {$EXTERNALSYM ImageGetCertificateHeader}
  235. function ImageLoad(DllName: PSTR; DllPath: PSTR): PLOADED_IMAGE; stdcall;
  236. {$EXTERNALSYM ImageLoad}
  237. function ImageUnload(const LoadedImage: LOADED_IMAGE): BOOL; stdcall;
  238. {$EXTERNALSYM ImageUnload}
  239. function MapAndLoad(ImageName, DllPath: PSTR; var LoadedImage: LOADED_IMAGE;
  240.   DotDll: BOOL; ReadOnly: BOOL): BOOL; stdcall;
  241. {$EXTERNALSYM MapAndLoad}
  242. function UnMapAndLoad(const LoadedImage: LOADED_IMAGE): BOOL; stdcall;
  243. {$EXTERNALSYM UnMapAndLoad}
  244. function TouchFileTimes(FileHandle: HANDLE; pSystemTime: PSYSTEMTIME): BOOL; stdcall;
  245. {$EXTERNALSYM TouchFileTimes}
  246. function SplitSymbols(ImageName, SymbolsPath, SymbolFilePath: PSTR; Flags: DWORD): BOOL; stdcall;
  247. {$EXTERNALSYM SplitSymbols}
  248. function UpdateDebugInfoFile(ImageFileName, SymbolPath, DebugFilePath: PSTR;
  249.   const NtHeaders: IMAGE_NT_HEADERS32): BOOL; stdcall;
  250. {$EXTERNALSYM UpdateDebugInfoFile}
  251. function UpdateDebugInfoFileEx(ImageFileName, SymbolPath, DebugFilePath: PSTR;
  252.   const NtHeaders: IMAGE_NT_HEADERS32; OldChecksum: DWORD): BOOL; stdcall;
  253. {$EXTERNALSYM UpdateDebugInfoFileEx}
  254. function FindDebugInfoFile(FileName, SymbolPath, DebugFilePath: PSTR): HANDLE; stdcall;
  255. {$EXTERNALSYM FindDebugInfoFile}
  256. type
  257.   PFIND_DEBUG_FILE_CALLBACK = function (FileHandle: HANDLE; FileName: PSTR;
  258.     CallerData: PVOID): BOOL; stdcall;
  259.   {$EXTERNALSYM PFIND_DEBUG_FILE_CALLBACK}
  260.   PFindDebugFileCallback = PFIND_DEBUG_FILE_CALLBACK;
  261. function FindDebugInfoFileEx(FileName, SymbolPath, DebugFilePath: PSTR;
  262.   Callback: PFIND_DEBUG_FILE_CALLBACK; CallerData: PVOID): HANDLE; stdcall;
  263. {$EXTERNALSYM FindDebugInfoFileEx}
  264. type
  265.   PFINDFILEINPATHCALLBACK = function (filename: PSTR; context: PVOID): BOOL; stdcall;
  266.   {$EXTERNALSYM PFINDFILEINPATHCALLBACK}
  267. function SymFindFileInPath(hprocess: HANDLE; SearchPath, FileName: LPSTR; id: PVOID; two, three, flags: DWORD;
  268.   FoundFile: LPSTR; callback: PFINDFILEINPATHCALLBACK; context: PVOID): BOOL; stdcall;
  269. {$EXTERNALSYM SymFindFileInPath}
  270. function FindExecutableImage(FileName, SymbolPath, ImageFilePath: PSTR): HANDLE; stdcall;
  271. {$EXTERNALSYM FindExecutableImage}
  272. type
  273.   PFIND_EXE_FILE_CALLBACK = function (FileHandle: HANDLE; FileName: PSTR;
  274.     CallerData: PVOID): BOOL; stdcall;
  275.   {$EXTERNALSYM PFIND_EXE_FILE_CALLBACK}
  276.   PFindExeFileCallback = PFIND_EXE_FILE_CALLBACK;
  277. function FindExecutableImageEx(FileName, SymbolPath, ImageFilePath: PSTR;
  278.   Callback: PFIND_EXE_FILE_CALLBACK; CallerData: PVOID): HANDLE; stdcall;
  279. {$EXTERNALSYM FindExecutableImageEx}
  280. function ImageNtHeader(Base: PVOID): PIMAGE_NT_HEADERS; stdcall;
  281. {$EXTERNALSYM ImageNtHeader}
  282. function ImageDirectoryEntryToDataEx(Base: PVOID; MappedAsImage: ByteBool;
  283.   DirectoryEntry: USHORT; var Size: ULONG; var FoundHeader: PIMAGE_SECTION_HEADER): PVOID; stdcall;
  284. {$EXTERNALSYM ImageDirectoryEntryToDataEx}
  285. function ImageDirectoryEntryToData(Base: PVOID; MappedAsImage: ByteBool;
  286.   DirectoryEntry: USHORT; var Size: ULONG): PVOID; stdcall;
  287. {$EXTERNALSYM ImageDirectoryEntryToData}
  288. function ImageRvaToSection(NtHeaders: PIMAGE_NT_HEADERS; Base: PVOID; Rva: ULONG): PIMAGE_SECTION_HEADER; stdcall;
  289. {$EXTERNALSYM ImageRvaToSection}
  290. function ImageRvaToVa(NtHeaders: PIMAGE_NT_HEADERS; Base: PVOID; Rva: ULONG;
  291.   var LastRvaSection: PIMAGE_SECTION_HEADER): PVOID; stdcall;
  292. {$EXTERNALSYM ImageRvaToVa}
  293. // Symbol server exports
  294. type
  295.   PSYMBOLSERVERPROC = function (a1, a2: LPCSTR; a3: PVOID; a4, a5: DWORD; a6: LPSTR): BOOL; stdcall;
  296.   {$EXTERNALSYM PSYMBOLSERVERPROC}
  297.   PSYMBOLSERVEROPENPROC = function: BOOL; stdcall;
  298.   {$EXTERNALSYM PSYMBOLSERVEROPENPROC}
  299.   PSYMBOLSERVERCLOSEPROC = function: BOOL; stdcall;
  300.   {$EXTERNALSYM PSYMBOLSERVERCLOSEPROC}
  301.   PSYMBOLSERVERSETOPTIONSPROC = function (a1: UINT_PTR; a2: ULONG64): BOOL; stdcall;
  302.   {$EXTERNALSYM PSYMBOLSERVERSETOPTIONSPROC}
  303.   PSYMBOLSERVERCALLBACKPROC = function (action: UINT_PTR; data: ULONG64; context: ULONG64): BOOL; stdcall;
  304.   {$EXTERNALSYM PSYMBOLSERVERCALLBACKPROC}
  305.   PSYMBOLSERVERGETOPTIONSPROC = function: UINT_PTR; stdcall;
  306.   {$EXTERNALSYM PSYMBOLSERVERGETOPTIONSPROC}
  307.   PSYMBOLSERVERPINGPROC = function (a1: LPCSTR): BOOL; stdcall;
  308.   {$EXTERNALSYM PSYMBOLSERVERPINGPROC}
  309. const
  310.   SSRVOPT_CALLBACK   = $01;
  311.   {$EXTERNALSYM SSRVOPT_CALLBACK}
  312.   SSRVOPT_DWORD      = $02;
  313.   {$EXTERNALSYM SSRVOPT_DWORD}
  314.   SSRVOPT_DWORDPTR   = $04;
  315.   {$EXTERNALSYM SSRVOPT_DWORDPTR}
  316.   SSRVOPT_GUIDPTR    = $08;
  317.   {$EXTERNALSYM SSRVOPT_GUIDPTR}
  318.   SSRVOPT_OLDGUIDPTR = $10;
  319.   {$EXTERNALSYM SSRVOPT_OLDGUIDPTR}
  320.   SSRVOPT_UNATTENDED = $20;
  321.   {$EXTERNALSYM SSRVOPT_UNATTENDED}
  322.   SSRVOPT_RESET      = ULONG_PTR(-1);
  323.   {$EXTERNALSYM SSRVOPT_RESET}
  324.   SSRVACTION_TRACE   = 1;
  325.   {$EXTERNALSYM SSRVACTION_TRACE}
  326. // This api won't be ported to Win64 - Fix your code.
  327. type
  328.   PIMAGE_DEBUG_INFORMATION = ^IMAGE_DEBUG_INFORMATION;
  329.   {$EXTERNALSYM PIMAGE_DEBUG_INFORMATION}
  330.   _IMAGE_DEBUG_INFORMATION = record
  331.     List: LIST_ENTRY;
  332.     ReservedSize: DWORD;
  333.     ReservedMappedBase: PVOID;
  334.     ReservedMachine: USHORT;
  335.     ReservedCharacteristics: USHORT;
  336.     ReservedCheckSum: DWORD;
  337.     ImageBase: DWORD;
  338.     SizeOfImage: DWORD;
  339.     ReservedNumberOfSections: DWORD;
  340.     ReservedSections: PIMAGE_SECTION_HEADER;
  341.     ReservedExportedNamesSize: DWORD;
  342.     ReservedExportedNames: PSTR;
  343.     ReservedNumberOfFunctionTableEntries: DWORD;
  344.     ReservedFunctionTableEntries: PIMAGE_FUNCTION_ENTRY;
  345.     ReservedLowestFunctionStartingAddress: DWORD;
  346.     ReservedHighestFunctionEndingAddress: DWORD;
  347.     ReservedNumberOfFpoTableEntries: DWORD;
  348.     ReservedFpoTableEntries: PFPO_DATA;
  349.     SizeOfCoffSymbols: DWORD;
  350.     CoffSymbols: PIMAGE_COFF_SYMBOLS_HEADER;
  351.     ReservedSizeOfCodeViewSymbols: DWORD;
  352.     ReservedCodeViewSymbols: PVOID;
  353.     ImageFilePath: PSTR;
  354.     ImageFileName: PSTR;
  355.     ReservedDebugFilePath: PSTR;
  356.     ReservedTimeDateStamp: DWORD;
  357.     ReservedRomImage: BOOL;
  358.     ReservedDebugDirectory: PIMAGE_DEBUG_DIRECTORY;
  359.     ReservedNumberOfDebugDirectories: DWORD;
  360.     ReservedOriginalFunctionTableBaseAddress: DWORD;
  361.     Reserved: array [0..1] of DWORD;
  362.   end;
  363.   {$EXTERNALSYM _IMAGE_DEBUG_INFORMATION}
  364.   IMAGE_DEBUG_INFORMATION = _IMAGE_DEBUG_INFORMATION;
  365.   {$EXTERNALSYM IMAGE_DEBUG_INFORMATION}
  366.   TImageDebugInformation = IMAGE_DEBUG_INFORMATION;
  367.   PImageDebugInformation = PIMAGE_DEBUG_INFORMATION;
  368. function MapDebugInformation(FileHandle: HANDLE; FileName, SymbolPath: PSTR;
  369.   ImageBase: DWORD): PIMAGE_DEBUG_INFORMATION; stdcall;
  370. {$EXTERNALSYM MapDebugInformation}
  371. function UnmapDebugInformation(DebugInfo: PIMAGE_DEBUG_INFORMATION): BOOL; stdcall;
  372. {$EXTERNALSYM UnmapDebugInformation}
  373. function SearchTreeForFile(RootPath, InputPathName, OutputPathBuffer: PSTR): BOOL; stdcall;
  374. {$EXTERNALSYM SearchTreeForFile}
  375. type
  376.   PENUMDIRTREE_CALLBACK = function (FilePath: LPCSTR; CallerData: PVOID): BOOL; stdcall;
  377.   {$EXTERNALSYM PENUMDIRTREE_CALLBACK}
  378.   PEnumDirTreeCallback = PENUMDIRTREE_CALLBACK;
  379. function EnumDirTree(hProcess: HANDLE; RootPath, InputPathName, OutputPathBuffer: PSTR;
  380.   Callback: PENUMDIRTREE_CALLBACK; CallbackData: PVOID): BOOL; stdcall;
  381. {$EXTERNALSYM EnumDirTree}
  382. function MakeSureDirectoryPathExists(DirPath: PCSTR): BOOL; stdcall;
  383. {$EXTERNALSYM MakeSureDirectoryPathExists}
  384. //
  385. // UnDecorateSymbolName Flags
  386. //
  387. const
  388.   UNDNAME_COMPLETE               = ($0000); // Enable full undecoration
  389.   {$EXTERNALSYM UNDNAME_COMPLETE}
  390.   UNDNAME_NO_LEADING_UNDERSCORES = ($0001); // Remove leading underscores from MS extended keywords
  391.   {$EXTERNALSYM UNDNAME_NO_LEADING_UNDERSCORES}
  392.   UNDNAME_NO_MS_KEYWORDS         = ($0002); // Disable expansion of MS extended keywords
  393.   {$EXTERNALSYM UNDNAME_NO_MS_KEYWORDS}
  394.   UNDNAME_NO_FUNCTION_RETURNS    = ($0004); // Disable expansion of return type for primary declaration
  395.   {$EXTERNALSYM UNDNAME_NO_FUNCTION_RETURNS}
  396.   UNDNAME_NO_ALLOCATION_MODEL    = ($0008); // Disable expansion of the declaration model
  397.   {$EXTERNALSYM UNDNAME_NO_ALLOCATION_MODEL}
  398.   UNDNAME_NO_ALLOCATION_LANGUAGE = ($0010); // Disable expansion of the declaration language specifier
  399.   {$EXTERNALSYM UNDNAME_NO_ALLOCATION_LANGUAGE}
  400.   UNDNAME_NO_MS_THISTYPE         = ($0020); // NYI Disable expansion of MS keywords on the 'this' type for primary declaration
  401.   {$EXTERNALSYM UNDNAME_NO_MS_THISTYPE}
  402.   UNDNAME_NO_CV_THISTYPE         = ($0040); // NYI Disable expansion of CV modifiers on the 'this' type for primary declaration
  403.   {$EXTERNALSYM UNDNAME_NO_CV_THISTYPE}
  404.   UNDNAME_NO_THISTYPE            = ($0060); // Disable all modifiers on the 'this' type
  405.   {$EXTERNALSYM UNDNAME_NO_THISTYPE}
  406.   UNDNAME_NO_ACCESS_SPECIFIERS   = ($0080); // Disable expansion of access specifiers for members
  407.   {$EXTERNALSYM UNDNAME_NO_ACCESS_SPECIFIERS}
  408.   UNDNAME_NO_THROW_SIGNATURES    = ($0100); // Disable expansion of 'throw-signatures' for functions and pointers to functions
  409.   {$EXTERNALSYM UNDNAME_NO_THROW_SIGNATURES}
  410.   UNDNAME_NO_MEMBER_TYPE         = ($0200); // Disable expansion of 'static' or 'virtual'ness of members
  411.   {$EXTERNALSYM UNDNAME_NO_MEMBER_TYPE}
  412.   UNDNAME_NO_RETURN_UDT_MODEL    = ($0400); // Disable expansion of MS model for UDT returns
  413.   {$EXTERNALSYM UNDNAME_NO_RETURN_UDT_MODEL}
  414.   UNDNAME_32_BIT_DECODE          = ($0800); // Undecorate 32-bit decorated names
  415.   {$EXTERNALSYM UNDNAME_32_BIT_DECODE}
  416.   UNDNAME_NAME_ONLY              = ($1000); // Crack only the name for primary declaration;
  417.   {$EXTERNALSYM UNDNAME_NAME_ONLY}
  418.                                                                                                    //  return just [scope::]name.  Does expand template params
  419.   UNDNAME_NO_ARGUMENTS    = ($2000); // Don't undecorate arguments to function
  420.   {$EXTERNALSYM UNDNAME_NO_ARGUMENTS}
  421.   UNDNAME_NO_SPECIAL_SYMS = ($4000); // Don't undecorate special names (v-table, vcall, vector xxx, metatype, etc)
  422.   {$EXTERNALSYM UNDNAME_NO_SPECIAL_SYMS}
  423. function UnDecorateSymbolName(DecoratedName: PCSTR; UnDecoratedName: PSTR;
  424.   UndecoratedLength: DWORD; Flags: DWORD): DWORD; stdcall;
  425. {$EXTERNALSYM UnDecorateSymbolName}
  426. //
  427. // these values are used for synthesized file types
  428. // that can be passed in as image headers instead of
  429. // the standard ones from ntimage.h
  430. //
  431. const
  432.   DBHHEADER_DEBUGDIRS    = $1;
  433.   {$EXTERNALSYM DBHHEADER_DEBUGDIRS}
  434. type
  435.   _MODLOAD_DATA = record
  436.     ssize: DWORD;                  // size of this struct
  437.     ssig: DWORD;                   // signature identifying the passed data
  438.     data: PVOID;                   // pointer to passed data
  439.     size: DWORD;                   // size of passed data
  440.     flags: DWORD;                  // options
  441.   end;
  442.   {$EXTERNALSYM _MODLOAD_DATA}
  443.   MODLOAD_DATA = _MODLOAD_DATA;
  444.   {$EXTERNALSYM MODLOAD_DATA}
  445.   PMODLOAD_DATA = ^MODLOAD_DATA;
  446.   {$EXTERNALSYM PMODLOAD_DATA}
  447.   TModLoadData = MODLOAD_DATA;
  448.   PModLoadData = PMODLOAD_DATA;
  449. //
  450. // StackWalking API
  451. //
  452. type
  453.   ADDRESS_MODE = (
  454.     AddrMode1616,
  455.     AddrMode1632,
  456.     AddrModeReal,
  457.     AddrModeFlat);
  458.   {$EXTERNALSYM ADDRESS_MODE}
  459.   TAddressMode = ADDRESS_MODE;
  460.   LPADDRESS64 = ^ADDRESS64;
  461.   {$EXTERNALSYM PADDRESS64}
  462.   _tagADDRESS64 = record
  463.     Offset: DWORD64;
  464.     Segment: WORD;
  465.     Mode: ADDRESS_MODE;
  466.   end;
  467.   {$EXTERNALSYM _tagADDRESS64}
  468.   ADDRESS64 = _tagADDRESS64;
  469.   {$EXTERNALSYM ADDRESS64}
  470.   TAddress64 = ADDRESS64;
  471.   PAddress64 = LPADDRESS64;
  472.   LPADDRESS = ^ADDRESS;
  473.   {$EXTERNALSYM PADDRESS}
  474.   _tagADDRESS = record
  475.     Offset: DWORD;
  476.     Segment: WORD;
  477.     Mode: ADDRESS_MODE;
  478.   end;
  479.   {$EXTERNALSYM _tagADDRESS}
  480.   ADDRESS = _tagADDRESS;
  481.   {$EXTERNALSYM ADDRESS}
  482.   TAddress = ADDRESS;
  483.   PAddress = LPADDRESS;
  484. procedure Address32To64(a32: LPADDRESS; a64: LPADDRESS64);
  485. {$EXTERNALSYM Address32To64}
  486. procedure Address64To32(a64: LPADDRESS64; a32: LPADDRESS);
  487. {$EXTERNALSYM Address64To32}
  488. //
  489. // This structure is included in the STACKFRAME structure,
  490. // and is used to trace through usermode callbacks in a thread's
  491. // kernel stack.  The values must be copied by the kernel debugger
  492. // from the DBGKD_GET_VERSION and WAIT_STATE_CHANGE packets.
  493. //
  494. //
  495. // New KDHELP structure for 64 bit system support.
  496. // This structure is preferred in new code.
  497. //
  498. type
  499.   PKDHELP64 = ^KDHELP64;
  500.   {$EXTERNALSYM PKDHELP64}
  501.   _KDHELP64 = record
  502.     //
  503.     // address of kernel thread object, as provided in the
  504.     // WAIT_STATE_CHANGE packet.
  505.     //
  506.     Thread: DWORD64;
  507.     //
  508.     // offset in thread object to pointer to the current callback frame
  509.     // in kernel stack.
  510.     //
  511.     ThCallbackStack: DWORD;
  512.     //
  513.     // offset in thread object to pointer to the current callback backing
  514.     // store frame in kernel stack.
  515.     //
  516.     ThCallbackBStore: DWORD;
  517.     //
  518.     // offsets to values in frame:
  519.     //
  520.     // address of next callback frame
  521.     NextCallback: DWORD;
  522.     // address of saved frame pointer (if applicable)
  523.     FramePointer: DWORD;
  524.     //
  525.     // Address of the kernel function that calls out to user mode
  526.     //
  527.     KiCallUserMode: DWORD64;
  528.     //
  529.     // Address of the user mode dispatcher function
  530.     //
  531.     KeUserCallbackDispatcher: DWORD64;
  532.     //
  533.     // Lowest kernel mode address
  534.     //
  535.     SystemRangeStart: DWORD64;
  536.     Reserved: array [0..7] of DWORD64;
  537.   end;
  538.   {$EXTERNALSYM _KDHELP64}
  539.   KDHELP64 = _KDHELP64;
  540.   {$EXTERNALSYM KDHELP64}
  541.   TKdHelp64 = KDHELP64;
  542.   //PKdHelp64 = PKDHELP64;
  543.   PKDHELP = ^KDHELP;
  544.   {$EXTERNALSYM PKDHELP}
  545.   _KDHELP = record
  546.     //
  547.     // address of kernel thread object, as provided in the
  548.     // WAIT_STATE_CHANGE packet.
  549.     //
  550.     Thread: DWORD;
  551.     //
  552.     // offset in thread object to pointer to the current callback frame
  553.     // in kernel stack.
  554.     //
  555.     ThCallbackStack: DWORD;
  556.     //
  557.     // offsets to values in frame:
  558.     //
  559.     // address of next callback frame
  560.     NextCallback: DWORD;
  561.     // address of saved frame pointer (if applicable)
  562.     FramePointer: DWORD;
  563.     //
  564.     // Address of the kernel function that calls out to user mode
  565.     //
  566.     KiCallUserMode: DWORD;
  567.     //
  568.     // Address of the user mode dispatcher function
  569.     //
  570.     KeUserCallbackDispatcher: DWORD;
  571.     //
  572.     // Lowest kernel mode address
  573.     //
  574.     SystemRangeStart: DWORD;
  575.     //
  576.     // offset in thread object to pointer to the current callback backing
  577.     // store frame in kernel stack.
  578.     //
  579.     ThCallbackBStore: DWORD;
  580.     Reserved: array [0..7] of DWORD;
  581.   end;
  582.   {$EXTERNALSYM _KDHELP}
  583.   KDHELP = _KDHELP;
  584.   {$EXTERNALSYM KDHELP}
  585.   TKdHelp = KDHELP;
  586.   //PKdHelp = PKDHELP;
  587. procedure KdHelp32To64(p32: PKDHELP; p64: PKDHELP64);
  588. {$EXTERNALSYM KdHelp32To64}
  589. type
  590.   LPSTACKFRAME64 = ^STACKFRAME64;
  591.   {$EXTERNALSYM LPSTACKFRAME64}
  592.   _tagSTACKFRAME64 = record
  593.     AddrPC: ADDRESS64; // program counter
  594.     AddrReturn: ADDRESS64; // return address
  595.     AddrFrame: ADDRESS64; // frame pointer
  596.     AddrStack: ADDRESS64; // stack pointer
  597.     AddrBStore: ADDRESS64; // backing store pointer
  598.     FuncTableEntry: PVOID; // pointer to pdata/fpo or NULL
  599.     Params: array [0..3] of DWORD64; // possible arguments to the function
  600.     Far: BOOL; // WOW far call
  601.     Virtual: BOOL; // is this a virtual frame?
  602.     Reserved: array [0..2] of DWORD64;
  603.     KdHelp: KDHELP64;
  604.   end;
  605.   {$EXTERNALSYM _tagSTACKFRAME64}
  606.   STACKFRAME64 = _tagSTACKFRAME64;
  607.   {$EXTERNALSYM STACKFRAME64}
  608.   TStackFrame64 = STACKFRAME64;
  609.   PStackFrame64 = LPSTACKFRAME64;
  610.   LPSTACKFRAME = ^STACKFRAME;
  611.   {$EXTERNALSYM LPSTACKFRAME}
  612.   _tagSTACKFRAME = record
  613.     AddrPC: ADDRESS; // program counter
  614.     AddrReturn: ADDRESS; // return address
  615.     AddrFrame: ADDRESS; // frame pointer
  616.     AddrStack: ADDRESS; // stack pointer
  617.     FuncTableEntry: PVOID; // pointer to pdata/fpo or NULL
  618.     Params: array [0..3] of DWORD; // possible arguments to the function
  619.     Far: BOOL; // WOW far call
  620.     Virtual: BOOL; // is this a virtual frame?
  621.     Reserved: array [0..2] of DWORD;
  622.     KdHelp: KDHELP;
  623.     AddrBStore: ADDRESS; // backing store pointer
  624.   end;
  625.   {$EXTERNALSYM _tagSTACKFRAME}
  626.   STACKFRAME = _tagSTACKFRAME;
  627.   {$EXTERNALSYM STACKFRAME}
  628.   TStackFrame = STACKFRAME;
  629.   PStackFrame = LPSTACKFRAME;
  630.   PREAD_PROCESS_MEMORY_ROUTINE64 = function (hProcess: HANDLE; qwBaseAddress: DWORD64;
  631.     lpBuffer: PVOID; nSize: DWORD; var lpNumberOfBytesRead: DWORD): BOOL; stdcall;
  632.   {$EXTERNALSYM PREAD_PROCESS_MEMORY_ROUTINE64}
  633.   PReadProcessMemoryRoutine64 = PREAD_PROCESS_MEMORY_ROUTINE64;
  634.   PFUNCTION_TABLE_ACCESS_ROUTINE64 = function (hProcess: HANDLE;
  635.     AddrBase: DWORD64): PVOID; stdcall;
  636.   {$EXTERNALSYM PFUNCTION_TABLE_ACCESS_ROUTINE64}
  637.   PFunctionTableAccessRoutine64 = PFUNCTION_TABLE_ACCESS_ROUTINE64;
  638.   PGET_MODULE_BASE_ROUTINE64 = function (hProcess: HANDLE;
  639.     Address: DWORD64): DWORD64; stdcall;
  640.   {$EXTERNALSYM PGET_MODULE_BASE_ROUTINE64}
  641.   PGetModuleBaseRoutine64 = PGET_MODULE_BASE_ROUTINE64;
  642.   PTRANSLATE_ADDRESS_ROUTINE64 = function (hProcess: HANDLE; hThread: HANDLE;
  643.     const lpaddr: ADDRESS64): DWORD64; stdcall;
  644.   {$EXTERNALSYM PTRANSLATE_ADDRESS_ROUTINE64}
  645.   PTranslateAddressRoutine64 = PTRANSLATE_ADDRESS_ROUTINE64;
  646. function StackWalk64(MachineType: DWORD; hProcess: HANDLE; hThread: HANDLE;
  647.   var StackFrame: STACKFRAME64; ContextRecord: PVOID;
  648.   ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE64;
  649.   FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE64;
  650.   GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE64;
  651.   TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE64): BOOL; stdcall;
  652. {$EXTERNALSYM StackWalk64}
  653. type
  654.   PREAD_PROCESS_MEMORY_ROUTINE = function (hProcess: HANDLE;
  655.     lpBaseAddress: DWORD; lpBuffer: PVOID; nSize: DWORD;
  656.     var lpNumberOfBytesRead: DWORD): BOOL; stdcall;
  657.   {$EXTERNALSYM PREAD_PROCESS_MEMORY_ROUTINE}
  658.   PreadProcessMemoryRoutine = PREAD_PROCESS_MEMORY_ROUTINE;
  659.   PFUNCTION_TABLE_ACCESS_ROUTINE = function (hProcess: HANDLE; AddrBase: DWORD): PVOID; stdcall;
  660.   {$EXTERNALSYM PFUNCTION_TABLE_ACCESS_ROUTINE}
  661.   PFunctionTableAccessRoutine = PFUNCTION_TABLE_ACCESS_ROUTINE;
  662.   PGET_MODULE_BASE_ROUTINE = function (hProcess: HANDLE; Address: DWORD): DWORD; stdcall;
  663.   {$EXTERNALSYM PGET_MODULE_BASE_ROUTINE}
  664.   PGetModuleBaseRoutine = PGET_MODULE_BASE_ROUTINE;
  665.   PTRANSLATE_ADDRESS_ROUTINE = function (hProcess: HANDLE; hThread: HANDLE;
  666.     const lpaddr: ADDRESS): DWORD; stdcall;
  667.   {$EXTERNALSYM PTRANSLATE_ADDRESS_ROUTINE}
  668.   PTranslateAddressRoutine = PTRANSLATE_ADDRESS_ROUTINE;
  669. function StackWalk(MachineType: DWORD; hProcess: HANDLE; hThread: HANDLE;
  670.   var StackFrame: STACKFRAME; ContextRecord: PVOID;
  671.   ReadMemoryRoutine: PREAD_PROCESS_MEMORY_ROUTINE;
  672.   FunctionTableAccessRoutine: PFUNCTION_TABLE_ACCESS_ROUTINE;
  673.   GetModuleBaseRoutine: PGET_MODULE_BASE_ROUTINE;
  674.   TranslateAddress: PTRANSLATE_ADDRESS_ROUTINE): BOOL; stdcall;
  675. {$EXTERNALSYM StackWalk}
  676. const
  677.   API_VERSION_NUMBER = 9;
  678.   {$EXTERNALSYM API_VERSION_NUMBER}
  679. type
  680.   LPAPI_VERSION = ^API_VERSION;
  681.   {$EXTERNALSYM LPAPI_VERSION}
  682.   API_VERSION = record
  683.     MajorVersion: USHORT;
  684.     MinorVersion: USHORT;
  685.     Revision: USHORT;
  686.     Reserved: USHORT;
  687.   end;
  688.   {$EXTERNALSYM API_VERSION}
  689.   TApiVersion = API_VERSION;
  690.   PApiVersion = LPAPI_VERSION;
  691. function ImagehlpApiVersion: LPAPI_VERSION; stdcall;
  692. {$EXTERNALSYM ImagehlpApiVersion}
  693. function ImagehlpApiVersionEx(const AppVersion: API_VERSION): LPAPI_VERSION; stdcall;
  694. {$EXTERNALSYM ImagehlpApiVersionEx}
  695. function GetTimestampForLoadedLibrary(Module: HMODULE): DWORD; stdcall;
  696. {$EXTERNALSYM GetTimestampForLoadedLibrary}
  697. //
  698. // typedefs for function pointers
  699. //
  700. type
  701.   PSYM_ENUMMODULES_CALLBACK64 = function (ModuleName: PSTR; BaseOfDll: DWORD64;
  702.     UserContext: PVOID): BOOL; stdcall;
  703.   {$EXTERNALSYM PSYM_ENUMMODULES_CALLBACK64}
  704.   PSymEnummodulesCallback64 = PSYM_ENUMMODULES_CALLBACK64;
  705.   PSYM_ENUMSYMBOLS_CALLBACK64 = function (SymbolName: PSTR; SymbolAddress: DWORD64;
  706.     SymbolSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  707.   {$EXTERNALSYM PSYM_ENUMSYMBOLS_CALLBACK64}
  708.   PSymEnumsymbolsCallback64 = PSYM_ENUMSYMBOLS_CALLBACK64;
  709.   PSYM_ENUMSYMBOLS_CALLBACK64W = function (SymbolName: PWSTR;
  710.     SymbolAddress: DWORD64; SymbolSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  711.   {$EXTERNALSYM PSYM_ENUMSYMBOLS_CALLBACK64W}
  712.   PSymEnumsymbolsCallback64w = PSYM_ENUMSYMBOLS_CALLBACK64W;
  713.   PENUMLOADED_MODULES_CALLBACK64 = function (ModuleName: PSTR;
  714.     ModuleBase: DWORD64; ModuleSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  715.   {$EXTERNALSYM PENUMLOADED_MODULES_CALLBACK64}
  716.   PSnumloadedModulesCallback64 = PENUMLOADED_MODULES_CALLBACK64;
  717.   PSYMBOL_REGISTERED_CALLBACK64 = function (hProcess: HANDLE; ActionCode: ULONG;
  718.     CallbackData: ULONG64; UserContext: ULONG64): BOOL; stdcall;
  719.   {$EXTERNALSYM PSYMBOL_REGISTERED_CALLBACK64}
  720.   PSymbolRegisteredCallback64 = PSYMBOL_REGISTERED_CALLBACK64;
  721.   PSYMBOL_FUNCENTRY_CALLBACK = function (hProcess: HANDLE; AddrBase: DWORD;
  722.     UserContext: PVOID): PVOID; stdcall;
  723.   {$EXTERNALSYM PSYMBOL_FUNCENTRY_CALLBACK}
  724.   PSymbolFuncentryCallback = PSYMBOL_FUNCENTRY_CALLBACK;
  725.   PSYMBOL_FUNCENTRY_CALLBACK64 = function (hProcess: HANDLE; AddrBase: ULONG64;
  726.     UserContext: ULONG64): PVOID; stdcall;
  727.   {$EXTERNALSYM PSYMBOL_FUNCENTRY_CALLBACK64}
  728.   PSymbolFuncentryCallback64 = PSYMBOL_FUNCENTRY_CALLBACK64;
  729.   PSYM_ENUMMODULES_CALLBACK = function (ModuleName: PSTR; BaseOfDll: ULONG;
  730.     UserContext: PVOID): BOOL; stdcall;
  731.   {$EXTERNALSYM PSYM_ENUMMODULES_CALLBACK}
  732.   PSymEnummodulesCallback = PSYM_ENUMMODULES_CALLBACK;
  733.   PSYM_ENUMSYMBOLS_CALLBACK = function (SymbolName: PSTR; SymbolAddress: ULONG;
  734.     SymbolSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  735.   {$EXTERNALSYM PSYM_ENUMSYMBOLS_CALLBACK}
  736.   PSymEnumsymbolsCallback = PSYM_ENUMSYMBOLS_CALLBACK;
  737.   PSYM_ENUMSYMBOLS_CALLBACKW = function (SymbolName: PWSTR; SymbolAddress: ULONG;
  738.     SymbolSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  739.   {$EXTERNALSYM PSYM_ENUMSYMBOLS_CALLBACKW}
  740.   PSymEnumsymbolsCallbackw = PSYM_ENUMSYMBOLS_CALLBACKW;
  741.   PENUMLOADED_MODULES_CALLBACK = function (ModuleName: PSTR; ModuleBase: ULONG;
  742.     ModuleSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  743.   {$EXTERNALSYM PENUMLOADED_MODULES_CALLBACK}
  744.   PEnumloadedModulesCallback = PENUMLOADED_MODULES_CALLBACK;
  745.   PSYMBOL_REGISTERED_CALLBACK = function (hProcess: HANDLE; ActionCode: ULONG;
  746.     CallbackData: PVOID; UserContext: PVOID): BOOL; stdcall;
  747.   {$EXTERNALSYM PSYMBOL_REGISTERED_CALLBACK}
  748.   PSymbolRegisteredCallback = PSYMBOL_REGISTERED_CALLBACK;
  749. //
  750. // flags found in SYMBOL_INFO.Flags
  751. //
  752. const
  753.   SYMFLAG_VALUEPRESENT   = $00000001;
  754.   {$EXTERNALSYM SYMFLAG_VALUEPRESENT}
  755.   SYMFLAG_REGISTER       = $00000008;
  756.   {$EXTERNALSYM SYMFLAG_REGISTER}
  757.   SYMFLAG_REGREL         = $00000010;
  758.   {$EXTERNALSYM SYMFLAG_REGREL}
  759.   SYMFLAG_FRAMEREL       = $00000020;
  760.   {$EXTERNALSYM SYMFLAG_FRAMEREL}
  761.   SYMFLAG_PARAMETER      = $00000040;
  762.   {$EXTERNALSYM SYMFLAG_PARAMETER}
  763.   SYMFLAG_LOCAL          = $00000080;
  764.   {$EXTERNALSYM SYMFLAG_LOCAL}
  765.   SYMFLAG_CONSTANT       = $00000100;
  766.   {$EXTERNALSYM SYMFLAG_CONSTANT}
  767.   SYMFLAG_EXPORT         = $00000200;
  768.   {$EXTERNALSYM SYMFLAG_EXPORT}
  769.   SYMFLAG_FORWARDER      = $00000400;
  770.   {$EXTERNALSYM SYMFLAG_FORWARDER}
  771.   SYMFLAG_FUNCTION       = $00000800;
  772.   {$EXTERNALSYM SYMFLAG_FUNCTION}
  773.   SYMFLAG_VIRTUAL        = $00001000;
  774.   {$EXTERNALSYM SYMFLAG_VIRTUAL}
  775.   SYMFLAG_THUNK          = $00002000;
  776.   {$EXTERNALSYM SYMFLAG_THUNK}
  777.   SYMFLAG_TLSREL         = $00004000;
  778.   {$EXTERNALSYM SYMFLAG_TLSREL}
  779. //
  780. // symbol type enumeration
  781. //
  782. type
  783.   SYM_TYPE = (
  784.     SymNone,
  785.     SymCoff,
  786.     SymCv,
  787.     SymPdb,
  788.     SymExport,
  789.     SymDeferred,
  790.     SymSym,                   // .sym file
  791.     SymDia,
  792.     SymVirtual,
  793.     NumSymTypes);
  794.   {$EXTERNALSYM SYM_TYPE}
  795.   TSymType = SYM_TYPE;
  796. //
  797. // symbol data structure
  798. //
  799.   PIMAGEHLP_SYMBOL64 = ^IMAGEHLP_SYMBOL64;
  800.   {$EXTERNALSYM PIMAGEHLP_SYMBOL64}
  801.   _IMAGEHLP_SYMBOL64 = record
  802.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_SYMBOL64)
  803.     Address: DWORD64; // virtual address including dll base address
  804.     Size: DWORD; // estimated size of symbol, can be zero
  805.     Flags: DWORD; // info about the symbols, see the SYMF defines
  806.     MaxNameLength: DWORD; // maximum size of symbol name in 'Name'
  807.     Name: array [0..0] of CHAR; // symbol name (null terminated string)
  808.   end;
  809.   {$EXTERNALSYM _IMAGEHLP_SYMBOL64}
  810.   IMAGEHLP_SYMBOL64 = _IMAGEHLP_SYMBOL64;
  811.   {$EXTERNALSYM IMAGEHLP_SYMBOL64}
  812.   TImageHlpSymbol64 = IMAGEHLP_SYMBOL64;
  813.   PImageHlpSymbol64 = PIMAGEHLP_SYMBOL64;
  814.   _IMAGEHLP_SYMBOL64_PACKAGE = record
  815.     sym: IMAGEHLP_SYMBOL64;
  816.     name: array [0..MAX_SYM_NAME] of CHAR;
  817.   end;
  818.   {$EXTERNALSYM _IMAGEHLP_SYMBOL64_PACKAGE}
  819.   IMAGEHLP_SYMBOL64_PACKAGE = _IMAGEHLP_SYMBOL64_PACKAGE;
  820.   {$EXTERNALSYM IMAGEHLP_SYMBOL64_PACKAGE}
  821.   PIMAGEHLP_SYMBOL64_PACKAGE = ^IMAGEHLP_SYMBOL64_PACKAGE;
  822.   {$EXTERNALSYM PIMAGEHLP_SYMBOL64_PACKAGE}
  823.   TImageHlpSymbol64Package = IMAGEHLP_SYMBOL64_PACKAGE;
  824.   PImageHlpSymbol64Package = PIMAGEHLP_SYMBOL64_PACKAGE;  
  825. //#if !defined(_IMAGEHLP_SOURCE_) && defined(_IMAGEHLP64)
  826. //
  827. //#define IMAGEHLP_SYMBOL IMAGEHLP_SYMBOL64
  828. //#define PIMAGEHLP_SYMBOL PIMAGEHLP_SYMBOL64
  829. //#define IMAGEHLP_SYMBOL_PACKAGE IMAGEHLP_SYMBOL64_PACKAGE
  830. //#define PIMAGEHLP_SYMBOL_PACKAGE PIMAGEHLP_SYMBOL64_PACKAGE
  831. //
  832. //#else
  833.   PIMAGEHLP_SYMBOL = ^IMAGEHLP_SYMBOL;
  834.   {$EXTERNALSYM PIMAGEHLP_SYMBOL}
  835.   _IMAGEHLP_SYMBOL = record
  836.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_SYMBOL)
  837.     Address: DWORD; // virtual address including dll base address
  838.     Size: DWORD; // estimated size of symbol, can be zero
  839.     Flags: DWORD; // info about the symbols, see the SYMF defines
  840.     MaxNameLength: DWORD; // maximum size of symbol name in 'Name'
  841.     Name: array [0..0] of CHAR; // symbol name (null terminated string)
  842.   end;
  843.   {$EXTERNALSYM _IMAGEHLP_SYMBOL}
  844.   IMAGEHLP_SYMBOL = _IMAGEHLP_SYMBOL;
  845.   {$EXTERNALSYM IMAGEHLP_SYMBOL}
  846.   TImageHlpSymbol = IMAGEHLP_SYMBOL;
  847.   PImageHlpSymbol = PIMAGEHLP_SYMBOL;
  848.   _IMAGEHLP_SYMBOL_PACKAGE = record
  849.     sym: IMAGEHLP_SYMBOL;
  850.     name: array [0..MAX_SYM_NAME] of CHAR;
  851.   end;
  852.   {$EXTERNALSYM _IMAGEHLP_SYMBOL_PACKAGE}
  853.   IMAGEHLP_SYMBOL_PACKAGE = _IMAGEHLP_SYMBOL_PACKAGE;
  854.   {$EXTERNALSYM IMAGEHLP_SYMBOL_PACKAGE}
  855.   PIMAGEHLP_SYMBOL_PACKAGE = ^IMAGEHLP_SYMBOL_PACKAGE;
  856.   {$EXTERNALSYM PIMAGEHLP_SYMBOL_PACKAGE}
  857.   TImageHlpSymbolPackage = IMAGEHLP_SYMBOL_PACKAGE;
  858.   PImageHlpSymbolPackage = PIMAGEHLP_SYMBOL_PACKAGE;
  859. //#endif
  860. //
  861. // module data structure
  862. //
  863.   PIMAGEHLP_MODULE64 = ^IMAGEHLP_MODULE64;
  864.   {$EXTERNALSYM PIMAGEHLP_MODULE64}
  865.   _IMAGEHLP_MODULE64 = record
  866.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_MODULE64)
  867.     BaseOfImage: DWORD64; // base load address of module
  868.     ImageSize: DWORD; // virtual size of the loaded module
  869.     TimeDateStamp: DWORD; // date/time stamp from pe header
  870.     CheckSum: DWORD; // checksum from the pe header
  871.     NumSyms: DWORD; // number of symbols in the symbol table
  872.     SymType: SYM_TYPE; // type of symbols loaded
  873.     ModuleName: array [0..3] of CHAR; // module name
  874.     ImageName: array [0..255] of CHAR; // image name
  875.     LoadedImageName: array [0..255] of CHAR; // symbol file name
  876.   end;
  877.   {$EXTERNALSYM _IMAGEHLP_MODULE64}
  878.   IMAGEHLP_MODULE64 = _IMAGEHLP_MODULE64;
  879.   {$EXTERNALSYM IMAGEHLP_MODULE64}
  880.   TImageHlpModule64 = IMAGEHLP_MODULE64;
  881.   PImageHlpModule64 = PIMAGEHLP_MODULE64;
  882.   PIMAGEHLP_MODULEW64 = ^IMAGEHLP_MODULEW64;
  883.   {$EXTERNALSYM PIMAGEHLP_MODULEW64}
  884.   _IMAGEHLP_MODULE64W = record
  885.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_MODULE64)
  886.     BaseOfImage: DWORD64; // base load address of module
  887.     ImageSize: DWORD; // virtual size of the loaded module
  888.     TimeDateStamp: DWORD; // date/time stamp from pe header
  889.     CheckSum: DWORD; // checksum from the pe header
  890.     NumSyms: DWORD; // number of symbols in the symbol table
  891.     SymType: SYM_TYPE; // type of symbols loaded
  892.     ModuleName: array [0..31] of WCHAR; // module name
  893.     ImageName: array [0..255] of WCHAR; // image name
  894.     LoadedImageName: array [0..255] of WCHAR; // symbol file name
  895.   end;
  896.   {$EXTERNALSYM _IMAGEHLP_MODULE64W}
  897.   IMAGEHLP_MODULEW64 = _IMAGEHLP_MODULE64W;
  898.   {$EXTERNALSYM IMAGEHLP_MODULEW64}
  899.   TImageHlpModuleW64 = IMAGEHLP_MODULEW64;
  900.   PImageHlpModuleW64 = PIMAGEHLP_MODULEW64;
  901.   PIMAGEHLP_MODULE = ^IMAGEHLP_MODULE;
  902.   {$EXTERNALSYM PIMAGEHLP_MODULE}
  903.   _IMAGEHLP_MODULE = record
  904.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_MODULE)
  905.     BaseOfImage: DWORD; // base load address of module
  906.     ImageSize: DWORD; // virtual size of the loaded module
  907.     TimeDateStamp: DWORD; // date/time stamp from pe header
  908.     CheckSum: DWORD; // checksum from the pe header
  909.     NumSyms: DWORD; // number of symbols in the symbol table
  910.     SymType: SYM_TYPE; // type of symbols loaded
  911.     ModuleName: array [0..31] of CHAR; // module name
  912.     ImageName: array [0..255] of CHAR; // image name
  913.     LoadedImageName: array [0..255] of CHAR; // symbol file name
  914.   end;
  915.   {$EXTERNALSYM _IMAGEHLP_MODULE}
  916.   IMAGEHLP_MODULE = _IMAGEHLP_MODULE;
  917.   {$EXTERNALSYM IMAGEHLP_MODULE}
  918.   TImageHlpModule = IMAGEHLP_MODULE;
  919.   PImageHlpModule = PIMAGEHLP_MODULE;
  920.   PIMAGEHLP_MODULEW = ^IMAGEHLP_MODULEW;
  921.   {$EXTERNALSYM PIMAGEHLP_MODULEW}
  922.   _IMAGEHLP_MODULEW = record
  923.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_MODULE)
  924.     BaseOfImage: DWORD; // base load address of module
  925.     ImageSize: DWORD; // virtual size of the loaded module
  926.     TimeDateStamp: DWORD; // date/time stamp from pe header
  927.     CheckSum: DWORD; // checksum from the pe header
  928.     NumSyms: DWORD; // number of symbols in the symbol table
  929.     SymType: SYM_TYPE; // type of symbols loaded
  930.     ModuleName: array [0..31] of WCHAR; // module name
  931.     ImageName: array [0..255] of WCHAR; // image name
  932.     LoadedImageName: array [0..255] of WCHAR; // symbol file name
  933.   end;
  934.   {$EXTERNALSYM _IMAGEHLP_MODULEW}
  935.   IMAGEHLP_MODULEW = _IMAGEHLP_MODULEW;
  936.   {$EXTERNALSYM IMAGEHLP_MODULEW}
  937.   TImageHlpModuleW = IMAGEHLP_MODULEW;
  938.   PImageHlpModuleW = PIMAGEHLP_MODULEW;
  939. //
  940. // source file line data structure
  941. //
  942.   PIMAGEHLP_LINE64 = ^IMAGEHLP_LINE64;
  943.   {$EXTERNALSYM PIMAGEHLP_LINE64}
  944.   _IMAGEHLP_LINE64 = record
  945.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_LINE64)
  946.     Key: PVOID; // internal
  947.     LineNumber: DWORD; // line number in file
  948.     FileName: PCHAR; // full filename
  949.     Address: DWORD64; // first instruction of line
  950.   end;
  951.   {$EXTERNALSYM _IMAGEHLP_LINE64}
  952.   IMAGEHLP_LINE64 = _IMAGEHLP_LINE64;
  953.   {$EXTERNALSYM IMAGEHLP_LINE64}
  954.   TImageHlpLine64 = IMAGEHLP_LINE64;
  955.   PImageHlpLine64 = PIMAGEHLP_LINE64;
  956.   PIMAGEHLP_LINE = ^IMAGEHLP_LINE;
  957.   {$EXTERNALSYM PIMAGEHLP_LINE}
  958.   _IMAGEHLP_LINE = record
  959.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_LINE)
  960.     Key: PVOID; // internal
  961.     LineNumber: DWORD; // line number in file
  962.     FileName: PCHAR; // full filename
  963.     Address: DWORD; // first instruction of line
  964.   end;
  965.   {$EXTERNALSYM _IMAGEHLP_LINE}
  966.   IMAGEHLP_LINE = _IMAGEHLP_LINE;
  967.   {$EXTERNALSYM IMAGEHLP_LINE}
  968.   TImageHlpLine = IMAGEHLP_LINE;
  969.   PImageHlpLine = PIMAGEHLP_LINE;
  970. //
  971. // source file structure
  972. //
  973. type
  974.   _SOURCEFILE = record
  975.     ModBase: DWORD64;                // base address of loaded module
  976.     FileName: PCHAR;                 // full filename of source
  977.   end;
  978.   {$EXTERNALSYM _SOURCEFILE}
  979.   SOURCEFILE = _SOURCEFILE;
  980.   {$EXTERNALSYM SOURCEFILE}
  981.   PSOURCEFILE = ^SOURCEFILE;
  982.   {$EXTERNALSYM PSOURCEFILE}
  983.   TSourceFile = SOURCEFILE;
  984. //
  985. // data structures used for registered symbol callbacks
  986. //
  987. const
  988.   CBA_DEFERRED_SYMBOL_LOAD_START    = $00000001;
  989.   {$EXTERNALSYM CBA_DEFERRED_SYMBOL_LOAD_START}
  990.   CBA_DEFERRED_SYMBOL_LOAD_COMPLETE = $00000002;
  991.   {$EXTERNALSYM CBA_DEFERRED_SYMBOL_LOAD_COMPLETE}
  992.   CBA_DEFERRED_SYMBOL_LOAD_FAILURE  = $00000003;
  993.   {$EXTERNALSYM CBA_DEFERRED_SYMBOL_LOAD_FAILURE}
  994.   CBA_SYMBOLS_UNLOADED              = $00000004;
  995.   {$EXTERNALSYM CBA_SYMBOLS_UNLOADED}
  996.   CBA_DUPLICATE_SYMBOL              = $00000005;
  997.   {$EXTERNALSYM CBA_DUPLICATE_SYMBOL}
  998.   CBA_READ_MEMORY                   = $00000006;
  999.   {$EXTERNALSYM CBA_READ_MEMORY}
  1000.   CBA_DEFERRED_SYMBOL_LOAD_CANCEL   = $00000007;
  1001.   {$EXTERNALSYM CBA_DEFERRED_SYMBOL_LOAD_CANCEL}
  1002.   CBA_SET_OPTIONS                   = $00000008;
  1003.   {$EXTERNALSYM CBA_SET_OPTIONS}
  1004.   CBA_EVENT                         = $00000010;
  1005.   {$EXTERNALSYM CBA_EVENT}
  1006.   CBA_DEFERRED_SYMBOL_LOAD_PARTIAL  = $00000020;
  1007.   {$EXTERNALSYM CBA_DEFERRED_SYMBOL_LOAD_PARTIAL}
  1008.   CBA_DEBUG_INFO                    = $10000000;
  1009.   {$EXTERNALSYM CBA_DEBUG_INFO}
  1010. type
  1011.   PIMAGEHLP_CBA_READ_MEMORY = ^IMAGEHLP_CBA_READ_MEMORY;
  1012.   {$EXTERNALSYM PIMAGEHLP_CBA_READ_MEMORY}
  1013.   _IMAGEHLP_CBA_READ_MEMORY = record
  1014.     addr: DWORD64; // address to read from
  1015.     buf: PVOID; // buffer to read to
  1016.     bytes: DWORD; // amount of bytes to read
  1017.     bytesread: LPDWORD; // pointer to store amount of bytes read
  1018.   end;
  1019.   {$EXTERNALSYM _IMAGEHLP_CBA_READ_MEMORY}
  1020.   IMAGEHLP_CBA_READ_MEMORY = _IMAGEHLP_CBA_READ_MEMORY;
  1021.   {$EXTERNALSYM IMAGEHLP_CBA_READ_MEMORY}
  1022.   TImageHlpCbaReadMemory = IMAGEHLP_CBA_READ_MEMORY;
  1023.   PImageHlpCbaReadMemory = PIMAGEHLP_CBA_READ_MEMORY;
  1024. const
  1025.   sevInfo    = 0;
  1026.   {$EXTERNALSYM sevInfo}
  1027.   sevProblem = 1;
  1028.   {$EXTERNALSYM sevProblem}
  1029.   sevAttn    = 2;
  1030.   {$EXTERNALSYM sevAttn}
  1031.   sevFatal   = 3;
  1032.   {$EXTERNALSYM sevFatal}
  1033.   sevMax     = 4; // unused
  1034.   {$EXTERNALSYM sevMax}
  1035. type
  1036.   _IMAGEHLP_CBA_EVENT = record
  1037.     severity: DWORD;                                     // values from sevInfo to sevFatal
  1038.     code: DWORD;                                         // numerical code IDs the error
  1039.     desc: PCHAR;                                         // may contain a text description of the error
  1040.     object_: PVOID;                                      // value dependant upon the error code
  1041.   end;
  1042.   {$EXTERNALSYM _IMAGEHLP_CBA_EVENT}
  1043.   IMAGEHLP_CBA_EVENT = _IMAGEHLP_CBA_EVENT;
  1044.   {$EXTERNALSYM IMAGEHLP_CBA_EVENT}
  1045.   PIMAGEHLP_CBA_EVENT = ^IMAGEHLP_CBA_EVENT;
  1046.   {$EXTERNALSYM PIMAGEHLP_CBA_EVENT}
  1047.   TImageHlpCbaEvent = IMAGEHLP_CBA_EVENT;
  1048.   PImageHlpCbaEvent = PIMAGEHLP_CBA_EVENT;
  1049.   PIMAGEHLP_DEFERRED_SYMBOL_LOAD64 = ^IMAGEHLP_DEFERRED_SYMBOL_LOAD64;
  1050.   {$EXTERNALSYM PIMAGEHLP_DEFERRED_SYMBOL_LOAD64}
  1051.   _IMAGEHLP_DEFERRED_SYMBOL_LOAD64 = record
  1052.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD64)
  1053.     BaseOfImage: DWORD64; // base load address of module
  1054.     CheckSum: DWORD; // checksum from the pe header
  1055.     TimeDateStamp: DWORD; // date/time stamp from pe header
  1056.     FileName: array [0..MAX_PATH - 1] of CHAR; // symbols file or image name
  1057.     Reparse: ByteBool; // load failure reparse
  1058.     hFile: HANDLE; // file handle, if passed
  1059.     Flags: DWORD; //
  1060.   end;
  1061.   {$EXTERNALSYM _IMAGEHLP_DEFERRED_SYMBOL_LOAD64}
  1062.   IMAGEHLP_DEFERRED_SYMBOL_LOAD64 = _IMAGEHLP_DEFERRED_SYMBOL_LOAD64;
  1063.   {$EXTERNALSYM IMAGEHLP_DEFERRED_SYMBOL_LOAD64}
  1064.   TImageHlpDeferredSymbolLoad64 = IMAGEHLP_DEFERRED_SYMBOL_LOAD64;
  1065.   PImageHlpDeferredSymbolLoad64 = PIMAGEHLP_DEFERRED_SYMBOL_LOAD64;
  1066. const
  1067.   DSLFLAG_MISMATCHED_PDB = $1;
  1068.   {$EXTERNALSYM DSLFLAG_MISMATCHED_PDB}
  1069.   DSLFLAG_MISMATCHED_DBG = $2;
  1070.   {$EXTERNALSYM DSLFLAG_MISMATCHED_DBG}
  1071. type
  1072.   PIMAGEHLP_DEFERRED_SYMBOL_LOAD = ^IMAGEHLP_DEFERRED_SYMBOL_LOAD;
  1073.   {$EXTERNALSYM PIMAGEHLP_DEFERRED_SYMBOL_LOAD}
  1074.   _IMAGEHLP_DEFERRED_SYMBOL_LOAD = record
  1075.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_DEFERRED_SYMBOL_LOAD)
  1076.     BaseOfImage: DWORD; // base load address of module
  1077.     CheckSum: DWORD; // checksum from the pe header
  1078.     TimeDateStamp: DWORD; // date/time stamp from pe header
  1079.     FileName: array [0..MAX_PATH - 1] of CHAR; // symbols file or image name
  1080.     Reparse: ByteBool; // load failure reparse
  1081.     hFile: HANDLE; // file handle, if passed    
  1082.   end;
  1083.   {$EXTERNALSYM _IMAGEHLP_DEFERRED_SYMBOL_LOAD}
  1084.   IMAGEHLP_DEFERRED_SYMBOL_LOAD = _IMAGEHLP_DEFERRED_SYMBOL_LOAD;
  1085.   {$EXTERNALSYM IMAGEHLP_DEFERRED_SYMBOL_LOAD}
  1086.   TImageHlpDeferredSymbolLoad = IMAGEHLP_DEFERRED_SYMBOL_LOAD;
  1087.   PImageHlpDeferredSymbolLoad = PIMAGEHLP_DEFERRED_SYMBOL_LOAD;
  1088.   PIMAGEHLP_DUPLICATE_SYMBOL64 = ^IMAGEHLP_DUPLICATE_SYMBOL64;
  1089.   {$EXTERNALSYM PIMAGEHLP_DUPLICATE_SYMBOL64}
  1090.   _IMAGEHLP_DUPLICATE_SYMBOL64 = record
  1091.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL64)
  1092.     NumberOfDups: DWORD; // number of duplicates in the Symbol array
  1093.     Symbol: PIMAGEHLP_SYMBOL64; // array of duplicate symbols
  1094.     SelectedSymbol: DWORD; // symbol selected (-1 to start)
  1095.   end;
  1096.   {$EXTERNALSYM _IMAGEHLP_DUPLICATE_SYMBOL64}
  1097.   IMAGEHLP_DUPLICATE_SYMBOL64 = _IMAGEHLP_DUPLICATE_SYMBOL64;
  1098.   {$EXTERNALSYM IMAGEHLP_DUPLICATE_SYMBOL64}
  1099.   TImageHlpDuplicateSymbol64 = IMAGEHLP_DUPLICATE_SYMBOL64;
  1100.   PImageHlpDuplicateSymbol64 = PIMAGEHLP_DUPLICATE_SYMBOL64;
  1101.   PIMAGEHLP_DUPLICATE_SYMBOL = ^IMAGEHLP_DUPLICATE_SYMBOL;
  1102.   {$EXTERNALSYM PIMAGEHLP_DUPLICATE_SYMBOL}
  1103.   _IMAGEHLP_DUPLICATE_SYMBOL = record
  1104.     SizeOfStruct: DWORD; // set to sizeof(IMAGEHLP_DUPLICATE_SYMBOL)
  1105.     NumberOfDups: DWORD; // number of duplicates in the Symbol array
  1106.     Symbol: PIMAGEHLP_SYMBOL; // array of duplicate symbols
  1107.     SelectedSymbol: DWORD; // symbol selected (-1 to start)
  1108.   end;
  1109.   {$EXTERNALSYM _IMAGEHLP_DUPLICATE_SYMBOL}
  1110.   IMAGEHLP_DUPLICATE_SYMBOL = _IMAGEHLP_DUPLICATE_SYMBOL;
  1111.   {$EXTERNALSYM IMAGEHLP_DUPLICATE_SYMBOL}
  1112.   TImageHlpDuplicateSymbol = IMAGEHLP_DUPLICATE_SYMBOL;
  1113.   PImageHlpDuplicateSymbol = PIMAGEHLP_DUPLICATE_SYMBOL;
  1114. // If dbghelp ever needs to display graphical UI, it will use this as the parent window.
  1115. //BOOL
  1116. //SymSetParentWindow(
  1117. //    HWND hwnd
  1118. //    );
  1119. //
  1120. // options that are set/returned by SymSetOptions() & SymGetOptions()
  1121. // these are used as a mask
  1122. //
  1123. const
  1124.   SYMOPT_CASE_INSENSITIVE  = $00000001;
  1125.   {$EXTERNALSYM SYMOPT_CASE_INSENSITIVE}
  1126.   SYMOPT_UNDNAME           = $00000002;
  1127.   {$EXTERNALSYM SYMOPT_UNDNAME}
  1128.   SYMOPT_DEFERRED_LOADS    = $00000004;
  1129.   {$EXTERNALSYM SYMOPT_DEFERRED_LOADS}
  1130.   SYMOPT_NO_CPP            = $00000008;
  1131.   {$EXTERNALSYM SYMOPT_NO_CPP}
  1132.   SYMOPT_LOAD_LINES        = $00000010;
  1133.   {$EXTERNALSYM SYMOPT_LOAD_LINES}
  1134.   SYMOPT_OMAP_FIND_NEAREST = $00000020;
  1135.   {$EXTERNALSYM SYMOPT_OMAP_FIND_NEAREST}
  1136.   SYMOPT_LOAD_ANYTHING         = $00000040;
  1137.   {$EXTERNALSYM SYMOPT_LOAD_ANYTHING}
  1138.   SYMOPT_IGNORE_CVREC          = $00000080;
  1139.   {$EXTERNALSYM SYMOPT_IGNORE_CVREC}
  1140.   SYMOPT_NO_UNQUALIFIED_LOADS  = $00000100;
  1141.   {$EXTERNALSYM SYMOPT_NO_UNQUALIFIED_LOADS}
  1142.   SYMOPT_FAIL_CRITICAL_ERRORS  = $00000200;
  1143.   {$EXTERNALSYM SYMOPT_FAIL_CRITICAL_ERRORS}
  1144.   SYMOPT_EXACT_SYMBOLS         = $00000400;
  1145.   {$EXTERNALSYM SYMOPT_EXACT_SYMBOLS}
  1146.   SYMOPT_ALLOW_ABSOLUTE_SYMBOLS = $00000800;
  1147.   {$EXTERNALSYM SYMOPT_ALLOW_ABSOLUTE_SYMBOLS}
  1148.   SYMOPT_IGNORE_NT_SYMPATH      = $00001000;
  1149.   {$EXTERNALSYM SYMOPT_IGNORE_NT_SYMPATH}
  1150.   SYMOPT_INCLUDE_32BIT_MODULES = $00002000;
  1151.   {$EXTERNALSYM SYMOPT_INCLUDE_32BIT_MODULES}
  1152.   SYMOPT_PUBLICS_ONLY          = $00004000;
  1153.   {$EXTERNALSYM SYMOPT_PUBLICS_ONLY}
  1154.   SYMOPT_NO_PUBLICS            = $00008000;
  1155.   {$EXTERNALSYM SYMOPT_NO_PUBLICS}
  1156.   SYMOPT_AUTO_PUBLICS          = $00010000;
  1157.   {$EXTERNALSYM SYMOPT_AUTO_PUBLICS}
  1158.   SYMOPT_NO_IMAGE_SEARCH       = $00020000;
  1159.   {$EXTERNALSYM SYMOPT_NO_IMAGE_SEARCH}
  1160.   SYMOPT_SECURE                = $00040000;
  1161.   {$EXTERNALSYM SYMOPT_SECURE}
  1162.   SYMOPT_DEBUG             = DWORD($80000000);
  1163.   {$EXTERNALSYM SYMOPT_DEBUG}
  1164. function SymSetOptions(SymOptions: DWORD): DWORD; stdcall;
  1165. {$EXTERNALSYM SymSetOptions}
  1166. function SymGetOptions: DWORD; stdcall;
  1167. {$EXTERNALSYM SymGetOptions}
  1168. function SymCleanup(hProcess: HANDLE): BOOL; stdcall;
  1169. {$EXTERNALSYM SymCleanup}
  1170. function SymMatchString(string_, expression: LPSTR; fCase: BOOL): BOOL; stdcall;
  1171. {$EXTERNALSYM SymMatchString}
  1172. type
  1173.   PSYM_ENUMSOURCFILES_CALLBACK = function (pSourceFile: PSOURCEFILE; UserContext: PVOID): BOOL; stdcall;
  1174.   {$EXTERNALSYM PSYM_ENUMSOURCFILES_CALLBACK}
  1175.   PSymEnumSourceFilesCallback = PSYM_ENUMSOURCFILES_CALLBACK;
  1176. function SymEnumSourceFiles(hProcess: HANDLE; ModBase: ULONG64; Mask: LPSTR;
  1177.   cbSrcFiles: PSYM_ENUMSOURCFILES_CALLBACK; UserContext: PVOID): BOOL; stdcall;
  1178. {$EXTERNALSYM SymEnumSourceFiles}
  1179. function SymEnumerateModules64(hProcess: HANDLE; EnumModulesCallback: PSYM_ENUMMODULES_CALLBACK64;
  1180.   UserContext: PVOID): BOOL; stdcall;
  1181. {$EXTERNALSYM SymEnumerateModules64}
  1182. function SymEnumerateModules(hProcess: HANDLE; EnumModulesCallback: PSYM_ENUMMODULES_CALLBACK;
  1183.   UserContext: PVOID): BOOL; stdcall;
  1184. {$EXTERNALSYM SymEnumerateModules}
  1185. function SymEnumerateSymbols64(hProcess: HANDLE; BaseOfDll: DWORD64;
  1186.   EnumSymbolsCallback: PSYM_ENUMSYMBOLS_CALLBACK64; UserContext: PVOID): BOOL; stdcall;
  1187. {$EXTERNALSYM SymEnumerateSymbols64}
  1188. function SymEnumerateSymbolsW64(hProcess: HANDLE; BaseOfDll: DWORD64;
  1189.   EnumSymbolsCallback: PSYM_ENUMSYMBOLS_CALLBACK64W; UserContext: PVOID): BOOL; stdcall;
  1190. {$EXTERNALSYM SymEnumerateSymbolsW64}
  1191. function SymEnumerateSymbols(hProcess: HANDLE; BaseOfDll: DWORD;
  1192.   EnumSymbolsCallback: PSYM_ENUMSYMBOLS_CALLBACK; UserContext: PVOID): BOOL; stdcall;
  1193. {$EXTERNALSYM SymEnumerateSymbols}
  1194. function SymEnumerateSymbolsW(hProcess: HANDLE; BaseOfDll: DWORD;
  1195.   EnumSymbolsCallback: PSYM_ENUMSYMBOLS_CALLBACKW; UserContext: PVOID): BOOL; stdcall;
  1196. {$EXTERNALSYM SymEnumerateSymbolsW}
  1197. function EnumerateLoadedModules64(hProcess: HANDLE; EnumLoadedModulesCallback: PENUMLOADED_MODULES_CALLBACK64;
  1198.   UserContext: PVOID): BOOL; stdcall;
  1199. {$EXTERNALSYM EnumerateLoadedModules64}
  1200. function EnumerateLoadedModules(hProcess: HANDLE; EnumLoadedModulesCallback: PENUMLOADED_MODULES_CALLBACK;
  1201.   UserContext: PVOID): BOOL; stdcall;
  1202. {$EXTERNALSYM EnumerateLoadedModules}
  1203. function SymFunctionTableAccess64(hProcess: HANDLE; AddrBase: DWORD64): PVOID; stdcall;
  1204. {$EXTERNALSYM SymFunctionTableAccess64}
  1205. function SymFunctionTableAccess(hProcess: HANDLE; AddrBase: DWORD): PVOID; stdcall;
  1206. {$EXTERNALSYM SymFunctionTableAccess}
  1207. function SymGetModuleInfo64(hProcess: HANDLE; qwAddr: DWORD64;
  1208.   var ModuleInfo: IMAGEHLP_MODULE64): BOOL; stdcall;
  1209. {$EXTERNALSYM SymGetModuleInfo64}
  1210. function SymGetModuleInfoW64(hProcess: HANDLE; qwAddr: DWORD64;
  1211.   var ModuleInfo: IMAGEHLP_MODULEW64): BOOL; stdcall;
  1212. {$EXTERNALSYM SymGetModuleInfoW64}
  1213. function SymGetModuleInfo(hProcess: HANDLE; dwAddr: DWORD;
  1214.   var ModuleInfo: IMAGEHLP_MODULE): BOOL; stdcall;
  1215. {$EXTERNALSYM SymGetModuleInfo}
  1216. function SymGetModuleInfoW(hProcess: HANDLE; dwAddr: DWORD;
  1217.   var ModuleInfo: IMAGEHLP_MODULEW): BOOL; stdcall;
  1218. {$EXTERNALSYM SymGetModuleInfoW}
  1219. function SymGetModuleBase64(hProcess: HANDLE; qwAddr: DWORD64): DWORD64; stdcall;
  1220. {$EXTERNALSYM SymGetModuleBase64}
  1221. function SymGetModuleBase(hProcess: HANDLE; dwAddr: DWORD): DWORD; stdcall;
  1222. {$EXTERNALSYM SymGetModuleBase}
  1223. function SymGetSymNext64(hProcess: HANDLE; var Symbol: IMAGEHLP_SYMBOL64): BOOL; stdcall;
  1224. {$EXTERNALSYM SymGetSymNext64}
  1225. function SymGetSymNext(hProcess: HANDLE; var Symbol: IMAGEHLP_SYMBOL): BOOL; stdcall;
  1226. {$EXTERNALSYM SymGetSymNext}
  1227. function SymGetSymPrev64(hProcess: HANDLE; var Symbol: IMAGEHLP_SYMBOL64): BOOL; stdcall;
  1228. {$EXTERNALSYM SymGetSymPrev64}
  1229. function SymGetSymPrev(hProcess: HANDLE; var Symbol: IMAGEHLP_SYMBOL): BOOL; stdcall;
  1230. {$EXTERNALSYM SymGetSymPrev}
  1231. function SymGetLineFromAddr64(hProcess: HANDLE; qwAddr: DWORD64;
  1232.   var pdwDisplacement: DWORD; var Line64: IMAGEHLP_LINE64): BOOL; stdcall;
  1233. {$EXTERNALSYM SymGetLineFromAddr64}
  1234. function SymGetLineFromAddr(hProcess: HANDLE; dwAddr: DWORD;
  1235.   var pdwDisplacement: DWORD; var Line: IMAGEHLP_LINE): BOOL; stdcall;
  1236. {$EXTERNALSYM SymGetLineFromAddr}
  1237. function SymGetLineFromName64(hProcess: HANDLE; ModuleName: PSTR; FileName: PSTR;
  1238.   dwLineNumber: DWORD; var plDisplacement: LONG; var Line: IMAGEHLP_LINE64): BOOL; stdcall;
  1239. {$EXTERNALSYM SymGetLineFromName64}
  1240. function SymGetLineFromName(hProcess: HANDLE; ModuleName: PSTR; FileName: PSTR;
  1241.   dwLineNumber: DWORD; var plDisplacement: LONG; var Line: IMAGEHLP_LINE): BOOL; stdcall;
  1242. {$EXTERNALSYM SymGetLineFromName}
  1243. function SymGetLineNext64(hProcess: HANDLE; var Line: IMAGEHLP_LINE64): BOOL; stdcall;
  1244. {$EXTERNALSYM SymGetLineNext64}
  1245. function SymGetLineNext(hProcess: HANDLE; var Line: IMAGEHLP_LINE): BOOL; stdcall;
  1246. {$EXTERNALSYM SymGetLineNext}
  1247. function SymGetLinePrev64(hProcess: HANDLE; var Line: IMAGEHLP_LINE64): BOOL; stdcall;
  1248. {$EXTERNALSYM SymGetLinePrev64}
  1249. function SymGetLinePrev(hProcess: HANDLE; var Line: IMAGEHLP_LINE): BOOL; stdcall;
  1250. {$EXTERNALSYM SymGetLinePrev}
  1251. function SymMatchFileName(FileName, Match: PSTR; var FileNameStop, MatchStop: PSTR): BOOL; stdcall;
  1252. {$EXTERNALSYM SymMatchFileName}
  1253. function SymInitialize(hProcess: HANDLE; UserSearchPath: PSTR; fInvadeProcess: BOOL): BOOL; stdcall;
  1254. {$EXTERNALSYM SymInitialize}
  1255. function SymGetSearchPath(hProcess: HANDLE; SearchPath: PSTR; SearchPathLength: DWORD): BOOL; stdcall;
  1256. {$EXTERNALSYM SymGetSearchPath}
  1257. function SymSetSearchPath(hProcess: HANDLE; SearchPath: PSTR): BOOL; stdcall;
  1258. {$EXTERNALSYM SymSetSearchPath}
  1259. function SymLoadModule64(hProcess, hFile: HANDLE; ImageName, ModuleName: PSTR;
  1260.   BaseOfDll: DWORD64; SizeOfDll: DWORD): DWORD64; stdcall;
  1261. {$EXTERNALSYM SymLoadModule64}
  1262. const
  1263.   SLMFLAG_VIRTUAL = $1;
  1264.   {$EXTERNALSYM SLMFLAG_VIRTUAL}
  1265. function SymLoadModuleEx(hProcess, hFile: HANDLE; ImageName, ModuleName: PSTR; BaseOfDll: DWORD64;
  1266.   DllSize: DWORD; Data: PMODLOAD_DATA; Flag: DWORD): DWORD64; stdcall;
  1267. {$EXTERNALSYM SymLoadModuleEx}
  1268. function SymLoadModule(hProcess, hFile: HANDLE; ImageName, ModuleName: PSTR;
  1269.   BaseOfDll: DWORD; SizeOfDll: DWORD): DWORD; stdcall;
  1270. {$EXTERNALSYM SymLoadModule}
  1271. function SymUnloadModule64(hProcess: HANDLE; BaseOfDll: DWORD64): BOOL; stdcall;
  1272. {$EXTERNALSYM SymUnloadModule64}
  1273. function SymUnloadModule(hProcess: HANDLE; BaseOfDll: DWORD): BOOL; stdcall;
  1274. {$EXTERNALSYM SymUnloadModule}
  1275. function SymUnDName64(const sym: IMAGEHLP_SYMBOL64; UnDecName: PSTR;
  1276.   UnDecNameLength: DWORD): BOOL; stdcall;
  1277. {$EXTERNALSYM SymUnDName64}
  1278. function SymUnDName(const sym: IMAGEHLP_SYMBOL; UnDecName: PSTR;
  1279.   UnDecNameLength: DWORD): BOOL; stdcall;
  1280. {$EXTERNALSYM SymUnDName}
  1281. function SymRegisterCallback64(hProcess: HANDLE; CallbackFunction: PSYMBOL_REGISTERED_CALLBACK64;
  1282.   UserContext: ULONG64): BOOL; stdcall;
  1283. {$EXTERNALSYM SymRegisterCallback64}
  1284. function SymRegisterFunctionEntryCallback64(hProcess: HANDLE; CallbackFunction: PSYMBOL_FUNCENTRY_CALLBACK64;
  1285.   UserContext: ULONG64): BOOL; stdcall;
  1286. {$EXTERNALSYM SymRegisterFunctionEntryCallback64}
  1287. function SymRegisterCallback(hProcess: HANDLE; CallbackFunction: PSYMBOL_REGISTERED_CALLBACK;
  1288.   UserContext: PVOID): BOOL; stdcall;
  1289. {$EXTERNALSYM SymRegisterCallback}
  1290. function SymRegisterFunctionEntryCallback(hProcess: HANDLE; CallbackFunction: PSYMBOL_FUNCENTRY_CALLBACK;
  1291.   UserContext: PVOID): BOOL; stdcall;
  1292. {$EXTERNALSYM SymRegisterFunctionEntryCallback}
  1293. type
  1294.   PIMAGEHLP_SYMBOL_SRC = ^IMAGEHLP_SYMBOL_SRC;
  1295.   {$EXTERNALSYM PIMAGEHLP_SYMBOL_SRC}
  1296.   _IMAGEHLP_SYMBOL_SRC = record
  1297.     sizeofstruct: DWORD;
  1298.     type_: DWORD;
  1299.     file_: array [0..MAX_PATH - 1] of Char;
  1300.   end;
  1301.   {$EXTERNALSYM _IMAGEHLP_SYMBOL_SRC}
  1302.   IMAGEHLP_SYMBOL_SRC = _IMAGEHLP_SYMBOL_SRC;
  1303.   {$EXTERNALSYM IMAGEHLP_SYMBOL_SRC}
  1304.   TImageHlpSymbolSrc = IMAGEHLP_SYMBOL_SRC;
  1305.   PImageHlpSymbolSrc = PIMAGEHLP_SYMBOL_SRC;
  1306.   PMODULE_TYPE_INFO = ^MODULE_TYPE_INFO;
  1307.   {$EXTERNALSYM PMODULE_TYPE_INFO}
  1308.   _MODULE_TYPE_INFO = record
  1309.     dataLength: USHORT;
  1310.     leaf: USHORT;
  1311.     data: array [0..0] of BYTE;
  1312.   end;
  1313.   {$EXTERNALSYM _MODULE_TYPE_INFO}
  1314.   MODULE_TYPE_INFO = _MODULE_TYPE_INFO;
  1315.   {$EXTERNALSYM MODULE_TYPE_INFO}
  1316.   TModuleTypeInfo = MODULE_TYPE_INFO;
  1317.   PModuleTypeInfo = PMODULE_TYPE_INFO;
  1318. type
  1319.   PSYMBOL_INFO = ^SYMBOL_INFO;
  1320.   {$EXTERNALSYM PSYMBOL_INFO}
  1321.   _SYMBOL_INFO = record
  1322.     SizeOfStruct: ULONG;
  1323.     TypeIndex: ULONG; // Type Index of symbol
  1324.     Reserved: array [0..1] of ULONG64;
  1325.     Info: ULONG;
  1326.     Size: ULONG;
  1327.     ModBase: ULONG64; // Base Address of module comtaining this symbol
  1328.     Flags: ULONG;
  1329.     Value: ULONG64; // Value of symbol, ValuePresent should be 1
  1330.     Address: ULONG64; // Address of symbol including base address of module
  1331.     Register_: ULONG; // register holding value or pointer to value
  1332.     Scope: ULONG; // scope of the symbol
  1333.     Tag: ULONG; // pdb classification
  1334.     NameLen: ULONG; // Actual length of name
  1335.     MaxNameLen: ULONG;
  1336.     Name: array [0..0] of CHAR; // Name of symbol
  1337.   end;
  1338.   {$EXTERNALSYM _SYMBOL_INFO}
  1339.   SYMBOL_INFO = _SYMBOL_INFO;
  1340.   {$EXTERNALSYM SYMBOL_INFO}
  1341.   TSymbolInfo = SYMBOL_INFO;
  1342.   PSymbolInfo = PSYMBOL_INFO;
  1343.   _SYMBOL_INFO_PACKAGE = record
  1344.     si: SYMBOL_INFO;
  1345.     name: array [0..MAX_SYM_NAME] of CHAR;
  1346.   end;
  1347.   {$EXTERNALSYM _SYMBOL_INFO_PACKAGE}
  1348.   SYMBOL_INFO_PACKAGE = _SYMBOL_INFO_PACKAGE;
  1349.   {$EXTERNALSYM SYMBOL_INFO_PACKAGE}
  1350.   PSYMBOL_INFO_PACKAGE = ^SYMBOL_INFO_PACKAGE;
  1351.   {$EXTERNALSYM PSYMBOL_INFO_PACKAGE}
  1352.   TSymbolInfoPackage = SYMBOL_INFO_PACKAGE;
  1353.   PSymbolInfoPackage = PSYMBOL_INFO_PACKAGE;
  1354.   PIMAGEHLP_STACK_FRAME = ^IMAGEHLP_STACK_FRAME;
  1355.   {$EXTERNALSYM PIMAGEHLP_STACK_FRAME}
  1356.   _IMAGEHLP_STACK_FRAME = record
  1357.     InstructionOffset: ULONG64;
  1358.     ReturnOffset: ULONG64;
  1359.     FrameOffset: ULONG64;
  1360.     StackOffset: ULONG64;
  1361.     BackingStoreOffset: ULONG64;
  1362.     FuncTableEntry: ULONG64;
  1363.     Params: array [0..3] of ULONG64;
  1364.     Reserved: array [0..4] of ULONG64;
  1365.     Virtual_: BOOL;
  1366.     Reserved2: ULONG;
  1367.   end;
  1368.   {$EXTERNALSYM _IMAGEHLP_STACK_FRAME}
  1369.   IMAGEHLP_STACK_FRAME = _IMAGEHLP_STACK_FRAME;
  1370.   {$EXTERNALSYM IMAGEHLP_STACK_FRAME}
  1371.   TImageHlpStackFrame = IMAGEHLP_STACK_FRAME;
  1372.   PImageHlpStackFrame = PIMAGEHLP_STACK_FRAME;
  1373.   IMAGEHLP_CONTEXT = LPVOID;
  1374.   {$EXTERNALSYM IMAGEHLP_CONTEXT}
  1375.   PIMAGEHLP_CONTEXT = ^IMAGEHLP_CONTEXT;
  1376.   {$EXTERNALSYM PIMAGEHLP_CONTEXT}
  1377.   TImageHlpContext = IMAGEHLP_CONTEXT;
  1378.   PImageHlpContext = PIMAGEHLP_CONTEXT;
  1379. function SymSetContext(hProcess: HANDLE; StackFrame: PIMAGEHLP_STACK_FRAME; Context: PIMAGEHLP_CONTEXT): BOOL; stdcall;
  1380. {$EXTERNALSYM SymSetContext}
  1381. function SymFromAddr(hProcess: HANDLE; Address: DWORD64; Displacement: PDWORD64; Symbol: PSYMBOL_INFO): BOOL; stdcall;
  1382. {$EXTERNALSYM SymFromAddr}
  1383. // While SymFromName will provide a symbol from a name,
  1384. // SymEnumSymbols can provide the same matching information
  1385. // for ALL symbols with a matching name, even regular
  1386. // expressions.  That way you can search across modules
  1387. // and differentiate between identically named symbols.
  1388. function SymFromName(hProcess: HANDLE; Name: LPSTR; Symbol: PSYMBOL_INFO): BOOL; stdcall;
  1389. {$EXTERNALSYM SymFromName}
  1390. type
  1391.   PSYM_ENUMERATESYMBOLS_CALLBACK = function (pSymInfo: PSYMBOL_INFO; SymbolSize: ULONG; UserContext: PVOID): BOOL; stdcall;
  1392.   {$EXTERNALSYM PSYM_ENUMERATESYMBOLS_CALLBACK}
  1393.   PSymEnumerateSymbolsCallback = PSYM_ENUMERATESYMBOLS_CALLBACK;
  1394. function SymEnumSymbols(hProcess: HANDLE; BaseOfDll: ULONG64; Mask: PCSTR; EnumSymbolsCallback: PSYM_ENUMERATESYMBOLS_CALLBACK; UserContext: PVOID): BOOL; stdcall;
  1395. {$EXTERNALSYM SymEnumSymbols}
  1396. function SymEnumSymbolsForAddr(hProcess: HANDLE; Address: DWORD64;
  1397.   EnumSymbolsCallback: PSYM_ENUMERATESYMBOLS_CALLBACK; UserContext: PVOID): BOOL; stdcall;
  1398. {$EXTERNALSYM SymEnumSymbolsForAddr}
  1399. type
  1400.   _IMAGEHLP_SYMBOL_TYPE_INFO = (
  1401.     TI_GET_SYMTAG,
  1402.     TI_GET_SYMNAME,
  1403.     TI_GET_LENGTH,
  1404.     TI_GET_TYPE,
  1405.     TI_GET_TYPEID,
  1406.     TI_GET_BASETYPE,
  1407.     TI_GET_ARRAYINDEXTYPEID,
  1408.     TI_FINDCHILDREN,
  1409.     TI_GET_DATAKIND,
  1410.     TI_GET_ADDRESSOFFSET,
  1411.     TI_GET_OFFSET,
  1412.     TI_GET_VALUE,
  1413.     TI_GET_COUNT,
  1414.     TI_GET_CHILDRENCOUNT,
  1415.     TI_GET_BITPOSITION,
  1416.     TI_GET_VIRTUALBASECLASS,
  1417.     TI_GET_VIRTUALTABLESHAPEID,
  1418.     TI_GET_VIRTUALBASEPOINTEROFFSET,
  1419.     TI_GET_CLASSPARENTID,
  1420.     TI_GET_NESTED,
  1421.     TI_GET_SYMINDEX,
  1422.     TI_GET_LEXICALPARENT,
  1423.     TI_GET_ADDRESS,
  1424.     TI_GET_THISADJUST,
  1425.     TI_GET_UDTKIND,
  1426.     TI_IS_EQUIV_TO,
  1427.     TI_GET_CALLING_CONVENTION);
  1428.   {$EXTERNALSYM _IMAGEHLP_SYMBOL_TYPE_INFO}
  1429.   IMAGEHLP_SYMBOL_TYPE_INFO = _IMAGEHLP_SYMBOL_TYPE_INFO;
  1430.   {$EXTERNALSYM IMAGEHLP_SYMBOL_TYPE_INFO}
  1431.   TImageHlpSymbolTypeInfo = IMAGEHLP_SYMBOL_TYPE_INFO;
  1432.   PTI_FINDCHILDREN_PARAMS = ^TI_FINDCHILDREN_PARAMS;
  1433.   {$EXTERNALSYM PTI_FINDCHILDREN_PARAMS}
  1434.   _TI_FINDCHILDREN_PARAMS = record
  1435.     Count: ULONG;
  1436.     Start: ULONG;
  1437.     ChildId: array [0..0] of ULONG;
  1438.   end;
  1439.   {$EXTERNALSYM _TI_FINDCHILDREN_PARAMS}
  1440.   TI_FINDCHILDREN_PARAMS = _TI_FINDCHILDREN_PARAMS;
  1441.   {$EXTERNALSYM TI_FINDCHILDREN_PARAMS}
  1442.   TTiFindChildrenParams = TI_FINDCHILDREN_PARAMS;
  1443.   PTiFindChildrenParams = PTI_FINDCHILDREN_PARAMS;
  1444. function SymGetTypeInfo(hProcess: HANDLE; ModBase: DWORD64; TypeId: ULONG; GetType: IMAGEHLP_SYMBOL_TYPE_INFO; pInfo: PVOID): BOOL; stdcall;
  1445. {$EXTERNALSYM SymGetTypeInfo}
  1446. function SymEnumTypes(hProcess: HANDLE; BaseOfDll: ULONG64; EnumSymbolsCallback: PSYM_ENUMERATESYMBOLS_CALLBACK; UserContext: PVOID): BOOL; stdcall;
  1447. {$EXTERNALSYM SymEnumTypes}
  1448. function SymGetTypeFromName(hProcess: HANDLE; BaseOfDll: ULONG64; Name: LPSTR; Symbol: PSYMBOL_INFO): BOOL; stdcall;
  1449. {$EXTERNALSYM SymGetTypeFromName}
  1450. function SymAddSymbol(hProcess: HANDLE; BaseOfDll: ULONG64; Name: PCSTR; Address: DWORD64; Size, Flags: DWORD): BOOL; stdcall;
  1451. {$EXTERNALSYM SymAddSymbol}
  1452. function SymDeleteSymbol(hProcess: HANDLE; BaseOfDll: ULONG64; Name: PCSTR; Address: DWORD64; Flags: DWORD): BOOL; stdcall;
  1453. {$EXTERNALSYM SymDeleteSymbol}
  1454. //
  1455. // Full user-mode dump creation.
  1456. //
  1457. type
  1458.   PDBGHELP_CREATE_USER_DUMP_CALLBACK = function (DataType: DWORD; var Data: PVOID; DataLength: LPDWORD; UserData: PVOID): BOOL; stdcall;
  1459.   {$EXTERNALSYM PDBGHELP_CREATE_USER_DUMP_CALLBACK}
  1460.   PDbgHelpCreateUserDumpCallback = PDBGHELP_CREATE_USER_DUMP_CALLBACK;
  1461. function DbgHelpCreateUserDump(FileName: LPSTR; Callback: PDBGHELP_CREATE_USER_DUMP_CALLBACK; UserData: PVOID): BOOL; stdcall;
  1462. {$EXTERNALSYM DbgHelpCreateUserDump}
  1463. function DbgHelpCreateUserDumpW(FileName: LPWSTR; Callback: PDBGHELP_CREATE_USER_DUMP_CALLBACK; UserData: PVOID): BOOL; stdcall;
  1464. {$EXTERNALSYM DbgHelpCreateUserDumpW}
  1465. // -----------------------------------------------------------------
  1466. // The following 4 legacy APIs are fully supported, but newer
  1467. // ones are recommended.  SymFromName and SymFromAddr provide
  1468. // much more detailed info on the returned symbol.
  1469. function SymGetSymFromAddr64(hProcess: HANDLE; qwAddr: DWORD64; pdwDisplacement: PDWORD64; Symbol: PIMAGEHLP_SYMBOL64): BOOL; stdcall;
  1470. {$EXTERNALSYM SymGetSymFromAddr64}
  1471. function SymGetSymFromAddr(hProcess: HANDLE; dwAddr: DWORD; pdwDisplacement: PDWORD; Symbol: PIMAGEHLP_SYMBOL): BOOL; stdcall;
  1472. {$EXTERNALSYM SymGetSymFromAddr}
  1473. // While following two APIs will provide a symbol from a name,
  1474. // SymEnumSymbols can provide the same matching information
  1475. // for ALL symbols with a matching name, even regular
  1476. // expressions.  That way you can search across modules
  1477. // and differentiate between identically named symbols.
  1478. function SymGetSymFromName64(hProcess: HANDLE; Name: PSTR; Symbol: PIMAGEHLP_SYMBOL64): BOOL; stdcall;
  1479. {$EXTERNALSYM SymGetSymFromName64}
  1480. function SymGetSymFromName(hProcess: HANDLE; Name: PSTR; Symbol: PIMAGEHLP_SYMBOL): BOOL; stdcall;
  1481. {$EXTERNALSYM SymGetSymFromName}
  1482. // -----------------------------------------------------------------
  1483. // The following APIs exist only for backwards compatibility
  1484. // with a pre-release version documented in an MSDN release.
  1485. // You should use SymFindFileInPath if you want to maintain
  1486. // future compatibility.
  1487. function FindFileInPath(hprocess: HANDLE; SearchPath: LPSTR; FileName: LPSTR; id: PVOID; two: DWORD; three: DWORD; flags: DWORD; FilePath: LPSTR): BOOL; stdcall;
  1488. {$EXTERNALSYM FindFileInPath}
  1489. // You should use SymFindFileInPath if you want to maintain
  1490. // future compatibility.
  1491. function FindFileInSearchPath(hprocess: HANDLE; SearchPath: LPSTR; FileName: LPSTR; one: DWORD; two: DWORD; three: DWORD; FilePath: LPSTR): BOOL; stdcall;
  1492. {$EXTERNALSYM FindFileInSearchPath}
  1493. function SymEnumSym(hProcess: HANDLE; BaseOfDll: ULONG64; EnumSymbolsCallback: PSYM_ENUMERATESYMBOLS_CALLBACK; UserContext: PVOID): BOOL; stdcall;
  1494. {$EXTERNALSYM SymEnumSym}
  1495. // These values should not be used.
  1496. // They have been replaced by SYMFLAG_ values.
  1497. const
  1498.   SYMF_OMAP_GENERATED  = $00000001;
  1499.   SYMF_OMAP_MODIFIED   = $00000002;
  1500.   SYMF_REGISTER        = $00000008;
  1501.   SYMF_REGREL          = $00000010;
  1502.   SYMF_FRAMEREL        = $00000020;
  1503.   SYMF_PARAMETER       = $00000040;
  1504.   SYMF_LOCAL           = $00000080;
  1505.   SYMF_CONSTANT        = $00000100;
  1506.   SYMF_EXPORT          = $00000200;
  1507.   SYMF_FORWARDER       = $00000400;
  1508.   SYMF_FUNCTION        = $00000800;
  1509.   SYMF_VIRTUAL         = $00001000;
  1510.   SYMF_THUNK           = $00002000;
  1511.   SYMF_TLSREL          = $00004000;
  1512. // These values should also not be used.
  1513. // They have been replaced by SYMFLAG_ values.
  1514.   IMAGEHLP_SYMBOL_INFO_VALUEPRESENT         = 1;
  1515.   IMAGEHLP_SYMBOL_INFO_REGISTER             = SYMF_REGISTER;        // 0x0008
  1516.   IMAGEHLP_SYMBOL_INFO_REGRELATIVE          = SYMF_REGREL;          // 0x0010
  1517.   IMAGEHLP_SYMBOL_INFO_FRAMERELATIVE        = SYMF_FRAMEREL;        // 0x0020
  1518.   IMAGEHLP_SYMBOL_INFO_PARAMETER            = SYMF_PARAMETER;       // 0x0040
  1519.   IMAGEHLP_SYMBOL_INFO_LOCAL                = SYMF_LOCAL;           // 0x0080
  1520.   IMAGEHLP_SYMBOL_INFO_CONSTANT             = SYMF_CONSTANT;        // 0x0100
  1521.   IMAGEHLP_SYMBOL_FUNCTION                  = SYMF_FUNCTION;        // 0x0800
  1522.   IMAGEHLP_SYMBOL_VIRTUAL                   = SYMF_VIRTUAL;         // 0x1000
  1523.   IMAGEHLP_SYMBOL_THUNK                     = SYMF_THUNK;           // 0x2000
  1524.   IMAGEHLP_SYMBOL_INFO_TLSRELATIVE          = SYMF_TLSREL;          // 0x4000
  1525. const
  1526.   MINIDUMP_SIGNATURE = ('PMDM');
  1527.   {$EXTERNALSYM MINIDUMP_SIGNATURE}
  1528.   MINIDUMP_VERSION   = (42899);
  1529.   {$EXTERNALSYM MINIDUMP_VERSION}
  1530. type
  1531.   RVA = DWORD;
  1532.   {$EXTERNALSYM RVA}
  1533.   RVA64 = ULONG64;
  1534.   {$EXTERNALSYM RVA64}
  1535.   _MINIDUMP_LOCATION_DESCRIPTOR = record
  1536.     DataSize: ULONG32;
  1537.     Rva: RVA;
  1538.   end;
  1539.   {$EXTERNALSYM _MINIDUMP_LOCATION_DESCRIPTOR}
  1540.   MINIDUMP_LOCATION_DESCRIPTOR = _MINIDUMP_LOCATION_DESCRIPTOR;
  1541.   {$EXTERNALSYM MINIDUMP_LOCATION_DESCRIPTOR}
  1542.   TMinidumpLocationDescriptor = MINIDUMP_LOCATION_DESCRIPTOR;
  1543.   PMinidumpLocationDescriptor = ^MINIDUMP_LOCATION_DESCRIPTOR;
  1544.   _MINIDUMP_LOCATION_DESCRIPTOR64 = record
  1545.     DataSize: ULONG64;
  1546.     Rva: RVA64;
  1547.   end;
  1548.   {$EXTERNALSYM _MINIDUMP_LOCATION_DESCRIPTOR64}
  1549.   MINIDUMP_LOCATION_DESCRIPTOR64 = _MINIDUMP_LOCATION_DESCRIPTOR64;
  1550.   {$EXTERNALSYM MINIDUMP_LOCATION_DESCRIPTOR64}
  1551.   TMinidumpLocationDescriptor64 = MINIDUMP_LOCATION_DESCRIPTOR64;
  1552.   PMinidumpLocationDescriptor64 = ^MINIDUMP_LOCATION_DESCRIPTOR64;
  1553.   PMINIDUMP_MEMORY_DESCRIPTOR = ^MINIDUMP_MEMORY_DESCRIPTOR;
  1554.   {$EXTERNALSYM PMINIDUMP_MEMORY_DESCRIPTOR}
  1555.   _MINIDUMP_MEMORY_DESCRIPTOR = record
  1556.     StartOfMemoryRange: ULONG64;
  1557.     Memory: MINIDUMP_LOCATION_DESCRIPTOR;
  1558.   end;
  1559.   {$EXTERNALSYM _MINIDUMP_MEMORY_DESCRIPTOR}
  1560.   MINIDUMP_MEMORY_DESCRIPTOR = _MINIDUMP_MEMORY_DESCRIPTOR;
  1561.   {$EXTERNALSYM MINIDUMP_MEMORY_DESCRIPTOR}
  1562.   TMinidumpMemoryDescriptor = MINIDUMP_MEMORY_DESCRIPTOR;
  1563.   PMinidumpMemoryDescriptor = PMINIDUMP_MEMORY_DESCRIPTOR;
  1564. // DESCRIPTOR64 is used for full-memory minidumps where
  1565. // all of the raw memory is laid out sequentially at the
  1566. // end of the dump.  There is no need for individual RVAs
  1567. // as the RVA is the base RVA plus the sum of the preceeding
  1568. // data blocks.
  1569.   PMINIDUMP_MEMORY_DESCRIPTOR64 = ^MINIDUMP_MEMORY_DESCRIPTOR64;
  1570.   {$EXTERNALSYM PMINIDUMP_MEMORY_DESCRIPTOR64}
  1571.   _MINIDUMP_MEMORY_DESCRIPTOR64 = record
  1572.     StartOfMemoryRange: ULONG64;
  1573.     DataSize: ULONG64;
  1574.   end;
  1575.   {$EXTERNALSYM _MINIDUMP_MEMORY_DESCRIPTOR64}
  1576.   MINIDUMP_MEMORY_DESCRIPTOR64 = _MINIDUMP_MEMORY_DESCRIPTOR64;
  1577.   {$EXTERNALSYM MINIDUMP_MEMORY_DESCRIPTOR64}
  1578.   TMinidumpMemoryDescriptor64 = MINIDUMP_MEMORY_DESCRIPTOR64;
  1579.   PMinidumpMemoryDescriptor64 = PMINIDUMP_MEMORY_DESCRIPTOR64;
  1580.   PMINIDUMP_HEADER = ^MINIDUMP_HEADER;
  1581.   {$EXTERNALSYM PMINIDUMP_HEADER}
  1582.   _MINIDUMP_HEADER = record
  1583.     Signature: ULONG32;
  1584.     Version: ULONG32;
  1585.     NumberOfStreams: ULONG32;
  1586.     StreamDirectoryRva: RVA;
  1587.     CheckSum: ULONG32;
  1588.     U: record
  1589.     case Integer of
  1590.       0: (Reserved: ULONG32);
  1591.       1: (TimeDateStamp: ULONG32);
  1592.     end;
  1593.     Flags: ULONG64;
  1594.   end;
  1595.   {$EXTERNALSYM _MINIDUMP_HEADER}
  1596.   MINIDUMP_HEADER = _MINIDUMP_HEADER;
  1597.   {$EXTERNALSYM MINIDUMP_HEADER}
  1598.   TMinidumpHeader = MINIDUMP_HEADER;
  1599.   PMinidumpHeader = PMINIDUMP_HEADER;
  1600. //
  1601. // The MINIDUMP_HEADER field StreamDirectoryRva points to 
  1602. // an array of MINIDUMP_DIRECTORY structures.
  1603. //
  1604.   PMINIDUMP_DIRECTORY = ^MINIDUMP_DIRECTORY;
  1605.   {$EXTERNALSYM PMINIDUMP_DIRECTORY}
  1606.   _MINIDUMP_DIRECTORY = record
  1607.     StreamType: ULONG32;
  1608.     Location: MINIDUMP_LOCATION_DESCRIPTOR;
  1609.   end;
  1610.   {$EXTERNALSYM _MINIDUMP_DIRECTORY}
  1611.   MINIDUMP_DIRECTORY = _MINIDUMP_DIRECTORY;
  1612.   {$EXTERNALSYM MINIDUMP_DIRECTORY}
  1613.   TMinidumpDirectory = MINIDUMP_DIRECTORY;
  1614.   PMinidumpDirectory = PMINIDUMP_DIRECTORY;
  1615.   PMINIDUMP_STRING = ^MINIDUMP_STRING;
  1616.   {$EXTERNALSYM PMINIDUMP_STRING}
  1617.   _MINIDUMP_STRING = record
  1618.     Length: ULONG32; // Length in bytes of the string
  1619.     Buffer: PWCHAR; // Variable size buffer
  1620.   end;
  1621.   {$EXTERNALSYM _MINIDUMP_STRING}
  1622.   MINIDUMP_STRING = _MINIDUMP_STRING;
  1623.   {$EXTERNALSYM MINIDUMP_STRING}
  1624.   TMinidumpString = MINIDUMP_STRING;
  1625.   PMinidumpString = PMINIDUMP_STRING;
  1626. //
  1627. // The MINIDUMP_DIRECTORY field StreamType may be one of the following types.
  1628. // Types will be added in the future, so if a program reading the minidump
  1629. // header encounters a stream type it does not understand it should ignore
  1630. // the data altogether. Any tag above LastReservedStream will not be used by
  1631. // the system and is reserved for program-specific information.
  1632. //
  1633. const
  1634.   UnusedStream                = 0;
  1635.   {$EXTERNALSYM UnusedStream}
  1636.   ReservedStream0             = 1;
  1637.   {$EXTERNALSYM ReservedStream0}
  1638.   ReservedStream1             = 2;
  1639.   {$EXTERNALSYM ReservedStream1}
  1640.   ThreadListStream            = 3;
  1641.   {$EXTERNALSYM ThreadListStream}
  1642.   ModuleListStream            = 4;
  1643.   {$EXTERNALSYM ModuleListStream}
  1644.   MemoryListStream            = 5;
  1645.   {$EXTERNALSYM MemoryListStream}
  1646.   ExceptionStream             = 6;
  1647.   {$EXTERNALSYM ExceptionStream}
  1648.   SystemInfoStream            = 7;
  1649.   {$EXTERNALSYM SystemInfoStream}
  1650.   ThreadExListStream          = 8;
  1651.   {$EXTERNALSYM ThreadExListStream}
  1652.   Memory64ListStream          = 9;
  1653.   {$EXTERNALSYM Memory64ListStream}
  1654.   CommentStreamA              = 10;
  1655.   {$EXTERNALSYM CommentStreamA}
  1656.   CommentStreamW              = 11;
  1657.   {$EXTERNALSYM CommentStreamW}
  1658.   HandleDataStream            = 12;
  1659.   {$EXTERNALSYM HandleDataStream}
  1660.   FunctionTableStream         = 13;
  1661.   {$EXTERNALSYM FunctionTableStream}
  1662.   UnloadedModuleListStream   = 14;
  1663.   {$EXTERNALSYM UnloadedModuleListStream}
  1664.   MiscInfoStream             = 15;
  1665.   {$EXTERNALSYM MiscInfoStream}
  1666.   LastReservedStream          = $ffff;
  1667.   {$EXTERNALSYM LastReservedStream}
  1668. type
  1669.   _MINIDUMP_STREAM_TYPE = DWORD;
  1670.   {$EXTERNALSYM MINIDUMP_STREAM_TYPE}
  1671.   MINIDUMP_STREAM_TYPE = _MINIDUMP_STREAM_TYPE;
  1672.   {$EXTERNALSYM _MINIDUMP_STREAM_TYPE}
  1673.   TMinidumpStreamType = MINIDUMP_STREAM_TYPE;
  1674. //
  1675. // The minidump system information contains processor and
  1676. // Operating System specific information.
  1677. //
  1678. type
  1679.   _CPU_INFORMATION = record
  1680.     case Integer of
  1681.         //
  1682.         // X86 platforms use CPUID function to obtain processor information.
  1683.         //
  1684.         0: (
  1685.           //
  1686.           // CPUID Subfunction 0, register EAX (VendorId [0]),
  1687.           // EBX (VendorId [1]) and ECX (VendorId [2]).
  1688.           //
  1689.           VendorId: array [0..2] of ULONG32;
  1690.           //
  1691.           // CPUID Subfunction 1, register EAX
  1692.           //
  1693.           VersionInformation: ULONG32;
  1694.           //
  1695.           // CPUID Subfunction 1, register EDX
  1696.           //
  1697.           FeatureInformation: ULONG32;
  1698.           //
  1699.           // CPUID, Subfunction 80000001, register EBX. This will only
  1700.           // be obtained if the vendor id is "AuthenticAMD".
  1701.           //
  1702.           AMDExtendedCpuFeatures: ULONG32);
  1703.         //
  1704.         // Non-x86 platforms use processor feature flags.
  1705.         //
  1706.         1: (
  1707.           ProcessorFeatures: array [0..1] of ULONG64);
  1708.     end;
  1709.   _MINIDUMP_SYSTEM_INFO = record
  1710.     //
  1711.     // ProcessorArchitecture, ProcessorLevel and ProcessorRevision are all
  1712.     // taken from the SYSTEM_INFO structure obtained by GetSystemInfo( ).
  1713.     //
  1714.     ProcessorArchitecture: USHORT;
  1715.     ProcessorLevel: USHORT;
  1716.     ProcessorRevision: USHORT;
  1717.     U: record
  1718.     case Integer of
  1719.       0: (Reserved0: USHORT);
  1720.       1: (
  1721.         NumberOfProcessors: UCHAR;
  1722.         ProductType: UCHAR);
  1723.     end;
  1724.     //
  1725.     // MajorVersion, MinorVersion, BuildNumber, PlatformId and
  1726.     // CSDVersion are all taken from the OSVERSIONINFO structure
  1727.     // returned by GetVersionEx( ).
  1728.     //
  1729.     MajorVersion: ULONG32;
  1730.     MinorVersion: ULONG32;
  1731.     BuildNumber: ULONG32;
  1732.     PlatformId: ULONG32;
  1733.     //
  1734.     // RVA to a CSDVersion string in the string table.
  1735.     //
  1736.     CSDVersionRva: RVA;
  1737.     U2: record
  1738.     case Integer of
  1739.       0: (Reserved1: ULONG32);
  1740.       1: (
  1741.         SuiteMask: USHORT;
  1742.         Reserved2: USHORT);
  1743.     end;
  1744.     
  1745.     //
  1746.     // CPU information is obtained from one of two places.
  1747.     //
  1748.     //  1) On x86 computers, CPU_INFORMATION is obtained from the CPUID
  1749.     //     instruction. You must use the X86 portion of the union for X86
  1750.     //     computers.
  1751.     //
  1752.     //  2) On non-x86 architectures, CPU_INFORMATION is obtained by calling
  1753.     //     IsProcessorFeatureSupported().
  1754.     //
  1755.     Cpu: _CPU_INFORMATION;
  1756.   end;
  1757.   {$EXTERNALSYM _MINIDUMP_SYSTEM_INFO}
  1758.   MINIDUMP_SYSTEM_INFO = _MINIDUMP_SYSTEM_INFO;
  1759.   {$EXTERNALSYM MINIDUMP_SYSTEM_INFO}
  1760.   PMINIDUMP_SYSTEM_INFO = ^MINIDUMP_SYSTEM_INFO;
  1761.   {$EXTERNALSYM PMINIDUMP_SYSTEM_INFO}
  1762.   TMinidumpSystemInfo = MINIDUMP_SYSTEM_INFO;
  1763.   PMinidumpSystemInfo = PMINIDUMP_SYSTEM_INFO;
  1764.   CPU_INFORMATION = _CPU_INFORMATION;
  1765.   {$EXTERNALSYM CPU_INFORMATION}
  1766.   PCPU_INFORMATION = CPU_INFORMATION;
  1767.   {$EXTERNALSYM PCPU_INFORMATION}
  1768. //
  1769. // The minidump thread contains standard thread
  1770. // information plus an RVA to the memory for this 
  1771. // thread and an RVA to the CONTEXT structure for
  1772. // this thread.
  1773. //
  1774. //
  1775. // ThreadId must be 4 bytes on all architectures.
  1776. //
  1777. // C_ASSERT (sizeof ( ((PPROCESS_INFORMATION)0)->dwThreadId ) == 4);
  1778. type
  1779.   PMINIDUMP_THREAD = ^MINIDUMP_THREAD;
  1780.   {$EXTERNALSYM PMINIDUMP_THREAD}
  1781.   _MINIDUMP_THREAD = record
  1782.     ThreadId: ULONG32;
  1783.     SuspendCount: ULONG32;
  1784.     PriorityClass: ULONG32;
  1785.     Priority: ULONG32;
  1786.     Teb: ULONG64;
  1787.     Stack: MINIDUMP_MEMORY_DESCRIPTOR;
  1788.     ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR;
  1789.   end;
  1790.   {$EXTERNALSYM _MINIDUMP_THREAD}
  1791.   MINIDUMP_THREAD = _MINIDUMP_THREAD;
  1792.   {$EXTERNALSYM MINIDUMP_THREAD}
  1793.   TMinidumpThread = MINIDUMP_THREAD;
  1794.   PMinidumpThread = PMINIDUMP_THREAD;
  1795. //
  1796. // The thread list is a container of threads.
  1797. //
  1798.   PMINIDUMP_THREAD_LIST = ^MINIDUMP_THREAD_LIST;
  1799.   {$EXTERNALSYM PMINIDUMP_THREAD_LIST}
  1800.   _MINIDUMP_THREAD_LIST = record
  1801.     NumberOfThreads: ULONG32;
  1802.     Threads: array [0..0] of MINIDUMP_THREAD;
  1803.   end;
  1804.   {$EXTERNALSYM _MINIDUMP_THREAD_LIST}
  1805.   MINIDUMP_THREAD_LIST = _MINIDUMP_THREAD_LIST;
  1806.   {$EXTERNALSYM MINIDUMP_THREAD_LIST}
  1807.   TMinidumpThreadList = MINIDUMP_THREAD_LIST;
  1808.   PMinidumpThreadList = PMINIDUMP_THREAD_LIST;
  1809.   PMINIDUMP_THREAD_EX = ^MINIDUMP_THREAD_EX;
  1810.   {$EXTERNALSYM PMINIDUMP_THREAD_EX}
  1811.   _MINIDUMP_THREAD_EX = record
  1812.     ThreadId: ULONG32;
  1813.     SuspendCount: ULONG32;
  1814.     PriorityClass: ULONG32;
  1815.     Priority: ULONG32;
  1816.     Teb: ULONG64;
  1817.     Stack: MINIDUMP_MEMORY_DESCRIPTOR;
  1818.     ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR;
  1819.     BackingStore: MINIDUMP_MEMORY_DESCRIPTOR;
  1820.   end;
  1821.   {$EXTERNALSYM _MINIDUMP_THREAD_EX}
  1822.   MINIDUMP_THREAD_EX = _MINIDUMP_THREAD_EX;
  1823.   {$EXTERNALSYM MINIDUMP_THREAD_EX}
  1824.   TMinidumpThreadEx = MINIDUMP_THREAD_EX;
  1825.   PMinidumpThreadEx = PMINIDUMP_THREAD_EX;
  1826. //
  1827. // The thread list is a container of threads.
  1828. //
  1829.   PMINIDUMP_THREAD_EX_LIST = ^MINIDUMP_THREAD_EX_LIST;
  1830.   {$EXTERNALSYM PMINIDUMP_THREAD_EX_LIST}
  1831.   _MINIDUMP_THREAD_EX_LIST = record
  1832.     NumberOfThreads: ULONG32;
  1833.     Threads: array [0..0] of MINIDUMP_THREAD_EX;
  1834.   end;
  1835.   {$EXTERNALSYM _MINIDUMP_THREAD_EX_LIST}
  1836.   MINIDUMP_THREAD_EX_LIST = _MINIDUMP_THREAD_EX_LIST;
  1837.   {$EXTERNALSYM MINIDUMP_THREAD_EX_LIST}
  1838.   TMinidumpThreadExList = MINIDUMP_THREAD_EX_LIST;
  1839.   PMinidumpThreadExList = PMINIDUMP_THREAD_EX_LIST;
  1840. //
  1841. // The MINIDUMP_EXCEPTION is the same as EXCEPTION on Win64.
  1842. //
  1843.   PMINIDUMP_EXCEPTION = ^MINIDUMP_EXCEPTION;
  1844.   {$EXTERNALSYM PMINIDUMP_EXCEPTION}
  1845.   _MINIDUMP_EXCEPTION = record
  1846.     ExceptionCode: ULONG32;
  1847.     ExceptionFlags: ULONG32;
  1848.     ExceptionRecord: ULONG64;
  1849.     ExceptionAddress: ULONG64;
  1850.     NumberParameters: ULONG32;
  1851.     __unusedAlignment: ULONG32;
  1852.     ExceptionInformation: array [0..EXCEPTION_MAXIMUM_PARAMETERS - 1] of ULONG64;
  1853.   end;
  1854.   {$EXTERNALSYM _MINIDUMP_EXCEPTION}
  1855.   MINIDUMP_EXCEPTION = _MINIDUMP_EXCEPTION;
  1856.   {$EXTERNALSYM MINIDUMP_EXCEPTION}
  1857.   TMinidumpException = MINIDUMP_EXCEPTION;
  1858.   PMinidumpException = PMINIDUMP_EXCEPTION;
  1859. //
  1860. // The exception information stream contains the id of the thread that caused
  1861. // the exception (ThreadId), the exception record for the exception
  1862. // (ExceptionRecord) and an RVA to the thread context where the exception
  1863. // occured.
  1864. //
  1865.   PMINIDUMP_EXCEPTION_STREAM = ^MINIDUMP_EXCEPTION_STREAM;
  1866.   {$EXTERNALSYM PMINIDUMP_EXCEPTION_STREAM}
  1867.   _MINIDUMP_EXCEPTION_STREAM = record
  1868.     ThreadId: ULONG32;
  1869.     __alignment: ULONG32;
  1870.     ExceptionRecord: MINIDUMP_EXCEPTION;
  1871.     ThreadContext: MINIDUMP_LOCATION_DESCRIPTOR;
  1872.   end;
  1873.   {$EXTERNALSYM _MINIDUMP_EXCEPTION_STREAM}
  1874.   MINIDUMP_EXCEPTION_STREAM = _MINIDUMP_EXCEPTION_STREAM;
  1875.   {$EXTERNALSYM MINIDUMP_EXCEPTION_STREAM}
  1876.   TMinidumpExceptionStream = MINIDUMP_EXCEPTION_STREAM;
  1877.   PMinidumpExceptionStream = PMINIDUMP_EXCEPTION_STREAM;
  1878. //
  1879. // The MINIDUMP_MODULE contains information about a
  1880. // a specific module. It includes the CheckSum and
  1881. // the TimeDateStamp for the module so the module
  1882. // can be reloaded during the analysis phase.
  1883. //
  1884.   PMINIDUMP_MODULE = ^MINIDUMP_MODULE;
  1885.   {$EXTERNALSYM PMINIDUMP_MODULE}
  1886.   _MINIDUMP_MODULE = record
  1887.     BaseOfImage: ULONG64;
  1888.     SizeOfImage: ULONG32;
  1889.     CheckSum: ULONG32;
  1890.     TimeDateStamp: ULONG32;
  1891.     ModuleNameRva: RVA;
  1892.     VersionInfo: VS_FIXEDFILEINFO;
  1893.     CvRecord: MINIDUMP_LOCATION_DESCRIPTOR;
  1894.     MiscRecord: MINIDUMP_LOCATION_DESCRIPTOR;
  1895.     Reserved0: ULONG64; // Reserved for future use.
  1896.     Reserved1: ULONG64; // Reserved for future use.
  1897.   end;
  1898.   {$EXTERNALSYM _MINIDUMP_MODULE}
  1899.   MINIDUMP_MODULE = _MINIDUMP_MODULE;
  1900.   {$EXTERNALSYM MINIDUMP_MODULE}
  1901.   TMinidumpModule = MINIDUMP_MODULE;
  1902.   PMinidumpModule = PMINIDUMP_MODULE;
  1903. //
  1904. // The minidump module list is a container for modules.
  1905. //
  1906.   PMINIDUMP_MODULE_LIST = ^MINIDUMP_MODULE_LIST;
  1907.   {$EXTERNALSYM PMINIDUMP_MODULE_LIST}
  1908.   _MINIDUMP_MODULE_LIST = record
  1909.     NumberOfModules: ULONG32;
  1910.     Modules: array [0..0] of MINIDUMP_MODULE;
  1911.   end;
  1912.   {$EXTERNALSYM _MINIDUMP_MODULE_LIST}
  1913.   MINIDUMP_MODULE_LIST = _MINIDUMP_MODULE_LIST;
  1914.   {$EXTERNALSYM MINIDUMP_MODULE_LIST}
  1915.   TMinidumpModuleList = MINIDUMP_MODULE_LIST;
  1916.   PMinidumpModuleList = PMINIDUMP_MODULE_LIST;
  1917. //
  1918. // Memory Ranges
  1919. //
  1920.   PMINIDUMP_MEMORY_LIST = ^MINIDUMP_MEMORY_LIST;
  1921.   {$EXTERNALSYM PMINIDUMP_MEMORY_LIST}
  1922.   _MINIDUMP_MEMORY_LIST = record
  1923.     NumberOfMemoryRanges: ULONG32;
  1924.     MemoryRanges: array [0..0] of MINIDUMP_MEMORY_DESCRIPTOR;
  1925.   end;
  1926.   {$EXTERNALSYM _MINIDUMP_MEMORY_LIST}
  1927.   MINIDUMP_MEMORY_LIST = _MINIDUMP_MEMORY_LIST;
  1928.   {$EXTERNALSYM MINIDUMP_MEMORY_LIST}
  1929.   TMinidumpMemoryList = MINIDUMP_MEMORY_LIST;
  1930.   PMinidumpMemoryList = PMINIDUMP_MEMORY_LIST;
  1931.   PMINIDUMP_MEMORY64_LIST = ^MINIDUMP_MEMORY64_LIST;
  1932.   {$EXTERNALSYM PMINIDUMP_MEMORY64_LIST}
  1933.   _MINIDUMP_MEMORY64_LIST = record
  1934.     NumberOfMemoryRanges: ULONG64;
  1935.     BaseRva: RVA64;
  1936.     MemoryRanges: array [0..0] of MINIDUMP_MEMORY_DESCRIPTOR64;
  1937.   end;
  1938.   {$EXTERNALSYM _MINIDUMP_MEMORY64_LIST}
  1939.   MINIDUMP_MEMORY64_LIST = _MINIDUMP_MEMORY64_LIST;
  1940.   {$EXTERNALSYM MINIDUMP_MEMORY64_LIST}
  1941.   TMinidumpMemory64List = MINIDUMP_MEMORY64_LIST;
  1942.   PMinidumpMemory64List = PMINIDUMP_MEMORY64_LIST;
  1943. //
  1944. // Support for user supplied exception information.
  1945. //
  1946.   PMINIDUMP_EXCEPTION_INFORMATION = ^MINIDUMP_EXCEPTION_INFORMATION;
  1947.   {$EXTERNALSYM PMINIDUMP_EXCEPTION_INFORMATION}
  1948.   _MINIDUMP_EXCEPTION_INFORMATION = record
  1949.     ThreadId: DWORD;
  1950.     ExceptionPointers: PEXCEPTION_POINTERS;
  1951.     ClientPointers: BOOL;
  1952.   end;
  1953.   {$EXTERNALSYM _MINIDUMP_EXCEPTION_INFORMATION}
  1954.   MINIDUMP_EXCEPTION_INFORMATION = _MINIDUMP_EXCEPTION_INFORMATION;
  1955.   {$EXTERNALSYM MINIDUMP_EXCEPTION_INFORMATION}
  1956.   TMinidumpExceptionInformation = MINIDUMP_EXCEPTION_INFORMATION;
  1957.   PMinidumpExceptionInformation = PMINIDUMP_EXCEPTION_INFORMATION;
  1958. //
  1959. // Support for capturing system handle state at the time of the dump.
  1960. //
  1961.   PMINIDUMP_HANDLE_DESCRIPTOR = ^MINIDUMP_HANDLE_DESCRIPTOR;
  1962.   {$EXTERNALSYM PMINIDUMP_HANDLE_DESCRIPTOR}
  1963.   _MINIDUMP_HANDLE_DESCRIPTOR = record
  1964.     Handle: ULONG64;
  1965.     TypeNameRva: RVA;
  1966.     ObjectNameRva: RVA;
  1967.     Attributes: ULONG32;
  1968.     GrantedAccess: ULONG32;
  1969.     HandleCount: ULONG32;
  1970.     PointerCount: ULONG32;
  1971.   end;
  1972.   {$EXTERNALSYM _MINIDUMP_HANDLE_DESCRIPTOR}
  1973.   MINIDUMP_HANDLE_DESCRIPTOR = _MINIDUMP_HANDLE_DESCRIPTOR;
  1974.   {$EXTERNALSYM MINIDUMP_HANDLE_DESCRIPTOR}
  1975.   TMinidumpHandleDescriptor = MINIDUMP_HANDLE_DESCRIPTOR;
  1976.   PMinidumpHandleDescriptor = PMINIDUMP_HANDLE_DESCRIPTOR;
  1977.   PMINIDUMP_HANDLE_DATA_STREAM = ^MINIDUMP_HANDLE_DATA_STREAM;
  1978.   {$EXTERNALSYM PMINIDUMP_HANDLE_DATA_STREAM}
  1979.   _MINIDUMP_HANDLE_DATA_STREAM = record
  1980.     SizeOfHeader: ULONG32;
  1981.     SizeOfDescriptor: ULONG32;
  1982.     NumberOfDescriptors: ULONG32;
  1983.     Reserved: ULONG32;
  1984.   end;
  1985.   {$EXTERNALSYM _MINIDUMP_HANDLE_DATA_STREAM}
  1986.   MINIDUMP_HANDLE_DATA_STREAM = _MINIDUMP_HANDLE_DATA_STREAM;
  1987.   {$EXTERNALSYM MINIDUMP_HANDLE_DATA_STREAM}
  1988.   TMinidumpHandleDataStream = MINIDUMP_HANDLE_DATA_STREAM;
  1989.   PMinidumpHandleDataStream = PMINIDUMP_HANDLE_DATA_STREAM;
  1990. //
  1991. // Support for capturing dynamic function table state at the time of the dump.
  1992. //
  1993.   PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR = ^MINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
  1994.   {$EXTERNALSYM PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR}
  1995.   _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR = record
  1996.     MinimumAddress: ULONG64;
  1997.     MaximumAddress: ULONG64;
  1998.     BaseAddress: ULONG64;
  1999.     EntryCount: ULONG32;
  2000.     SizeOfAlignPad: ULONG32;
  2001.   end;
  2002.   {$EXTERNALSYM _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR}
  2003.   MINIDUMP_FUNCTION_TABLE_DESCRIPTOR = _MINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
  2004.   {$EXTERNALSYM MINIDUMP_FUNCTION_TABLE_DESCRIPTOR}
  2005.   TMinidumpFunctionTableDescriptor = MINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
  2006.   PMinidumpFunctionTableDescriptor = PMINIDUMP_FUNCTION_TABLE_DESCRIPTOR;
  2007.   PMINIDUMP_FUNCTION_TABLE_STREAM = ^MINIDUMP_FUNCTION_TABLE_STREAM;
  2008.   {$EXTERNALSYM PMINIDUMP_FUNCTION_TABLE_STREAM}
  2009.   _MINIDUMP_FUNCTION_TABLE_STREAM = record
  2010.     SizeOfHeader: ULONG32;
  2011.     SizeOfDescriptor: ULONG32;
  2012.     SizeOfNativeDescriptor: ULONG32;
  2013.     SizeOfFunctionEntry: ULONG32;
  2014.     NumberOfDescriptors: ULONG32;
  2015.     SizeOfAlignPad: ULONG32;
  2016.   end;
  2017.   {$EXTERNALSYM _MINIDUMP_FUNCTION_TABLE_STREAM}
  2018.   MINIDUMP_FUNCTION_TABLE_STREAM = _MINIDUMP_FUNCTION_TABLE_STREAM;
  2019.   {$EXTERNALSYM MINIDUMP_FUNCTION_TABLE_STREAM}
  2020.   TMinidumpFunctionTableStream = MINIDUMP_FUNCTION_TABLE_STREAM;
  2021.   PMinidumpFunctionTableStream = PMINIDUMP_FUNCTION_TABLE_STREAM;
  2022. //
  2023. // The MINIDUMP_UNLOADED_MODULE contains information about a
  2024. // a specific module that was previously loaded but no
  2025. // longer is.  This can help with diagnosing problems where
  2026. // callers attempt to call code that is no longer loaded.
  2027. //
  2028.   _MINIDUMP_UNLOADED_MODULE = record
  2029.     BaseOfImage: ULONG64;
  2030.     SizeOfImage: ULONG32;
  2031.     CheckSum: ULONG32;
  2032.     TimeDateStamp: ULONG32;
  2033.     ModuleNameRva: RVA;
  2034.   end;
  2035.   {$EXTERNALSYM _MINIDUMP_UNLOADED_MODULE}
  2036.   MINIDUMP_UNLOADED_MODULE = _MINIDUMP_UNLOADED_MODULE;
  2037.   {$EXTERNALSYM MINIDUMP_UNLOADED_MODULE}
  2038.   PMINIDUMP_UNLOADED_MODULE = ^MINIDUMP_UNLOADED_MODULE;
  2039.   {$EXTERNALSYM PMINIDUMP_UNLOADED_MODULE}
  2040.   TMiniDumpUnloadedModule = MINIDUMP_UNLOADED_MODULE;
  2041.   PMiniDumpUnloadedModule = PMINIDUMP_UNLOADED_MODULE;
  2042. //
  2043. // The minidump unloaded module list is a container for unloaded modules.
  2044. //
  2045.   _MINIDUMP_UNLOADED_MODULE_LIST = record
  2046.     SizeOfHeader: ULONG32;
  2047.     SizeOfEntry: ULONG32;
  2048.     NumberOfEntries: ULONG32;
  2049.   end;
  2050.   {$EXTERNALSYM _MINIDUMP_UNLOADED_MODULE_LIST}
  2051.   MINIDUMP_UNLOADED_MODULE_LIST = _MINIDUMP_UNLOADED_MODULE_LIST;
  2052.   {$EXTERNALSYM MINIDUMP_UNLOADED_MODULE_LIST}
  2053.   PMINIDUMP_UNLOADED_MODULE_LIST = ^MINIDUMP_UNLOADED_MODULE_LIST;
  2054.   {$EXTERNALSYM PMINIDUMP_UNLOADED_MODULE_LIST}
  2055.   TMiniDumpUnloadedModuleList = MINIDUMP_UNLOADED_MODULE_LIST;
  2056.   PMiniDumpUnloadedModuleList = PMINIDUMP_UNLOADED_MODULE_LIST;
  2057. //
  2058. // The miscellaneous information stream contains a variety
  2059. // of small pieces of information.  A member is valid if
  2060. // it's within the available size and its corresponding
  2061. // bit is set.