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

Windows编程

开发平台:

Delphi

  1.   TImgLineNoType = record
  2.     case Integer of
  3.       0: (SymbolTableIndex: DWORD);               // Symbol table index of function name if Linenumber is 0.
  4.       1: (VirtualAddress: DWORD);                 // Virtual address of line number.
  5.   end;
  6.   PIMAGE_LINENUMBER = ^IMAGE_LINENUMBER;
  7.   {$EXTERNALSYM PIMAGE_LINENUMBER}
  8.   _IMAGE_LINENUMBER = record
  9.     Type_: TImgLineNoType;
  10.     Linenumber: WORD;                         // Line number.
  11.   end;
  12.   {$EXTERNALSYM _IMAGE_LINENUMBER}
  13.   IMAGE_LINENUMBER = _IMAGE_LINENUMBER;
  14.   {$EXTERNALSYM IMAGE_LINENUMBER}
  15.   TImageLineNumber = IMAGE_LINENUMBER;
  16.   PImageLineNumber = PIMAGE_LINENUMBER;
  17. const
  18.   IMAGE_SIZEOF_LINENUMBER = 6;
  19.   {$EXTERNALSYM IMAGE_SIZEOF_LINENUMBER}
  20. // #include "poppack.h"                        // Back to 4 byte packing
  21. //
  22. // Based relocation format.
  23. //
  24. type
  25.   PIMAGE_BASE_RELOCATION = ^IMAGE_BASE_RELOCATION;
  26.   {$EXTERNALSYM PIMAGE_BASE_RELOCATION}
  27.   _IMAGE_BASE_RELOCATION = record
  28.     VirtualAddress: DWORD;
  29.     SizeOfBlock: DWORD;
  30.     //  WORD    TypeOffset[1];
  31.   end;
  32.   {$EXTERNALSYM _IMAGE_BASE_RELOCATION}
  33.   IMAGE_BASE_RELOCATION = _IMAGE_BASE_RELOCATION;
  34.   {$EXTERNALSYM IMAGE_BASE_RELOCATION}
  35.   TImageBaseRelocation = IMAGE_BASE_RELOCATION;
  36.   PImageBaseRelocation = PIMAGE_BASE_RELOCATION;
  37. const
  38.   IMAGE_SIZEOF_BASE_RELOCATION = 8;
  39.   {$EXTERNALSYM IMAGE_SIZEOF_BASE_RELOCATION}
  40. //
  41. // Based relocation types.
  42. //
  43.   IMAGE_REL_BASED_ABSOLUTE     = 0;
  44.   {$EXTERNALSYM IMAGE_REL_BASED_ABSOLUTE}
  45.   IMAGE_REL_BASED_HIGH         = 1;
  46.   {$EXTERNALSYM IMAGE_REL_BASED_HIGH}
  47.   IMAGE_REL_BASED_LOW          = 2;
  48.   {$EXTERNALSYM IMAGE_REL_BASED_LOW}
  49.   IMAGE_REL_BASED_HIGHLOW      = 3;
  50.   {$EXTERNALSYM IMAGE_REL_BASED_HIGHLOW}
  51.   IMAGE_REL_BASED_HIGHADJ      = 4;
  52.   {$EXTERNALSYM IMAGE_REL_BASED_HIGHADJ}
  53.   IMAGE_REL_BASED_MIPS_JMPADDR = 5;
  54.   {$EXTERNALSYM IMAGE_REL_BASED_MIPS_JMPADDR}
  55.   IMAGE_REL_BASED_MIPS_JMPADDR16 = 9;
  56.   {$EXTERNALSYM IMAGE_REL_BASED_MIPS_JMPADDR16}
  57.   IMAGE_REL_BASED_IA64_IMM64     = 9;
  58.   {$EXTERNALSYM IMAGE_REL_BASED_IA64_IMM64}
  59.   IMAGE_REL_BASED_DIR64          = 10;
  60.   {$EXTERNALSYM IMAGE_REL_BASED_DIR64}
  61. //
  62. // Archive format.
  63. //
  64.   IMAGE_ARCHIVE_START_SIZE       = 8;
  65.   {$EXTERNALSYM IMAGE_ARCHIVE_START_SIZE}
  66.   IMAGE_ARCHIVE_START            = '!<arch>n';
  67.   {$EXTERNALSYM IMAGE_ARCHIVE_START}
  68.   IMAGE_ARCHIVE_END              = '`n';
  69.   {$EXTERNALSYM IMAGE_ARCHIVE_END}
  70.   IMAGE_ARCHIVE_PAD              = 'n';
  71.   {$EXTERNALSYM IMAGE_ARCHIVE_PAD}
  72.   IMAGE_ARCHIVE_LINKER_MEMBER    = '/               ';
  73.   {$EXTERNALSYM IMAGE_ARCHIVE_LINKER_MEMBER}
  74.   IMAGE_ARCHIVE_LONGNAMES_MEMBER = '//              ';
  75.   {$EXTERNALSYM IMAGE_ARCHIVE_LONGNAMES_MEMBER}
  76. type
  77.   PIMAGE_ARCHIVE_MEMBER_HEADER = ^IMAGE_ARCHIVE_MEMBER_HEADER;
  78.   {$EXTERNALSYM PIMAGE_ARCHIVE_MEMBER_HEADER}
  79.   _IMAGE_ARCHIVE_MEMBER_HEADER = record
  80.     Name: array [0..15] of Byte; // File member name - `/' terminated.
  81.     Date: array [0..11] of Byte; // File member date - decimal.
  82.     UserID: array [0..5] of Byte; // File member user id - decimal.
  83.     GroupID: array [0..5] of Byte; // File member group id - decimal.
  84.     Mode: array [0..7] of Byte; // File member mode - octal.
  85.     Size: array [0..9] of Byte; // File member size - decimal.
  86.     EndHeader: array [0..1] of Byte; // String to end header.
  87.   end;
  88.   {$EXTERNALSYM _IMAGE_ARCHIVE_MEMBER_HEADER}
  89.   IMAGE_ARCHIVE_MEMBER_HEADER = _IMAGE_ARCHIVE_MEMBER_HEADER;
  90.   {$EXTERNALSYM IMAGE_ARCHIVE_MEMBER_HEADER}
  91.   TImageArchiveMemberHeader = IMAGE_ARCHIVE_MEMBER_HEADER;
  92.   PImageArchiveMemberHeader = PIMAGE_ARCHIVE_MEMBER_HEADER;
  93. const
  94.   IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR = 60;
  95.   {$EXTERNALSYM IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR}
  96. //
  97. // DLL support.
  98. //
  99. //
  100. // Export Format
  101. //
  102. type
  103.   PIMAGE_EXPORT_DIRECTORY = ^IMAGE_EXPORT_DIRECTORY;
  104.   {$EXTERNALSYM PIMAGE_EXPORT_DIRECTORY}
  105.   _IMAGE_EXPORT_DIRECTORY = record
  106.     Characteristics: DWORD;
  107.     TimeDateStamp: DWORD;
  108.     MajorVersion: Word;
  109.     MinorVersion: Word;
  110.     Name: DWORD;
  111.     Base: DWORD;
  112.     NumberOfFunctions: DWORD;
  113.     NumberOfNames: DWORD;
  114.     AddressOfFunctions: DWORD; // RVA from base of image
  115.     AddressOfNames: DWORD; // RVA from base of image
  116.     AddressOfNameOrdinals: DWORD; // RVA from base of image
  117.   end;
  118.   {$EXTERNALSYM _IMAGE_EXPORT_DIRECTORY}
  119.   IMAGE_EXPORT_DIRECTORY = _IMAGE_EXPORT_DIRECTORY;
  120.   {$EXTERNALSYM IMAGE_EXPORT_DIRECTORY}
  121.   TImageExportDirectory = IMAGE_EXPORT_DIRECTORY;
  122.   PImageExportDirectory = PIMAGE_EXPORT_DIRECTORY;
  123. //
  124. // Import Format
  125. //
  126.   PIMAGE_IMPORT_BY_NAME = ^IMAGE_IMPORT_BY_NAME;
  127.   {$EXTERNALSYM PIMAGE_IMPORT_BY_NAME}
  128.   _IMAGE_IMPORT_BY_NAME = record
  129.     Hint: Word;
  130.     Name: array [0..0] of Byte;
  131.   end;
  132.   {$EXTERNALSYM _IMAGE_IMPORT_BY_NAME}
  133.   IMAGE_IMPORT_BY_NAME = _IMAGE_IMPORT_BY_NAME;
  134.   {$EXTERNALSYM IMAGE_IMPORT_BY_NAME}
  135.   TImageImportByName = IMAGE_IMPORT_BY_NAME;
  136.   PImageImportByName = PIMAGE_IMPORT_BY_NAME;
  137. // #include "pshpack8.h"                       // Use align 8 for the 64-bit IAT.
  138.   PIMAGE_THUNK_DATA64 = ^IMAGE_THUNK_DATA64;
  139.   {$EXTERNALSYM PIMAGE_THUNK_DATA64}
  140.   _IMAGE_THUNK_DATA64 = record
  141.     case Integer of
  142.       0: (ForwarderString: ULONGLONG);   // PBYTE
  143.       1: (Function_: ULONGLONG);         // PDWORD
  144.       2: (Ordinal: ULONGLONG);
  145.       3: (AddressOfData: ULONGLONG);     // PIMAGE_IMPORT_BY_NAME
  146.   end;
  147.   {$EXTERNALSYM _IMAGE_THUNK_DATA64}
  148.   IMAGE_THUNK_DATA64 = _IMAGE_THUNK_DATA64;
  149.   {$EXTERNALSYM IMAGE_THUNK_DATA64}
  150.   TImageThunkData64 = IMAGE_THUNK_DATA64;
  151.   PImageThunkData64 = PIMAGE_THUNK_DATA64;
  152. // #include "poppack.h"                        // Back to 4 byte packing
  153.   PIMAGE_THUNK_DATA32 = ^IMAGE_THUNK_DATA32;
  154.   {$EXTERNALSYM PIMAGE_THUNK_DATA32}
  155.   _IMAGE_THUNK_DATA32 = record
  156.     case Integer of
  157.       0: (ForwarderString: DWORD);   // PBYTE
  158.       1: (Function_: DWORD);         // PDWORD
  159.       2: (Ordinal: DWORD);
  160.       3: (AddressOfData: DWORD);     // PIMAGE_IMPORT_BY_NAME
  161.   end;
  162.   {$EXTERNALSYM _IMAGE_THUNK_DATA32}
  163.   IMAGE_THUNK_DATA32 = _IMAGE_THUNK_DATA32;
  164.   {$EXTERNALSYM IMAGE_THUNK_DATA32}
  165.   TImageThunkData32 = IMAGE_THUNK_DATA32;
  166.   PImageThunkData32 = PIMAGE_THUNK_DATA32;
  167. const
  168.   IMAGE_ORDINAL_FLAG64 = ULONGLONG($8000000000000000);
  169.   {$EXTERNALSYM IMAGE_ORDINAL_FLAG64}
  170.   IMAGE_ORDINAL_FLAG32 = DWORD($80000000);
  171.   {$EXTERNALSYM IMAGE_ORDINAL_FLAG32}
  172. function IMAGE_ORDINAL64(Ordinal: ULONGLONG): ULONGLONG;
  173. {$EXTERNALSYM IMAGE_ORDINAL64}
  174. function IMAGE_ORDINAL32(Ordinal: DWORD): DWORD;
  175. {$EXTERNALSYM IMAGE_ORDINAL32}
  176. function IMAGE_SNAP_BY_ORDINAL64(Ordinal: ULONGLONG): Boolean;
  177. {$EXTERNALSYM IMAGE_SNAP_BY_ORDINAL64}
  178. function IMAGE_SNAP_BY_ORDINAL32(Ordinal: DWORD): Boolean;
  179. {$EXTERNALSYM IMAGE_SNAP_BY_ORDINAL32}
  180. //
  181. // Thread Local Storage
  182. //
  183. type
  184.   PIMAGE_TLS_CALLBACK = procedure (DllHandle: Pointer; Reason: DWORD; Reserved: Pointer); stdcall;
  185.   {$EXTERNALSYM PIMAGE_TLS_CALLBACK}
  186.   TImageTlsCallback = PIMAGE_TLS_CALLBACK;
  187.   PIMAGE_TLS_DIRECTORY64 = ^IMAGE_TLS_DIRECTORY64;
  188.   {$EXTERNALSYM PIMAGE_TLS_DIRECTORY64}
  189.   _IMAGE_TLS_DIRECTORY64 = record
  190.     StartAddressOfRawData: ULONGLONG;
  191.     EndAddressOfRawData: ULONGLONG;
  192.     AddressOfIndex: ULONGLONG;         // PDWORD
  193.     AddressOfCallBacks: ULONGLONG;     // PIMAGE_TLS_CALLBACK *;
  194.     SizeOfZeroFill: DWORD;
  195.     Characteristics: DWORD;
  196.   end;
  197.   {$EXTERNALSYM _IMAGE_TLS_DIRECTORY64}
  198.   IMAGE_TLS_DIRECTORY64 = _IMAGE_TLS_DIRECTORY64;
  199.   {$EXTERNALSYM IMAGE_TLS_DIRECTORY64}
  200.   TImageTlsDirectory64 = IMAGE_TLS_DIRECTORY64;
  201.   PImageTlsDirectory64 = PIMAGE_TLS_DIRECTORY64;
  202.   PIMAGE_TLS_DIRECTORY32 = ^IMAGE_TLS_DIRECTORY32;
  203.   {$EXTERNALSYM PIMAGE_TLS_DIRECTORY32}
  204.   _IMAGE_TLS_DIRECTORY32 = record
  205.     StartAddressOfRawData: DWORD;
  206.     EndAddressOfRawData: DWORD;
  207.     AddressOfIndex: DWORD;             // PDWORD
  208.     AddressOfCallBacks: DWORD;         // PIMAGE_TLS_CALLBACK *
  209.     SizeOfZeroFill: DWORD;
  210.     Characteristics: DWORD;
  211.   end;
  212.   {$EXTERNALSYM _IMAGE_TLS_DIRECTORY32}
  213.   IMAGE_TLS_DIRECTORY32 = _IMAGE_TLS_DIRECTORY32;
  214.   {$EXTERNALSYM IMAGE_TLS_DIRECTORY32}
  215.   TImageTlsDirectory32 = IMAGE_TLS_DIRECTORY32;
  216.   PImageTlsDirectory32 = PIMAGE_TLS_DIRECTORY32;
  217. const
  218.   IMAGE_ORDINAL_FLAG = IMAGE_ORDINAL_FLAG32;
  219.   {$EXTERNALSYM IMAGE_ORDINAL_FLAG}
  220. function IMAGE_ORDINAL(Ordinal: DWORD): DWORD;
  221. type
  222.   IMAGE_THUNK_DATA = IMAGE_THUNK_DATA32;
  223.   {$EXTERNALSYM IMAGE_THUNK_DATA}
  224.   PIMAGE_THUNK_DATA = PIMAGE_THUNK_DATA32;
  225.   {$EXTERNALSYM PIMAGE_THUNK_DATA}
  226.   TImageThunkData = TImageThunkData32;
  227.   PImageThunkData = PImageThunkData32;
  228. function IMAGE_SNAP_BY_ORDINAL(Ordinal: DWORD): Boolean;
  229. {$EXTERNALSYM IMAGE_SNAP_BY_ORDINAL}
  230. type
  231.   IMAGE_TLS_DIRECTORY = IMAGE_TLS_DIRECTORY32;
  232.   {$EXTERNALSYM IMAGE_TLS_DIRECTORY}
  233.   PIMAGE_TLS_DIRECTORY = PIMAGE_TLS_DIRECTORY32;
  234.   {$EXTERNALSYM PIMAGE_TLS_DIRECTORY}
  235.   TImageTlsDirectory = TImageTlsDirectory32;
  236.   PImageTlsDirectory = PImageTlsDirectory32;
  237.   TIIDUnion = record
  238.     case Integer of
  239.       0: (Characteristics: DWORD);         // 0 for terminating null import descriptor
  240.       1: (OriginalFirstThunk: DWORD);      // RVA to original unbound IAT (PIMAGE_THUNK_DATA)
  241.   end;
  242.   PIMAGE_IMPORT_DESCRIPTOR = ^IMAGE_IMPORT_DESCRIPTOR;
  243.   {$EXTERNALSYM PIMAGE_IMPORT_DESCRIPTOR}
  244.   _IMAGE_IMPORT_DESCRIPTOR = record
  245.     Union: TIIDUnion;
  246.     TimeDateStamp: DWORD;                  // 0 if not bound,
  247.                                            // -1 if bound, and real datetime stamp
  248.                                            //     in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND)
  249.                                            // O.W. date/time stamp of DLL bound to (Old BIND)
  250.     ForwarderChain: DWORD;                 // -1 if no forwarders
  251.     Name: DWORD;
  252.     FirstThunk: DWORD;                     // RVA to IAT (if bound this IAT has actual addresses)
  253.   end;
  254.   {$EXTERNALSYM _IMAGE_IMPORT_DESCRIPTOR}
  255.   IMAGE_IMPORT_DESCRIPTOR = _IMAGE_IMPORT_DESCRIPTOR;
  256.   {$EXTERNALSYM IMAGE_IMPORT_DESCRIPTOR}
  257.   TImageImportDecriptor = IMAGE_IMPORT_DESCRIPTOR;
  258.   PImageImportDecriptor = PIMAGE_IMPORT_DESCRIPTOR;
  259. //
  260. // New format import descriptors pointed to by DataDirectory[ IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT ]
  261. //
  262. type
  263.   PIMAGE_BOUND_IMPORT_DESCRIPTOR = ^IMAGE_BOUND_IMPORT_DESCRIPTOR;
  264.   {$EXTERNALSYM PIMAGE_BOUND_IMPORT_DESCRIPTOR}
  265.   _IMAGE_BOUND_IMPORT_DESCRIPTOR = record
  266.     TimeDateStamp: DWORD;
  267.     OffsetModuleName: Word;
  268.     NumberOfModuleForwarderRefs: Word;
  269.     // Array of zero or more IMAGE_BOUND_FORWARDER_REF follows
  270.   end;
  271.   {$EXTERNALSYM _IMAGE_BOUND_IMPORT_DESCRIPTOR}
  272.   IMAGE_BOUND_IMPORT_DESCRIPTOR = _IMAGE_BOUND_IMPORT_DESCRIPTOR;
  273.   {$EXTERNALSYM IMAGE_BOUND_IMPORT_DESCRIPTOR}
  274.   TImageBoundImportDescriptor = IMAGE_BOUND_IMPORT_DESCRIPTOR;
  275.   PImageBoundImportDescriptor = PIMAGE_BOUND_IMPORT_DESCRIPTOR;
  276.   PIMAGE_BOUND_FORWARDER_REF = ^IMAGE_BOUND_FORWARDER_REF;
  277.   {$EXTERNALSYM PIMAGE_BOUND_FORWARDER_REF}
  278.   _IMAGE_BOUND_FORWARDER_REF = record
  279.     TimeDateStamp: DWORD;
  280.     OffsetModuleName: Word;
  281.     Reserved: Word;
  282.   end;
  283.   {$EXTERNALSYM _IMAGE_BOUND_FORWARDER_REF}
  284.   IMAGE_BOUND_FORWARDER_REF = _IMAGE_BOUND_FORWARDER_REF;
  285.   {$EXTERNALSYM IMAGE_BOUND_FORWARDER_REF}
  286.   TImageBoundForwarderRef = IMAGE_BOUND_FORWARDER_REF;
  287.   PImageBoundForwarderRef = PIMAGE_BOUND_FORWARDER_REF;
  288. //
  289. // Resource Format.
  290. //
  291. //
  292. // Resource directory consists of two counts, following by a variable length
  293. // array of directory entries.  The first count is the number of entries at
  294. // beginning of the array that have actual names associated with each entry.
  295. // The entries are in ascending order, case insensitive strings.  The second
  296. // count is the number of entries that immediately follow the named entries.
  297. // This second count identifies the number of entries that have 16-bit integer
  298. // Ids as their name.  These entries are also sorted in ascending order.
  299. //
  300. // This structure allows fast lookup by either name or number, but for any
  301. // given resource entry only one form of lookup is supported, not both.
  302. // This is consistant with the syntax of the .RC file and the .RES file.
  303. //
  304.   PIMAGE_RESOURCE_DIRECTORY = ^IMAGE_RESOURCE_DIRECTORY;
  305.   {$EXTERNALSYM PIMAGE_RESOURCE_DIRECTORY}
  306.   _IMAGE_RESOURCE_DIRECTORY = record
  307.     Characteristics: DWORD;
  308.     TimeDateStamp: DWORD;
  309.     MajorVersion: Word;
  310.     MinorVersion: Word;
  311.     NumberOfNamedEntries: Word;
  312.     NumberOfIdEntries: Word;
  313.     // IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
  314.   end;
  315.   {$EXTERNALSYM _IMAGE_RESOURCE_DIRECTORY}
  316.   IMAGE_RESOURCE_DIRECTORY = _IMAGE_RESOURCE_DIRECTORY;
  317.   {$EXTERNALSYM IMAGE_RESOURCE_DIRECTORY}
  318.   TImageResourceDirectory = IMAGE_RESOURCE_DIRECTORY;
  319.   PImageResourceDirectory = PIMAGE_RESOURCE_DIRECTORY;
  320. const
  321.   IMAGE_RESOURCE_NAME_IS_STRING    = DWORD($80000000);
  322.   {$EXTERNALSYM IMAGE_RESOURCE_NAME_IS_STRING}
  323.   IMAGE_RESOURCE_DATA_IS_DIRECTORY = DWORD($80000000);
  324.   {$EXTERNALSYM IMAGE_RESOURCE_DATA_IS_DIRECTORY}
  325. //
  326. // Each directory contains the 32-bit Name of the entry and an offset,
  327. // relative to the beginning of the resource directory of the data associated
  328. // with this directory entry.  If the name of the entry is an actual text
  329. // string instead of an integer Id, then the high order bit of the name field
  330. // is set to one and the low order 31-bits are an offset, relative to the
  331. // beginning of the resource directory of the string, which is of type
  332. // IMAGE_RESOURCE_DIRECTORY_STRING.  Otherwise the high bit is clear and the
  333. // low-order 16-bits are the integer Id that identify this resource directory
  334. // entry. If the directory entry is yet another resource directory (i.e. a
  335. // subdirectory), then the high order bit of the offset field will be
  336. // set to indicate this.  Otherwise the high bit is clear and the offset
  337. // field points to a resource data entry.
  338. //
  339. type
  340.   TIRDEName = record
  341.     case Integer of
  342.       0: (
  343.         NameOffset: DWORD); // 0..30: NameOffset; 31: NameIsString
  344.       1: (
  345.         Name: DWORD);
  346.       2: (
  347.         Id: WORD);
  348.   end;
  349.   TIRDEDirectory = record
  350.     case Integer of
  351.       0: (
  352.         OffsetToData: DWORD);
  353.       1: (
  354.         OffsetToDirectory: DWORD); // 0..30: OffsetToDirectory; 31: DataIsDirectory
  355.   end;
  356.   PIMAGE_RESOURCE_DIRECTORY_ENTRY = ^IMAGE_RESOURCE_DIRECTORY_ENTRY;
  357.   {$EXTERNALSYM PIMAGE_RESOURCE_DIRECTORY_ENTRY}
  358.   _IMAGE_RESOURCE_DIRECTORY_ENTRY = record
  359.     Name: TIRDEName;
  360.     Directory: TIRDEDirectory;
  361.   end;
  362.   {$EXTERNALSYM _IMAGE_RESOURCE_DIRECTORY_ENTRY}
  363.   IMAGE_RESOURCE_DIRECTORY_ENTRY = _IMAGE_RESOURCE_DIRECTORY_ENTRY;
  364.   {$EXTERNALSYM IMAGE_RESOURCE_DIRECTORY_ENTRY}
  365.   TImageResourceDirectoryEntry = IMAGE_RESOURCE_DIRECTORY_ENTRY;
  366.   PImageResourceDirectoryEntry = PIMAGE_RESOURCE_DIRECTORY_ENTRY;
  367. //
  368. // For resource directory entries that have actual string names, the Name
  369. // field of the directory entry points to an object of the following type.
  370. // All of these string objects are stored together after the last resource
  371. // directory entry and before the first resource data object.  This minimizes
  372. // the impact of these variable length objects on the alignment of the fixed
  373. // size directory entry objects.
  374. //
  375. type
  376.   PIMAGE_RESOURCE_DIRECTORY_STRING = ^IMAGE_RESOURCE_DIRECTORY_STRING;
  377.   {$EXTERNALSYM PIMAGE_RESOURCE_DIRECTORY_STRING}
  378.   _IMAGE_RESOURCE_DIRECTORY_STRING = record
  379.     Length: Word;
  380.     NameString: array [0..0] of CHAR;
  381.   end;
  382.   {$EXTERNALSYM _IMAGE_RESOURCE_DIRECTORY_STRING}
  383.   IMAGE_RESOURCE_DIRECTORY_STRING = _IMAGE_RESOURCE_DIRECTORY_STRING;
  384.   {$EXTERNALSYM IMAGE_RESOURCE_DIRECTORY_STRING}
  385.   TImageResourceDirectoryString = IMAGE_RESOURCE_DIRECTORY_STRING;
  386.   PImageResourceDirectoryString = PIMAGE_RESOURCE_DIRECTORY_STRING;
  387.   PIMAGE_RESOURCE_DIR_STRING_U = ^IMAGE_RESOURCE_DIR_STRING_U;
  388.   {$EXTERNALSYM PIMAGE_RESOURCE_DIR_STRING_U}
  389.   _IMAGE_RESOURCE_DIR_STRING_U = record
  390.     Length: Word;
  391.     NameString: array [0..0] of WCHAR;
  392.   end;
  393.   {$EXTERNALSYM _IMAGE_RESOURCE_DIR_STRING_U}
  394.   IMAGE_RESOURCE_DIR_STRING_U = _IMAGE_RESOURCE_DIR_STRING_U;
  395.   {$EXTERNALSYM IMAGE_RESOURCE_DIR_STRING_U}
  396.   TImageResourceDirStringU = IMAGE_RESOURCE_DIR_STRING_U;
  397.   PImageResourceDirStringU = PIMAGE_RESOURCE_DIR_STRING_U;
  398. //
  399. // Each resource data entry describes a leaf node in the resource directory
  400. // tree.  It contains an offset, relative to the beginning of the resource
  401. // directory of the data for the resource, a size field that gives the number
  402. // of bytes of data at that offset, a CodePage that should be used when
  403. // decoding code point values within the resource data.  Typically for new
  404. // applications the code page would be the unicode code page.
  405. //
  406.   PIMAGE_RESOURCE_DATA_ENTRY = ^IMAGE_RESOURCE_DATA_ENTRY;
  407.   {$EXTERNALSYM PIMAGE_RESOURCE_DATA_ENTRY}
  408.   _IMAGE_RESOURCE_DATA_ENTRY = record
  409.     OffsetToData: DWORD;
  410.     Size: DWORD;
  411.     CodePage: DWORD;
  412.     Reserved: DWORD;
  413.   end;
  414.   {$EXTERNALSYM _IMAGE_RESOURCE_DATA_ENTRY}
  415.   IMAGE_RESOURCE_DATA_ENTRY = _IMAGE_RESOURCE_DATA_ENTRY;
  416.   {$EXTERNALSYM IMAGE_RESOURCE_DATA_ENTRY}
  417.   TImageResourceDataEntry = IMAGE_RESOURCE_DATA_ENTRY;
  418.   PImageResourceDataEntry = PIMAGE_RESOURCE_DATA_ENTRY;
  419. //
  420. // Load Configuration Directory Entry
  421. //
  422. type
  423.   PIMAGE_LOAD_CONFIG_DIRECTORY32 = ^IMAGE_LOAD_CONFIG_DIRECTORY32;
  424.   {$EXTERNALSYM PIMAGE_LOAD_CONFIG_DIRECTORY32}
  425.   IMAGE_LOAD_CONFIG_DIRECTORY32 = record
  426.     Characteristics: DWORD;
  427.     TimeDateStamp: DWORD;
  428.     MajorVersion: WORD;
  429.     MinorVersion: WORD;
  430.     GlobalFlagsClear: DWORD;
  431.     GlobalFlagsSet: DWORD;
  432.     CriticalSectionDefaultTimeout: DWORD;
  433.     DeCommitFreeBlockThreshold: DWORD;
  434.     DeCommitTotalFreeThreshold: DWORD;
  435.     LockPrefixTable: DWORD;            // VA
  436.     MaximumAllocationSize: DWORD;
  437.     VirtualMemoryThreshold: DWORD;
  438.     ProcessHeapFlags: DWORD;
  439.     ProcessAffinityMask: DWORD;
  440.     CSDVersion: WORD;
  441.     Reserved1: WORD;
  442.     EditList: DWORD;                   // VA
  443.     Reserved: array [0..0] of DWORD;
  444.   end;
  445.   {$EXTERNALSYM IMAGE_LOAD_CONFIG_DIRECTORY32}
  446.   TImageLoadConfigDirectory32 = IMAGE_LOAD_CONFIG_DIRECTORY32;
  447.   PImageLoadConfigDirectory32 = PIMAGE_LOAD_CONFIG_DIRECTORY32;
  448.   PIMAGE_LOAD_CONFIG_DIRECTORY64 = ^IMAGE_LOAD_CONFIG_DIRECTORY64;
  449.   {$EXTERNALSYM PIMAGE_LOAD_CONFIG_DIRECTORY64}
  450.   IMAGE_LOAD_CONFIG_DIRECTORY64 = record
  451.     Characteristics: DWORD;
  452.     TimeDateStamp: DWORD;
  453.     MajorVersion: WORD;
  454.     MinorVersion: WORD;
  455.     GlobalFlagsClear: DWORD;
  456.     GlobalFlagsSet: DWORD;
  457.     CriticalSectionDefaultTimeout: DWORD;
  458.     DeCommitFreeBlockThreshold: ULONGLONG;
  459.     DeCommitTotalFreeThreshold: ULONGLONG;
  460.     LockPrefixTable: ULONGLONG;         // VA
  461.     MaximumAllocationSize: ULONGLONG;
  462.     VirtualMemoryThreshold: ULONGLONG;
  463.     ProcessAffinityMask: ULONGLONG;
  464.     ProcessHeapFlags: DWORD;
  465.     CSDVersion: WORD;
  466.     Reserved1: WORD;
  467.     EditList: ULONGLONG;                // VA
  468.     Reserved: array [0..1] of DWORD;
  469.   end;
  470.   {$EXTERNALSYM IMAGE_LOAD_CONFIG_DIRECTORY64}
  471.   TImageLoadConfigDirectory64 = IMAGE_LOAD_CONFIG_DIRECTORY64;
  472.   PImageLoadConfigDirectory64 = PIMAGE_LOAD_CONFIG_DIRECTORY64;
  473.   IMAGE_LOAD_CONFIG_DIRECTORY = IMAGE_LOAD_CONFIG_DIRECTORY32;
  474.   {$EXTERNALSYM IMAGE_LOAD_CONFIG_DIRECTORY}
  475.   PIMAGE_LOAD_CONFIG_DIRECTORY = PIMAGE_LOAD_CONFIG_DIRECTORY32;
  476.   {$EXTERNALSYM PIMAGE_LOAD_CONFIG_DIRECTORY}
  477.   TImageLoadConfigDirectory = TImageLoadConfigDirectory32;
  478.   PImageLoadConfigDirectory = PImageLoadConfigDirectory32;
  479. //
  480. // WIN CE Exception table format
  481. //
  482. //
  483. // Function table entry format.  Function table is pointed to by the
  484. // IMAGE_DIRECTORY_ENTRY_EXCEPTION directory entry.
  485. //
  486. type
  487.   PIMAGE_CE_RUNTIME_FUNCTION_ENTRY = ^IMAGE_CE_RUNTIME_FUNCTION_ENTRY;
  488.   {$EXTERNALSYM PIMAGE_CE_RUNTIME_FUNCTION_ENTRY}
  489.   _IMAGE_CE_RUNTIME_FUNCTION_ENTRY = record
  490.     FuncStart: DWORD;
  491.     Flags: DWORD;
  492.     //DWORD PrologLen : 8;
  493.     //DWORD FuncLen : 22;
  494.     //DWORD ThirtyTwoBit : 1;
  495.     //DWORD ExceptionFlag : 1;
  496.   end;
  497.   {$EXTERNALSYM _IMAGE_CE_RUNTIME_FUNCTION_ENTRY}
  498.   IMAGE_CE_RUNTIME_FUNCTION_ENTRY = _IMAGE_CE_RUNTIME_FUNCTION_ENTRY;
  499.   {$EXTERNALSYM IMAGE_CE_RUNTIME_FUNCTION_ENTRY}
  500.   TImageCERuntimeFunctionEntry = IMAGE_CE_RUNTIME_FUNCTION_ENTRY;
  501.   PImageCERuntimeFunctionEntry = PIMAGE_CE_RUNTIME_FUNCTION_ENTRY;
  502. //
  503. // Debug Format
  504. //
  505. type
  506.   PIMAGE_DEBUG_DIRECTORY = ^IMAGE_DEBUG_DIRECTORY;
  507.   {$EXTERNALSYM PIMAGE_DEBUG_DIRECTORY}
  508.   _IMAGE_DEBUG_DIRECTORY = record
  509.     Characteristics: DWORD;
  510.     TimeDateStamp: DWORD;
  511.     MajorVersion: Word;
  512.     MinorVersion: Word;
  513.     Type_: DWORD;
  514.     SizeOfData: DWORD;
  515.     AddressOfRawData: DWORD;
  516.     PointerToRawData: DWORD;
  517.   end;
  518.   {$EXTERNALSYM _IMAGE_DEBUG_DIRECTORY}
  519.   IMAGE_DEBUG_DIRECTORY = _IMAGE_DEBUG_DIRECTORY;
  520.   {$EXTERNALSYM IMAGE_DEBUG_DIRECTORY}
  521.   TImageDebugDirectory = IMAGE_DEBUG_DIRECTORY;
  522.   PImageDebugDirectory = PIMAGE_DEBUG_DIRECTORY;
  523. const
  524.   IMAGE_DEBUG_TYPE_UNKNOWN       = 0;
  525.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_UNKNOWN}
  526.   IMAGE_DEBUG_TYPE_COFF          = 1;
  527.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_COFF}
  528.   IMAGE_DEBUG_TYPE_CODEVIEW      = 2;
  529.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_CODEVIEW}
  530.   IMAGE_DEBUG_TYPE_FPO           = 3;
  531.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_FPO}
  532.   IMAGE_DEBUG_TYPE_MISC          = 4;
  533.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_MISC}
  534.   IMAGE_DEBUG_TYPE_EXCEPTION     = 5;
  535.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_EXCEPTION}
  536.   IMAGE_DEBUG_TYPE_FIXUP         = 6;
  537.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_FIXUP}
  538.   IMAGE_DEBUG_TYPE_OMAP_TO_SRC   = 7;
  539.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_OMAP_TO_SRC}
  540.   IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8;
  541.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_OMAP_FROM_SRC}
  542.   IMAGE_DEBUG_TYPE_BORLAND       = 9;
  543.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_BORLAND}
  544.   IMAGE_DEBUG_TYPE_RESERVED10    = 10;
  545.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_RESERVED10}
  546.   IMAGE_DEBUG_TYPE_CLSID         = 11;
  547.   {$EXTERNALSYM IMAGE_DEBUG_TYPE_CLSID}
  548. type
  549.   PIMAGE_COFF_SYMBOLS_HEADER = ^IMAGE_COFF_SYMBOLS_HEADER;
  550.   {$EXTERNALSYM PIMAGE_COFF_SYMBOLS_HEADER}
  551.   _IMAGE_COFF_SYMBOLS_HEADER = record
  552.     NumberOfSymbols: DWORD;
  553.     LvaToFirstSymbol: DWORD;
  554.     NumberOfLinenumbers: DWORD;
  555.     LvaToFirstLinenumber: DWORD;
  556.     RvaToFirstByteOfCode: DWORD;
  557.     RvaToLastByteOfCode: DWORD;
  558.     RvaToFirstByteOfData: DWORD;
  559.     RvaToLastByteOfData: DWORD;
  560.   end;
  561.   {$EXTERNALSYM _IMAGE_COFF_SYMBOLS_HEADER}
  562.   IMAGE_COFF_SYMBOLS_HEADER = _IMAGE_COFF_SYMBOLS_HEADER;
  563.   {$EXTERNALSYM IMAGE_COFF_SYMBOLS_HEADER}
  564.   TImageCoffSymbolsHeader = IMAGE_COFF_SYMBOLS_HEADER;
  565.   PImageCoffSymbolsHeader = PIMAGE_COFF_SYMBOLS_HEADER;
  566. const
  567.   FRAME_FPO    = 0;
  568.   {$EXTERNALSYM FRAME_FPO}
  569.   FRAME_TRAP   = 1;
  570.   {$EXTERNALSYM FRAME_TRAP}
  571.   FRAME_TSS    = 2;
  572.   {$EXTERNALSYM FRAME_TSS}
  573.   FRAME_NONFPO = 3;
  574.   {$EXTERNALSYM FRAME_NONFPO}
  575.   FPOFLAGS_PROLOG   = $00FF; // # bytes in prolog
  576.   FPOFLAGS_REGS     = $0700; // # regs saved
  577.   FPOFLAGS_HAS_SEH  = $0800; // TRUE if SEH in func
  578.   FPOFLAGS_USE_BP   = $1000; // TRUE if EBP has been allocated
  579.   FPOFLAGS_RESERVED = $2000; // reserved for future use
  580.   FPOFLAGS_FRAME    = $C000; // frame type
  581. type
  582.   PFPO_DATA = ^FPO_DATA;
  583.   {$EXTERNALSYM PFPO_DATA}
  584.   _FPO_DATA = record
  585.     ulOffStart: DWORD;       // offset 1st byte of function code
  586.     cbProcSize: DWORD;       // # bytes in function
  587.     cdwLocals: DWORD;        // # bytes in locals/4
  588.     cdwParams: WORD;         // # bytes in params/4
  589.     Flags: WORD;
  590.   end;
  591.   {$EXTERNALSYM _FPO_DATA}
  592.   FPO_DATA = _FPO_DATA;
  593.   {$EXTERNALSYM FPO_DATA}
  594.   TFpoData = FPO_DATA;
  595.   PFpoData = PFPO_DATA;
  596. const
  597.   SIZEOF_RFPO_DATA = 16;
  598.   {$EXTERNALSYM SIZEOF_RFPO_DATA}
  599.   IMAGE_DEBUG_MISC_EXENAME = 1;
  600.   {$EXTERNALSYM IMAGE_DEBUG_MISC_EXENAME}
  601. type
  602.   PIMAGE_DEBUG_MISC = ^IMAGE_DEBUG_MISC;
  603.   {$EXTERNALSYM PIMAGE_DEBUG_MISC}
  604.   _IMAGE_DEBUG_MISC = record
  605.     DataType: DWORD;   // type of misc data, see defines
  606.     Length: DWORD;     // total length of record, rounded to four byte multiple.
  607.     Unicode: ByteBool; // TRUE if data is unicode string
  608.     Reserved: array [0..2] of Byte;
  609.     Data: array [0..0] of Byte; // Actual data
  610.   end;
  611.   {$EXTERNALSYM _IMAGE_DEBUG_MISC}
  612.   IMAGE_DEBUG_MISC = _IMAGE_DEBUG_MISC;
  613.   {$EXTERNALSYM IMAGE_DEBUG_MISC}
  614.   TImageDebugMisc = IMAGE_DEBUG_MISC;
  615.   PImageDebugMisc = PIMAGE_DEBUG_MISC;
  616. //
  617. // Function table extracted from MIPS/ALPHA/IA64 images.  Does not contain
  618. // information needed only for runtime support.  Just those fields for
  619. // each entry needed by a debugger.
  620. //
  621.   PIMAGE_FUNCTION_ENTRY = ^IMAGE_FUNCTION_ENTRY;
  622.   {$EXTERNALSYM PIMAGE_FUNCTION_ENTRY}
  623.   _IMAGE_FUNCTION_ENTRY = record
  624.     StartingAddress: DWORD;
  625.     EndingAddress: DWORD;
  626.     EndOfPrologue: DWORD;
  627.   end;
  628.   {$EXTERNALSYM _IMAGE_FUNCTION_ENTRY}
  629.   IMAGE_FUNCTION_ENTRY = _IMAGE_FUNCTION_ENTRY;
  630.   {$EXTERNALSYM IMAGE_FUNCTION_ENTRY}
  631.   TImageFunctionEntry = IMAGE_FUNCTION_ENTRY;
  632.   PImageFunctionEntry = PIMAGE_FUNCTION_ENTRY;
  633.   PIMAGE_FUNCTION_ENTRY64 = ^IMAGE_FUNCTION_ENTRY64;
  634.   {$EXTERNALSYM PIMAGE_FUNCTION_ENTRY64}
  635.   _IMAGE_FUNCTION_ENTRY64 = record
  636.     StartingAddress: ULONGLONG;
  637.     EndingAddress: ULONGLONG;
  638.     case Integer of
  639.       0: (EndOfPrologue: ULONGLONG);
  640.       1: (UnwindInfoAddress: ULONGLONG);
  641.   end;
  642.   {$EXTERNALSYM _IMAGE_FUNCTION_ENTRY64}
  643.   IMAGE_FUNCTION_ENTRY64 = _IMAGE_FUNCTION_ENTRY64;
  644.   {$EXTERNALSYM IMAGE_FUNCTION_ENTRY64}
  645.   TImageFunctionEntry64 = IMAGE_FUNCTION_ENTRY64;
  646.   PImageFunctionEntry64 = PIMAGE_FUNCTION_ENTRY64;
  647. //
  648. // Debugging information can be stripped from an image file and placed
  649. // in a separate .DBG file, whose file name part is the same as the
  650. // image file name part (e.g. symbols for CMD.EXE could be stripped
  651. // and placed in CMD.DBG).  This is indicated by the IMAGE_FILE_DEBUG_STRIPPED
  652. // flag in the Characteristics field of the file header.  The beginning of
  653. // the .DBG file contains the following structure which captures certain
  654. // information from the image file.  This allows a debug to proceed even if
  655. // the original image file is not accessable.  This header is followed by
  656. // zero of more IMAGE_SECTION_HEADER structures, followed by zero or more
  657. // IMAGE_DEBUG_DIRECTORY structures.  The latter structures and those in
  658. // the image file contain file offsets relative to the beginning of the
  659. // .DBG file.
  660. //
  661. // If symbols have been stripped from an image, the IMAGE_DEBUG_MISC structure
  662. // is left in the image file, but not mapped.  This allows a debugger to
  663. // compute the name of the .DBG file, from the name of the image in the
  664. // IMAGE_DEBUG_MISC structure.
  665. //
  666.   PIMAGE_SEPARATE_DEBUG_HEADER = ^IMAGE_SEPARATE_DEBUG_HEADER;
  667.   {$EXTERNALSYM PIMAGE_SEPARATE_DEBUG_HEADER}
  668.   _IMAGE_SEPARATE_DEBUG_HEADER = record
  669.     Signature: Word;
  670.     Flags: Word;
  671.     Machine: Word;
  672.     Characteristics: Word;
  673.     TimeDateStamp: DWORD;
  674.     CheckSum: DWORD;
  675.     ImageBase: DWORD;
  676.     SizeOfImage: DWORD;
  677.     NumberOfSections: DWORD;
  678.     ExportedNamesSize: DWORD;
  679.     DebugDirectorySize: DWORD;
  680.     SectionAlignment: DWORD;
  681.     Reserved: array [0..1] of DWORD;
  682.   end;
  683.   {$EXTERNALSYM _IMAGE_SEPARATE_DEBUG_HEADER}
  684.   IMAGE_SEPARATE_DEBUG_HEADER = _IMAGE_SEPARATE_DEBUG_HEADER;
  685.   {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_HEADER}
  686.   TImageSeparateDebugHeader = IMAGE_SEPARATE_DEBUG_HEADER;
  687.   PImageSeparateDebugHeader = PIMAGE_SEPARATE_DEBUG_HEADER;
  688.   _NON_PAGED_DEBUG_INFO = record
  689.     Signature: WORD;
  690.     Flags: WORD;
  691.     Size: DWORD;
  692.     Machine: WORD;
  693.     Characteristics: WORD;
  694.     TimeDateStamp: DWORD;
  695.     CheckSum: DWORD;
  696.     SizeOfImage: DWORD;
  697.     ImageBase: ULONGLONG;
  698.     //DebugDirectorySize
  699.     //IMAGE_DEBUG_DIRECTORY
  700.   end;
  701.   {$EXTERNALSYM _NON_PAGED_DEBUG_INFO}
  702.   NON_PAGED_DEBUG_INFO = _NON_PAGED_DEBUG_INFO;
  703.   {$EXTERNALSYM NON_PAGED_DEBUG_INFO}
  704.   PNON_PAGED_DEBUG_INFO = ^NON_PAGED_DEBUG_INFO;
  705.   {$EXTERNALSYM PNON_PAGED_DEBUG_INFO}
  706. const
  707.   IMAGE_SEPARATE_DEBUG_SIGNATURE = $4944;
  708.   {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_SIGNATURE}
  709.   NON_PAGED_DEBUG_SIGNATURE      = $494E;
  710.   {$EXTERNALSYM NON_PAGED_DEBUG_SIGNATURE}
  711.   IMAGE_SEPARATE_DEBUG_FLAGS_MASK = $8000;
  712.   {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_FLAGS_MASK}
  713.   IMAGE_SEPARATE_DEBUG_MISMATCH   = $8000; // when DBG was updated, the old checksum didn't match.
  714.   {$EXTERNALSYM IMAGE_SEPARATE_DEBUG_MISMATCH}
  715. //
  716. //  The .arch section is made up of headers, each describing an amask position/value
  717. //  pointing to an array of IMAGE_ARCHITECTURE_ENTRY's.  Each "array" (both the header
  718. //  and entry arrays) are terminiated by a quadword of 0xffffffffL.
  719. //
  720. //  NOTE: There may be quadwords of 0 sprinkled around and must be skipped.
  721. //
  722. const
  723.   IAHMASK_VALUE = $00000001; // 1 -> code section depends on mask bit
  724.                              // 0 -> new instruction depends on mask bit
  725.   IAHMASK_MBZ7  = $000000FE; // MBZ
  726.   IAHMASK_SHIFT = $0000FF00; // Amask bit in question for this fixup
  727.   IAHMASK_MBZ16 = DWORD($FFFF0000); // MBZ
  728. type
  729.   PIMAGE_ARCHITECTURE_HEADER = ^IMAGE_ARCHITECTURE_HEADER;
  730.   {$EXTERNALSYM PIMAGE_ARCHITECTURE_HEADER}
  731.   _ImageArchitectureHeader = record
  732.     Mask: DWORD;
  733.     FirstEntryRVA: DWORD;    // RVA into .arch section to array of ARCHITECTURE_ENTRY's
  734.   end;
  735.   {$EXTERNALSYM _ImageArchitectureHeader}
  736.   IMAGE_ARCHITECTURE_HEADER = _ImageArchitectureHeader;
  737.   {$EXTERNALSYM IMAGE_ARCHITECTURE_HEADER}
  738.   TImageArchitectureHeader = IMAGE_ARCHITECTURE_HEADER;
  739.   PImageArchitectureHeader = PIMAGE_ARCHITECTURE_HEADER;
  740.   PIMAGE_ARCHITECTURE_ENTRY = ^IMAGE_ARCHITECTURE_ENTRY;
  741.   {$EXTERNALSYM PIMAGE_ARCHITECTURE_ENTRY}
  742.   _ImageArchitectureEntry = record
  743.     FixupInstRVA: DWORD;                         // RVA of instruction to fixup
  744.     NewInst: DWORD;                              // fixup instruction (see alphaops.h)
  745.   end;
  746.   {$EXTERNALSYM _ImageArchitectureEntry}
  747.   IMAGE_ARCHITECTURE_ENTRY = _ImageArchitectureEntry;
  748.   {$EXTERNALSYM IMAGE_ARCHITECTURE_ENTRY}
  749.   TImageArchitectureEntry = IMAGE_ARCHITECTURE_ENTRY;
  750.   PImageArchitectureEntry = PIMAGE_ARCHITECTURE_ENTRY;
  751. // #include "poppack.h"                // Back to the initial value
  752. // The following structure defines the new import object.  Note the values of the first two fields,
  753. // which must be set as stated in order to differentiate old and new import members.
  754. // Following this structure, the linker emits two null-terminated strings used to recreate the
  755. // import at the time of use.  The first string is the import's name, the second is the dll's name.
  756. const
  757.   IMPORT_OBJECT_HDR_SIG2 = $ffff;
  758.   {$EXTERNALSYM IMPORT_OBJECT_HDR_SIG2}
  759. const
  760.   IOHFLAGS_TYPE = $0003;      // IMPORT_TYPE
  761.   IAHFLAGS_NAMETYPE = $001C;  // IMPORT_NAME_TYPE
  762.   IAHFLAGS_RESERVED = $FFE0;  // Reserved. Must be zero.
  763. type
  764.   PImportObjectHeader = ^IMPORT_OBJECT_HEADER;
  765.   IMPORT_OBJECT_HEADER = record
  766.     Sig1: WORD;                       // Must be IMAGE_FILE_MACHINE_UNKNOWN
  767.     Sig2: WORD;                       // Must be IMPORT_OBJECT_HDR_SIG2.
  768.     Version: WORD;
  769.     Machine: WORD;
  770.     TimeDateStamp: DWORD;             // Time/date stamp
  771.     SizeOfData: DWORD;                // particularly useful for incremental links
  772.     OrdinalOrHint: record
  773.     case Integer of
  774.       0: (Ordinal: WORD);             // if grf & IMPORT_OBJECT_ORDINAL
  775.       1: (Flags: DWORD);
  776.     end;
  777.     Flags: WORD;
  778.     //WORD    Type : 2;                   // IMPORT_TYPE
  779.     //WORD    NameType : 3;               // IMPORT_NAME_TYPE
  780.     //WORD    Reserved : 11;              // Reserved. Must be zero.
  781.   end;
  782.   {$EXTERNALSYM IMPORT_OBJECT_HEADER}
  783.   TImportObjectHeader = IMPORT_OBJECT_HEADER;
  784.   IMPORT_OBJECT_TYPE = (IMPORT_OBJECT_CODE, IMPORT_OBJECT_DATA, IMPORT_OBJECT_CONST);
  785.   {$EXTERNALSYM IMPORT_OBJECT_TYPE}
  786.   TImportObjectType = IMPORT_OBJECT_TYPE;
  787.   IMPORT_OBJECT_NAME_TYPE = (
  788.     IMPORT_OBJECT_ORDINAL,          // Import by ordinal
  789.     IMPORT_OBJECT_NAME,             // Import name == public symbol name.
  790.     IMPORT_OBJECT_NAME_NO_PREFIX,   // Import name == public symbol name skipping leading ?, @, or optionally _.
  791.     IMPORT_OBJECT_NAME_UNDECORATE); // Import name == public symbol name skipping leading ?, @, or optionally _
  792.                                     // and truncating at first @
  793.   {$EXTERNALSYM IMPORT_OBJECT_NAME_TYPE}
  794.   TImportObjectNameType = IMPORT_OBJECT_NAME_TYPE;
  795.   ReplacesCorHdrNumericDefines = DWORD;
  796.   {$EXTERNALSYM ReplacesCorHdrNumericDefines}
  797. const
  798. // COM+ Header entry point flags.
  799.   COMIMAGE_FLAGS_ILONLY               = $00000001;
  800.   {$EXTERNALSYM COMIMAGE_FLAGS_ILONLY}
  801.   COMIMAGE_FLAGS_32BITREQUIRED        = $00000002;
  802.   {$EXTERNALSYM COMIMAGE_FLAGS_32BITREQUIRED}
  803.   COMIMAGE_FLAGS_IL_LIBRARY           = $00000004;
  804.   {$EXTERNALSYM COMIMAGE_FLAGS_IL_LIBRARY}
  805.   COMIMAGE_FLAGS_STRONGNAMESIGNED     = $00000008;
  806.   {$EXTERNALSYM COMIMAGE_FLAGS_STRONGNAMESIGNED}
  807.   COMIMAGE_FLAGS_TRACKDEBUGDATA       = $00010000;
  808.   {$EXTERNALSYM COMIMAGE_FLAGS_TRACKDEBUGDATA}
  809. // Version flags for image.
  810.   COR_VERSION_MAJOR_V2                = 2;
  811.   {$EXTERNALSYM COR_VERSION_MAJOR_V2}
  812.   COR_VERSION_MAJOR                   = COR_VERSION_MAJOR_V2;
  813.   {$EXTERNALSYM COR_VERSION_MAJOR}
  814.   COR_VERSION_MINOR                   = 0;
  815.   {$EXTERNALSYM COR_VERSION_MINOR}
  816.   COR_DELETED_NAME_LENGTH             = 8;
  817.   {$EXTERNALSYM COR_DELETED_NAME_LENGTH}
  818.   COR_VTABLEGAP_NAME_LENGTH           = 8;
  819.   {$EXTERNALSYM COR_VTABLEGAP_NAME_LENGTH}
  820. // Maximum size of a NativeType descriptor.
  821.   NATIVE_TYPE_MAX_CB                  = 1;
  822.   {$EXTERNALSYM NATIVE_TYPE_MAX_CB}
  823.   COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE= $FF;
  824.   {$EXTERNALSYM COR_ILMETHOD_SECT_SMALL_MAX_DATASIZE}
  825. // #defines for the MIH FLAGS
  826.   IMAGE_COR_MIH_METHODRVA             = $01;
  827.   {$EXTERNALSYM IMAGE_COR_MIH_METHODRVA}
  828.   IMAGE_COR_MIH_EHRVA                 = $02;
  829.   {$EXTERNALSYM IMAGE_COR_MIH_EHRVA}
  830.   IMAGE_COR_MIH_BASICBLOCK            = $08;
  831.   {$EXTERNALSYM IMAGE_COR_MIH_BASICBLOCK}
  832. // V-table constants
  833.   COR_VTABLE_32BIT                    = $01;          // V-table slots are 32-bits in size.
  834.   {$EXTERNALSYM COR_VTABLE_32BIT}
  835.   COR_VTABLE_64BIT                    = $02;          // V-table slots are 64-bits in size.
  836.   {$EXTERNALSYM COR_VTABLE_64BIT}
  837.   COR_VTABLE_FROM_UNMANAGED           = $04;          // If set, transition from unmanaged.
  838.   {$EXTERNALSYM COR_VTABLE_FROM_UNMANAGED}
  839.   COR_VTABLE_CALL_MOST_DERIVED        = $10;          // Call most derived method described by
  840.   {$EXTERNALSYM COR_VTABLE_CALL_MOST_DERIVED}
  841. // EATJ constants
  842.   IMAGE_COR_EATJ_THUNK_SIZE           = 32;            // Size of a jump thunk reserved range.
  843.   {$EXTERNALSYM IMAGE_COR_EATJ_THUNK_SIZE}
  844. // Max name lengths
  845. // Change to unlimited name lengths.
  846.   MAX_CLASS_NAME                      = 1024;
  847.   {$EXTERNALSYM MAX_CLASS_NAME}
  848.   MAX_PACKAGE_NAME                    = 1024;
  849.   {$EXTERNALSYM MAX_PACKAGE_NAME}
  850. // COM+ 2.0 header structure.
  851. type
  852.   IMAGE_COR20_HEADER = record
  853.     // Header versioning
  854.     cb: DWORD;
  855.     MajorRuntimeVersion: WORD;
  856.     MinorRuntimeVersion: WORD;
  857.     // Symbol table and startup information
  858.     MetaData: IMAGE_DATA_DIRECTORY;
  859.     Flags: DWORD;
  860.     EntryPointToken: DWORD;
  861.     // Binding information
  862.     Resources: IMAGE_DATA_DIRECTORY;
  863.     StrongNameSignature: IMAGE_DATA_DIRECTORY;
  864.     // Regular fixup and binding information
  865.     CodeManagerTable: IMAGE_DATA_DIRECTORY;
  866.     VTableFixups: IMAGE_DATA_DIRECTORY;
  867.     ExportAddressTableJumps: IMAGE_DATA_DIRECTORY;
  868.     // Precompiled image info (internal use only - set to zero)
  869.     ManagedNativeHeader: IMAGE_DATA_DIRECTORY;
  870.   end;
  871.   {$EXTERNALSYM IMAGE_COR20_HEADER}
  872.   PIMAGE_COR20_HEADER = ^IMAGE_COR20_HEADER;
  873.   {$EXTERNALSYM PIMAGE_COR20_HEADER}
  874.   TImageCor20Header = IMAGE_COR20_HEADER;
  875.   PImageCor20Header = PIMAGE_COR20_HEADER;
  876. //
  877. // End Image Format
  878. //
  879. type
  880.   SLIST_ENTRY = SINGLE_LIST_ENTRY;
  881.   {$EXTERNALSYM SLIST_ENTRY}
  882.   _SLIST_ENTRY = _SINGLE_LIST_ENTRY;
  883.   {$EXTERNALSYM _SLIST_ENTRY}
  884.   PSLIST_ENTRY = PSINGLE_LIST_ENTRY;
  885.   {$EXTERNALSYM PSLIST_ENTRY}
  886.   TSListEntry = SLIST_ENTRY;
  887.   PSListEntry = PSLIST_ENTRY;  
  888. type
  889.   _SLIST_HEADER = record
  890.   case Integer of
  891.     0: (
  892.       Alignment: ULONGLONG);
  893.     1: (
  894.       Next: SLIST_ENTRY;
  895.       Depth: WORD;
  896.       Sequence: WORD);
  897.   end;
  898.   {$EXTERNALSYM _SLIST_HEADER}
  899.   SLIST_HEADER = _SLIST_HEADER;
  900.   {$EXTERNALSYM SLIST_HEADER}
  901.   PSLIST_HEADER = ^SLIST_HEADER;
  902.   {$EXTERNALSYM PSLIST_HEADER}
  903.   TSListHeader = SLIST_HEADER;
  904.   PSListHeader = PSLIST_HEADER;  
  905. procedure RtlInitializeSListHead(ListHead: PSLIST_HEADER); stdcall;
  906. {$EXTERNALSYM RtlInitializeSListHead}
  907. function RtlFirstEntrySList(ListHead: PSLIST_HEADER): PSLIST_ENTRY; stdcall;
  908. {$EXTERNALSYM RtlFirstEntrySList}
  909. function RtlInterlockedPopEntrySList(ListHead: PSLIST_HEADER): PSLIST_ENTRY; stdcall;
  910. {$EXTERNALSYM RtlInterlockedPopEntrySList}
  911. function RtlInterlockedPushEntrySList(ListHead, ListEntry: PSLIST_HEADER): PSLIST_ENTRY; stdcall;
  912. {$EXTERNALSYM RtlInterlockedPushEntrySList}
  913. function RtlInterlockedFlushSList(ListHead: PSLIST_HEADER): PSLIST_ENTRY; stdcall;
  914. {$EXTERNALSYM RtlInterlockedFlushSList}
  915. function RtlQueryDepthSList(ListHead: PSLIST_HEADER): WORD; stdcall;
  916. {$EXTERNALSYM RtlQueryDepthSList}
  917. const
  918.   HEAP_NO_SERIALIZE             = $00000001;
  919.   {$EXTERNALSYM HEAP_NO_SERIALIZE}
  920.   HEAP_GROWABLE                 = $00000002;
  921.   {$EXTERNALSYM HEAP_GROWABLE}
  922.   HEAP_GENERATE_EXCEPTIONS      = $00000004;
  923.   {$EXTERNALSYM HEAP_GENERATE_EXCEPTIONS}
  924.   HEAP_ZERO_MEMORY              = $00000008;
  925.   {$EXTERNALSYM HEAP_ZERO_MEMORY}
  926.   HEAP_REALLOC_IN_PLACE_ONLY    = $00000010;
  927.   {$EXTERNALSYM HEAP_REALLOC_IN_PLACE_ONLY}
  928.   HEAP_TAIL_CHECKING_ENABLED    = $00000020;
  929.   {$EXTERNALSYM HEAP_TAIL_CHECKING_ENABLED}
  930.   HEAP_FREE_CHECKING_ENABLED    = $00000040;
  931.   {$EXTERNALSYM HEAP_FREE_CHECKING_ENABLED}
  932.   HEAP_DISABLE_COALESCE_ON_FREE = $00000080;
  933.   {$EXTERNALSYM HEAP_DISABLE_COALESCE_ON_FREE}
  934.   HEAP_CREATE_ALIGN_16          = $00010000;
  935.   {$EXTERNALSYM HEAP_CREATE_ALIGN_16}
  936.   HEAP_CREATE_ENABLE_TRACING    = $00020000;
  937.   {$EXTERNALSYM HEAP_CREATE_ENABLE_TRACING}
  938.   HEAP_MAXIMUM_TAG              = $0FFF;
  939.   {$EXTERNALSYM HEAP_MAXIMUM_TAG}
  940.   HEAP_PSEUDO_TAG_FLAG          = $8000;
  941.   {$EXTERNALSYM HEAP_PSEUDO_TAG_FLAG}
  942.   HEAP_TAG_SHIFT                = 18;
  943.   {$EXTERNALSYM HEAP_TAG_SHIFT}
  944. function HEAP_MAKE_TAG_FLAGS(b, o: DWORD): DWORD;
  945. {$EXTERNALSYM HEAP_MAKE_TAG_FLAGS}
  946. const
  947.   IS_TEXT_UNICODE_ASCII16         = $0001;
  948.   {$EXTERNALSYM IS_TEXT_UNICODE_ASCII16}
  949.   IS_TEXT_UNICODE_REVERSE_ASCII16 = $0010;
  950.   {$EXTERNALSYM IS_TEXT_UNICODE_REVERSE_ASCII16}
  951.   IS_TEXT_UNICODE_STATISTICS         = $0002;
  952.   {$EXTERNALSYM IS_TEXT_UNICODE_STATISTICS}
  953.   IS_TEXT_UNICODE_REVERSE_STATISTICS = $0020;
  954.   {$EXTERNALSYM IS_TEXT_UNICODE_REVERSE_STATISTICS}
  955.   IS_TEXT_UNICODE_CONTROLS         = $0004;
  956.   {$EXTERNALSYM IS_TEXT_UNICODE_CONTROLS}
  957.   IS_TEXT_UNICODE_REVERSE_CONTROLS = $0040;
  958.   {$EXTERNALSYM IS_TEXT_UNICODE_REVERSE_CONTROLS}
  959.   IS_TEXT_UNICODE_SIGNATURE         = $0008;
  960.   {$EXTERNALSYM IS_TEXT_UNICODE_SIGNATURE}
  961.   IS_TEXT_UNICODE_REVERSE_SIGNATURE = $0080;
  962.   {$EXTERNALSYM IS_TEXT_UNICODE_REVERSE_SIGNATURE}
  963.   IS_TEXT_UNICODE_ILLEGAL_CHARS = $0100;
  964.   {$EXTERNALSYM IS_TEXT_UNICODE_ILLEGAL_CHARS}
  965.   IS_TEXT_UNICODE_ODD_LENGTH    = $0200;
  966.   {$EXTERNALSYM IS_TEXT_UNICODE_ODD_LENGTH}
  967.   IS_TEXT_UNICODE_DBCS_LEADBYTE = $0400;
  968.   {$EXTERNALSYM IS_TEXT_UNICODE_DBCS_LEADBYTE}
  969.   IS_TEXT_UNICODE_NULL_BYTES    = $1000;
  970.   {$EXTERNALSYM IS_TEXT_UNICODE_NULL_BYTES}
  971.   IS_TEXT_UNICODE_UNICODE_MASK     = $000F;
  972.   {$EXTERNALSYM IS_TEXT_UNICODE_UNICODE_MASK}
  973.   IS_TEXT_UNICODE_REVERSE_MASK     = $00F0;
  974.   {$EXTERNALSYM IS_TEXT_UNICODE_REVERSE_MASK}
  975.   IS_TEXT_UNICODE_NOT_UNICODE_MASK = $0F00;
  976.   {$EXTERNALSYM IS_TEXT_UNICODE_NOT_UNICODE_MASK}
  977.   IS_TEXT_UNICODE_NOT_ASCII_MASK   = $F000;
  978.   {$EXTERNALSYM IS_TEXT_UNICODE_NOT_ASCII_MASK}
  979.   COMPRESSION_FORMAT_NONE     = ($0000);
  980.   {$EXTERNALSYM COMPRESSION_FORMAT_NONE}
  981.   COMPRESSION_FORMAT_DEFAULT  = ($0001);
  982.   {$EXTERNALSYM COMPRESSION_FORMAT_DEFAULT}
  983.   COMPRESSION_FORMAT_LZNT1    = ($0002);
  984.   {$EXTERNALSYM COMPRESSION_FORMAT_LZNT1}
  985.   COMPRESSION_ENGINE_STANDARD = ($0000);
  986.   {$EXTERNALSYM COMPRESSION_ENGINE_STANDARD}
  987.   COMPRESSION_ENGINE_MAXIMUM  = ($0100);
  988.   {$EXTERNALSYM COMPRESSION_ENGINE_MAXIMUM}
  989.   COMPRESSION_ENGINE_HIBER    = ($0200);
  990.   {$EXTERNALSYM COMPRESSION_ENGINE_HIBER}
  991. function RtlCompareMemory(const Source1, Source2: Pointer; Length: SIZE_T): SIZE_T; stdcall;
  992. {$EXTERNALSYM RtlCompareMemory}
  993. type
  994.   PMESSAGE_RESOURCE_ENTRY = ^MESSAGE_RESOURCE_ENTRY;
  995.   {$EXTERNALSYM PMESSAGE_RESOURCE_ENTRY}
  996.   _MESSAGE_RESOURCE_ENTRY = record
  997.     Length: Word;
  998.     Flags: Word;
  999.     Text: array [0..0] of Byte;
  1000.   end;
  1001.   {$EXTERNALSYM _MESSAGE_RESOURCE_ENTRY}
  1002.   MESSAGE_RESOURCE_ENTRY = _MESSAGE_RESOURCE_ENTRY;
  1003.   {$EXTERNALSYM MESSAGE_RESOURCE_ENTRY}
  1004.   TMessageResourceEntry = MESSAGE_RESOURCE_ENTRY;
  1005.   PMessageResourceEntry = PMESSAGE_RESOURCE_ENTRY;
  1006. const
  1007.   MESSAGE_RESOURCE_UNICODE = $0001;
  1008.   {$EXTERNALSYM MESSAGE_RESOURCE_UNICODE}
  1009. type
  1010.   PMESSAGE_RESOURCE_BLOCK = ^MESSAGE_RESOURCE_BLOCK;
  1011.   {$EXTERNALSYM PMESSAGE_RESOURCE_BLOCK}
  1012.   _MESSAGE_RESOURCE_BLOCK = record
  1013.     LowId: DWORD;
  1014.     HighId: DWORD;
  1015.     OffsetToEntries: DWORD;
  1016.   end;
  1017.   {$EXTERNALSYM _MESSAGE_RESOURCE_BLOCK}
  1018.   MESSAGE_RESOURCE_BLOCK = _MESSAGE_RESOURCE_BLOCK;
  1019.   {$EXTERNALSYM MESSAGE_RESOURCE_BLOCK}
  1020.   TMessageResourceBlock = MESSAGE_RESOURCE_BLOCK;
  1021.   PMessageResourceBlock = PMESSAGE_RESOURCE_BLOCK;
  1022.   PMESSAGE_RESOURCE_DATA = ^MESSAGE_RESOURCE_DATA;
  1023.   {$EXTERNALSYM PMESSAGE_RESOURCE_DATA}
  1024.   _MESSAGE_RESOURCE_DATA = record
  1025.     NumberOfBlocks: DWORD;
  1026.     Blocks: array [0..0] of MESSAGE_RESOURCE_BLOCK;
  1027.   end;
  1028.   {$EXTERNALSYM _MESSAGE_RESOURCE_DATA}
  1029.   MESSAGE_RESOURCE_DATA = _MESSAGE_RESOURCE_DATA;
  1030.   {$EXTERNALSYM MESSAGE_RESOURCE_DATA}
  1031.   TMessageResourceData = MESSAGE_RESOURCE_DATA;
  1032.   PMessageResourceData = PMESSAGE_RESOURCE_DATA;
  1033.   LPOSVERSIONINFOA = ^OSVERSIONINFOA;
  1034.   {$EXTERNALSYM LPOSVERSIONINFOA}
  1035.   _OSVERSIONINFOA = record
  1036.     dwOSVersionInfoSize: DWORD;
  1037.     dwMajorVersion: DWORD;
  1038.     dwMinorVersion: DWORD;
  1039.     dwBuildNumber: DWORD;
  1040.     dwPlatformId: DWORD;
  1041.     szCSDVersion: array [0..127] of CHAR; // Maintenance string for PSS usage
  1042.   end;
  1043.   {$EXTERNALSYM _OSVERSIONINFOA}
  1044.   OSVERSIONINFOA = _OSVERSIONINFOA;
  1045.   {$EXTERNALSYM OSVERSIONINFOA}
  1046.   TOsVersionInfoA = OSVERSIONINFOA;
  1047.   POsVersionInfoA = LPOSVERSIONINFOA;
  1048.   LPOSVERSIONINFOW = ^OSVERSIONINFOW;
  1049.   {$EXTERNALSYM LPOSVERSIONINFOW}
  1050.   _OSVERSIONINFOW = record
  1051.     dwOSVersionInfoSize: DWORD;
  1052.     dwMajorVersion: DWORD;
  1053.     dwMinorVersion: DWORD;
  1054.     dwBuildNumber: DWORD;
  1055.     dwPlatformId: DWORD;
  1056.     szCSDVersion: array [0..127] of WCHAR; // Maintenance string for PSS usage
  1057.   end;
  1058.   {$EXTERNALSYM _OSVERSIONINFOW}
  1059.   OSVERSIONINFOW = _OSVERSIONINFOW;
  1060.   {$EXTERNALSYM OSVERSIONINFOW}
  1061.   TOsVersionInfoW = OSVERSIONINFOW;
  1062.   POsVersionInfoW = LPOSVERSIONINFOW;
  1063. {$IFDEF UNICODE}
  1064.   OSVERSIONINFO = OSVERSIONINFOW;
  1065.   {$EXTERNALSYM OSVERSIONINFO}
  1066.   POSVERSIONINFO = POSVERSIONINFOW;
  1067.   {$EXTERNALSYM POSVERSIONINFO}
  1068.   LPOSVERSIONINFO = LPOSVERSIONINFOW;
  1069.   {$EXTERNALSYM LPOSVERSIONINFO}
  1070.   TOSVersionInfo = TOSVersionInfoW;
  1071. {$ELSE}
  1072.   OSVERSIONINFO = OSVERSIONINFOA;
  1073.   {$EXTERNALSYM OSVERSIONINFO}
  1074.   POSVERSIONINFO = POSVERSIONINFOA;
  1075.   {$EXTERNALSYM POSVERSIONINFO}
  1076.   LPOSVERSIONINFO = LPOSVERSIONINFOA;
  1077.   {$EXTERNALSYM LPOSVERSIONINFO}
  1078.   TOSVersionInfo = TOSVersionInfoA;
  1079. {$ENDIF}
  1080. type
  1081.   POSVERSIONINFOEXA = ^OSVERSIONINFOEXA;
  1082.   {$EXTERNALSYM POSVERSIONINFOEXA}
  1083.   _OSVERSIONINFOEXA = record
  1084.     dwOSVersionInfoSize: DWORD;
  1085.     dwMajorVersion: DWORD;
  1086.     dwMinorVersion: DWORD;
  1087.     dwBuildNumber: DWORD;
  1088.     dwPlatformId: DWORD;
  1089.     szCSDVersion: array [0..127] of CHAR;     // Maintenance string for PSS usage
  1090.     wServicePackMajor: WORD;
  1091.     wServicePackMinor: WORD;
  1092.     wSuiteMask: WORD;
  1093.     wProductType: BYTE;
  1094.     wReserved: BYTE;
  1095.   end;
  1096.   {$EXTERNALSYM _OSVERSIONINFOEXA}
  1097.   OSVERSIONINFOEXA = _OSVERSIONINFOEXA;
  1098.   {$EXTERNALSYM OSVERSIONINFOEXA}
  1099.   LPOSVERSIONINFOEXA = ^OSVERSIONINFOEXA;
  1100.   {$EXTERNALSYM LPOSVERSIONINFOEXA}
  1101.   TOSVersionInfoExA = _OSVERSIONINFOEXA;
  1102.   POSVERSIONINFOEXW = ^OSVERSIONINFOEXW;
  1103.   {$EXTERNALSYM POSVERSIONINFOEXW}
  1104.   _OSVERSIONINFOEXW = record
  1105.     dwOSVersionInfoSize: DWORD;
  1106.     dwMajorVersion: DWORD;
  1107.     dwMinorVersion: DWORD;
  1108.     dwBuildNumber: DWORD;
  1109.     dwPlatformId: DWORD;
  1110.     szCSDVersion: array [0..127] of WCHAR;     // Maintenance string for PSS usage
  1111.     wServicePackMajor: WORD;
  1112.     wServicePackMinor: WORD;
  1113.     wSuiteMask: WORD;
  1114.     wProductType: BYTE;
  1115.     wReserved: BYTE;
  1116.   end;
  1117.   {$EXTERNALSYM _OSVERSIONINFOEXW}
  1118.   OSVERSIONINFOEXW = _OSVERSIONINFOEXW;
  1119.   {$EXTERNALSYM OSVERSIONINFOEXW}
  1120.   LPOSVERSIONINFOEXW = ^OSVERSIONINFOEXW;
  1121.   {$EXTERNALSYM LPOSVERSIONINFOEXW}
  1122.   RTL_OSVERSIONINFOEXW = _OSVERSIONINFOEXW;
  1123.   {$EXTERNALSYM RTL_OSVERSIONINFOEXW}
  1124.   PRTL_OSVERSIONINFOEXW = ^RTL_OSVERSIONINFOEXW;
  1125.   {$EXTERNALSYM PRTL_OSVERSIONINFOEXW}
  1126.   TOSVersionInfoExW = _OSVERSIONINFOEXW;
  1127. {$IFDEF UNICODE}
  1128.   OSVERSIONINFOEX = OSVERSIONINFOEXW;
  1129.   {$EXTERNALSYM OSVERSIONINFOEX}
  1130.   POSVERSIONINFOEX = POSVERSIONINFOEXW;
  1131.   {$EXTERNALSYM POSVERSIONINFOEX}
  1132.   LPOSVERSIONINFOEX = LPOSVERSIONINFOEXW;
  1133.   {$EXTERNALSYM LPOSVERSIONINFOEX}
  1134.   TOSVersionInfoEx = TOSVersionInfoExW;
  1135. {$ELSE}
  1136.   OSVERSIONINFOEX = OSVERSIONINFOEXA;
  1137.   {$EXTERNALSYM OSVERSIONINFOEX}
  1138.   POSVERSIONINFOEX = POSVERSIONINFOEXA;
  1139.   {$EXTERNALSYM POSVERSIONINFOEX}
  1140.   LPOSVERSIONINFOEX = LPOSVERSIONINFOEXA;
  1141.   {$EXTERNALSYM LPOSVERSIONINFOEX}
  1142.   TOSVersionInfoEx = TOSVersionInfoExA;  
  1143. {$ENDIF}
  1144. //
  1145. // RtlVerifyVersionInfo() conditions
  1146. //
  1147. const
  1148.   VER_EQUAL         = 1;
  1149.   {$EXTERNALSYM VER_EQUAL}
  1150.   VER_GREATER       = 2;
  1151.   {$EXTERNALSYM VER_GREATER}
  1152.   VER_GREATER_EQUAL = 3;
  1153.   {$EXTERNALSYM VER_GREATER_EQUAL}
  1154.   VER_LESS          = 4;
  1155.   {$EXTERNALSYM VER_LESS}
  1156.   VER_LESS_EQUAL    = 5;
  1157.   {$EXTERNALSYM VER_LESS_EQUAL}
  1158.   VER_AND           = 6;
  1159.   {$EXTERNALSYM VER_AND}
  1160.   VER_OR            = 7;
  1161.   {$EXTERNALSYM VER_OR}
  1162.   VER_CONDITION_MASK              = 7;
  1163.   {$EXTERNALSYM VER_CONDITION_MASK}
  1164.   VER_NUM_BITS_PER_CONDITION_MASK = 3;
  1165.   {$EXTERNALSYM VER_NUM_BITS_PER_CONDITION_MASK}
  1166. //
  1167. // RtlVerifyVersionInfo() type mask bits
  1168. //
  1169.   VER_MINORVERSION     = $0000001;
  1170.   {$EXTERNALSYM VER_MINORVERSION}
  1171.   VER_MAJORVERSION     = $0000002;
  1172.   {$EXTERNALSYM VER_MAJORVERSION}
  1173.   VER_BUILDNUMBER      = $0000004;
  1174.   {$EXTERNALSYM VER_BUILDNUMBER}
  1175.   VER_PLATFORMID       = $0000008;
  1176.   {$EXTERNALSYM VER_PLATFORMID}
  1177.   VER_SERVICEPACKMINOR = $0000010;
  1178.   {$EXTERNALSYM VER_SERVICEPACKMINOR}
  1179.   VER_SERVICEPACKMAJOR = $0000020;
  1180.   {$EXTERNALSYM VER_SERVICEPACKMAJOR}
  1181.   VER_SUITENAME        = $0000040;
  1182.   {$EXTERNALSYM VER_SUITENAME}
  1183.   VER_PRODUCT_TYPE     = $0000080;
  1184.   {$EXTERNALSYM VER_PRODUCT_TYPE}
  1185. //
  1186. // RtlVerifyVersionInfo() os product type values
  1187. //
  1188.   VER_NT_WORKSTATION       = $0000001;
  1189.   {$EXTERNALSYM VER_NT_WORKSTATION}
  1190.   VER_NT_DOMAIN_CONTROLLER = $0000002;
  1191.   {$EXTERNALSYM VER_NT_DOMAIN_CONTROLLER}
  1192.   VER_NT_SERVER            = $0000003;
  1193.   {$EXTERNALSYM VER_NT_SERVER}
  1194. //
  1195. // dwPlatformId defines:
  1196. //
  1197.   VER_PLATFORM_WIN32s        = 0;
  1198.   {$EXTERNALSYM VER_PLATFORM_WIN32s}
  1199.   VER_PLATFORM_WIN32_WINDOWS = 1;
  1200.   {$EXTERNALSYM VER_PLATFORM_WIN32_WINDOWS}
  1201.   VER_PLATFORM_WIN32_NT      = 2;
  1202.   {$EXTERNALSYM VER_PLATFORM_WIN32_NT}
  1203. //
  1204. //
  1205. // VerifyVersionInfo() macro to set the condition mask
  1206. //
  1207. // For documentation sakes here's the old version of the macro that got
  1208. // changed to call an API
  1209. // #define VER_SET_CONDITION(_m_,_t_,_c_)  _m_=(_m_|(_c_<<(1<<_t_)))
  1210. //
  1211. procedure VER_SET_CONDITION(var Mask: DWORDLONG; TypeBitmask, ConditionMask: ULONG);
  1212. {$EXTERNALSYM VER_SET_CONDITION}
  1213. function VerSetConditionMask(ConditionMask: ULONGLONG; TypeMask: DWORD;
  1214.   Condition: BYTE): ULONGLONG; stdcall;
  1215. {$EXTERNALSYM VerSetConditionMask}
  1216. type
  1217.   PRTL_CRITICAL_SECTION_DEBUG = ^RTL_CRITICAL_SECTION_DEBUG;
  1218.   {$EXTERNALSYM PRTL_CRITICAL_SECTION_DEBUG}
  1219.   _RTL_CRITICAL_SECTION_DEBUG = record
  1220.     _Type: WORD;
  1221.     CreatorBackTraceIndex: WORD;
  1222.     CriticalSection: PRTL_CRITICAL_SECTION_DEBUG;
  1223.     ProcessLocksList: LIST_ENTRY;
  1224.     EntryCount: DWORD;
  1225.     ContentionCount: DWORD;
  1226.     Spare: array [0..1] of DWORD;
  1227.   end;
  1228.   {$EXTERNALSYM _RTL_CRITICAL_SECTION_DEBUG}
  1229.   RTL_CRITICAL_SECTION_DEBUG = _RTL_CRITICAL_SECTION_DEBUG;
  1230.   {$EXTERNALSYM RTL_CRITICAL_SECTION_DEBUG}
  1231.   TRtlCriticalSectionDebug = RTL_CRITICAL_SECTION_DEBUG;
  1232.   PRtlCriticalSectionDebug = PRTL_CRITICAL_SECTION_DEBUG;
  1233.   RTL_RESOURCE_DEBUG = _RTL_CRITICAL_SECTION_DEBUG;
  1234.   {$EXTERNALSYM RTL_RESOURCE_DEBUG}
  1235.   PRTL_RESOURCE_DEBUG = RTL_RESOURCE_DEBUG;
  1236.   {$EXTERNALSYM PRTL_RESOURCE_DEBUG}
  1237.   TRtlResourceDebug = RTL_CRITICAL_SECTION_DEBUG;
  1238.   PRtlResourceDebug = PRTL_CRITICAL_SECTION_DEBUG;
  1239. const
  1240.   RTL_CRITSECT_TYPE = 0;
  1241.   {$EXTERNALSYM RTL_CRITSECT_TYPE}
  1242.   RTL_RESOURCE_TYPE = 1;
  1243.   {$EXTERNALSYM RTL_RESOURCE_TYPE}
  1244. type
  1245.   PRTL_CRITICAL_SECTION = ^RTL_CRITICAL_SECTION;
  1246.   {$EXTERNALSYM PRTL_CRITICAL_SECTION}
  1247.   _RTL_CRITICAL_SECTION = record
  1248.     DebugInfo: PRTL_CRITICAL_SECTION_DEBUG;
  1249.     //
  1250.     //  The following three fields control entering and exiting the critical
  1251.     //  section for the resource
  1252.     //
  1253.     LockCount: LONG;
  1254.     RecursionCount: LONG;
  1255.     OwningThread: HANDLE;        // from the thread's ClientId->UniqueThread
  1256.     LockSemaphore: HANDLE;
  1257.     SpinCount: ULONG_PTR;        // force size on 64-bit systems when packed
  1258.   end;
  1259.   {$EXTERNALSYM _RTL_CRITICAL_SECTION}
  1260.   RTL_CRITICAL_SECTION = _RTL_CRITICAL_SECTION;
  1261.   {$EXTERNALSYM RTL_CRITICAL_SECTION}
  1262.   TRtlCriticalSection = RTL_CRITICAL_SECTION;
  1263.   PRtlCriticalSection = PRTL_CRITICAL_SECTION;
  1264.   RTL_VERIFIER_DLL_LOAD_CALLBACK = procedure (DllName: PWSTR; DllBase: PVOID; DllSize: SIZE_T;
  1265.     Reserved: PVOID); stdcall;
  1266.   {$EXTERNALSYM RTL_VERIFIER_DLL_LOAD_CALLBACK}
  1267.   RTL_VERIFIER_DLL_UNLOAD_CALLBACK = procedure (DllName: PWSTR; DllBase: PVOID; DllSize: SIZE_T;
  1268.     Reserved: PVOID); stdcall;
  1269.   {$EXTERNALSYM RTL_VERIFIER_DLL_UNLOAD_CALLBACK}
  1270.   PRTL_VERIFIER_THUNK_DESCRIPTOR = ^RTL_VERIFIER_THUNK_DESCRIPTOR;
  1271.   {$EXTERNALSYM PRTL_VERIFIER_THUNK_DESCRIPTOR}
  1272.   _RTL_VERIFIER_THUNK_DESCRIPTOR = record
  1273.     ThunkName: PCHAR;
  1274.     ThunkOldAddress: PVOID;
  1275.     ThunkNewAddress: PVOID;
  1276.   end;
  1277.   {$EXTERNALSYM _RTL_VERIFIER_THUNK_DESCRIPTOR}
  1278.   RTL_VERIFIER_THUNK_DESCRIPTOR = _RTL_VERIFIER_THUNK_DESCRIPTOR;
  1279.   {$EXTERNALSYM RTL_VERIFIER_THUNK_DESCRIPTOR}
  1280.   TRtlVerifierThunkDescriptor = RTL_VERIFIER_THUNK_DESCRIPTOR;
  1281.   PRtlVerifierThunkDescriptor = PRTL_VERIFIER_THUNK_DESCRIPTOR;
  1282.   PRTL_VERIFIER_DLL_DESCRIPTOR = ^RTL_VERIFIER_DLL_DESCRIPTOR;
  1283.   {$EXTERNALSYM PRTL_VERIFIER_DLL_DESCRIPTOR}
  1284.   _RTL_VERIFIER_DLL_DESCRIPTOR = record
  1285.     DllName: PWCHAR;
  1286.     DllFlags: DWORD;
  1287.     DllAddress: PVOID;
  1288.     DllThunks: PRTL_VERIFIER_THUNK_DESCRIPTOR;
  1289.   end;
  1290.   {$EXTERNALSYM _RTL_VERIFIER_DLL_DESCRIPTOR}
  1291.   RTL_VERIFIER_DLL_DESCRIPTOR = _RTL_VERIFIER_DLL_DESCRIPTOR;
  1292.   {$EXTERNALSYM RTL_VERIFIER_DLL_DESCRIPTOR}
  1293.   TRtlVerifierDllDescriptor = RTL_VERIFIER_DLL_DESCRIPTOR;
  1294.   PRtlVerifierDllDescriptor = PRTL_VERIFIER_DLL_DESCRIPTOR;
  1295.   PRTL_VERIFIER_PROVIDER_DESCRIPTOR = ^RTL_VERIFIER_PROVIDER_DESCRIPTOR;
  1296.   {$EXTERNALSYM PRTL_VERIFIER_PROVIDER_DESCRIPTOR}
  1297.   _RTL_VERIFIER_PROVIDER_DESCRIPTOR = record
  1298.     //
  1299.     // Filled by verifier provider DLL
  1300.     //
  1301.     Length: DWORD;
  1302.     ProviderDlls: PRTL_VERIFIER_DLL_DESCRIPTOR;
  1303.     ProviderDllLoadCallback: RTL_VERIFIER_DLL_LOAD_CALLBACK;
  1304.     ProviderDllUnloadCallback: RTL_VERIFIER_DLL_UNLOAD_CALLBACK;
  1305.     //
  1306.     // Filled by verifier engine
  1307.     //
  1308.     VerifierImage: PWSTR;
  1309.     VerifierFlags: DWORD;
  1310.     VerifierDebug: DWORD;
  1311.     RtlpGetStackTraceAddress: PVOID;
  1312.     RtlpDebugPageHeapCreate: PVOID;
  1313.     RtlpDebugPageHeapDestroy: PVOID;
  1314.   end;
  1315.   {$EXTERNALSYM _RTL_VERIFIER_PROVIDER_DESCRIPTOR}
  1316.   RTL_VERIFIER_PROVIDER_DESCRIPTOR = _RTL_VERIFIER_PROVIDER_DESCRIPTOR;
  1317.   {$EXTERNALSYM RTL_VERIFIER_PROVIDER_DESCRIPTOR}
  1318.   TRtlVerifierProviderDescriptor = RTL_VERIFIER_PROVIDER_DESCRIPTOR;
  1319.   PRtlVerifierProviderDescriptor = PRTL_VERIFIER_PROVIDER_DESCRIPTOR;
  1320. //
  1321. // Application verifier standard flags
  1322. //
  1323. const
  1324.   RTL_VRF_FLG_FULL_PAGE_HEAP                 = $00000001;
  1325.   RTL_VRF_FLG_LOCK_CHECKS                    = $00000002;
  1326.   RTL_VRF_FLG_HANDLE_CHECKS                  = $00000004;
  1327.   RTL_VRF_FLG_STACK_CHECKS                   = $00000008;
  1328.   RTL_VRF_FLG_APPCOMPAT_CHECKS               = $00000010;
  1329.   RTL_VRF_FLG_TLS_CHECKS                     = $00000020;
  1330.   RTL_VRF_FLG_DIRTY_STACKS                   = $00000040;
  1331.   RTL_VRF_FLG_RPC_CHECKS                     = $00000080;
  1332.   RTL_VRF_FLG_COM_CHECKS                     = $00000100;
  1333.   RTL_VRF_FLG_DANGEROUS_APIS                 = $00000200;
  1334.   RTL_VRF_FLG_RACE_CHECKS                    = $00000400;
  1335.   RTL_VRF_FLG_DEADLOCK_CHECKS                = $00000800;
  1336.   RTL_VRF_FLG_FIRST_CHANCE_EXCEPTION_CHECKS  = $00001000;
  1337.   RTL_VRF_FLG_VIRTUAL_MEM_CHECKS             = $00002000;
  1338.   RTL_VRF_FLG_ENABLE_LOGGING                 = $00004000;
  1339.   RTL_VRF_FLG_FAST_FILL_HEAP                 = $00008000;
  1340.   RTL_VRF_FLG_VIRTUAL_SPACE_TRACKING         = $00010000;
  1341.   RTL_VRF_FLG_ENABLED_SYSTEM_WIDE            = $00020000;
  1342.   RTL_VRF_FLG_MISCELLANEOUS_CHECKS           = $00020000;
  1343. //
  1344. // Application verifier standard stop codes
  1345. //
  1346.   APPLICATION_VERIFIER_INTERNAL_ERROR    = DWORD($80000000);
  1347.   {$EXTERNALSYM APPLICATION_VERIFIER_INTERNAL_ERROR}
  1348.   APPLICATION_VERIFIER_INTERNAL_WARNING  = $40000000;
  1349.   {$EXTERNALSYM APPLICATION_VERIFIER_INTERNAL_WARNING}
  1350.   APPLICATION_VERIFIER_NO_BREAK          = $20000000;
  1351.   {$EXTERNALSYM APPLICATION_VERIFIER_NO_BREAK}
  1352.   APPLICATION_VERIFIER_CONTINUABLE_BREAK = $10000000;
  1353.   {$EXTERNALSYM APPLICATION_VERIFIER_CONTINUABLE_BREAK}
  1354.   APPLICATION_VERIFIER_UNKNOWN_ERROR         = $0001;
  1355.   {$EXTERNALSYM APPLICATION_VERIFIER_UNKNOWN_ERROR}
  1356.   APPLICATION_VERIFIER_ACCESS_VIOLATION      = $0002;
  1357.   {$EXTERNALSYM APPLICATION_VERIFIER_ACCESS_VIOLATION}
  1358.   APPLICATION_VERIFIER_UNSYNCHRONIZED_ACCESS = $0003;
  1359.   {$EXTERNALSYM APPLICATION_VERIFIER_UNSYNCHRONIZED_ACCESS}
  1360.   APPLICATION_VERIFIER_EXTREME_SIZE_REQUEST  = $0004;
  1361.   {$EXTERNALSYM APPLICATION_VERIFIER_EXTREME_SIZE_REQUEST}
  1362.   APPLICATION_VERIFIER_BAD_HEAP_HANDLE       = $0005;
  1363.   {$EXTERNALSYM APPLICATION_VERIFIER_BAD_HEAP_HANDLE}
  1364.   APPLICATION_VERIFIER_SWITCHED_HEAP_HANDLE  = $0006;
  1365.   {$EXTERNALSYM APPLICATION_VERIFIER_SWITCHED_HEAP_HANDLE}
  1366.   APPLICATION_VERIFIER_DOUBLE_FREE           = $0007;
  1367.   {$EXTERNALSYM APPLICATION_VERIFIER_DOUBLE_FREE}
  1368.   APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK  = $0008;
  1369.   {$EXTERNALSYM APPLICATION_VERIFIER_CORRUPTED_HEAP_BLOCK}
  1370.   APPLICATION_VERIFIER_DESTROY_PROCESS_HEAP  = $0009;
  1371.   {$EXTERNALSYM APPLICATION_VERIFIER_DESTROY_PROCESS_HEAP}
  1372.   APPLICATION_VERIFIER_UNEXPECTED_EXCEPTION  = $000A;
  1373.   {$EXTERNALSYM APPLICATION_VERIFIER_UNEXPECTED_EXCEPTION}
  1374.   APPLICATION_VERIFIER_STACK_OVERFLOW        = $000B;
  1375.   {$EXTERNALSYM APPLICATION_VERIFIER_STACK_OVERFLOW}
  1376.   APPLICATION_VERIFIER_TERMINATE_THREAD_CALL = $0100;
  1377.   {$EXTERNALSYM APPLICATION_VERIFIER_TERMINATE_THREAD_CALL}
  1378.   APPLICATION_VERIFIER_EXIT_THREAD_OWNS_LOCK        = $0200;
  1379.   {$EXTERNALSYM APPLICATION_VERIFIER_EXIT_THREAD_OWNS_LOCK}
  1380.   APPLICATION_VERIFIER_LOCK_IN_UNLOADED_DLL         = $0201;
  1381.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_IN_UNLOADED_DLL}
  1382.   APPLICATION_VERIFIER_LOCK_IN_FREED_HEAP           = $0202;
  1383.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_IN_FREED_HEAP}
  1384.   APPLICATION_VERIFIER_LOCK_DOUBLE_INITIALIZE       = $0203;
  1385.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_DOUBLE_INITIALIZE}
  1386.   APPLICATION_VERIFIER_LOCK_IN_FREED_MEMORY         = $0204;
  1387.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_IN_FREED_MEMORY}
  1388.   APPLICATION_VERIFIER_LOCK_CORRUPTED               = $0205;
  1389.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_CORRUPTED}
  1390.   APPLICATION_VERIFIER_LOCK_INVALID_OWNER           = $0206;
  1391.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_INVALID_OWNER}
  1392.   APPLICATION_VERIFIER_LOCK_INVALID_RECURSION_COUNT = $0207;
  1393.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_INVALID_RECURSION_COUNT}
  1394.   APPLICATION_VERIFIER_LOCK_INVALID_LOCK_COUNT      = $0208;
  1395.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_INVALID_LOCK_COUNT}
  1396.   APPLICATION_VERIFIER_LOCK_OVER_RELEASED           = $0209;
  1397.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_OVER_RELEASED}
  1398.   APPLICATION_VERIFIER_LOCK_NOT_INITIALIZED         = $0210;
  1399.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_NOT_INITIALIZED}
  1400.   APPLICATION_VERIFIER_LOCK_ALREADY_INITIALIZED     = $0211;
  1401.   {$EXTERNALSYM APPLICATION_VERIFIER_LOCK_ALREADY_INITIALIZED}
  1402.   APPLICATION_VERIFIER_INVALID_HANDLE      = $0300;
  1403.   {$EXTERNALSYM APPLICATION_VERIFIER_INVALID_HANDLE}
  1404.   APPLICATION_VERIFIER_INVALID_TLS_VALUE   = $0301;
  1405.   {$EXTERNALSYM APPLICATION_VERIFIER_INVALID_TLS_VALUE}
  1406.   APPLICATION_VERIFIER_INCORRECT_WAIT_CALL = $0302;
  1407.   {$EXTERNALSYM APPLICATION_VERIFIER_INCORRECT_WAIT_CALL}
  1408.   APPLICATION_VERIFIER_NULL_HANDLE         = $0303;
  1409.   {$EXTERNALSYM APPLICATION_VERIFIER_NULL_HANDLE}
  1410.   APPLICATION_VERIFIER_WAIT_IN_DLLMAIN     = $0304;
  1411.   {$EXTERNALSYM APPLICATION_VERIFIER_WAIT_IN_DLLMAIN}
  1412.   APPLICATION_VERIFIER_COM_ERROR                   = $0400;
  1413.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_ERROR}
  1414.   APPLICATION_VERIFIER_COM_API_IN_DLLMAIN          = $0401;
  1415.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_API_IN_DLLMAIN}
  1416.   APPLICATION_VERIFIER_COM_UNHANDLED_EXCEPTION     = $0402;
  1417.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_UNHANDLED_EXCEPTION}
  1418.   APPLICATION_VERIFIER_COM_UNBALANCED_COINIT       = $0403;
  1419.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_UNBALANCED_COINIT}
  1420.   APPLICATION_VERIFIER_COM_UNBALANCED_OLEINIT      = $0404;
  1421.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_UNBALANCED_OLEINIT}
  1422.   APPLICATION_VERIFIER_COM_UNBALANCED_SWC          = $0405;
  1423.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_UNBALANCED_SWC}
  1424.   APPLICATION_VERIFIER_COM_NULL_DACL               = $0406;
  1425.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_NULL_DACL}
  1426.   APPLICATION_VERIFIER_COM_UNSAFE_IMPERSONATION    = $0407;
  1427.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_UNSAFE_IMPERSONATION}
  1428.   APPLICATION_VERIFIER_COM_SMUGGLED_WRAPPER        = $0408;
  1429.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_SMUGGLED_WRAPPER}
  1430.   APPLICATION_VERIFIER_COM_SMUGGLED_PROXY          = $0409;
  1431.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_SMUGGLED_PROXY}
  1432.   APPLICATION_VERIFIER_COM_CF_SUCCESS_WITH_NULL    = $040A;
  1433.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_CF_SUCCESS_WITH_NULL}
  1434.   APPLICATION_VERIFIER_COM_GCO_SUCCESS_WITH_NULL   = $040B;
  1435.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_GCO_SUCCESS_WITH_NULL}
  1436.   APPLICATION_VERIFIER_COM_OBJECT_IN_FREED_MEMORY  = $040C;
  1437.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_OBJECT_IN_FREED_MEMORY}
  1438.   APPLICATION_VERIFIER_COM_OBJECT_IN_UNLOADED_DLL  = $040D;
  1439.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_OBJECT_IN_UNLOADED_DLL}
  1440.   APPLICATION_VERIFIER_COM_VTBL_IN_FREED_MEMORY    = $040E;
  1441.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_VTBL_IN_FREED_MEMORY}
  1442.   APPLICATION_VERIFIER_COM_VTBL_IN_UNLOADED_DLL    = $040F;
  1443.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_VTBL_IN_UNLOADED_DLL}
  1444.   APPLICATION_VERIFIER_COM_HOLDING_LOCKS_ON_CALL   = $0410;
  1445.   {$EXTERNALSYM APPLICATION_VERIFIER_COM_HOLDING_LOCKS_ON_CALL}
  1446.   APPLICATION_VERIFIER_RPC_ERROR                  = $0500;
  1447.   {$EXTERNALSYM APPLICATION_VERIFIER_RPC_ERROR}
  1448.   APPLICATION_VERIFIER_INVALID_FREEMEM            = $0600;
  1449.   {$EXTERNALSYM APPLICATION_VERIFIER_INVALID_FREEMEM}
  1450.   APPLICATION_VERIFIER_INVALID_ALLOCMEM           = $0601;
  1451.   {$EXTERNALSYM APPLICATION_VERIFIER_INVALID_ALLOCMEM}
  1452.   APPLICATION_VERIFIER_INVALID_MAPVIEW            = $0602;
  1453.   {$EXTERNALSYM APPLICATION_VERIFIER_INVALID_MAPVIEW}
  1454. (* TODO
  1455. #define VERIFIER_STOP(Code, Msg, P1, S1, P2, S2, P3, S3, P4, S4) {  
  1456.         RtlApplicationVerifierStop ((Code),                         
  1457.                                     (Msg),                          
  1458.                                     (ULONG_PTR)(P1),(S1),           
  1459.                                     (ULONG_PTR)(P2),(S2),           
  1460.                                     (ULONG_PTR)(P3),(S3),           
  1461.                                     (ULONG_PTR)(P4),(S4));          
  1462.   }
  1463. VOID NTAPI
  1464. RtlApplicationVerifierStop (
  1465.     ULONG_PTR Code,
  1466.     PCHAR Message,
  1467.     ULONG_PTR Param1, PCHAR Description1,
  1468.     ULONG_PTR Param2, PCHAR Description2,
  1469.     ULONG_PTR Param3, PCHAR Description3,
  1470.     ULONG_PTR Param4, PCHAR Description4
  1471.     );
  1472. *)
  1473. type
  1474.   PVECTORED_EXCEPTION_HANDLER = function (ExceptionInfo: PEXCEPTION_POINTERS): LONG; stdcall;
  1475.   {$EXTERNALSYM PVECTORED_EXCEPTION_HANDLER}
  1476.   PVectoredExceptionHandler = PVECTORED_EXCEPTION_HANDLER;
  1477. const
  1478.   SEF_DACL_AUTO_INHERIT             = $01;
  1479.   {$EXTERNALSYM SEF_DACL_AUTO_INHERIT}
  1480.   SEF_SACL_AUTO_INHERIT             = $02;
  1481.   {$EXTERNALSYM SEF_SACL_AUTO_INHERIT}
  1482.   SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT = $04;
  1483.   {$EXTERNALSYM SEF_DEFAULT_DESCRIPTOR_FOR_OBJECT}
  1484.   SEF_AVOID_PRIVILEGE_CHECK         = $08;
  1485.   {$EXTERNALSYM SEF_AVOID_PRIVILEGE_CHECK}
  1486.   SEF_AVOID_OWNER_CHECK             = $10;
  1487.   {$EXTERNALSYM SEF_AVOID_OWNER_CHECK}
  1488.   SEF_DEFAULT_OWNER_FROM_PARENT     = $20;
  1489.   {$EXTERNALSYM SEF_DEFAULT_OWNER_FROM_PARENT}
  1490.   SEF_DEFAULT_GROUP_FROM_PARENT     = $40;
  1491.   {$EXTERNALSYM SEF_DEFAULT_GROUP_FROM_PARENT}
  1492. type
  1493.   _HEAP_INFORMATION_CLASS = (HeapCompatibilityInformation);
  1494.   {$EXTERNALSYM _HEAP_INFORMATION_CLASS}
  1495.   HEAP_INFORMATION_CLASS = _HEAP_INFORMATION_CLASS;
  1496.   {$EXTERNALSYM HEAP_INFORMATION_CLASS}
  1497.   THeapInformationClass = HEAP_INFORMATION_CLASS;
  1498. { TODO
  1499. DWORD NTAPI
  1500. RtlSetHeapInformation (
  1501.     IN PVOID HeapHandle,
  1502.     IN HEAP_INFORMATION_CLASS HeapInformationClass,
  1503.     IN PVOID HeapInformation OPTIONAL,
  1504.     IN SIZE_T HeapInformationLength OPTIONAL
  1505.     );
  1506. DWORD NTAPI
  1507. RtlQueryHeapInformation (
  1508.     IN PVOID HeapHandle,
  1509.     IN HEAP_INFORMATION_CLASS HeapInformationClass,
  1510.     OUT PVOID HeapInformation OPTIONAL,
  1511.     IN SIZE_T HeapInformationLength OPTIONAL,
  1512.     OUT PSIZE_T ReturnLength OPTIONAL
  1513.     );
  1514. //
  1515. //  Multiple alloc-free APIS
  1516. //
  1517. DWORD
  1518. NTAPI
  1519. RtlMultipleAllocateHeap (
  1520.     IN PVOID HeapHandle,
  1521.     IN DWORD Flags,
  1522.     IN SIZE_T Size,
  1523.     IN DWORD Count,
  1524.     OUT PVOID * Array
  1525.     );
  1526. DWORD
  1527. NTAPI
  1528. RtlMultipleFreeHeap (
  1529.     IN PVOID HeapHandle,
  1530.     IN DWORD Flags,
  1531.     IN DWORD Count,
  1532.     OUT PVOID * Array
  1533.     );
  1534. }
  1535. const
  1536.   WT_EXECUTEDEFAULT                 = $00000000;
  1537.   {$EXTERNALSYM WT_EXECUTEDEFAULT}
  1538.   WT_EXECUTEINIOTHREAD              = $00000001;
  1539.   {$EXTERNALSYM WT_EXECUTEINIOTHREAD}
  1540.   WT_EXECUTEINUITHREAD              = $00000002;
  1541.   {$EXTERNALSYM WT_EXECUTEINUITHREAD}
  1542.   WT_EXECUTEINWAITTHREAD            = $00000004;
  1543.   {$EXTERNALSYM WT_EXECUTEINWAITTHREAD}
  1544.   WT_EXECUTEONLYONCE                = $00000008;
  1545.   {$EXTERNALSYM WT_EXECUTEONLYONCE}
  1546.   WT_EXECUTEINTIMERTHREAD           = $00000020;
  1547.   {$EXTERNALSYM WT_EXECUTEINTIMERTHREAD}
  1548.   WT_EXECUTELONGFUNCTION            = $00000010;
  1549.   {$EXTERNALSYM WT_EXECUTELONGFUNCTION}
  1550.   WT_EXECUTEINPERSISTENTIOTHREAD    = $00000040;
  1551.   {$EXTERNALSYM WT_EXECUTEINPERSISTENTIOTHREAD}
  1552.   WT_EXECUTEINPERSISTENTTHREAD      = $00000080;
  1553.   {$EXTERNALSYM WT_EXECUTEINPERSISTENTTHREAD}
  1554.   WT_TRANSFER_IMPERSONATION         = $00000100;
  1555.   {$EXTERNALSYM WT_TRANSFER_IMPERSONATION}
  1556. function WT_SET_MAX_THREADPOOL_THREADS(var Flags: DWORD; Limit: DWORD): DWORD;
  1557. {$EXTERNALSYM WT_SET_MAX_THREADPOOL_THREADS}
  1558. type
  1559.   WAITORTIMERCALLBACKFUNC = procedure (P: PVOID; B: ByteBool); stdcall;
  1560.   {$EXTERNALSYM WAITORTIMERCALLBACKFUNC}
  1561.   WORKERCALLBACKFUNC = procedure (P: PVOID); stdcall;
  1562.   {$EXTERNALSYM WORKERCALLBACKFUNC}
  1563.   APC_CALLBACK_FUNCTION = procedure (D: DWORD; P1, P2: PVOID); stdcall;
  1564.   {$EXTERNALSYM APC_CALLBACK_FUNCTION}
  1565. const
  1566.   WT_EXECUTEINLONGTHREAD = $00000010;
  1567.   {$EXTERNALSYM WT_EXECUTEINLONGTHREAD}
  1568.   WT_EXECUTEDELETEWAIT   = $00000008;
  1569.   {$EXTERNALSYM WT_EXECUTEDELETEWAIT}
  1570. type
  1571.   _ACTIVATION_CONTEXT_INFO_CLASS = DWORD;
  1572.   {$EXTERNALSYM _ACTIVATION_CONTEXT_INFO_CLASS}
  1573.   ACTIVATION_CONTEXT_INFO_CLASS = _ACTIVATION_CONTEXT_INFO_CLASS;
  1574.   {$EXTERNALSYM ACTIVATION_CONTEXT_INFO_CLASS}
  1575.   TActivationContextInfoClass = ACTIVATION_CONTEXT_INFO_CLASS;
  1576. const
  1577.   ActivationContextBasicInformation                       = 1;
  1578.   {$EXTERNALSYM ActivationContextBasicInformation}
  1579.   ActivationContextDetailedInformation                    = 2;
  1580.   {$EXTERNALSYM ActivationContextDetailedInformation}
  1581.   AssemblyDetailedInformationInActivationContxt           = 3;
  1582.   {$EXTERNALSYM AssemblyDetailedInformationInActivationContxt}
  1583.   FileInformationInAssemblyOfAssemblyInActivationContxt   = 4;
  1584.   {$EXTERNALSYM FileInformationInAssemblyOfAssemblyInActivationContxt}
  1585.   MaxActivationContextInfoClass                           = 5;
  1586.   {$EXTERNALSYM MaxActivationContextInfoClass}
  1587. type
  1588.   PACTIVATION_CONTEXT_QUERY_INDEX = ^ACTIVATION_CONTEXT_QUERY_INDEX;
  1589.   {$EXTERNALSYM PACTIVATION_CONTEXT_QUERY_INDEX}
  1590.   _ACTIVATION_CONTEXT_QUERY_INDEX = record
  1591.     ulAssemblyIndex: DWORD;
  1592.     ulFileIndexInAssembly: DWORD;
  1593.   end;
  1594.   {$EXTERNALSYM _ACTIVATION_CONTEXT_QUERY_INDEX}
  1595.   ACTIVATION_CONTEXT_QUERY_INDEX = _ACTIVATION_CONTEXT_QUERY_INDEX;
  1596.   {$EXTERNALSYM ACTIVATION_CONTEXT_QUERY_INDEX}
  1597.   TActivationContextQueryIndex = ACTIVATION_CONTEXT_QUERY_INDEX;
  1598.   PActivationContextQueryIndex = PACTIVATION_CONTEXT_QUERY_INDEX;
  1599. const
  1600.   ACTIVATION_CONTEXT_PATH_TYPE_NONE        = (1);
  1601.   {$EXTERNALSYM ACTIVATION_CONTEXT_PATH_TYPE_NONE}
  1602.   ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE  = (2);
  1603.   {$EXTERNALSYM ACTIVATION_CONTEXT_PATH_TYPE_WIN32_FILE}
  1604.   ACTIVATION_CONTEXT_PATH_TYPE_URL         = (3);
  1605.   {$EXTERNALSYM ACTIVATION_CONTEXT_PATH_TYPE_URL}
  1606.   ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF = (4);
  1607.   {$EXTERNALSYM ACTIVATION_CONTEXT_PATH_TYPE_ASSEMBLYREF}
  1608. type
  1609.   PASSEMBLY_FILE_DETAILED_INFORMATION = ^ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION;
  1610.   {$EXTERNALSYM PASSEMBLY_FILE_DETAILED_INFORMATION}
  1611.   _ASSEMBLY_FILE_DETAILED_INFORMATION = record
  1612.     ulFlags: DWORD;
  1613.     ulFilenameLength: DWORD;
  1614.     ulPathLength: DWORD;
  1615.     lpFileName: LPCWSTR;
  1616.     lpFilePath: LPCWSTR;
  1617.   end;
  1618.   {$EXTERNALSYM _ASSEMBLY_FILE_DETAILED_INFORMATION}
  1619.   ASSEMBLY_FILE_DETAILED_INFORMATION = _ASSEMBLY_FILE_DETAILED_INFORMATION;
  1620.   {$EXTERNALSYM ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION}
  1621.   PCASSEMBLY_FILE_DETAILED_INFORMATION = PASSEMBLY_FILE_DETAILED_INFORMATION;
  1622.   {$EXTERNALSYM PCASSEMBLY_FILE_DETAILED_INFORMATION}
  1623.   TAssemblyFileDetailedInformation = ASSEMBLY_FILE_DETAILED_INFORMATION;
  1624.   PAssemblyFileDetailedInformation = PASSEMBLY_FILE_DETAILED_INFORMATION;
  1625. //
  1626. // compatibility with old names
  1627. // The new names use "file" consistently.
  1628. //
  1629.   _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = _ASSEMBLY_FILE_DETAILED_INFORMATION;
  1630.   {$EXTERNALSYM _ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION}
  1631.   ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = ASSEMBLY_FILE_DETAILED_INFORMATION;
  1632.   {$EXTERNALSYM ASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION}
  1633.   PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = PASSEMBLY_FILE_DETAILED_INFORMATION;
  1634.   {$EXTERNALSYM PASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION}
  1635.   PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION = PCASSEMBLY_FILE_DETAILED_INFORMATION;
  1636.   {$EXTERNALSYM PCASSEMBLY_DLL_REDIRECTION_DETAILED_INFORMATION}
  1637.   TAssemblyDllRedirectionDetailedInformation = TAssemblyFileDetailedInformation;
  1638.   PAssemblyDllRedirectionDetailedInformation = PAssemblyFileDetailedInformation;
  1639.   PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = ^ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
  1640.   {$EXTERNALSYM PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION}
  1641.   _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = record
  1642.     ulFlags: DWORD;
  1643.     ulEncodedAssemblyIdentityLength: DWORD; // in bytes
  1644.     ulManifestPathType: DWORD;              // ACTIVATION_CONTEXT_PATH_TYPE_*
  1645.     ulManifestPathLength: DWORD;            // in bytes
  1646.     liManifestLastWriteTime: LARGE_INTEGER; // FILETIME
  1647.     ulPolicyPathType: DWORD;                // ACTIVATION_CONTEXT_PATH_TYPE_*
  1648.     ulPolicyPathLength: DWORD;              // in bytes
  1649.     liPolicyLastWriteTime: LARGE_INTEGER;   // FILETIME
  1650.     ulMetadataSatelliteRosterIndex: DWORD;
  1651.     ulManifestVersionMajor: DWORD;          // 1
  1652.     ulManifestVersionMinor: DWORD;          // 0
  1653.     ulPolicyVersionMajor: DWORD;            // 0
  1654.     ulPolicyVersionMinor: DWORD;            // 0
  1655.     ulAssemblyDirectoryNameLength: DWORD;   // in bytes
  1656.     lpAssemblyEncodedAssemblyIdentity: LPCWSTR;
  1657.     lpAssemblyManifestPath: LPCWSTR;
  1658.     lpAssemblyPolicyPath: LPCWSTR;
  1659.     lpAssemblyDirectoryName: LPCWSTR;
  1660.     ulFileCount: DWORD;
  1661.   end;
  1662.   {$EXTERNALSYM _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION}
  1663.   ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION = _ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
  1664.   {$EXTERNALSYM ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION}
  1665.   TActivationContextAssemblyDetailedInformation = ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
  1666.   PActivationContextAssemblyDetailedInformation = PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION;
  1667.   PACTIVATION_CONTEXT_DETAILED_INFORMATION = ^ACTIVATION_CONTEXT_DETAILED_INFORMATION;
  1668.   {$EXTERNALSYM PACTIVATION_CONTEXT_DETAILED_INFORMATION}
  1669.   _ACTIVATION_CONTEXT_DETAILED_INFORMATION = record
  1670.     dwFlags: DWORD;
  1671.     ulFormatVersion: DWORD;
  1672.     ulAssemblyCount: DWORD;
  1673.     ulRootManifestPathType: DWORD;
  1674.     ulRootManifestPathChars: DWORD;
  1675.     ulRootConfigurationPathType: DWORD;
  1676.     ulRootConfigurationPathChars: DWORD;
  1677.     ulAppDirPathType: DWORD;
  1678.     ulAppDirPathChars: DWORD;
  1679.     lpRootManifestPath: LPCWSTR;
  1680.     lpRootConfigurationPath: LPCWSTR;
  1681.     lpAppDirPath: LPCWSTR;
  1682.   end;
  1683.   {$EXTERNALSYM _ACTIVATION_CONTEXT_DETAILED_INFORMATION}
  1684.   ACTIVATION_CONTEXT_DETAILED_INFORMATION = _ACTIVATION_CONTEXT_DETAILED_INFORMATION;
  1685.   {$EXTERNALSYM ACTIVATION_CONTEXT_DETAILED_INFORMATION}
  1686.   TActivationContextDetailedInformation = ACTIVATION_CONTEXT_DETAILED_INFORMATION;
  1687.   PActivationContextDetailedInformation = PACTIVATION_CONTEXT_DETAILED_INFORMATION;
  1688. const
  1689.   DLL_PROCESS_ATTACH     = 1;
  1690.   {$EXTERNALSYM DLL_PROCESS_ATTACH}
  1691.   DLL_THREAD_ATTACH      = 2;
  1692.   {$EXTERNALSYM DLL_THREAD_ATTACH}
  1693.   DLL_THREAD_DETACH      = 3;
  1694.   {$EXTERNALSYM DLL_THREAD_DETACH}
  1695.   DLL_PROCESS_DETACH     = 0;
  1696.   {$EXTERNALSYM DLL_PROCESS_DETACH}
  1697.   DLL_PROCESS_VERIFIER   = 4;
  1698.   {$EXTERNALSYM DLL_PROCESS_VERIFIER}
  1699. //
  1700. // Defines for the READ flags for Eventlogging
  1701. //
  1702.   EVENTLOG_SEQUENTIAL_READ = $0001;
  1703.   {$EXTERNALSYM EVENTLOG_SEQUENTIAL_READ}
  1704.   EVENTLOG_SEEK_READ       = $0002;
  1705.   {$EXTERNALSYM EVENTLOG_SEEK_READ}
  1706.   EVENTLOG_FORWARDS_READ   = $0004;
  1707.   {$EXTERNALSYM EVENTLOG_FORWARDS_READ}
  1708.   EVENTLOG_BACKWARDS_READ  = $0008;
  1709.   {$EXTERNALSYM EVENTLOG_BACKWARDS_READ}
  1710. //
  1711. // The types of events that can be logged.
  1712. //
  1713.   EVENTLOG_SUCCESS          = $0000;
  1714.   {$EXTERNALSYM EVENTLOG_SUCCESS}
  1715.   EVENTLOG_ERROR_TYPE       = $0001;
  1716.   {$EXTERNALSYM EVENTLOG_ERROR_TYPE}
  1717.   EVENTLOG_WARNING_TYPE     = $0002;
  1718.   {$EXTERNALSYM EVENTLOG_WARNING_TYPE}
  1719.   EVENTLOG_INFORMATION_TYPE = $0004;
  1720.   {$EXTERNALSYM EVENTLOG_INFORMATION_TYPE}
  1721.   EVENTLOG_AUDIT_SUCCESS    = $0008;
  1722.   {$EXTERNALSYM EVENTLOG_AUDIT_SUCCESS}
  1723.   EVENTLOG_AUDIT_FAILURE    = $0010;
  1724.   {$EXTERNALSYM EVENTLOG_AUDIT_FAILURE}
  1725. //
  1726. // Defines for the WRITE flags used by Auditing for paired events
  1727. // These are not implemented in Product 1
  1728. //
  1729.   EVENTLOG_START_PAIRED_EVENT    = $0001;
  1730.   {$EXTERNALSYM EVENTLOG_START_PAIRED_EVENT}
  1731.   EVENTLOG_END_PAIRED_EVENT      = $0002;
  1732.   {$EXTERNALSYM EVENTLOG_END_PAIRED_EVENT}
  1733.   EVENTLOG_END_ALL_PAIRED_EVENTS = $0004;
  1734.   {$EXTERNALSYM EVENTLOG_END_ALL_PAIRED_EVENTS}
  1735.   EVENTLOG_PAIRED_EVENT_ACTIVE   = $0008;
  1736.   {$EXTERNALSYM EVENTLOG_PAIRED_EVENT_ACTIVE}
  1737.   EVENTLOG_PAIRED_EVENT_INACTIVE = $0010;
  1738.   {$EXTERNALSYM EVENTLOG_PAIRED_EVENT_INACTIVE}
  1739. //
  1740. // Structure that defines the header of the Eventlog record. This is the
  1741. // fixed-sized portion before all the variable-length strings, binary
  1742. // data and pad bytes.
  1743. //
  1744. // TimeGenerated is the time it was generated at the client.
  1745. // TimeWritten is the time it was put into the log at the server end.
  1746. //
  1747. type
  1748.   PEventlogrecord = ^EVENTLOGRECORD;
  1749.   _EVENTLOGRECORD = record
  1750.     Length: DWORD; // Length of full record
  1751.     Reserved: DWORD; // Used by the service
  1752.     RecordNumber: DWORD; // Absolute record number
  1753.     TimeGenerated: DWORD; // Seconds since 1-1-1970
  1754.     TimeWritten: DWORD; // Seconds since 1-1-1970
  1755.     EventID: DWORD;
  1756.     EventType: Word;
  1757.     NumStrings: Word;
  1758.     EventCategory: Word;
  1759.     ReservedFlags: Word; // For use with paired events (auditing)
  1760.     ClosingRecordNumber: DWORD; // For use with paired events (auditing)
  1761.     StringOffset: DWORD; // Offset from beginning of record
  1762.     UserSidLength: DWORD;
  1763.     UserSidOffset: DWORD;
  1764.     DataLength: DWORD;
  1765.     DataOffset: DWORD; // Offset from beginning of record
  1766.     //
  1767.     // Then follow:
  1768.     //
  1769.     // WCHAR SourceName[]
  1770.     // WCHAR Computername[]
  1771.     // SID   UserSid
  1772.     // WCHAR Strings[]
  1773.     // BYTE  Data[]
  1774.     // CHAR  Pad[]
  1775.     // DWORD Length;
  1776.     //
  1777.   end;
  1778.   {$EXTERNALSYM _EVENTLOGRECORD}
  1779.   EVENTLOGRECORD = _EVENTLOGRECORD;
  1780.   {$EXTERNALSYM EVENTLOGRECORD}
  1781.   TEventlogrecord = EVENTLOGRECORD;
  1782. const
  1783.   MAXLOGICALLOGNAMESIZE = 256;
  1784.   {$EXTERNALSYM MAXLOGICALLOGNAMESIZE}
  1785. type
  1786.   PEventsForLogFile = ^EVENTSFORLOGFILE;
  1787.   _EVENTSFORLOGFILE = record
  1788.     ulSize: DWORD;
  1789.     szLogicalLogFile: array [0..MAXLOGICALLOGNAMESIZE - 1] of WCHAR; // name of the logical file-security/application/system
  1790.     ulNumRecords: DWORD;
  1791.     pEventLogRecords: array [0..0] of EVENTLOGRECORD;
  1792.   end;
  1793.   {$EXTERNALSYM _EVENTSFORLOGFILE}
  1794.   EVENTSFORLOGFILE = _EVENTSFORLOGFILE;
  1795.   {$EXTERNALSYM EVENTSFORLOGFILE}
  1796.   TEventsForLogFile = EVENTSFORLOGFILE;
  1797.   PPackedEventInfo = ^PACKEDEVENTINFO;
  1798.   _PACKEDEVENTINFO = record
  1799.     ulSize: DWORD;                    // total size of the structure
  1800.     ulNumEventsForLogFile: DWORD;     // number of EventsForLogFile structure that follow
  1801.     ulOffsets: array [0..0] of DWORD; // the offsets from the start of this structure to the EVENTSFORLOGFILE structure
  1802.   end;
  1803.   {$EXTERNALSYM _PACKEDEVENTINFO}
  1804.   PACKEDEVENTINFO = _PACKEDEVENTINFO;
  1805.   {$EXTERNALSYM PACKEDEVENTINFO}
  1806.   TPackedEventInfo = PACKEDEVENTINFO;
  1807. //
  1808. // Registry Specific Access Rights.
  1809. //
  1810. const
  1811.   KEY_QUERY_VALUE        = ($0001);
  1812.   {$EXTERNALSYM KEY_QUERY_VALUE}
  1813.   KEY_SET_VALUE          = ($0002);
  1814.   {$EXTERNALSYM KEY_SET_VALUE}
  1815.   KEY_CREATE_SUB_KEY     = ($0004);
  1816.   {$EXTERNALSYM KEY_CREATE_SUB_KEY}
  1817.   KEY_ENUMERATE_SUB_KEYS = ($0008);
  1818.   {$EXTERNALSYM KEY_ENUMERATE_SUB_KEYS}
  1819.   KEY_NOTIFY             = ($0010);
  1820.   {$EXTERNALSYM KEY_NOTIFY}
  1821.   KEY_CREATE_LINK        = ($0020);
  1822.   {$EXTERNALSYM KEY_CREATE_LINK}
  1823.   KEY_WOW64_32KEY        = ($0200);
  1824.   {$EXTERNALSYM KEY_WOW64_32KEY}
  1825.   KEY_WOW64_64KEY        = ($0100);
  1826.   {$EXTERNALSYM KEY_WOW64_64KEY}
  1827.   KEY_WOW64_RES          = ($0300);
  1828.   {$EXTERNALSYM KEY_WOW64_RES}
  1829.   KEY_READ = STANDARD_RIGHTS_READ or KEY_QUERY_VALUE or KEY_ENUMERATE_SUB_KEYS or
  1830.     KEY_NOTIFY  and (not SYNCHRONIZE);
  1831.   {$EXTERNALSYM KEY_READ}
  1832.   KEY_WRITE = STANDARD_RIGHTS_WRITE or KEY_SET_VALUE or KEY_CREATE_SUB_KEY and
  1833.     (not SYNCHRONIZE);
  1834.   {$EXTERNALSYM KEY_WRITE}
  1835.   KEY_EXECUTE = KEY_READ and  (not SYNCHRONIZE);
  1836.   {$EXTERNALSYM KEY_EXECUTE}
  1837.   KEY_ALL_ACCESS = STANDARD_RIGHTS_ALL or KEY_QUERY_VALUE or KEY_SET_VALUE or
  1838.     KEY_CREATE_SUB_KEY or KEY_ENUMERATE_SUB_KEYS or KEY_NOTIFY or
  1839.     KEY_CREATE_LINK and (not SYNCHRONIZE);
  1840.   {$EXTERNALSYM KEY_ALL_ACCESS}
  1841. //
  1842. // Open/Create Options
  1843. //
  1844.   REG_OPTION_RESERVED = ($00000000); // Parameter is reserved
  1845.   {$EXTERNALSYM REG_OPTION_RESERVED}
  1846.   REG_OPTION_NON_VOLATILE = ($00000000); // Key is preserved when system is rebooted
  1847.   {$EXTERNALSYM REG_OPTION_NON_VOLATILE}
  1848.   REG_OPTION_VOLATILE = ($00000001); // Key is not preserved when system is rebooted
  1849.   {$EXTERNALSYM REG_OPTION_VOLATILE}
  1850.   REG_OPTION_CREATE_LINK = ($00000002); // Created key is a symbolic link
  1851.   {$EXTERNALSYM REG_OPTION_CREATE_LINK}
  1852.   REG_OPTION_BACKUP_RESTORE = ($00000004); // open for backup or restore
  1853.   {$EXTERNALSYM REG_OPTION_BACKUP_RESTORE}
  1854.                                                     // special access rules
  1855.                                                     // privilege required
  1856.   REG_OPTION_OPEN_LINK = ($00000008); // Open symbolic link
  1857.   {$EXTERNALSYM REG_OPTION_OPEN_LINK}
  1858.   REG_LEGAL_OPTION = REG_OPTION_RESERVED or REG_OPTION_NON_VOLATILE or
  1859.     REG_OPTION_VOLATILE or REG_OPTION_CREATE_LINK or REG_OPTION_BACKUP_RESTORE or
  1860.     REG_OPTION_OPEN_LINK;
  1861.   {$EXTERNALSYM REG_LEGAL_OPTION}
  1862. //
  1863. // Key creation/open disposition
  1864. //
  1865.   REG_CREATED_NEW_KEY     = ($00000001); // New Registry Key created
  1866.   {$EXTERNALSYM REG_CREATED_NEW_KEY}
  1867.   REG_OPENED_EXISTING_KEY = ($00000002); // Existing Key opened
  1868.   {$EXTERNALSYM REG_OPENED_EXISTING_KEY}
  1869. //
  1870. // hive format to be used by Reg(Nt)SaveKeyEx
  1871. //
  1872.   REG_STANDARD_FORMAT    = 1;
  1873.   {$EXTERNALSYM REG_STANDARD_FORMAT}
  1874.   REG_LATEST_FORMAT      = 2;
  1875.   {$EXTERNALSYM REG_LATEST_FORMAT}
  1876.   REG_NO_COMPRESSION     = 4;
  1877.   {$EXTERNALSYM REG_NO_COMPRESSION}
  1878. //
  1879. // Key restore flags
  1880. //
  1881.   REG_WHOLE_HIVE_VOLATILE = ($00000001); // Restore whole hive volatile
  1882.   {$EXTERNALSYM REG_WHOLE_HIVE_VOLATILE}
  1883.   REG_REFRESH_HIVE        = ($00000002); // Unwind changes to last flush
  1884.   {$EXTERNALSYM REG_REFRESH_HIVE}
  1885.   REG_NO_LAZY_FLUSH       = ($00000004); // Never lazy flush this hive
  1886.   {$EXTERNALSYM REG_NO_LAZY_FLUSH}
  1887.   REG_FORCE_RESTORE       = ($00000008); // Force the restore process even when we have open handles on subkeys
  1888.   {$EXTERNALSYM REG_FORCE_RESTORE}
  1889. // end_ntddk end_wdm end_nthal
  1890. //
  1891. // Notify filter values
  1892. //
  1893.   REG_NOTIFY_CHANGE_NAME       = ($00000001); // Create or delete (child)
  1894.   {$EXTERNALSYM REG_NOTIFY_CHANGE_NAME}
  1895.   REG_NOTIFY_CHANGE_ATTRIBUTES = ($00000002);
  1896.   {$EXTERNALSYM REG_NOTIFY_CHANGE_ATTRIBUTES}
  1897.   REG_NOTIFY_CHANGE_LAST_SET   = ($00000004); // time stamp
  1898.   {$EXTERNALSYM REG_NOTIFY_CHANGE_LAST_SET}
  1899.   REG_NOTIFY_CHANGE_SECURITY   = ($00000008);
  1900.   {$EXTERNALSYM REG_NOTIFY_CHANGE_SECURITY}
  1901.   REG_LEGAL_CHANGE_FILTER = REG_NOTIFY_CHANGE_NAME or REG_NOTIFY_CHANGE_ATTRIBUTES or
  1902.     REG_NOTIFY_CHANGE_LAST_SET or REG_NOTIFY_CHANGE_SECURITY;
  1903.   {$EXTERNALSYM REG_LEGAL_CHANGE_FILTER}
  1904. //
  1905. //
  1906. // Predefined Value Types.
  1907. //
  1908.   REG_NONE      = ( 0 ); // No value type
  1909.   {$EXTERNALSYM REG_NONE}
  1910.   REG_SZ        = ( 1 ); // Unicode nul terminated string
  1911.   {$EXTERNALSYM REG_SZ}
  1912.   REG_EXPAND_SZ = ( 2 ); // Unicode nul terminated string
  1913.   {$EXTERNALSYM REG_EXPAND_SZ}
  1914.                                             // (with environment variable references)
  1915.   REG_BINARY                     = ( 3 ); // Free form binary
  1916.   {$EXTERNALSYM REG_BINARY}
  1917.   REG_DWORD                      = ( 4 ); // 32-bit number
  1918.   {$EXTERNALSYM REG_DWORD}
  1919.   REG_DWORD_LITTLE_ENDIAN        = ( 4 ); // 32-bit number (same as REG_DWORD)
  1920.   {$EXTERNALSYM REG_DWORD_LITTLE_ENDIAN}
  1921.   REG_DWORD_BIG_ENDIAN           = ( 5 ); // 32-bit number
  1922.   {$EXTERNALSYM REG_DWORD_BIG_ENDIAN}
  1923.   REG_LINK                       = ( 6 ); // Symbolic Link (unicode)
  1924.   {$EXTERNALSYM REG_LINK}
  1925.   REG_MULTI_SZ                   = ( 7 ); // Multiple Unicode strings
  1926.   {$EXTERNALSYM REG_MULTI_SZ}
  1927.   REG_RESOURCE_LIST              = ( 8 ); // Resource list in the resource map
  1928.   {$EXTERNALSYM REG_RESOURCE_LIST}
  1929.   REG_FULL_RESOURCE_DESCRIPTOR   = ( 9 ); // Resource list in the hardware description
  1930.   {$EXTERNALSYM REG_FULL_RESOURCE_DESCRIPTOR}
  1931.   REG_RESOURCE_REQUIREMENTS_LIST = ( 10 );
  1932.   {$EXTERNALSYM REG_RESOURCE_REQUIREMENTS_LIST}
  1933.   REG_QWORD                      = ( 11 ); // 64-bit number
  1934.   {$EXTERNALSYM REG_QWORD}
  1935.   REG_QWORD_LITTLE_ENDIAN        = ( 11 ); // 64-bit number (same as REG_QWORD)
  1936.   {$EXTERNALSYM REG_QWORD_LITTLE_ENDIAN}
  1937. //
  1938. // Service Types (Bit Mask)
  1939. //
  1940.   SERVICE_KERNEL_DRIVER      = $00000001;
  1941.   {$EXTERNALSYM SERVICE_KERNEL_DRIVER}
  1942.   SERVICE_FILE_SYSTEM_DRIVER = $00000002;
  1943.   {$EXTERNALSYM SERVICE_FILE_SYSTEM_DRIVER}
  1944.   SERVICE_ADAPTER            = $00000004;
  1945.   {$EXTERNALSYM SERVICE_ADAPTER}
  1946.   SERVICE_RECOGNIZER_DRIVER  = $00000008;
  1947.   {$EXTERNALSYM SERVICE_RECOGNIZER_DRIVER}
  1948.   SERVICE_DRIVER = SERVICE_KERNEL_DRIVER or SERVICE_FILE_SYSTEM_DRIVER or
  1949.     SERVICE_RECOGNIZER_DRIVER;
  1950.   {$EXTERNALSYM SERVICE_DRIVER}
  1951.   SERVICE_WIN32_OWN_PROCESS   = $00000010;
  1952.   {$EXTERNALSYM SERVICE_WIN32_OWN_PROCESS}
  1953.   SERVICE_WIN32_SHARE_PROCESS = $00000020;
  1954.   {$EXTERNALSYM SERVICE_WIN32_SHARE_PROCESS}
  1955.   SERVICE_WIN32 = SERVICE_WIN32_OWN_PROCESS or SERVICE_WIN32_SHARE_PROCESS;
  1956.   {$EXTERNALSYM SERVICE_WIN32}
  1957.   SERVICE_INTERACTIVE_PROCESS = $00000100;
  1958.   {$EXTERNALSYM SERVICE_INTERACTIVE_PROCESS}
  1959.   SERVICE_TYPE_ALL = SERVICE_WIN32 or SERVICE_ADAPTER or SERVICE_DRIVER or
  1960.     SERVICE_INTERACTIVE_PROCESS;
  1961.   {$EXTERNALSYM SERVICE_TYPE_ALL}
  1962. //
  1963. // Start Type
  1964. //
  1965.   SERVICE_BOOT_START   = $00000000;
  1966.   {$EXTERNALSYM SERVICE_BOOT_START}
  1967.   SERVICE_SYSTEM_START = $00000001;
  1968.   {$EXTERNALSYM SERVICE_SYSTEM_START}
  1969.   SERVICE_AUTO_START   = $00000002;
  1970.   {$EXTERNALSYM SERVICE_AUTO_START}
  1971.   SERVICE_DEMAND_START = $00000003;
  1972.   {$EXTERNALSYM SERVICE_DEMAND_START}
  1973.   SERVICE_DISABLED     = $00000004;
  1974.   {$EXTERNALSYM SERVICE_DISABLED}
  1975. //
  1976. // Error control type
  1977. //
  1978.   SERVICE_ERROR_IGNORE   = $00000000;
  1979.   {$EXTERNALSYM SERVICE_ERROR_IGNORE}
  1980.   SERVICE_ERROR_NORMAL   = $00000001;
  1981.   {$EXTERNALSYM SERVICE_ERROR_NORMAL}
  1982.   SERVICE_ERROR_SEVERE   = $00000002;
  1983.   {$EXTERNALSYM SERVICE_ERROR_SEVERE}
  1984.   SERVICE_ERROR_CRITICAL = $00000003;
  1985.   {$EXTERNALSYM SERVICE_ERROR_CRITICAL}
  1986. //
  1987. // Define the registry driver node enumerations
  1988. //
  1989. const
  1990. //SERVICE_NODE_TYPE
  1991.   DriverType               = SERVICE_KERNEL_DRIVER;
  1992.   FileSystemType           = SERVICE_FILE_SYSTEM_DRIVER;
  1993.   Win32ServiceOwnProcess   = SERVICE_WIN32_OWN_PROCESS;
  1994.   Win32ServiceShareProcess = SERVICE_WIN32_SHARE_PROCESS;
  1995.   AdapterType              = SERVICE_ADAPTER;
  1996.   RecognizerType           = SERVICE_RECOGNIZER_DRIVER;
  1997. //SERVICE_LOAD_TYPE
  1998.   BootLoad    = SERVICE_BOOT_START;
  1999.   SystemLoad  = SERVICE_SYSTEM_START;
  2000.   AutoLoad    = SERVICE_AUTO_START;
  2001.   DemandLoad  = SERVICE_DEMAND_START;
  2002.   DisableLoad = SERVICE_DISABLED;
  2003. //SERVICE_ERROR_TYPE
  2004.   IgnoreError   = SERVICE_ERROR_IGNORE;
  2005.   NormalError   = SERVICE_ERROR_NORMAL;
  2006.   SevereError   = SERVICE_ERROR_SEVERE;
  2007.   CriticalError = SERVICE_ERROR_CRITICAL;
  2008. //
  2009. // IOCTL_TAPE_ERASE definitions
  2010. //
  2011. type
  2012.   SERVICE_NODE_TYPE = DWORD;
  2013.   {$EXTERNALSYM SERVICE_NODE_TYPE}
  2014.   TServiceNodeType = SERVICE_NODE_TYPE;
  2015.   SERVICE_LOAD_TYPE = DWORD;
  2016.   {$EXTERNALSYM SERVICE_LOAD_TYPE}
  2017.   TServiceLoadType = SERVICE_LOAD_TYPE;
  2018.   SERVICE_ERROR_TYPE = DWORD;
  2019.   {$EXTERNALSYM SERVICE_ERROR_TYPE}
  2020.   TServiceErrorType = SERVICE_ERROR_TYPE;
  2021. const
  2022.   TAPE_ERASE_SHORT = 0;
  2023.   {$EXTERNALSYM TAPE_ERASE_SHORT}
  2024.   TAPE_ERASE_LONG  = 1;
  2025.   {$EXTERNALSYM TAPE_ERASE_LONG}
  2026. type
  2027.   PTAPE_ERASE = ^TAPE_ERASE;
  2028.   {$EXTERNALSYM PTAPE_ERASE}
  2029.   _TAPE_ERASE = record
  2030.     Type_: DWORD;
  2031.     Immediate: ByteBool;
  2032.   end;
  2033.   {$EXTERNALSYM _TAPE_ERASE}
  2034.   TAPE_ERASE = _TAPE_ERASE;
  2035.   {$EXTERNALSYM TAPE_ERASE}
  2036.   TTapeErase = TAPE_ERASE;
  2037.   PTapeErase = PTAPE_ERASE;
  2038. //
  2039. // IOCTL_TAPE_PREPARE definitions
  2040. //
  2041. const
  2042.   TAPE_LOAD    = 0;
  2043.   {$EXTERNALSYM TAPE_LOAD}
  2044.   TAPE_UNLOAD  = 1;
  2045.   {$EXTERNALSYM TAPE_UNLOAD}
  2046.   TAPE_TENSION = 2;
  2047.   {$EXTERNALSYM TAPE_TENSION}
  2048.   TAPE_LOCK    = 3;
  2049.   {$EXTERNALSYM TAPE_LOCK}
  2050.   TAPE_UNLOCK  = 4;
  2051.   {$EXTERNALSYM TAPE_UNLOCK}
  2052.   TAPE_FORMAT  = 5;
  2053.   {$EXTERNALSYM TAPE_FORMAT}
  2054. type
  2055.   PTAPE_PREPARE = ^TAPE_PREPARE;
  2056.   {$EXTERNALSYM PTAPE_PREPARE}
  2057.   _TAPE_PREPARE = record
  2058.     Operation: DWORD;
  2059.     Immediate: ByteBool;
  2060.   end;
  2061.   {$EXTERNALSYM _TAPE_PREPARE}
  2062.   TAPE_PREPARE = _TAPE_PREPARE;
  2063.   {$EXTERNALSYM TAPE_PREPARE}
  2064.   TTapePrepare = TAPE_PREPARE;
  2065.   PTapePrepare = PTAPE_PREPARE;
  2066. //
  2067. // IOCTL_TAPE_WRITE_MARKS definitions
  2068. //
  2069. const
  2070.   TAPE_SETMARKS        = 0;
  2071.   {$EXTERNALSYM TAPE_SETMARKS}
  2072.   TAPE_FILEMARKS       = 1;
  2073.   {$EXTERNALSYM TAPE_FILEMARKS}
  2074.   TAPE_SHORT_FILEMARKS = 2;
  2075.   {$EXTERNALSYM TAPE_SHORT_FILEMARKS}
  2076.   TAPE_LONG_FILEMARKS  = 3;
  2077.   {$EXTERNALSYM TAPE_LONG_FILEMARKS}
  2078. type
  2079.   PTAPE_WRITE_MARKS = ^TAPE_WRITE_MARKS;
  2080.   {$EXTERNALSYM PTAPE_WRITE_MARKS}
  2081.   _TAPE_WRITE_MARKS = record
  2082.     Type_: DWORD;
  2083.     Count: DWORD;
  2084.     Immediate: ByteBool;
  2085.   end;
  2086.   {$EXTERNALSYM _TAPE_WRITE_MARKS}
  2087.   TAPE_WRITE_MARKS = _TAPE_WRITE_MARKS;
  2088.   {$EXTERNALSYM TAPE_WRITE_MARKS}
  2089.   TTapeWriteMarks = TAPE_WRITE_MARKS;
  2090.   PTapeWriteMarks = PTAPE_WRITE_MARKS;
  2091. //
  2092. // IOCTL_TAPE_GET_POSITION definitions
  2093. //
  2094. const
  2095.   TAPE_ABSOLUTE_POSITION       = 0;
  2096.   {$EXTERNALSYM TAPE_ABSOLUTE_POSITION}
  2097.   TAPE_LOGICAL_POSITION        = 1;
  2098.   {$EXTERNALSYM TAPE_LOGICAL_POSITION}
  2099.   TAPE_PSEUDO_LOGICAL_POSITION = 2;
  2100.   {$EXTERNALSYM TAPE_PSEUDO_LOGICAL_POSITION}
  2101. type
  2102.   PTAPE_GET_POSITION = ^TAPE_GET_POSITION;
  2103.   {$EXTERNALSYM PTAPE_GET_POSITION}
  2104.   _TAPE_GET_POSITION = record
  2105.     Type_: DWORD;
  2106.     Partition: DWORD;
  2107.     Offset: LARGE_INTEGER;
  2108.   end;
  2109.   {$EXTERNALSYM _TAPE_GET_POSITION}
  2110.   TAPE_GET_POSITION = _TAPE_GET_POSITION;
  2111.   {$EXTERNALSYM TAPE_GET_POSITION}
  2112.   TTapeGetPosition = TAPE_GET_POSITION;
  2113.   PTapeGetPosition = PTAPE_GET_POSITION;
  2114. //
  2115. // IOCTL_TAPE_SET_POSITION definitions
  2116. //
  2117. const
  2118.   TAPE_REWIND                = 0;
  2119.   {$EXTERNALSYM TAPE_REWIND}
  2120.   TAPE_ABSOLUTE_BLOCK        = 1;
  2121.   {$EXTERNALSYM TAPE_ABSOLUTE_BLOCK}
  2122.   TAPE_LOGICAL_BLOCK         = 2;
  2123.   {$EXTERNALSYM TAPE_LOGICAL_BLOCK}
  2124.   TAPE_PSEUDO_LOGICAL_BLOCK  = 3;
  2125.   {$EXTERNALSYM TAPE_PSEUDO_LOGICAL_BLOCK}
  2126.   TAPE_SPACE_END_OF_DATA     = 4;
  2127.   {$EXTERNALSYM TAPE_SPACE_END_OF_DATA}
  2128.   TAPE_SPACE_RELATIVE_BLOCKS = 5;
  2129.   {$EXTERNALSYM TAPE_SPACE_RELATIVE_BLOCKS}
  2130.   TAPE_SPACE_FILEMARKS       = 6;
  2131.   {$EXTERNALSYM TAPE_SPACE_FILEMARKS}
  2132.   TAPE_SPACE_SEQUENTIAL_FMKS = 7;
  2133.   {$EXTERNALSYM TAPE_SPACE_SEQUENTIAL_FMKS}
  2134.   TAPE_SPACE_SETMARKS        = 8;
  2135.   {$EXTERNALSYM TAPE_SPACE_SETMARKS}
  2136.   TAPE_SPACE_SEQUENTIAL_SMKS = 9;
  2137.   {$EXTERNALSYM TAPE_SPACE_SEQUENTIAL_SMKS}
  2138. type
  2139.   PTAPE_SET_POSITION = ^TAPE_SET_POSITION;
  2140.   {$EXTERNALSYM PTAPE_SET_POSITION}
  2141.   _TAPE_SET_POSITION = record
  2142.     Method: DWORD;
  2143.     Partition: DWORD;
  2144.     Offset: LARGE_INTEGER;
  2145.     Immediate: ByteBool;
  2146.   end;
  2147.   {$EXTERNALSYM _TAPE_SET_POSITION}
  2148.   TAPE_SET_POSITION = _TAPE_SET_POSITION;
  2149.   {$EXTERNALSYM TAPE_SET_POSITION}
  2150.   TTapeSetPosition = TAPE_SET_POSITION;
  2151.   PTapeSetPosition = PTAPE_SET_POSITION;
  2152. //
  2153. // IOCTL_TAPE_GET_DRIVE_PARAMS definitions
  2154. //
  2155. //
  2156. // Definitions for FeaturesLow parameter
  2157. //
  2158. const
  2159.   TAPE_DRIVE_FIXED     = $00000001;
  2160.   {$EXTERNALSYM TAPE_DRIVE_FIXED}
  2161.   TAPE_DRIVE_SELECT    = $00000002;
  2162.   {$EXTERNALSYM TAPE_DRIVE_SELECT}
  2163.   TAPE_DRIVE_INITIATOR = $00000004;
  2164.   {$EXTERNALSYM TAPE_DRIVE_INITIATOR}
  2165.   TAPE_DRIVE_ERASE_SHORT     = $00000010;
  2166.   {$EXTERNALSYM TAPE_DRIVE_ERASE_SHORT}
  2167.   TAPE_DRIVE_ERASE_LONG      = $00000020;
  2168.   {$EXTERNALSYM TAPE_DRIVE_ERASE_LONG}
  2169.   TAPE_DRIVE_ERASE_BOP_ONLY  = $00000040;
  2170.   {$EXTERNALSYM TAPE_DRIVE_ERASE_BOP_ONLY}
  2171.   TAPE_DRIVE_ERASE_IMMEDIATE = $00000080;
  2172.   {$EXTERNALSYM TAPE_DRIVE_ERASE_IMMEDIATE}
  2173.   TAPE_DRIVE_TAPE_CAPACITY  = $00000100;
  2174.   {$EXTERNALSYM TAPE_DRIVE_TAPE_CAPACITY}
  2175.   TAPE_DRIVE_TAPE_REMAINING = $00000200;
  2176.   {$EXTERNALSYM TAPE_DRIVE_TAPE_REMAINING}
  2177.   TAPE_DRIVE_FIXED_BLOCK    = $00000400;
  2178.   {$EXTERNALSYM TAPE_DRIVE_FIXED_BLOCK}
  2179.   TAPE_DRIVE_VARIABLE_BLOCK = $00000800;
  2180.   {$EXTERNALSYM TAPE_DRIVE_VARIABLE_BLOCK}
  2181.   TAPE_DRIVE_WRITE_PROTECT = $00001000;
  2182.   {$EXTERNALSYM TAPE_DRIVE_WRITE_PROTECT}
  2183.   TAPE_DRIVE_EOT_WZ_SIZE   = $00002000;
  2184.   {$EXTERNALSYM TAPE_DRIVE_EOT_WZ_SIZE}
  2185.   TAPE_DRIVE_ECC         = $00010000;
  2186.   {$EXTERNALSYM TAPE_DRIVE_ECC}
  2187.   TAPE_DRIVE_COMPRESSION = $00020000;
  2188.   {$EXTERNALSYM TAPE_DRIVE_COMPRESSION}
  2189.   TAPE_DRIVE_PADDING     = $00040000;
  2190.   {$EXTERNALSYM TAPE_DRIVE_PADDING}
  2191.   TAPE_DRIVE_REPORT_SMKS = $00080000;
  2192.   {$EXTERNALSYM TAPE_DRIVE_REPORT_SMKS}
  2193.   TAPE_DRIVE_GET_ABSOLUTE_BLK = $00100000;
  2194.   {$EXTERNALSYM TAPE_DRIVE_GET_ABSOLUTE_BLK}
  2195.   TAPE_DRIVE_GET_LOGICAL_BLK  = $00200000;
  2196.   {$EXTERNALSYM TAPE_DRIVE_GET_LOGICAL_BLK}
  2197.   TAPE_DRIVE_SET_EOT_WZ_SIZE  = $00400000;
  2198.   {$EXTERNALSYM TAPE_DRIVE_SET_EOT_WZ_SIZE}
  2199.   TAPE_DRIVE_EJECT_MEDIA      = $01000000;
  2200.   {$EXTERNALSYM TAPE_DRIVE_EJECT_MEDIA}
  2201.   TAPE_DRIVE_CLEAN_REQUESTS   = $02000000;
  2202.   {$EXTERNALSYM TAPE_DRIVE_CLEAN_REQUESTS}
  2203.   TAPE_DRIVE_SET_CMP_BOP_ONLY = $04000000;
  2204.   {$EXTERNALSYM TAPE_DRIVE_SET_CMP_BOP_ONLY}
  2205.   TAPE_DRIVE_RESERVED_BIT = DWORD($80000000); // don't use this bit!
  2206.   {$EXTERNALSYM TAPE_DRIVE_RESERVED_BIT}
  2207.   //                                              //can't be a low features bit!
  2208. //                                              //reserved; high features only
  2209. //
  2210. // Definitions for FeaturesHigh parameter
  2211. //
  2212.   TAPE_DRIVE_LOAD_UNLOAD      = DWORD($80000001);
  2213.   {$EXTERNALSYM TAPE_DRIVE_LOAD_UNLOAD}
  2214.   TAPE_DRIVE_TENSION          = DWORD($80000002);
  2215.   {$EXTERNALSYM TAPE_DRIVE_TENSION}
  2216.   TAPE_DRIVE_LOCK_UNLOCK      = DWORD($80000004);
  2217.   {$EXTERNALSYM TAPE_DRIVE_LOCK_UNLOCK}
  2218.   TAPE_DRIVE_REWIND_IMMEDIATE = DWORD($80000008);
  2219.   {$EXTERNALSYM TAPE_DRIVE_REWIND_IMMEDIATE}
  2220.   TAPE_DRIVE_SET_BLOCK_SIZE  = DWORD($80000010);
  2221.   {$EXTERNALSYM TAPE_DRIVE_SET_BLOCK_SIZE}
  2222.   TAPE_DRIVE_LOAD_UNLD_IMMED = DWORD($80000020);
  2223.   {$EXTERNALSYM TAPE_DRIVE_LOAD_UNLD_IMMED}
  2224.   TAPE_DRIVE_TENSION_IMMED   = DWORD($80000040);
  2225.   {$EXTERNALSYM TAPE_DRIVE_TENSION_IMMED}
  2226.   TAPE_DRIVE_LOCK_UNLK_IMMED = DWORD($80000080);
  2227.   {$EXTERNALSYM TAPE_DRIVE_LOCK_UNLK_IMMED}
  2228.   TAPE_DRIVE_SET_ECC         = DWORD($80000100);
  2229.   {$EXTERNALSYM TAPE_DRIVE_SET_ECC}
  2230.   TAPE_DRIVE_SET_COMPRESSION = DWORD($80000200);
  2231.   {$EXTERNALSYM TAPE_DRIVE_SET_COMPRESSION}
  2232.   TAPE_DRIVE_SET_PADDING     = DWORD($80000400);
  2233.   {$EXTERNALSYM TAPE_DRIVE_SET_PADDING}
  2234.   TAPE_DRIVE_SET_REPORT_SMKS = DWORD($80000800);
  2235.   {$EXTERNALSYM TAPE_DRIVE_SET_REPORT_SMKS}
  2236.   TAPE_DRIVE_ABSOLUTE_BLK  = DWORD($80001000);
  2237.   {$EXTERNALSYM TAPE_DRIVE_ABSOLUTE_BLK}
  2238.   TAPE_DRIVE_ABS_BLK_IMMED = DWORD($80002000);
  2239.   {$EXTERNALSYM TAPE_DRIVE_ABS_BLK_IMMED}
  2240.   TAPE_DRIVE_LOGICAL_BLK   = DWORD($80004000);
  2241.   {$EXTERNALSYM TAPE_DRIVE_LOGICAL_BLK}
  2242.   TAPE_DRIVE_LOG_BLK_IMMED = DWORD($80008000);
  2243.   {$EXTERNALSYM TAPE_DRIVE_LOG_BLK_IMMED}
  2244.   TAPE_DRIVE_END_OF_DATA     = DWORD($80010000);
  2245.   {$EXTERNALSYM TAPE_DRIVE_END_OF_DATA}
  2246.   TAPE_DRIVE_RELATIVE_BLKS   = DWORD($80020000);
  2247.   {$EXTERNALSYM TAPE_DRIVE_RELATIVE_BLKS}
  2248.   TAPE_DRIVE_FILEMARKS       = DWORD($80040000);
  2249.   {$EXTERNALSYM TAPE_DRIVE_FILEMARKS}
  2250.   TAPE_DRIVE_SEQUENTIAL_FMKS = DWORD($80080000);
  2251.   {$EXTERNALSYM TAPE_DRIVE_SEQUENTIAL_FMKS}
  2252.   TAPE_DRIVE_SETMARKS         = DWORD($80100000);
  2253.   {$EXTERNALSYM TAPE_DRIVE_SETMARKS}
  2254.   TAPE_DRIVE_SEQUENTIAL_SMKS  = DWORD($80200000);
  2255.   {$EXTERNALSYM TAPE_DRIVE_SEQUENTIAL_SMKS}
  2256.   TAPE_DRIVE_REVERSE_POSITION = DWORD($80400000);
  2257.   {$EXTERNALSYM TAPE_DRIVE_REVERSE_POSITION}
  2258.   TAPE_DRIVE_SPACE_IMMEDIATE  = DWORD($80800000);
  2259.   {$EXTERNALSYM TAPE_DRIVE_SPACE_IMMEDIATE}
  2260.   TAPE_DRIVE_WRITE_SETMARKS   = DWORD($81000000);
  2261.   {$EXTERNALSYM TAPE_DRIVE_WRITE_SETMARKS}
  2262.   TAPE_DRIVE_WRITE_FILEMARKS  = DWORD($82000000);
  2263.   {$EXTERNALSYM TAPE_DRIVE_WRITE_FILEMARKS}
  2264.   TAPE_DRIVE_WRITE_SHORT_FMKS = DWORD($84000000);
  2265.   {$EXTERNALSYM TAPE_DRIVE_WRITE_SHORT_FMKS}
  2266.   TAPE_DRIVE_WRITE_LONG_FMKS  = DWORD($88000000);
  2267.   {$EXTERNALSYM TAPE_DRIVE_WRITE_LONG_FMKS}
  2268.   TAPE_DRIVE_WRITE_MARK_IMMED = DWORD($90000000);
  2269.   {$EXTERNALSYM TAPE_DRIVE_WRITE_MARK_IMMED}
  2270.   TAPE_DRIVE_FORMAT           = DWORD($A0000000);
  2271.   {$EXTERNALSYM TAPE_DRIVE_FORMAT}
  2272.   TAPE_DRIVE_FORMAT_IMMEDIATE = DWORD($C0000000);
  2273.   {$EXTERNALSYM TAPE_DRIVE_FORMAT_IMMEDIATE}
  2274.   TAPE_DRIVE_HIGH_FEATURES    = DWORD($80000000); // mask for high features flag
  2275.   {$EXTERNALSYM TAPE_DRIVE_HIGH_FEATURES}
  2276. type
  2277.   PTAPE_GET_DRIVE_PARAMETERS = ^TAPE_GET_DRIVE_PARAMETERS;
  2278.   {$EXTERNALSYM PTAPE_GET_DRIVE_PARAMETERS}
  2279.   _TAPE_GET_DRIVE_PARAMETERS = record
  2280.     ECC: ByteBool;
  2281.     Compression: ByteBool;
  2282.     DataPadding: ByteBool;
  2283.     ReportSetmarks: ByteBool;
  2284.     DefaultBlockSize: DWORD;
  2285.     MaximumBlockSize: DWORD;
  2286.     MinimumBlockSize: DWORD;
  2287.     MaximumPartitionCount: DWORD;
  2288.     FeaturesLow: DWORD;
  2289.     FeaturesHigh: DWORD;
  2290.     EOTWarningZoneSize: DWORD;
  2291.   end;
  2292.   {$EXTERNALSYM _TAPE_GET_DRIVE_PARAMETERS}
  2293.   TAPE_GET_DRIVE_PARAMETERS = _TAPE_GET_DRIVE_PARAMETERS;
  2294.   {$EXTERNALSYM TAPE_GET_DRIVE_PARAMETERS}
  2295.   TTapeGetDriveParameters = TAPE_GET_DRIVE_PARAMETERS;
  2296.   PTapeGetDriveParameters = PTAPE_GET_DRIVE_PARAMETERS;
  2297. //
  2298. // IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions
  2299. //
  2300.   PTAPE_SET_DRIVE_PARAMETERS = ^TAPE_SET_DRIVE_PARAMETERS;
  2301.   {$EXTERNALSYM PTAPE_SET_DRIVE_PARAMETERS}
  2302.   _TAPE_SET_DRIVE_PARAMETERS = record
  2303.     ECC: ByteBool;
  2304.     Compression: ByteBool;
  2305.     DataPadding: ByteBool;
  2306.     ReportSetmarks: ByteBool;
  2307.     EOTWarningZoneSize: DWORD;
  2308.   end;
  2309.   {$EXTERNALSYM _TAPE_SET_DRIVE_PARAMETERS}
  2310.   TAPE_SET_DRIVE_PARAMETERS = _TAPE_SET_DRIVE_PARAMETERS;
  2311.   {$EXTERNALSYM TAPE_SET_DRIVE_PARAMETERS}
  2312.   TTapeSetDriveParameters = TAPE_SET_DRIVE_PARAMETERS;
  2313.   PTapeSetDriveParameters = PTAPE_SET_DRIVE_PARAMETERS;
  2314. //
  2315. // IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions
  2316. //
  2317.   PTAPE_GET_MEDIA_PARAMETERS = ^TAPE_GET_MEDIA_PARAMETERS;
  2318.   {$EXTERNALSYM PTAPE_GET_MEDIA_PARAMETERS}
  2319.   _TAPE_GET_MEDIA_PARAMETERS = record
  2320.     Capacity: LARGE_INTEGER;
  2321.     Remaining: LARGE_INTEGER;
  2322.     BlockSize: DWORD;
  2323.     PartitionCount: DWORD;
  2324.     WriteProtected: ByteBool;
  2325.   end;
  2326.   {$EXTERNALSYM _TAPE_GET_MEDIA_PARAMETERS}
  2327.   TAPE_GET_MEDIA_PARAMETERS = _TAPE_GET_MEDIA_PARAMETERS;
  2328.   {$EXTERNALSYM TAPE_GET_MEDIA_PARAMETERS}
  2329.   TTapeGetMediaParameters = TAPE_GET_MEDIA_PARAMETERS;
  2330.   PTapeGetMediaParameters = PTAPE_GET_MEDIA_PARAMETERS;
  2331. //
  2332. // IOCTL_TAPE_SET_MEDIA_PARAMETERS definitions
  2333. //
  2334.   PTAPE_SET_MEDIA_PARAMETERS = ^TAPE_SET_MEDIA_PARAMETERS;
  2335.   {$EXTERNALSYM PTAPE_SET_MEDIA_PARAMETERS}
  2336.   _TAPE_SET_MEDIA_PARAMETERS = record
  2337.     BlockSize: DWORD;
  2338.   end;
  2339.   {$EXTERNALSYM _TAPE_SET_MEDIA_PARAMETERS}
  2340.   TAPE_SET_MEDIA_PARAMETERS = _TAPE_SET_MEDIA_PARAMETERS;
  2341.   {$EXTERNALSYM TAPE_SET_MEDIA_PARAMETERS}
  2342.   TTapeSetMediaParameters = TAPE_SET_MEDIA_PARAMETERS;
  2343.   PTapeSetMediaParameters = PTAPE_SET_MEDIA_PARAMETERS;
  2344. //
  2345. // IOCTL_TAPE_CREATE_PARTITION definitions
  2346. //
  2347. const
  2348.   TAPE_FIXED_PARTITIONS     = 0;
  2349.   {$EXTERNALSYM TAPE_FIXED_PARTITIONS}
  2350.   TAPE_SELECT_PARTITIONS    = 1;
  2351.   {$EXTERNALSYM TAPE_SELECT_PARTITIONS}
  2352.   TAPE_INITIATOR_PARTITIONS = 2;
  2353.   {$EXTERNALSYM TAPE_INITIATOR_PARTITIONS}
  2354. type
  2355.   PTAPE_CREATE_PARTITION = ^TAPE_CREATE_PARTITION;
  2356.   {$EXTERNALSYM PTAPE_CREATE_PARTITION}
  2357.   _TAPE_CREATE_PARTITION = record
  2358.     Method: DWORD;
  2359.     Count: DWORD;
  2360.     Size: DWORD;
  2361.   end;
  2362.   {$EXTERNALSYM _TAPE_CREATE_PARTITION}
  2363.   TAPE_CREATE_PARTITION = _TAPE_CREATE_PARTITION;
  2364.   {$EXTERNALSYM TAPE_CREATE_PARTITION}
  2365.   TTapeCreatePartition = TAPE_CREATE_PARTITION;
  2366.   PTapeCreatePartition = PTAPE_CREATE_PARTITION;
  2367. //
  2368. // WMI Methods
  2369. //
  2370. const
  2371.   TAPE_QUERY_DRIVE_PARAMETERS     = 0;
  2372.   {$EXTERNALSYM TAPE_QUERY_DRIVE_PARAMETERS}
  2373.   TAPE_QUERY_MEDIA_CAPACITY       = 1;
  2374.   {$EXTERNALSYM TAPE_QUERY_MEDIA_CAPACITY}
  2375.   TAPE_CHECK_FOR_DRIVE_PROBLEM    = 2;
  2376.   {$EXTERNALSYM TAPE_CHECK_FOR_DRIVE_PROBLEM}
  2377.   TAPE_QUERY_IO_ERROR_DATA        = 3;
  2378.   {$EXTERNALSYM TAPE_QUERY_IO_ERROR_DATA}
  2379.   TAPE_QUERY_DEVICE_ERROR_DATA    = 4;
  2380.   {$EXTERNALSYM TAPE_QUERY_DEVICE_ERROR_DATA}
  2381. type
  2382.   _TAPE_WMI_OPERATIONS = record
  2383.     Method: DWORD;
  2384.     DataBufferSize: DWORD;
  2385.     DataBuffer: PVOID;
  2386.   end;
  2387.   {$EXTERNALSYM _TAPE_WMI_OPERATIONS}
  2388.   TAPE_WMI_OPERATIONS = _TAPE_WMI_OPERATIONS;
  2389.   {$EXTERNALSYM TAPE_WMI_OPERATIONS}
  2390.   PTAPE_WMI_OPERATIONS = ^TAPE_WMI_OPERATIONS;
  2391.   {$EXTERNALSYM PTAPE_WMI_OPERATIONS}
  2392.   TTapeWMIOperations = TAPE_WMI_OPERATIONS;
  2393.   PTapeWMIOperations = PTAPE_WMI_OPERATIONS;
  2394. //
  2395. // Type of drive errors
  2396. //
  2397.   _TAPE_DRIVE_PROBLEM_TYPE = (
  2398.     TapeDriveProblemNone, TapeDriveReadWriteWarning,
  2399.     TapeDriveReadWriteError, TapeDriveReadWarning,
  2400.     TapeDriveWriteWarning, TapeDriveReadError,
  2401.     TapeDriveWriteError, TapeDriveHardwareError,
  2402.     TapeDriveUnsupportedMedia, TapeDriveScsiConnectionError,
  2403.     TapeDriveTimetoClean, TapeDriveCleanDriveNow,
  2404.     TapeDriveMediaLifeExpired, TapeDriveSnappedTape);
  2405.   {$EXTERNALSYM _TAPE_DRIVE_PROBLEM_TYPE}
  2406.   TAPE_DRIVE_PROBLEM_TYPE = _TAPE_DRIVE_PROBLEM_TYPE;
  2407.   TTapeDriveProblemType = TAPE_DRIVE_PROBLEM_TYPE;
  2408. const
  2409.   ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION         = (1);
  2410.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_ASSEMBLY_INFORMATION}
  2411.   ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION              = (2);
  2412.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_DLL_REDIRECTION}
  2413.   ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION     = (3);
  2414.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_WINDOW_CLASS_REDIRECTION}
  2415.   ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION       = (4);
  2416.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_COM_SERVER_REDIRECTION}
  2417.   ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION    = (5);
  2418.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_COM_INTERFACE_REDIRECTION}
  2419.   ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION = (6);
  2420.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_COM_TYPE_LIBRARY_REDIRECTION}
  2421.   ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION       = (7);
  2422.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_COM_PROGID_REDIRECTION}
  2423.   ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE   = (8);
  2424.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_GLOBAL_OBJECT_RENAME_TABLE}
  2425.   ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES               = (9);
  2426.   {$EXTERNALSYM ACTIVATION_CONTEXT_SECTION_CLR_SURROGATES}
  2427. implementation
  2428. const
  2429.   ntdll = 'ntdll.dll';
  2430.   kernel32 = 'kernel32.dll';
  2431. function WT_SET_MAX_THREADPOOL_THREADS(var Flags: DWORD; Limit: DWORD): DWORD;
  2432. begin
  2433.   Flags := Flags or (Limit shl 16);
  2434.   Result := Flags;
  2435. end;
  2436. function VALID_IMPERSONATION_LEVEL(L: TSecurityImpersonationLevel): BOOL;
  2437. begin
  2438.   Result := (L >= SECURITY_MIN_IMPERSONATION_LEVEL) and (L <= SECURITY_MAX_IMPERSONATION_LEVEL);
  2439. end;
  2440. {
  2441. function VALID_TOKEN_AUDIT_POLICY_ELEMENT(P: TOKEN_AUDIT_POLICY_ELEMENT): BOOL;
  2442. begin
  2443.   Result := ((P.PolicyMask and (not VALID_AUDIT_POLICY_BITS) = 0) and (P.Category <= AuditEventMaxType);
  2444. // ((((P).PolicyMask & ~VALID_AUDIT_POLICY_BITS) == 0) && 
  2445. //                                             ((P).Category <= AuditEventMaxType))
  2446. end;
  2447. }
  2448. function PER_USER_AUDITING_POLICY_SIZE(p: PTOKEN_AUDIT_POLICY): DWORD;
  2449. begin
  2450.   Result := SizeOf(TOKEN_AUDIT_POLICY);
  2451.   if p^.PolicyCount > ANYSIZE_ARRAY then
  2452.     Result := Result + SizeOf(TOKEN_AUDIT_POLICY_ELEMENT) * (P^.PolicyCount - ANYSIZE_ARRAY);
  2453. //  ( sizeof(TOKEN_AUDIT_POLICY) + (((p)->PolicyCount > ANYSIZE_ARRAY) ? (sizeof(TOKEN_AUDIT_POLICY_ELEMENT) * ((p)->PolicyCount - ANYSIZE_ARRAY)) : 0) )
  2454. end;
  2455. function PER_USER_AUDITING_POLICY_SIZE_BY_COUNT(C: DWORD): DWORD;
  2456. begin
  2457.   Result := SizeOf(TOKEN_AUDIT_POLICY);
  2458.   if C > ANYSIZE_ARRAY then
  2459.     Result := Result + SizeOf(TOKEN_AUDIT_POLICY_ELEMENT) * (C - ANYSIZE_ARRAY);
  2460. //    ( sizeof(TOKEN_AUDIT_POLICY) + (((C) > ANYSIZE_ARRAY) ? (sizeof(TOKEN_AUDIT_POLICY_ELEMENT) * ((C) - ANYSIZE_ARRAY)) : 0) )
  2461. end;
  2462. function NtCurrentTeb: PNT_TIB;
  2463. asm
  2464.         MOV     EAX, FS:[0]
  2465. end;
  2466. function GetFiberData: PVOID;
  2467. asm
  2468.         MOV     EAX, FS:[$10]
  2469.         MOV     EAX, [EAX]
  2470. end;
  2471. function GetCurrentFiber: PVOID;
  2472. asm
  2473.         MOV     EAX, FS:[$10]
  2474. end;
  2475. function Int32x32To64(a, b: LONG): LONGLONG;
  2476. begin
  2477.   Result := a * b;
  2478. end;
  2479. function UInt32x32To64(a, b: DWORD): ULONGLONG;
  2480. begin
  2481.   Result := a * b;
  2482. end;
  2483. function MAKELANGID(PrimaryLang, SubLang: USHORT): WORD;
  2484. begin
  2485.   Result := (SubLang shl 10) or PrimaryLang;
  2486. end;
  2487. function PRIMARYLANGID(LangId: WORD): WORD;
  2488. begin
  2489.   Result := LangId and $3FF;
  2490. end;
  2491. function SUBLANGID(LangId: WORD): WORD;
  2492. begin
  2493.   Result := LangId shr 10;
  2494. end;
  2495. function MAKELCID(LangId, SortId: WORD): DWORD;
  2496. begin
  2497.   Result := (DWORD(SortId) shl 16) or DWORD(LangId);
  2498. end;
  2499. function MAKESORTLCID(LangId, SortId, SortVersion: WORD): DWORD;
  2500. begin
  2501.   Result := MAKELCID(LangId, SortId) or (SortVersion shl 20);
  2502. end;
  2503. function LANGIDFROMLCID(LocaleId: LCID): WORD;
  2504. begin
  2505.   Result := WORD(LocaleId);
  2506. end;
  2507. function SORTIDFROMLCID(LocaleId: LCID): WORD;
  2508. begin
  2509.   Result := WORD((DWORD(LocaleId) shr 16) and $F);
  2510. end;
  2511. function SORTVERSIONFROMLCID(LocaleId: LCID): WORD;
  2512. begin
  2513.   Result := WORD((DWORD(LocaleId) shr 20) and $F);
  2514. end;
  2515. function LANG_SYSTEM_DEFAULT: WORD;
  2516. begin
  2517.   Result := MAKELANGID(LANG_NEUTRAL, SUBLANG_SYS_DEFAULT);
  2518. end;
  2519. function LANG_USER_DEFAULT: WORD;
  2520. begin
  2521.   Result := MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
  2522. end;
  2523. function LOCALE_SYSTEM_DEFAULT: DWORD;
  2524. begin
  2525.   Result := MAKELCID(LANG_SYSTEM_DEFAULT, SORT_DEFAULT);
  2526. end;
  2527. function LOCALE_USER_DEFAULT: DWORD;
  2528. begin
  2529.   Result := MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT);
  2530. end;
  2531. function LOCALE_NEUTRAL: DWORD;
  2532. begin
  2533.   Result := MAKELCID(MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), SORT_DEFAULT);
  2534. end;
  2535. function LOCALE_INVARIANT: DWORD;
  2536. begin
  2537.   Result := MAKELCID(MAKELANGID(LANG_INVARIANT, SUBLANG_NEUTRAL), SORT_DEFAULT);
  2538. end;
  2539. function IsReparseTagMicrosoft(Tag: ULONG): Boolean;
  2540. begin
  2541.   Result := (Tag and ULONG($80000000)) <> 0;
  2542. end;
  2543. function IsReparseTagHighLatency(Tag: ULONG): Boolean;
  2544. begin
  2545.   Result := (Tag and ULONG($40000000)) <> 0;
  2546. end;
  2547. function IsReparseTagNameSurrogate(Tag: ULONG): Boolean;
  2548. begin
  2549.   Result := (Tag and ULONG($20000000)) <> 0;
  2550. end;
  2551. function BTYPE(x: DWORD): DWORD;
  2552. begin
  2553.   Result := x and N_BTMASK;
  2554. end;
  2555. function ISPTR(x: DWORD): Boolean;
  2556. begin
  2557.   Result := (x and N_TMASK) = (IMAGE_SYM_DTYPE_POINTER shl N_BTSHFT);
  2558. end;
  2559. function ISFCN(x: DWORD): Boolean;
  2560. begin
  2561.   Result := (x and N_TMASK) = (IMAGE_SYM_DTYPE_FUNCTION shl N_BTSHFT);
  2562. end;
  2563. function ISARY(x: DWORD): Boolean;
  2564. begin
  2565.   Result := (x and N_TMASK) = (IMAGE_SYM_DTYPE_ARRAY shl N_BTSHFT);
  2566. end;
  2567. function ISTAG(x: DWORD): Boolean;
  2568. begin
  2569.   Result := (x = IMAGE_SYM_CLASS_STRUCT_TAG) or (x = IMAGE_SYM_CLASS_UNION_TAG) or
  2570.     (x = IMAGE_SYM_CLASS_ENUM_TAG);
  2571. end;
  2572. function IMAGE_ORDINAL64(Ordinal: ULONGLONG): ULONGLONG;
  2573. begin
  2574.   Result := (Ordinal and $ffff);
  2575. end;
  2576. function IMAGE_ORDINAL32(Ordinal: DWORD): DWORD;
  2577. begin
  2578.   Result := (Ordinal and $ffff);
  2579. end;
  2580. function IMAGE_ORDINAL(Ordinal: DWORD): DWORD;
  2581. begin
  2582.   Result := (Ordinal and $ffff);
  2583. end;
  2584. function IMAGE_SNAP_BY_ORDINAL64(Ordinal: ULONGLONG): Boolean;
  2585. begin
  2586.   Result := ((Ordinal and IMAGE_ORDINAL_FLAG64) <> 0);
  2587. end;
  2588. function IMAGE_SNAP_BY_ORDINAL32(Ordinal: DWORD): Boolean;
  2589. begin
  2590.   Result := ((Ordinal and IMAGE_ORDINAL_FLAG32) <> 0);
  2591. end;
  2592. function IMAGE_SNAP_BY_ORDINAL(Ordinal: DWORD): Boolean;
  2593. begin
  2594.   Result := ((Ordinal and IMAGE_ORDINAL_FLAG32) <> 0);
  2595. end;
  2596. function HEAP_MAKE_TAG_FLAGS(b, o: DWORD): DWORD;
  2597. begin
  2598.   Result := b + (o shl 18);
  2599. end;
  2600. procedure VER_SET_CONDITION(var Mask: DWORDLONG; TypeBitmask, ConditionMask: ULONG);
  2601. begin
  2602.   Mask := VerSetConditionMask(Mask, TypeBitmask, ConditionMask);
  2603. end;
  2604. {$IFDEF DYNAMIC_LINK}
  2605. var
  2606.   _RtlCompareMemory: Pointer;
  2607. function RtlCompareMemory;
  2608. begin
  2609.   GetProcedureAddress(_RtlCompareMemory, ntdll, 'RtlCompareMemory');
  2610.   asm
  2611.     mov esp, ebp
  2612.     pop ebp
  2613.     jmp [_RtlCompareMemory]
  2614.   end;
  2615. end;
  2616. {$ELSE}
  2617. function RtlCompareMemory; external ntdll name 'RtlCompareMemory';
  2618. {$ENDIF DYNAMIC_LINK}
  2619. {$IFDEF DYNAMIC_LINK}
  2620. var
  2621.   _VerSetConditionMask: Pointer;
  2622. function VerSetConditionMask;
  2623. begin
  2624.   GetProcedureAddress(_VerSetConditionMask, kernel32, 'VerSetConditionMask');
  2625.   asm
  2626.     mov esp, ebp
  2627.     pop ebp
  2628.     jmp [_VerSetConditionMask]
  2629.   end;
  2630. end;
  2631. {$ELSE}
  2632. function VerSetConditionMask; external kernel32 name 'VerSetConditionMask';
  2633. {$ENDIF DYNAMIC_LINK}
  2634. {$IFDEF DYNAMIC_LINK}
  2635. var
  2636.   _RtlInitializeSListHead: Pointer;
  2637. procedure RtlInitializeSListHead;
  2638. begin
  2639.   GetProcedureAddress(_RtlInitializeSListHead, 'ntdll.dll', 'RtlInitializeSListHead');
  2640.   asm
  2641.     mov esp, ebp
  2642.     pop ebp
  2643.     jmp [_RtlInitializeSListHead]
  2644.   end;
  2645. end;
  2646. {$ELSE}
  2647. procedure RtlInitializeSListHead; external 'ntdll.dll' name 'RtlInitializeSListHead';
  2648. {$ENDIF DYNAMIC_LINK}
  2649. {$IFDEF DYNAMIC_LINK}
  2650. var
  2651.   _RtlFirstEntrySList: Pointer;
  2652. function RtlFirstEntrySList;
  2653. begin
  2654.   GetProcedureAddress(_RtlFirstEntrySList, 'ntdll.dll', 'RtlFirstEntrySList');
  2655.   asm
  2656.     mov esp, ebp
  2657.     pop ebp
  2658.     jmp [_RtlFirstEntrySList]
  2659.   end;
  2660. end;
  2661. {$ELSE}
  2662. function RtlFirstEntrySList; external 'ntdll.dll' name 'RtlFirstEntrySList';
  2663. {$ENDIF DYNAMIC_LINK}
  2664. {$IFDEF DYNAMIC_LINK}
  2665. var
  2666.   _RtlInterlockedPopEntrySList: Pointer;
  2667. function RtlInterlockedPopEntrySList;
  2668. begin
  2669.   GetProcedureAddress(_RtlInterlockedPopEntrySList, 'ntdll.dll', 'RtlInterlockedPopEntrySList');
  2670.   asm
  2671.     mov esp, ebp
  2672.     pop ebp
  2673.     jmp [_RtlInterlockedPopEntrySList]
  2674.   end;
  2675. end;
  2676. {$ELSE}
  2677. function RtlInterlockedPopEntrySList; external 'ntdll.dll' name 'RtlInterlockedPopEntrySList';
  2678. {$ENDIF DYNAMIC_LINK}
  2679. {$IFDEF DYNAMIC_LINK}
  2680. var
  2681.   _RtlInterlockedPushEntrySList: Pointer;
  2682. function RtlInterlockedPushEntrySList;
  2683. begin
  2684.   GetProcedureAddress(_RtlInterlockedPushEntrySList, 'ntdll.dll', 'RtlInterlockedPushEntrySList');
  2685.   asm
  2686.     mov esp, ebp
  2687.     pop ebp
  2688.     jmp [_RtlInterlockedPushEntrySList]
  2689.   end;
  2690. end;
  2691. {$ELSE}
  2692. function RtlInterlockedPushEntrySList; external 'ntdll.dll' name 'RtlInterlockedPushEntrySList';
  2693. {$ENDIF DYNAMIC_LINK}
  2694. {$IFDEF DYNAMIC_LINK}
  2695. var
  2696.   _RtlInterlockedFlushSList: Pointer;
  2697. function RtlInterlockedFlushSList;
  2698. begin
  2699.   GetProcedureAddress(_RtlInterlockedFlushSList, 'ntdll.dll', 'RtlInterlockedFlushSList');
  2700.   asm
  2701.     mov esp, ebp
  2702.     pop ebp
  2703.     jmp [_RtlInterlockedFlushSList]
  2704.   end;
  2705. end;
  2706. {$ELSE}
  2707. function RtlInterlockedFlushSList; external 'ntdll.dll' name 'RtlInterlockedFlushSList';
  2708. {$ENDIF DYNAMIC_LINK}
  2709. {$IFDEF DYNAMIC_LINK}
  2710. var
  2711.   _RtlQueryDepthSList: Pointer;
  2712. function RtlQueryDepthSList;
  2713. begin
  2714.   GetProcedureAddress(_RtlQueryDepthSList, 'ntdll.dll', 'RtlQueryDepthSList');
  2715.   asm
  2716.     mov esp, ebp
  2717.     pop ebp
  2718.     jmp [_RtlQueryDepthSList]
  2719.   end;
  2720. end;
  2721. {$ELSE}
  2722. function RtlQueryDepthSList; external 'ntdll.dll' name 'RtlQueryDepthSList';
  2723. {$ENDIF DYNAMIC_LINK}
  2724. end.