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

Windows编程

开发平台:

Delphi

  1. function CreateDirectory(lpPathName: LPCSTR; lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  2. {$EXTERNALSYM CreateDirectory}
  3. {$ENDIF}
  4. function CreateDirectoryExA(lpTemplateDirectory: LPCSTR; lpNewDirectory: LPCSTR;
  5.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  6. {$EXTERNALSYM CreateDirectoryExA}
  7. function CreateDirectoryExW(lpTemplateDirectory: LPCWSTR; lpNewDirectory: LPCWSTR;
  8.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  9. {$EXTERNALSYM CreateDirectoryExW}
  10. {$IFDEF UNICODE}
  11. function CreateDirectoryEx(lpTemplateDirectory: LPCWSTR; lpNewDirectory: LPCWSTR;
  12.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  13. {$EXTERNALSYM CreateDirectoryEx}
  14. {$ELSE}
  15. function CreateDirectoryEx(lpTemplateDirectory: LPCSTR; lpNewDirectory: LPCSTR;
  16.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  17. {$EXTERNALSYM CreateDirectoryEx}
  18. {$ENDIF}
  19. function RemoveDirectoryA(lpPathName: LPCSTR): BOOL; stdcall;
  20. {$EXTERNALSYM RemoveDirectoryA}
  21. function RemoveDirectoryW(lpPathName: LPCWSTR): BOOL; stdcall;
  22. {$EXTERNALSYM RemoveDirectoryW}
  23. {$IFDEF UNICODE}
  24. function RemoveDirectory(lpPathName: LPCWSTR): BOOL; stdcall;
  25. {$EXTERNALSYM RemoveDirectory}
  26. {$ELSE}
  27. function RemoveDirectory(lpPathName: LPCSTR): BOOL; stdcall;
  28. {$EXTERNALSYM RemoveDirectory}
  29. {$ENDIF}
  30. function GetFullPathNameA(lpFileName: LPCSTR; nBufferLength: DWORD;
  31.   lpBuffer: LPSTR; var lpFilePart: LPSTR): DWORD; stdcall;
  32. {$EXTERNALSYM GetFullPathNameA}
  33. function GetFullPathNameW(lpFileName: LPCWSTR; nBufferLength: DWORD;
  34.   lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall;
  35. {$EXTERNALSYM GetFullPathNameA}
  36. {$IFDEF UNICODE}
  37. function GetFullPathName(lpFileName: LPCWSTR; nBufferLength: DWORD;
  38.   lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall;
  39. {$EXTERNALSYM GetFullPathName}
  40. {$ELSE}
  41. function GetFullPathName(lpFileName: LPCSTR; nBufferLength: DWORD;
  42.   lpBuffer: LPSTR; var lpFilePart: LPSTR): DWORD; stdcall;
  43. {$EXTERNALSYM GetFullPathName}
  44. {$ENDIF}
  45. const
  46.   DDD_RAW_TARGET_PATH       = $00000001;
  47.   {$EXTERNALSYM DDD_RAW_TARGET_PATH}
  48.   DDD_REMOVE_DEFINITION     = $00000002;
  49.   {$EXTERNALSYM DDD_REMOVE_DEFINITION}
  50.   DDD_EXACT_MATCH_ON_REMOVE = $00000004;
  51.   {$EXTERNALSYM DDD_EXACT_MATCH_ON_REMOVE}
  52.   DDD_NO_BROADCAST_SYSTEM   = $00000008;
  53.   {$EXTERNALSYM DDD_NO_BROADCAST_SYSTEM}
  54.   DDD_LUID_BROADCAST_DRIVE  = $00000010;
  55.   {$EXTERNALSYM DDD_LUID_BROADCAST_DRIVE}
  56. function DefineDosDeviceA(dwFlags: DWORD; lpDeviceName, lpTargetPath: LPCSTR): BOOL; stdcall;
  57. {$EXTERNALSYM DefineDosDeviceA}
  58. function DefineDosDeviceW(dwFlags: DWORD; lpDeviceName, lpTargetPath: LPCWSTR): BOOL; stdcall;
  59. {$EXTERNALSYM DefineDosDeviceW}
  60. {$IFDEF UNICODE}
  61. function DefineDosDevice(dwFlags: DWORD; lpDeviceName, lpTargetPath: LPCWSTR): BOOL; stdcall;
  62. {$EXTERNALSYM DefineDosDevice}
  63. {$ELSE}
  64. function DefineDosDevice(dwFlags: DWORD; lpDeviceName, lpTargetPath: LPCSTR): BOOL; stdcall;
  65. {$EXTERNALSYM DefineDosDevice}
  66. {$ENDIF}
  67. function QueryDosDeviceA(lpDeviceName, lpTargetPath: LPSTR; ucchMax: DWORD): DWORD; stdcall;
  68. {$EXTERNALSYM QueryDosDeviceA}
  69. function QueryDosDeviceW(lpDeviceName, lpTargetPath: LPWSTR; ucchMax: DWORD): DWORD; stdcall;
  70. {$EXTERNALSYM QueryDosDeviceW}
  71. {$IFDEF UNICODE}
  72. function QueryDosDevice(lpDeviceName, lpTargetPath: LPWSTR; ucchMax: DWORD): DWORD; stdcall;
  73. {$EXTERNALSYM QueryDosDevice}
  74. {$ELSE}
  75. function QueryDosDevice(lpDeviceName, lpTargetPath: LPSTR; ucchMax: DWORD): DWORD; stdcall;
  76. {$EXTERNALSYM QueryDosDevice}
  77. {$ENDIF}
  78. function CreateFileA(lpFileName: LPCSTR; dwDesiredAccess, dwShareMode: DWORD;
  79.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES; dwCreationDisposition: DWORD;
  80.   dwFlagsAndAttributes: DWORD; hTemplateFile: HANDLE): HANDLE; stdcall;
  81. {$EXTERNALSYM CreateFileA}
  82. function CreateFileW(lpFileName: LPCWSTR; dwDesiredAccess, dwShareMode: DWORD;
  83.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES; dwCreationDisposition: DWORD;
  84.   dwFlagsAndAttributes: DWORD; hTemplateFile: HANDLE): HANDLE; stdcall;
  85. {$EXTERNALSYM CreateFileW}
  86. {$IFDEF UNICODE}
  87. function CreateFile(lpFileName: LPCWSTR; dwDesiredAccess, dwShareMode: DWORD;
  88.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES; dwCreationDisposition: DWORD;
  89.   dwFlagsAndAttributes: DWORD; hTemplateFile: HANDLE): HANDLE; stdcall;
  90. {$EXTERNALSYM CreateFile}
  91. {$ELSE}
  92. function CreateFile(lpFileName: LPCSTR; dwDesiredAccess, dwShareMode: DWORD;
  93.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES; dwCreationDisposition: DWORD;
  94.   dwFlagsAndAttributes: DWORD; hTemplateFile: HANDLE): HANDLE; stdcall;
  95. {$EXTERNALSYM CreateFile}
  96. {$ENDIF}
  97. function SetFileAttributesA(lpFileName: LPCSTR; dwFileAttributes: DWORD): BOOL; stdcall;
  98. {$EXTERNALSYM SetFileAttributesA}
  99. function SetFileAttributesW(lpFileName: LPCWSTR; dwFileAttributes: DWORD): BOOL; stdcall;
  100. {$EXTERNALSYM SetFileAttributesW}
  101. {$IFDEF UNICODE}
  102. function SetFileAttributes(lpFileName: LPCWSTR; dwFileAttributes: DWORD): BOOL; stdcall;
  103. {$EXTERNALSYM SetFileAttributes}
  104. {$ELSE}
  105. function SetFileAttributes(lpFileName: LPCSTR; dwFileAttributes: DWORD): BOOL; stdcall;
  106. {$EXTERNALSYM SetFileAttributes}
  107. {$ENDIF}
  108. function GetFileAttributesA(lpFileName: LPCSTR): DWORD; stdcall;
  109. {$EXTERNALSYM GetFileAttributesA}
  110. function GetFileAttributesW(lpFileName: LPCWSTR): DWORD; stdcall;
  111. {$EXTERNALSYM GetFileAttributesW}
  112. {$IFDEF UNICODE}
  113. function GetFileAttributes(lpFileName: LPCWSTR): DWORD; stdcall;
  114. {$EXTERNALSYM GetFileAttributes}
  115. {$ELSE}
  116. function GetFileAttributes(lpFileName: LPCSTR): DWORD; stdcall;
  117. {$EXTERNALSYM GetFileAttributes}
  118. {$ENDIF}
  119. type
  120.   _GET_FILEEX_INFO_LEVELS = (GetFileExInfoStandard, GetFileExMaxInfoLevel);
  121.   {$EXTERNALSYM _GET_FILEEX_INFO_LEVELS}
  122.   GET_FILEEX_INFO_LEVELS = _GET_FILEEX_INFO_LEVELS;
  123.   {$EXTERNALSYM GET_FILEEX_INFO_LEVELS}
  124.   TGetFileExInfoLevels = GET_FILEEX_INFO_LEVELS;
  125. function GetFileAttributesExA(lpFileName: LPCSTR;
  126.   fInfoLevelId: GET_FILEEX_INFO_LEVELS; lpFileInformation: LPVOID): BOOL; stdcall;
  127. {$EXTERNALSYM GetFileAttributesExA}
  128. function GetFileAttributesExW(lpFileName: LPCWSTR;
  129.   fInfoLevelId: GET_FILEEX_INFO_LEVELS; lpFileInformation: LPVOID): BOOL; stdcall;
  130. {$EXTERNALSYM GetFileAttributesExW}
  131. {$IFDEF UNICODE}
  132. function GetFileAttributesEx(lpFileName: LPCWSTR;
  133.   fInfoLevelId: GET_FILEEX_INFO_LEVELS; lpFileInformation: LPVOID): BOOL; stdcall;
  134. {$EXTERNALSYM GetFileAttributesEx}
  135. {$ELSE}
  136. function GetFileAttributesEx(lpFileName: LPCSTR;
  137.   fInfoLevelId: GET_FILEEX_INFO_LEVELS; lpFileInformation: LPVOID): BOOL; stdcall;
  138. {$EXTERNALSYM GetFileAttributesEx}
  139. {$ENDIF}
  140. function GetCompressedFileSizeA(lpFileName: LPCSTR; lpFileSizeHigh: LPDWORD): DWORD; stdcall;
  141. {$EXTERNALSYM GetCompressedFileSizeA}
  142. function GetCompressedFileSizeW(lpFileName: LPCWSTR; lpFileSizeHigh: LPDWORD): DWORD; stdcall;
  143. {$EXTERNALSYM GetCompressedFileSizeW}
  144. {$IFDEF UNICODE}
  145. function GetCompressedFileSize(lpFileName: LPCWSTR; lpFileSizeHigh: LPDWORD): DWORD; stdcall;
  146. {$EXTERNALSYM GetCompressedFileSize}
  147. {$ELSE}
  148. function GetCompressedFileSize(lpFileName: LPCSTR; lpFileSizeHigh: LPDWORD): DWORD; stdcall;
  149. {$EXTERNALSYM GetCompressedFileSize}
  150. {$ENDIF}
  151. function DeleteFileA(lpFileName: LPCSTR): BOOL; stdcall;
  152. {$EXTERNALSYM DeleteFileA}
  153. function DeleteFileW(lpFileName: LPCWSTR): BOOL; stdcall;
  154. {$EXTERNALSYM DeleteFileW}
  155. {$IFDEF UNICODE}
  156. function DeleteFile(lpFileName: LPCWSTR): BOOL; stdcall;
  157. {$EXTERNALSYM DeleteFile}
  158. {$ELSE}
  159. function DeleteFile(lpFileName: LPCSTR): BOOL; stdcall;
  160. {$EXTERNALSYM DeleteFile}
  161. {$ENDIF}
  162. type
  163.   _FINDEX_INFO_LEVELS = (FindExInfoStandard, FindExInfoMaxInfoLevel);
  164.   {$EXTERNALSYM _FINDEX_INFO_LEVELS}
  165.   FINDEX_INFO_LEVELS = _FINDEX_INFO_LEVELS;
  166.   {$EXTERNALSYM FINDEX_INFO_LEVELS}
  167.   TFindExInfoLevels = FINDEX_INFO_LEVELS;
  168.   _FINDEX_SEARCH_OPS = (
  169.     FindExSearchNameMatch,
  170.     FindExSearchLimitToDirectories,
  171.     FindExSearchLimitToDevices,
  172.     FindExSearchMaxSearchOp);
  173.   {$EXTERNALSYM _FINDEX_SEARCH_OPS}
  174.   FINDEX_SEARCH_OPS = _FINDEX_SEARCH_OPS;
  175.   {$EXTERNALSYM FINDEX_SEARCH_OPS}
  176.   TFindExSearchOps = FINDEX_SEARCH_OPS;
  177. const
  178.   FIND_FIRST_EX_CASE_SENSITIVE = $00000001;
  179.   {$EXTERNALSYM FIND_FIRST_EX_CASE_SENSITIVE}
  180. function FindFirstFileExA(lpFileName: LPCSTR; fInfoLevelId: FINDEX_INFO_LEVELS;
  181.   lpFindFileData: LPVOID; fSearchOp: FINDEX_SEARCH_OPS; lpSearchFilter: LPVOID;
  182.   dwAdditionalFlags: DWORD): HANDLE; stdcall;
  183. {$EXTERNALSYM FindFirstFileExA}
  184. function FindFirstFileExW(lpFileName: LPCWSTR; fInfoLevelId: FINDEX_INFO_LEVELS;
  185.   lpFindFileData: LPVOID; fSearchOp: FINDEX_SEARCH_OPS; lpSearchFilter: LPVOID;
  186.   dwAdditionalFlags: DWORD): HANDLE; stdcall;
  187. {$EXTERNALSYM FindFirstFileExW}
  188. {$IFDEF UNICODE}
  189. function FindFirstFileEx(lpFileName: LPCWSTR; fInfoLevelId: FINDEX_INFO_LEVELS;
  190.   lpFindFileData: LPVOID; fSearchOp: FINDEX_SEARCH_OPS; lpSearchFilter: LPVOID;
  191.   dwAdditionalFlags: DWORD): HANDLE; stdcall;
  192. {$EXTERNALSYM FindFirstFileEx}
  193. {$ELSE}
  194. function FindFirstFileEx(lpFileName: LPCSTR; fInfoLevelId: FINDEX_INFO_LEVELS;
  195.   lpFindFileData: LPVOID; fSearchOp: FINDEX_SEARCH_OPS; lpSearchFilter: LPVOID;
  196.   dwAdditionalFlags: DWORD): HANDLE; stdcall;
  197. {$EXTERNALSYM FindFirstFileEx}
  198. {$ENDIF}
  199. function FindFirstFileA(lpFileName: LPCSTR; var lpFindFileData: WIN32_FIND_DATAA): HANDLE; stdcall;
  200. {$EXTERNALSYM FindFirstFileA}
  201. function FindFirstFileW(lpFileName: LPCWSTR; var lpFindFileData: WIN32_FIND_DATAW): HANDLE; stdcall;
  202. {$EXTERNALSYM FindFirstFileW}
  203. {$IFDEF UNICODE}
  204. function FindFirstFile(lpFileName: LPCWSTR; var lpFindFileData: WIN32_FIND_DATAW): HANDLE; stdcall;
  205. {$EXTERNALSYM FindFirstFile}
  206. {$ELSE}
  207. function FindFirstFile(lpFileName: LPCSTR; var lpFindFileData: WIN32_FIND_DATAA): HANDLE; stdcall;
  208. {$EXTERNALSYM FindFirstFile}
  209. {$ENDIF}
  210. function FindNextFileA(hFindFile: HANDLE; var FindFileData: WIN32_FIND_DATAA): BOOL; stdcall;
  211. {$EXTERNALSYM FindNextFileA}
  212. function FindNextFileW(hFindFile: HANDLE; var lpFindFileData: WIN32_FIND_DATAW): BOOL; stdcall;
  213. {$EXTERNALSYM FindNextFileW}
  214. {$IFDEF UNICODE}
  215. function FindNextFile(hFindFile: HANDLE; var lpFindFileData: WIN32_FIND_DATAW): BOOL; stdcall;
  216. {$EXTERNALSYM FindNextFile}
  217. {$ELSE}
  218. function FindNextFile(hFindFile: HANDLE; var lpFindFileData: WIN32_FIND_DATAA): BOOL; stdcall;
  219. {$EXTERNALSYM FindNextFile}
  220. {$ENDIF}
  221. function SearchPathA(lpPath, lpFileName, lpExtension: LPCSTR; nBufferLength: DWORD;
  222.   lpBuffer: LPSTR; var lpFilePart: LPSTR): DWORD; stdcall;
  223. {$EXTERNALSYM SearchPathA}
  224. function SearchPathW(lpPath, lpFileName, lpExtension: LPCWSTR; nBufferLength: DWORD;
  225.   lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall;
  226. {$EXTERNALSYM SearchPathW}
  227. {$IFDEF UNICODE}
  228. function SearchPath(lpPath, lpFileName, lpExtension: LPCWSTR; nBufferLength: DWORD;
  229.   lpBuffer: LPWSTR; var lpFilePart: LPWSTR): DWORD; stdcall;
  230. {$EXTERNALSYM SearchPath}
  231. {$ELSE}
  232. function SearchPath(lpPath, lpFileName, lpExtension: LPCSTR; nBufferLength: DWORD;
  233.   lpBuffer: LPSTR; var lpFilePart: LPSTR): DWORD; stdcall;
  234. {$EXTERNALSYM SearchPath}
  235. {$ENDIF}
  236. function CopyFileA(lpExistingFileName, lpNewFileName: LPCSTR; bFailIfExists: BOOL): BOOL; stdcall;
  237. {$EXTERNALSYM CopyFileA}
  238. function CopyFileW(lpExistingFileName, lpNewFileName: LPCWSTR; bFailIfExists: BOOL): BOOL; stdcall;
  239. {$EXTERNALSYM CopyFileW}
  240. {$IFDEF UNICODE}
  241. function CopyFile(lpExistingFileName, lpNewFileName: LPCWSTR; bFailIfExists: BOOL): BOOL; stdcall;
  242. {$EXTERNALSYM CopyFile}
  243. {$ELSE}
  244. function CopyFile(lpExistingFileName, lpNewFileName: LPCSTR; bFailIfExists: BOOL): BOOL; stdcall;
  245. {$EXTERNALSYM CopyFile}
  246. {$ENDIF}
  247. type
  248.   LPPROGRESS_ROUTINE = function (
  249.     TotalFileSize: LARGE_INTEGER;
  250.     TotalBytesTransferred: LARGE_INTEGER;
  251.     StreamSize: LARGE_INTEGER;
  252.     StreamBytesTransferred: LARGE_INTEGER;
  253.     dwStreamNumber: DWORD;
  254.     dwCallbackReason: DWORD;
  255.     hSourceFile: HANDLE;
  256.     hDestinationFile: HANDLE;
  257.     lpData: LPVOID): DWORD; stdcall;
  258.   {$EXTERNALSYM LPPROGRESS_ROUTINE}
  259.   TProgressRoutine = LPPROGRESS_ROUTINE;
  260. function CopyFileExA(lpExistingFileName, lpNewFileName: LPCSTR;
  261.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; var pbCancel: BOOL;
  262.   dwCopyFlags: DWORD): BOOL; stdcall;
  263. {$EXTERNALSYM CopyFileExA}
  264. function CopyFileExW(lpExistingFileName, lpNewFileName: LPCWSTR;
  265.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; var pbCancel: BOOL;
  266.   dwCopyFlags: DWORD): BOOL; stdcall;
  267. {$EXTERNALSYM CopyFileExW}
  268. {$IFDEF UNICODE}
  269. function CopyFileEx(lpExistingFileName, lpNewFileName: LPCWSTR;
  270.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; var pbCancel: BOOL;
  271.   dwCopyFlags: DWORD): BOOL; stdcall;
  272. {$EXTERNALSYM CopyFileEx}
  273. {$ELSE}
  274. function CopyFileEx(lpExistingFileName, lpNewFileName: LPCSTR;
  275.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; var pbCancel: BOOL;
  276.   dwCopyFlags: DWORD): BOOL; stdcall;
  277. {$EXTERNALSYM CopyFileEx}
  278. {$ENDIF}
  279. function MoveFileA(lpExistingFileName, lpNewFileName: LPCSTR): BOOL; stdcall;
  280. {$EXTERNALSYM MoveFileA}
  281. function MoveFileW(lpExistingFileName, lpNewFileName: LPCWSTR): BOOL; stdcall;
  282. {$EXTERNALSYM MoveFileW}
  283. {$IFDEF UNICODE}
  284. function MoveFile(lpExistingFileName, lpNewFileName: LPCWSTR): BOOL; stdcall;
  285. {$EXTERNALSYM MoveFile}
  286. {$ELSE}
  287. function MoveFile(lpExistingFileName, lpNewFileName: LPCSTR): BOOL; stdcall;
  288. {$EXTERNALSYM MoveFile}
  289. {$ENDIF}
  290. function MoveFileExA(lpExistingFileName, lpNewFileName: LPCSTR; dwFlags: DWORD): BOOL; stdcall;
  291. {$EXTERNALSYM MoveFileExA}
  292. function MoveFileExW(lpExistingFileName, lpNewFileName: LPCWSTR; dwFlags: DWORD): BOOL; stdcall;
  293. {$EXTERNALSYM MoveFileExW}
  294. {$IFDEF UNICODE}
  295. function MoveFileEx(lpExistingFileName, lpNewFileName: LPCWSTR; dwFlags: DWORD): BOOL; stdcall;
  296. {$EXTERNALSYM MoveFileEx}
  297. {$ELSE}
  298. function MoveFileEx(lpExistingFileName, lpNewFileName: LPCSTR; dwFlags: DWORD): BOOL; stdcall;
  299. {$EXTERNALSYM MoveFileEx}
  300. {$ENDIF}
  301. function MoveFileWithProgressA(lpExistingFileName, lpNewFileName: LPCSTR;
  302.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; dwFlags: DWORD): BOOL; stdcall;
  303. {$EXTERNALSYM MoveFileWithProgressA}
  304. function MoveFileWithProgressW(lpExistingFileName, lpNewFileName: LPCWSTR;
  305.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; dwFlags: DWORD): BOOL; stdcall;
  306. {$EXTERNALSYM MoveFileWithProgressW}
  307. {$IFDEF UNICODE}
  308. function MoveFileWithProgress(lpExistingFileName, lpNewFileName: LPCWSTR;
  309.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; dwFlags: DWORD): BOOL; stdcall;
  310. {$EXTERNALSYM MoveFileWithProgress}
  311. {$ELSE}
  312. function MoveFileWithProgress(lpExistingFileName, lpNewFileName: LPCSTR;
  313.   lpProgressRoutine: LPPROGRESS_ROUTINE; lpData: LPVOID; dwFlags: DWORD): BOOL; stdcall;
  314. {$EXTERNALSYM MoveFileWithProgress}
  315. {$ENDIF}
  316. const
  317.   MOVEFILE_REPLACE_EXISTING      = $00000001;
  318.   {$EXTERNALSYM MOVEFILE_REPLACE_EXISTING}
  319.   MOVEFILE_COPY_ALLOWED          = $00000002;
  320.   {$EXTERNALSYM MOVEFILE_COPY_ALLOWED}
  321.   MOVEFILE_DELAY_UNTIL_REBOOT    = $00000004;
  322.   {$EXTERNALSYM MOVEFILE_DELAY_UNTIL_REBOOT}
  323.   MOVEFILE_WRITE_THROUGH         = $00000008;
  324.   {$EXTERNALSYM MOVEFILE_WRITE_THROUGH}
  325.   MOVEFILE_CREATE_HARDLINK       = $00000010;
  326.   {$EXTERNALSYM MOVEFILE_CREATE_HARDLINK}
  327.   MOVEFILE_FAIL_IF_NOT_TRACKABLE = $00000020;
  328.   {$EXTERNALSYM MOVEFILE_FAIL_IF_NOT_TRACKABLE}
  329. function ReplaceFileA(lpReplacedFileName, lpReplacementFileName,
  330.   lpBackupFileName: LPCSTR; dwReplaceFlags: DWORD; lpExclude: LPVOID;
  331.   lpReserved: LPVOID): BOOL; stdcall;
  332. {$EXTERNALSYM ReplaceFileA}
  333. function ReplaceFileW(lpReplacedFileName, lpReplacementFileName,
  334.   lpBackupFileName: LPCWSTR; dwReplaceFlags: DWORD; lpExclude: LPVOID;
  335.   lpReserved: LPVOID): BOOL; stdcall;
  336. {$EXTERNALSYM ReplaceFileW}
  337. {$IFDEF UNICODE}
  338. function ReplaceFile(lpReplacedFileName, lpReplacementFileName,
  339.   lpBackupFileName: LPCWSTR; dwReplaceFlags: DWORD; lpExclude: LPVOID;
  340.   lpReserved: LPVOID): BOOL; stdcall;
  341. {$EXTERNALSYM ReplaceFile}
  342. {$ELSE}
  343. function ReplaceFile(lpReplacedFileName, lpReplacementFileName,
  344.   lpBackupFileName: LPCSTR; dwReplaceFlags: DWORD; lpExclude: LPVOID;
  345.   lpReserved: LPVOID): BOOL; stdcall;
  346. {$EXTERNALSYM ReplaceFile}
  347. {$ENDIF}
  348. //
  349. // API call to create hard links.
  350. //
  351. function CreateHardLinkA(lpFileName, lpExistingFileName: LPCSTR;
  352.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  353. {$EXTERNALSYM CreateHardLinkA}
  354. function CreateHardLinkW(lpFileName, lpExistingFileName: LPCWSTR;
  355.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  356. {$EXTERNALSYM CreateHardLinkW}
  357. {$IFDEF UNICODE}
  358. function CreateHardLink(lpFileName, lpExistingFileName: LPCWSTR;
  359.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  360. {$EXTERNALSYM CreateHardLink}
  361. {$ELSE}
  362. function CreateHardLink(lpFileName, lpExistingFileName: LPCSTR;
  363.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): BOOL; stdcall;
  364. {$EXTERNALSYM CreateHardLink}
  365. {$ENDIF}
  366. //#if (_WIN32_WINNT >= 0x0501)
  367. //
  368. // API call to enumerate for streams within a file
  369. //
  370. type
  371.   _STREAM_INFO_LEVELS = (FindStreamInfoStandard, FindStreamInfoMaxInfoLevel);
  372.   {$EXTERNALSYM _STREAM_INFO_LEVELS}
  373.   STREAM_INFO_LEVELS = _STREAM_INFO_LEVELS;
  374.   {$EXTERNALSYM STREAM_INFO_LEVELS}
  375.   TStreamInfoLevels = STREAM_INFO_LEVELS;
  376.   _WIN32_FIND_STREAM_DATA = record
  377.     StreamSize: LARGE_INTEGER;
  378.     cStreamName: array [0..MAX_PATH + 35] of WCHAR;
  379.   end;
  380.   {$EXTERNALSYM _WIN32_FIND_STREAM_DATA}
  381.   WIN32_FIND_STREAM_DATA = _WIN32_FIND_STREAM_DATA;
  382.   {$EXTERNALSYM WIN32_FIND_STREAM_DATA}
  383.   PWIN32_FIND_STREAM_DATA = ^WIN32_FIND_STREAM_DATA;
  384.   {$EXTERNALSYM PWIN32_FIND_STREAM_DATA}
  385.   TWin32FindStreamData = WIN32_FIND_STREAM_DATA;
  386.   PWin32FindStreamData = PWIN32_FIND_STREAM_DATA;
  387. function FindFirstStreamW(lpFileName: LPCWSTR; InfoLevel: STREAM_INFO_LEVELS; lpFindStreamData: LPVOID; dwFlags: DWORD): HANDLE; stdcall;
  388. {$EXTERNALSYM FindFirstStreamW}
  389. function FindNextStreamW(hFindStream: HANDLE; lpFindStreamData: LPVOID): BOOL; stdcall;
  390. {$EXTERNALSYM FindNextStreamW}
  391. //#endif // (_WIN32_WINNT >= 0x0500)
  392. function CreateNamedPipeA(lpName: LPCSTR; dwOpenMode, dwPipeMode, nMaxInstances,
  393.   nOutBufferSize, nInBufferSize, nDefaultTimeOut: DWORD;
  394.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE; stdcall;
  395. {$EXTERNALSYM CreateNamedPipeA}
  396. function CreateNamedPipeW(lpName: LPCWSTR; dwOpenMode, dwPipeMode, nMaxInstances,
  397.   nOutBufferSize, nInBufferSize, nDefaultTimeOut: DWORD;
  398.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE; stdcall;
  399. {$EXTERNALSYM CreateNamedPipeW}
  400. {$IFDEF UNICODE}
  401. function CreateNamedPipe(lpName: LPCWSTR; dwOpenMode, dwPipeMode, nMaxInstances,
  402.   nOutBufferSize, nInBufferSize, nDefaultTimeOut: DWORD;
  403.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE; stdcall;
  404. {$EXTERNALSYM CreateNamedPipe}
  405. {$ELSE}
  406. function CreateNamedPipe(lpName: LPCSTR; dwOpenMode, dwPipeMode, nMaxInstances,
  407.   nOutBufferSize, nInBufferSize, nDefaultTimeOut: DWORD;
  408.   lpSecurityAttributes: LPSECURITY_ATTRIBUTES): HANDLE; stdcall;
  409. {$EXTERNALSYM CreateNamedPipe}
  410. {$ENDIF}
  411. function GetNamedPipeHandleStateA(hNamedPipe: HANDLE; lpState, lpCurInstances,
  412.   lpMaxCollectionCount, lpCollectDataTimeout: LPDWORD; lpUserName: LPSTR;
  413.   nMaxUserNameSize: DWORD): BOOL; stdcall;
  414. {$EXTERNALSYM GetNamedPipeHandleStateA}
  415. function GetNamedPipeHandleStateW(hNamedPipe: HANDLE; lpState, lpCurInstances,
  416.   lpMaxCollectionCount, lpCollectDataTimeout: LPDWORD; lpUserName: LPWSTR;
  417.   nMaxUserNameSize: DWORD): BOOL; stdcall;
  418. {$EXTERNALSYM GetNamedPipeHandleStateW}
  419. {$IFDEF UNICODE}
  420. function GetNamedPipeHandleState(hNamedPipe: HANDLE; lpState, lpCurInstances,
  421.   lpMaxCollectionCount, lpCollectDataTimeout: LPDWORD; lpUserName: LPWSTR;
  422.   nMaxUserNameSize: DWORD): BOOL; stdcall;
  423. {$EXTERNALSYM GetNamedPipeHandleState}
  424. {$ELSE}
  425. function GetNamedPipeHandleState(hNamedPipe: HANDLE; lpState, lpCurInstances,
  426.   lpMaxCollectionCount, lpCollectDataTimeout: LPDWORD; lpUserName: LPSTR;
  427.   nMaxUserNameSize: DWORD): BOOL; stdcall;
  428. {$EXTERNALSYM GetNamedPipeHandleState}
  429. {$ENDIF}
  430. function CallNamedPipeA(lpNamedPipeName: LPCSTR; lpInBuffer: LPVOID;
  431.   nInBufferSize: DWORD; lpOutBuffer: LPVOID; nOutBufferSize: DWORD;
  432.   var lpBytesRead: DWORD; nTimeOut: DWORD): BOOL; stdcall;
  433. {$EXTERNALSYM CallNamedPipeA}
  434. function CallNamedPipeW(lpNamedPipeName: LPCWSTR; lpInBuffer: LPVOID;
  435.   nInBufferSize: DWORD; lpOutBuffer: LPVOID; nOutBufferSize: DWORD;
  436.   var lpBytesRead: DWORD; nTimeOut: DWORD): BOOL; stdcall;
  437. {$EXTERNALSYM CallNamedPipeW}
  438. {$IFDEF UNICODE}
  439. function CallNamedPipe(lpNamedPipeName: LPCWSTR; lpInBuffer: LPVOID;
  440.   nInBufferSize: DWORD; lpOutBuffer: LPVOID; nOutBufferSize: DWORD;
  441.   var lpBytesRead: DWORD; nTimeOut: DWORD): BOOL; stdcall;
  442. {$EXTERNALSYM CallNamedPipe}
  443. {$ELSE}
  444. function CallNamedPipe(lpNamedPipeName: LPCSTR; lpInBuffer: LPVOID;
  445.   nInBufferSize: DWORD; lpOutBuffer: LPVOID; nOutBufferSize: DWORD;
  446.   var lpBytesRead: DWORD; nTimeOut: DWORD): BOOL; stdcall;
  447. {$EXTERNALSYM CallNamedPipe}
  448. {$ENDIF}
  449. function WaitNamedPipeA(lpNamedPipeName: LPCSTR; nTimeOut: DWORD): BOOL; stdcall;
  450. {$EXTERNALSYM WaitNamedPipeA}
  451. function WaitNamedPipeW(lpNamedPipeName: LPCWSTR; nTimeOut: DWORD): BOOL; stdcall;
  452. {$EXTERNALSYM WaitNamedPipeW}
  453. {$IFDEF UNICODE}
  454. function WaitNamedPipe(lpNamedPipeName: LPCWSTR; nTimeOut: DWORD): BOOL; stdcall;
  455. {$EXTERNALSYM WaitNamedPipe}
  456. {$ELSE}
  457. function WaitNamedPipe(lpNamedPipeName: LPCSTR; nTimeOut: DWORD): BOOL; stdcall;
  458. {$EXTERNALSYM WaitNamedPipe}
  459. {$ENDIF}
  460. function SetVolumeLabelA(lpRootPathName, lpVolumeName: LPCSTR): BOOL; stdcall;
  461. {$EXTERNALSYM SetVolumeLabelA}
  462. function SetVolumeLabelW(lpRootPathName, lpVolumeName: LPCWSTR): BOOL; stdcall;
  463. {$EXTERNALSYM SetVolumeLabelW}
  464. {$IFDEF UNICODE}
  465. function SetVolumeLabel(lpRootPathName, lpVolumeName: LPCWSTR): BOOL; stdcall;
  466. {$EXTERNALSYM SetVolumeLabel}
  467. {$ELSE}
  468. function SetVolumeLabel(lpRootPathName, lpVolumeName: LPCSTR): BOOL; stdcall;
  469. {$EXTERNALSYM SetVolumeLabel}
  470. {$ENDIF}
  471. procedure SetFileApisToOEM; stdcall;
  472. {$EXTERNALSYM SetFileApisToOEM}
  473. procedure SetFileApisToANSI; stdcall;
  474. {$EXTERNALSYM SetFileApisToANSI}
  475. function AreFileApisANSI: BOOL; stdcall;
  476. {$EXTERNALSYM AreFileApisANSI}
  477. function GetVolumeInformationA(lpRootPathName: LPCSTR; lpVolumeNameBuffer: LPSTR;
  478.   nVolumeNameSize: DWORD; lpVolumeSerialNumber: LPDWORD;
  479.   var lpMaximumComponentLength, lpFileSystemFlags: DWORD;
  480.   lpFileSystemNameBuffer: LPSTR; nFileSystemNameSize: DWORD): BOOL; stdcall;
  481. {$EXTERNALSYM GetVolumeInformationA}
  482. function GetVolumeInformationW(lpRootPathName: LPCWSTR; lpVolumeNameBuffer: LPWSTR;
  483.   nVolumeNameSize: DWORD; lpVolumeSerialNumber: LPDWORD;
  484.   var lpMaximumComponentLength, lpFileSystemFlags: DWORD;
  485.   lpFileSystemNameBuffer: LPWSTR; nFileSystemNameSize: DWORD): BOOL; stdcall;
  486. {$EXTERNALSYM GetVolumeInformationW}
  487. {$IFDEF UNICODE}
  488. function GetVolumeInformation(lpRootPathName: LPCWSTR; lpVolumeNameBuffer: LPWSTR;
  489.   nVolumeNameSize: DWORD; lpVolumeSerialNumber: LPDWORD;
  490.   var lpMaximumComponentLength, lpFileSystemFlags: DWORD;
  491.   lpFileSystemNameBuffer: LPWSTR; nFileSystemNameSize: DWORD): BOOL; stdcall;
  492. {$EXTERNALSYM GetVolumeInformation}
  493. {$ELSE}
  494. function GetVolumeInformation(lpRootPathName: LPCSTR; lpVolumeNameBuffer: LPSTR;
  495.   nVolumeNameSize: DWORD; lpVolumeSerialNumber: LPDWORD;
  496.   var lpMaximumComponentLength, lpFileSystemFlags: DWORD;
  497.   lpFileSystemNameBuffer: LPSTR; nFileSystemNameSize: DWORD): BOOL; stdcall;
  498. {$EXTERNALSYM GetVolumeInformation}
  499. {$ENDIF}
  500. function CancelIo(hFile: HANDLE): BOOL; stdcall;
  501. {$EXTERNALSYM CancelIo}
  502. //
  503. // Event logging APIs
  504. //
  505. function ClearEventLogA(hEventLog: HANDLE; lpBackupFileName: LPCSTR): BOOL; stdcall;
  506. {$EXTERNALSYM ClearEventLogA}
  507. function ClearEventLogW(hEventLog: HANDLE; lpBackupFileName: LPCWSTR): BOOL; stdcall;
  508. {$EXTERNALSYM ClearEventLogW}
  509. {$IFDEF UNICODE}
  510. function ClearEventLog(hEventLog: HANDLE; lpBackupFileName: LPCWSTR): BOOL; stdcall;
  511. {$EXTERNALSYM ClearEventLogA}
  512. {$ELSE}
  513. function ClearEventLog(hEventLog: HANDLE; lpBackupFileName: LPCSTR): BOOL; stdcall;
  514. {$EXTERNALSYM ClearEventLogA}
  515. {$ENDIF}
  516. function BackupEventLogA(hEventLog: HANDLE; lpBackupFileName: LPCSTR): BOOL; stdcall;
  517. {$EXTERNALSYM BackupEventLogA}
  518. function BackupEventLogW(hEventLog: HANDLE; lpBackupFileName: LPCWSTR): BOOL; stdcall;
  519. {$EXTERNALSYM BackupEventLogW}
  520. {$IFDEF UNICODE}
  521. function BackupEventLog(hEventLog: HANDLE; lpBackupFileName: LPCWSTR): BOOL; stdcall;
  522. {$EXTERNALSYM BackupEventLogA}
  523. {$ELSE}
  524. function BackupEventLog(hEventLog: HANDLE; lpBackupFileName: LPCSTR): BOOL; stdcall;
  525. {$EXTERNALSYM BackupEventLogA}
  526. {$ENDIF}
  527. function CloseEventLog(hEventLog: HANDLE): BOOL; stdcall;
  528. {$EXTERNALSYM CloseEventLog}
  529. function DeregisterEventSource(hEventLog: HANDLE): BOOL; stdcall;
  530. {$EXTERNALSYM DeregisterEventSource}
  531. function NotifyChangeEventLog(hEventLog, hEvent: HANDLE): BOOL; stdcall;
  532. {$EXTERNALSYM NotifyChangeEventLog}
  533. function GetNumberOfEventLogRecords(hEventLog: HANDLE; var NumberOfRecords: DWORD): BOOL; stdcall;
  534. {$EXTERNALSYM GetNumberOfEventLogRecords}
  535. function GetOldestEventLogRecord(hEventLog: HANDLE; var OldestRecord: DWORD): BOOL; stdcall;
  536. {$EXTERNALSYM GetOldestEventLogRecord}
  537. function OpenEventLogA(lpUNCServerName, lpSourceName: LPCSTR): HANDLE; stdcall;
  538. {$EXTERNALSYM OpenEventLogA}
  539. function OpenEventLogW(lpUNCServerName, lpSourceName: LPCWSTR): HANDLE; stdcall;
  540. {$EXTERNALSYM OpenEventLogW}
  541. {$IFDEF UNICODE}
  542. function OpenEventLog(lpUNCServerName, lpSourceName: LPCWSTR): HANDLE; stdcall;
  543. {$EXTERNALSYM OpenEventLogA}
  544. {$ELSE}
  545. function OpenEventLog(lpUNCServerName, lpSourceName: LPCSTR): HANDLE; stdcall;
  546. {$EXTERNALSYM OpenEventLogA}
  547. {$ENDIF}
  548. function RegisterEventSourceA(lpUNCServerName, lpSourceName: LPCSTR): HANDLE; stdcall;
  549. {$EXTERNALSYM RegisterEventSourceA}
  550. function RegisterEventSourceW(lpUNCServerName, lpSourceName: LPCWSTR): HANDLE; stdcall;
  551. {$EXTERNALSYM RegisterEventSourceW}
  552. {$IFDEF UNICODE}
  553. function RegisterEventSource(lpUNCServerName, lpSourceName: LPCWSTR): HANDLE; stdcall;
  554. {$EXTERNALSYM RegisterEventSourceA}
  555. {$ELSE}
  556. function RegisterEventSource(lpUNCServerName, lpSourceName: LPCSTR): HANDLE; stdcall;
  557. {$EXTERNALSYM RegisterEventSourceA}
  558. {$ENDIF}
  559. function OpenBackupEventLogA(lpUNCServerName, lpFileName: LPCSTR): HANDLE; stdcall;
  560. {$EXTERNALSYM OpenBackupEventLogA}
  561. function OpenBackupEventLogW(lpUNCServerName, lpFileName: LPCWSTR): HANDLE; stdcall;
  562. {$EXTERNALSYM OpenBackupEventLogW}
  563. {$IFDEF UNICODE}
  564. function OpenBackupEventLog(lpUNCServerName, lpFileName: LPCWSTR): HANDLE; stdcall;
  565. {$EXTERNALSYM OpenBackupEventLogA}
  566. {$ELSE}
  567. function OpenBackupEventLog(lpUNCServerName, lpFileName: LPCSTR): HANDLE; stdcall;
  568. {$EXTERNALSYM OpenBackupEventLogA}
  569. {$ENDIF}
  570. function ReadEventLogA(hEventLog: HANDLE; dwReadFlags, dwRecordOffset: DWORD;
  571.   lpBuffer: LPVOID; nNumberOfBytesToRead: DWORD;
  572.   var pnBytesRead, pnMinNumberOfBytesNeeded: DWORD): BOOL; stdcall;
  573. {$EXTERNALSYM ReadEventLogA}
  574. function ReadEventLogW(hEventLog: HANDLE; dwReadFlags, dwRecordOffset: DWORD;
  575.   lpBuffer: LPVOID; nNumberOfBytesToRead: DWORD;
  576.   var pnBytesRead, pnMinNumberOfBytesNeeded: DWORD): BOOL; stdcall;
  577. {$EXTERNALSYM ReadEventLogW}
  578. {$IFDEF UNICODE}
  579. function ReadEventLog(hEventLog: HANDLE; dwReadFlags, dwRecordOffset: DWORD;
  580.   lpBuffer: LPVOID; nNumberOfBytesToRead: DWORD;
  581.   var pnBytesRead, pnMinNumberOfBytesNeeded: DWORD): BOOL; stdcall;
  582. {$EXTERNALSYM ReadEventLog}
  583. {$ELSE}
  584. function ReadEventLog(hEventLog: HANDLE; dwReadFlags, dwRecordOffset: DWORD;
  585.   lpBuffer: LPVOID; nNumberOfBytesToRead: DWORD;
  586.   var pnBytesRead, pnMinNumberOfBytesNeeded: DWORD): BOOL; stdcall;
  587. {$EXTERNALSYM ReadEventLog}
  588. {$ENDIF}
  589. function ReportEventA(hEventLog: HANDLE; wType, wCategory: WORD; dwEventID: DWORD;
  590.   lpUserSid: PSID; wNumStrings: WORD; dwDataSize: DWORD; lpStrings: LPCSTR;
  591.   lpRawData: LPVOID): BOOL; stdcall;
  592. {$EXTERNALSYM ReportEventA}
  593. function ReportEventW(hEventLog: HANDLE; wType, wCategory: WORD; dwEventID: DWORD;
  594.   lpUserSid: PSID; wNumStrings: WORD; dwDataSize: DWORD; lpStrings: LPCWSTR;
  595.   lpRawData: LPVOID): BOOL; stdcall;
  596. {$EXTERNALSYM ReportEventW}
  597. {$IFDEF UNICODE}
  598. function ReportEvent(hEventLog: HANDLE; wType, wCategory: WORD; dwEventID: DWORD;
  599.   lpUserSid: PSID; wNumStrings: WORD; dwDataSize: DWORD; lpStrings: LPCWSTR;
  600.   lpRawData: LPVOID): BOOL; stdcall;
  601. {$EXTERNALSYM ReportEvent}
  602. {$ELSE}
  603. function ReportEvent(hEventLog: HANDLE; wType, wCategory: WORD; dwEventID: DWORD;
  604.   lpUserSid: PSID; wNumStrings: WORD; dwDataSize: DWORD; lpStrings: LPCSTR;
  605.   lpRawData: LPVOID): BOOL; stdcall;
  606. {$EXTERNALSYM ReportEvent}
  607. {$ENDIF}
  608. const
  609.   EVENTLOG_FULL_INFO = 0;
  610.   {$EXTERNALSYM EVENTLOG_FULL_INFO}
  611. type
  612.   LPEVENTLOG_FULL_INFORMATION = ^EVENTLOG_FULL_INFORMATION;
  613.   {$EXTERNALSYM LPEVENTLOG_FULL_INFORMATION}
  614.   _EVENTLOG_FULL_INFORMATION = record
  615.     dwFull: DWORD;
  616.   end;
  617.   {$EXTERNALSYM _EVENTLOG_FULL_INFORMATION}
  618.   EVENTLOG_FULL_INFORMATION = _EVENTLOG_FULL_INFORMATION;
  619.   {$EXTERNALSYM EVENTLOG_FULL_INFORMATION}
  620.   TEventlogFullInformation = EVENTLOG_FULL_INFORMATION;
  621.   PEventlogFullInformation = LPEVENTLOG_FULL_INFORMATION;
  622. function GetEventLogInformation(hEventLog: HANDLE; dwInfoLevel: DWORD;
  623.   lpBuffer: LPVOID; cbBufSize: DWORD; var pcbBytesNeeded: DWORD): BOOL; stdcall;
  624. {$EXTERNALSYM GetEventLogInformation}
  625. //
  626. // Security APIs
  627. //
  628. function DuplicateToken(ExistingTokenHandle: HANDLE;
  629.   ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL; DuplicateTokenHandle: PHANDLE): BOOL; stdcall;
  630. {$EXTERNALSYM DuplicateToken}
  631. function GetKernelObjectSecurity(Handle: HANDLE;
  632.   RequestedInformation: SECURITY_INFORMATION;
  633.   pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD;
  634.   var lpnLengthNeeded: DWORD): BOOL; stdcall;
  635. {$EXTERNALSYM GetKernelObjectSecurity}
  636. function ImpersonateNamedPipeClient(hNamedPipe: HANDLE): BOOL; stdcall;
  637. {$EXTERNALSYM ImpersonateNamedPipeClient}
  638. function ImpersonateSelf(ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL): BOOL; stdcall;
  639. {$EXTERNALSYM ImpersonateSelf}
  640. function RevertToSelf : BOOL; stdcall;
  641. {$EXTERNALSYM RevertToSelf}
  642. function SetThreadToken(Thread: PHANDLE; Token: HANDLE): BOOL; stdcall;
  643. {$EXTERNALSYM SetThreadToken}
  644. function AccessCheck(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  645.   ClientToken: HANDLE; DesiredAccess: DWORD; const GenericMapping: GENERIC_MAPPING;
  646.   var PrivilegeSet: PRIVILEGE_SET; var PrivilegeSetLength,
  647.   GrantedAccess: DWORD; var AccessStatus: BOOL): BOOL; stdcall;
  648. {$EXTERNALSYM AccessCheck}
  649. function AccessCheckByType(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  650.   PrincipalSelfSid: PSID; ClientToken: HANDLE; DesiredAccess: DWORD;
  651.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  652.   const GenericMapping: GENERIC_MAPPING; var PrivilegeSet: PRIVILEGE_SET;
  653.   var PrivilegeSetLength, GrantedAccess: DWORD; var AccessStatus: BOOL): BOOL; stdcall;
  654. {$EXTERNALSYM AccessCheckByType}
  655. function AccessCheckByTypeResultList(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  656.   PrincipalSelfSid: PSID; ClientToken: HANDLE; DesiredAccess: DWORD;
  657.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  658.   const GenericMapping: GENERIC_MAPPING; var PrivilegeSet: PRIVILEGE_SET;
  659.   var PrivilegeSetLength, GrantedAccessList: DWORD;
  660.   var AccessStatusList: DWORD): BOOL; stdcall;
  661. {$EXTERNALSYM AccessCheckByTypeResultList}
  662. function OpenProcessToken(ProcessHandle: HANDLE; DesiredAccess: DWORD;
  663.   var TokenHandle: HANDLE): BOOL; stdcall;
  664. {$EXTERNALSYM OpenProcessToken}
  665. function OpenThreadToken(ThreadHandle: HANDLE; DesiredAccess: DWORD;
  666.   OpenAsSelf: BOOL; var TokenHandle: HANDLE): BOOL; stdcall;
  667. {$EXTERNALSYM OpenThreadToken}
  668. function GetTokenInformation(TokenHandle: HANDLE;
  669.   TokenInformationClass: TOKEN_INFORMATION_CLASS; TokenInformation: LPVOID;
  670.   TokenInformationLength: DWORD; var ReturnLength: DWORD): BOOL; stdcall;
  671. {$EXTERNALSYM GetTokenInformation}
  672. function SetTokenInformation(TokenHandle: HANDLE;
  673.   TokenInformationClass: TOKEN_INFORMATION_CLASS; TokenInformation: LPVOID;
  674.   TokenInformationLength: DWORD): BOOL; stdcall;
  675. {$EXTERNALSYM SetTokenInformation}
  676. function AdjustTokenPrivileges(TokenHandle: HANDLE; DisableAllPrivileges: BOOL;
  677.   NewState: PTOKEN_PRIVILEGES; BufferLength: DWORD;
  678.   PreviousState: PTOKEN_PRIVILEGES; ReturnLength: LPDWORD): BOOL; stdcall;
  679. {$EXTERNALSYM AdjustTokenPrivileges}
  680. function AdjustTokenGroups(TokenHandle: HANDLE; ResetToDefault: BOOL;
  681.   NewState: PTOKEN_GROUPS; BufferLength: DWORD; PreviousState: PTOKEN_GROUPS;
  682.   ReturnLength: PDWORD): BOOL; stdcall;
  683. {$EXTERNALSYM AdjustTokenGroups}
  684. function PrivilegeCheck(ClientToken: HANDLE;
  685.   RequiredPrivileges: PPRIVILEGE_SET; var pfResult: BOOL): BOOL; stdcall;
  686. {$EXTERNALSYM PrivilegeCheck}
  687. function AccessCheckAndAuditAlarmA(SubsystemName: LPCSTR; HandleId: LPVOID;
  688.   ObjectTypeName, ObjectName: LPSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  689.   DesiredAccess: DWORD; const GenericMapping: GENERIC_MAPPING;
  690.   ObjectCreation: BOOL; var GrantedAccess: DWORD;
  691.   var AccessStatus, pfGenerateOnClose: BOOL): BOOL; stdcall;
  692. {$EXTERNALSYM AccessCheckAndAuditAlarmA}
  693. function AccessCheckAndAuditAlarmW(SubsystemName: LPCWSTR; HandleId: LPVOID;
  694.   ObjectTypeName, ObjectName: LPWSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  695.   DesiredAccess: DWORD; const GenericMapping: GENERIC_MAPPING;
  696.   ObjectCreation: BOOL; var GrantedAccess: DWORD;
  697.   var AccessStatus, pfGenerateOnClose: BOOL): BOOL; stdcall;
  698. {$EXTERNALSYM AccessCheckAndAuditAlarmW}
  699. {$IFDEF UNICODE}
  700. function AccessCheckAndAuditAlarm(SubsystemName: LPCWSTR; HandleId: LPVOID;
  701.   ObjectTypeName, ObjectName: LPWSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  702.   DesiredAccess: DWORD; const GenericMapping: GENERIC_MAPPING;
  703.   ObjectCreation: BOOL; var GrantedAccess: DWORD;
  704.   var AccessStatus, pfGenerateOnClose: BOOL): BOOL; stdcall;
  705. {$EXTERNALSYM AccessCheckAndAuditAlarmA}
  706. {$ELSE}
  707. function AccessCheckAndAuditAlarm(SubsystemName: LPCSTR; HandleId: LPVOID;
  708.   ObjectTypeName, ObjectName: LPSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  709.   DesiredAccess: DWORD; const GenericMapping: GENERIC_MAPPING;
  710.   ObjectCreation: BOOL; var GrantedAccess: DWORD;
  711.   var AccessStatus, pfGenerateOnClose: BOOL): BOOL; stdcall;
  712. {$EXTERNALSYM AccessCheckAndAuditAlarmA}
  713. {$ENDIF}
  714. function AccessCheckByTypeAndAuditAlarmA(SubsystemName: LPCSTR; HandleId: LPVOID;
  715.   ObjectTypeName: LPCSTR; ObjectName: LPCSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  716.   PrincipalSelfSid: PSID; DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE;
  717.   Flags: DWORD; ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  718.   GenericMapping: PGENERIC_MAPPING; ObjectCreation: BOOL; GrantedAccess: LPDWORD;
  719.   AccessStatus: LPBOOL; pfGenerateOnClose: LPBOOL): BOOL; stdcall;
  720. {$EXTERNALSYM AccessCheckByTypeAndAuditAlarmA}
  721. function AccessCheckByTypeAndAuditAlarmW(SubsystemName: LPCWSTR; HandleId: LPVOID;
  722. ObjectTypeName: LPCWSTR; ObjectName: LPCWSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  723. PrincipalSelfSid: PSID; DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE;
  724. Flags: DWORD; ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  725. GenericMapping: PGENERIC_MAPPING; ObjectCreation: BOOL; GrantedAccess: LPDWORD;
  726. AccessStatus: LPBOOL; pfGenerateOnClose: LPBOOL): BOOL; stdcall;
  727. {$EXTERNALSYM AccessCheckByTypeAndAuditAlarmW}
  728. {$IFDEF UNICODE}
  729. function AccessCheckByTypeAndAuditAlarm(SubsystemName: LPCWSTR; HandleId: LPVOID;
  730.   ObjectTypeName, ObjectName: LPCWSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  731.   PrincipalSelfSid: PSID; DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE;
  732.   Flags: DWORD; ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  733.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  734.   var GrantedAccess: DWORD; var AccessStatus, pfGenerateOnClose: BOOL): BOOL; stdcall;
  735. {$EXTERNALSYM AccessCheckByTypeAndAuditAlarmA}
  736. {$ELSE}
  737. function AccessCheckByTypeAndAuditAlarm(SubsystemName: LPCSTR; HandleId: LPVOID;
  738.   ObjectTypeName, ObjectName: LPCSTR; SecurityDescriptor: PSECURITY_DESCRIPTOR;
  739.   PrincipalSelfSid: PSID; DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE;
  740.   Flags: DWORD; ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  741.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  742.   var GrantedAccess: DWORD; var AccessStatus, pfGenerateOnClose: BOOL): BOOL; stdcall;
  743. {$EXTERNALSYM AccessCheckByTypeAndAuditAlarmA}
  744. {$ENDIF}
  745. function AccessCheckByTypeResultListAndAuditAlarmA(SubsystemName: LPCSTR;
  746.   HandleId: LPVOID; ObjectTypeName, ObjectName: LPCSTR;
  747.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  748.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  749.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  750.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  751.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  752. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmA}
  753. function AccessCheckByTypeResultListAndAuditAlarmW(SubsystemName: LPCWSTR;
  754.   HandleId: LPVOID; ObjectTypeName, ObjectName: LPCWSTR;
  755.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  756.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  757.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  758.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  759.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  760. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmW}
  761. {$IFDEF UNICODE}
  762. function AccessCheckByTypeResultListAndAuditAlarm(SubsystemName: LPCWSTR;
  763.   HandleId: LPVOID; ObjectTypeName, ObjectName: LPCWSTR;
  764.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  765.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  766.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  767.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  768.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  769. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmA}
  770. {$ELSE}
  771. function AccessCheckByTypeResultListAndAuditAlarm(SubsystemName: LPCSTR;
  772.   HandleId: LPVOID; ObjectTypeName, ObjectName: LPCSTR;
  773.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  774.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  775.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  776.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  777.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  778. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmA}
  779. {$ENDIF}
  780. function AccessCheckByTypeResultListAndAuditAlarmByHandleA(SubsystemName: LPCSTR;
  781.   HandleId: LPVOID; ClientToken: HANDLE; ObjectTypeName, ObjectName: LPCSTR;
  782.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  783.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  784.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  785.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  786.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  787. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmByHandleA}
  788. function AccessCheckByTypeResultListAndAuditAlarmByHandleW(SubsystemName: LPCWSTR;
  789.   HandleId: LPVOID; ClientToken: HANDLE; ObjectTypeName, ObjectName: LPCWSTR;
  790.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  791.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  792.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  793.   const GenericMapping: PGENERIC_MAPPING; ObjectCreation: BOOL;
  794.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  795. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmByHandleW}
  796. {$IFDEF UNICODE}
  797. function AccessCheckByTypeResultListAndAuditAlarmByHandle(SubsystemName: LPCWSTR;
  798.   HandleId: LPVOID; ClientToken: HANDLE; ObjectTypeName, ObjectName: LPCWSTR;
  799.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  800.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  801.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  802.   const GenericMapping: PGENERIC_MAPPING; ObjectCreation: BOOL;
  803.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  804. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmByHandle}
  805. {$ELSE}
  806. function AccessCheckByTypeResultListAndAuditAlarmByHandle(SubsystemName: LPCSTR;
  807.   HandleId: LPVOID; ClientToken: HANDLE; ObjectTypeName, ObjectName: LPCSTR;
  808.   SecurityDescriptor: PSECURITY_DESCRIPTOR; PrincipalSelfSid: PSID;
  809.   DesiredAccess: DWORD; AuditType: AUDIT_EVENT_TYPE; Flags: DWORD;
  810.   ObjectTypeList: POBJECT_TYPE_LIST; ObjectTypeListLength: DWORD;
  811.   const GenericMapping: GENERIC_MAPPING; ObjectCreation: BOOL;
  812.   var GrantedAccess, AccessStatusList: DWORD; var pfGenerateOnClose: BOOL): BOOL; stdcall;
  813. {$EXTERNALSYM AccessCheckByTypeResultListAndAuditAlarmByHandleA}
  814. {$ENDIF}
  815. function ObjectOpenAuditAlarmA(SubsystemName: LPCSTR; HandleId: LPVOID;
  816.   ObjectTypeName: LPSTR; ObjectName: LPSTR; pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  817.   ClientToken: HANDLE; DesiredAccess, GrantedAccess: DWORD;
  818.   Privileges: PPRIVILEGE_SET; ObjectCreation: BOOL; AccessGranted: BOOL;
  819.   var GenerateOnClose: BOOL): BOOL; stdcall;
  820. {$EXTERNALSYM ObjectOpenAuditAlarmA}
  821. function ObjectOpenAuditAlarmW(SubsystemName: LPCWSTR; HandleId: LPVOID;
  822.   ObjectTypeName, ObjectName: LPWSTR; pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  823.   ClientToken: HANDLE; DesiredAccess: DWORD; GrantedAccess: DWORD;
  824.   Privileges: PPRIVILEGE_SET; ObjectCreation: BOOL; AccessGranted: BOOL;
  825.   var GenerateOnClose: BOOL): BOOL; stdcall;
  826. {$EXTERNALSYM ObjectOpenAuditAlarmW}
  827. {$IFDEF UNICODE}
  828. function ObjectOpenAuditAlarm(SubsystemName: LPCWSTR; HandleId: LPVOID;
  829.   ObjectTypeName: LPWSTR; ObjectName: LPWSTR; pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  830.   ClientToken: HANDLE; DesiredAccess: DWORD; GrantedAccess: DWORD;
  831.   Privileges: PPRIVILEGE_SET; ObjectCreation: BOOL; AccessGranted: BOOL;
  832.   var GenerateOnClose: BOOL): BOOL; stdcall;
  833. {$EXTERNALSYM ObjectOpenAuditAlarmA}
  834. {$ELSE}
  835. function ObjectOpenAuditAlarm(SubsystemName: LPCSTR; HandleId: LPVOID;
  836.   ObjectTypeName: LPSTR; ObjectName: LPSTR; pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  837.   ClientToken: HANDLE; DesiredAccess: DWORD; GrantedAccess: DWORD;
  838.   Privileges: PPRIVILEGE_SET; ObjectCreation: BOOL; AccessGranted: BOOL;
  839.   var GenerateOnClose: BOOL): BOOL; stdcall;
  840. {$EXTERNALSYM ObjectOpenAuditAlarmA}
  841. {$ENDIF}
  842. function ObjectPrivilegeAuditAlarmA(SubsystemName: LPCSTR; HandleId: LPVOID;
  843.   ClientToken: HANDLE; DesiredAccess: DWORD; const Privileges: PRIVILEGE_SET;
  844.   AccessGranted: BOOL): BOOL; stdcall;
  845. {$EXTERNALSYM ObjectPrivilegeAuditAlarmA}
  846. function ObjectPrivilegeAuditAlarmW(SubsystemName: LPCWSTR; HandleId: LPVOID;
  847.   ClientToken: HANDLE; DesiredAccess: DWORD; const Privileges: PRIVILEGE_SET;
  848.   AccessGranted: BOOL): BOOL; stdcall;
  849. {$EXTERNALSYM ObjectPrivilegeAuditAlarmW}
  850. {$IFDEF UNICODE}
  851. function ObjectPrivilegeAuditAlarm(SubsystemName: LPCWSTR; HandleId: LPVOID;
  852.   ClientToken: HANDLE; DesiredAccess: DWORD; const Privileges: PRIVILEGE_SET;
  853.   AccessGranted: BOOL): BOOL; stdcall;
  854. {$EXTERNALSYM ObjectPrivilegeAuditAlarmA}
  855. {$ELSE}
  856. function ObjectPrivilegeAuditAlarm(SubsystemName: LPCSTR; HandleId: LPVOID;
  857.   ClientToken: HANDLE; DesiredAccess: DWORD; const Privileges: PRIVILEGE_SET;
  858.   AccessGranted: BOOL): BOOL; stdcall;
  859. {$EXTERNALSYM ObjectPrivilegeAuditAlarmA}
  860. {$ENDIF}
  861. function ObjectCloseAuditAlarmA(SubsystemName: LPCSTR; HandleId: LPVOID;
  862.   GenerateOnClose: BOOL): BOOL; stdcall;
  863. {$EXTERNALSYM ObjectCloseAuditAlarmA}
  864. function ObjectCloseAuditAlarmW(SubsystemName: LPCWSTR; HandleId: LPVOID;
  865.   GenerateOnClose: BOOL): BOOL; stdcall;
  866. {$EXTERNALSYM ObjectCloseAuditAlarmW}
  867. {$IFDEF UNICODE}
  868. function ObjectCloseAuditAlarm(SubsystemName: LPCWSTR; HandleId: LPVOID;
  869.   GenerateOnClose: BOOL): BOOL; stdcall;
  870. {$EXTERNALSYM ObjectCloseAuditAlarmA}
  871. {$ELSE}
  872. function ObjectCloseAuditAlarm(SubsystemName: LPCSTR; HandleId: LPVOID;
  873.   GenerateOnClose: BOOL): BOOL; stdcall;
  874. {$EXTERNALSYM ObjectCloseAuditAlarmA}
  875. {$ENDIF}
  876. function ObjectDeleteAuditAlarmA(SubsystemName: LPCSTR; HandleId: LPVOID;
  877.   GenerateOnClose: BOOL): BOOL; stdcall;
  878. {$EXTERNALSYM ObjectDeleteAuditAlarmA}
  879. function ObjectDeleteAuditAlarmW(SubsystemName: LPCWSTR; HandleId: LPVOID;
  880.   GenerateOnClose: BOOL): BOOL; stdcall;
  881. {$EXTERNALSYM ObjectDeleteAuditAlarmW}
  882. {$IFDEF UNICODE}
  883. function ObjectDeleteAuditAlarm(SubsystemName: LPCWSTR; HandleId: LPVOID;
  884.   GenerateOnClose: BOOL): BOOL; stdcall;
  885. {$EXTERNALSYM ObjectDeleteAuditAlarmA}
  886. {$ELSE}
  887. function ObjectDeleteAuditAlarm(SubsystemName: LPCSTR; HandleId: LPVOID;
  888.   GenerateOnClose: BOOL): BOOL; stdcall;
  889. {$EXTERNALSYM ObjectDeleteAuditAlarmA}
  890. {$ENDIF}
  891. function PrivilegedServiceAuditAlarmA(SubsystemName, ServiceName: LPCSTR;
  892.   ClientToken: HANDLE; const Privileges: PRIVILEGE_SET; AccessGranted: BOOL): BOOL; stdcall;
  893. {$EXTERNALSYM PrivilegedServiceAuditAlarmA}
  894. function PrivilegedServiceAuditAlarmW(SubsystemName, ServiceName: LPCWSTR;
  895.   ClientToken: HANDLE; const Privileges: PRIVILEGE_SET; AccessGranted: BOOL): BOOL; stdcall;
  896. {$EXTERNALSYM PrivilegedServiceAuditAlarmW}
  897. {$IFDEF UNICODE}
  898. function PrivilegedServiceAuditAlarm(SubsystemName, ServiceName: LPCWSTR;
  899.   ClientToken: HANDLE; const Privileges: PRIVILEGE_SET; AccessGranted: BOOL): BOOL; stdcall;
  900. {$EXTERNALSYM PrivilegedServiceAuditAlarmA}
  901. {$ELSE}
  902. function PrivilegedServiceAuditAlarm(SubsystemName, ServiceName: LPCSTR;
  903.   ClientToken: HANDLE; const Privileges: PRIVILEGE_SET; AccessGranted: BOOL): BOOL; stdcall;
  904. {$EXTERNALSYM PrivilegedServiceAuditAlarmA}
  905. {$ENDIF}
  906. function IsWellKnownSid(pSid: PSID; WellKnownSidType: WELL_KNOWN_SID_TYPE): BOOL; stdcall;
  907. {$EXTERNALSYM IsWellKnownSid}
  908. function CreateWellKnownSid(WellKnownSidType: WELL_KNOWN_SID_TYPE; DomainSid: PSID;
  909.   pSid: PSID; var cbSid: DWORD): BOOL; stdcall;
  910. {$EXTERNALSYM CreateWellKnownSid}
  911. function EqualDomainSid(pSid1, pSid2: PSID; pfEqual: PBOOL): BOOL; stdcall;
  912. {$EXTERNALSYM EqualDomainSid}
  913. function GetWindowsAccountDomainSid(pSid, ppDomainSid: PSID; var cbSid: DWORD): BOOL; stdcall;
  914. {$EXTERNALSYM GetWindowsAccountDomainSid}
  915. function IsValidSid(pSid: PSID): BOOL; stdcall;
  916. {$EXTERNALSYM IsValidSid}
  917. function EqualSid(pSid1, pSid2: PSID): BOOL; stdcall;
  918. {$EXTERNALSYM EqualSid}
  919. function EqualPrefixSid(pSid1, pSid2: PSID): BOOL; stdcall;
  920. {$EXTERNALSYM EqualPrefixSid}
  921. function GetSidLengthRequired(nSubAuthorityCount: UCHAR): DWORD; stdcall;
  922. {$EXTERNALSYM GetSidLengthRequired}
  923. function AllocateAndInitializeSid(pIdentifierAuthority: PSID_IDENTIFIER_AUTHORITY;
  924.   SubAuthorityCount: BYTE; nSubAuthority0, nSubAuthority1, nSubAuthority2,
  925.   nSubAuthority3, nSubAuthority4, nSubAuthority5, nSubAuthority6,
  926.   nSubAuthority7: DWORD; var pSid: PSID): BOOL; stdcall;
  927. {$EXTERNALSYM AllocateAndInitializeSid}
  928. function FreeSid(pSid: PSID): PVOID; stdcall;
  929. {$EXTERNALSYM FreeSid}
  930. function InitializeSid(Sid: PSID; pIdentifierAuthority: PSID_IDENTIFIER_AUTHORITY;
  931.   nSubAuthorityCount: BYTE): BOOL; stdcall;
  932. {$EXTERNALSYM InitializeSid}
  933. function GetSidIdentifierAuthority(pSid: PSID): PSID_IDENTIFIER_AUTHORITY; stdcall;
  934. {$EXTERNALSYM GetSidIdentifierAuthority}
  935. function GetSidSubAuthority(pSid: PSID; nSubAuthority: DWORD): PDWORD; stdcall;
  936. {$EXTERNALSYM GetSidSubAuthority}
  937. function GetSidSubAuthorityCount(pSid: PSID): PUCHAR; stdcall;
  938. {$EXTERNALSYM GetSidSubAuthorityCount}
  939. function GetLengthSid(pSid: PSID): DWORD; stdcall;
  940. {$EXTERNALSYM GetLengthSid}
  941. function CopySid(nDestinationSidLength: DWORD; pDestinationSid: PSID;
  942.   pSourceSid: PSID): BOOL; stdcall;
  943. {$EXTERNALSYM CopySid}
  944. function AreAllAccessesGranted(GrantedAccess, DesiredAccess: DWORD): BOOL; stdcall;
  945. {$EXTERNALSYM AreAllAccessesGranted}
  946. function AreAnyAccessesGranted(GrantedAccess, DesiredAccess: DWORD): BOOL; stdcall;
  947. {$EXTERNALSYM AreAnyAccessesGranted}
  948. procedure MapGenericMask(var AccessMask: DWORD; var GenericMapping: GENERIC_MAPPING); stdcall;
  949. {$EXTERNALSYM MapGenericMask}
  950. function IsValidAcl(pAcl: PACL): BOOL; stdcall;
  951. {$EXTERNALSYM IsValidAcl}
  952. function InitializeAcl(pAcl: PACL; nAclLength: DWORD; dwAclRevision: DWORD): BOOL; stdcall;
  953. {$EXTERNALSYM InitializeAcl}
  954. function GetAclInformation(pAcl: PACL; pAclInformation: LPVOID;
  955.   nAclInformationLength: DWORD; dwAclInformationClass: ACL_INFORMATION_CLASS): BOOL; stdcall;
  956. {$EXTERNALSYM GetAclInformation}
  957. function SetAclInformation(pAcl: PACL; pAclInformation: LPVOID;
  958.   nAclInformationLength: DWORD; dwAclInformationClass: ACL_INFORMATION_CLASS): BOOL; stdcall;
  959. {$EXTERNALSYM SetAclInformation}
  960. function AddAce(pAcl: PACL; dwAceRevision: DWORD; dwStartingAceIndex: DWORD;
  961.   pAceList: LPVOID; nAceListLength: DWORD): BOOL; stdcall;
  962. {$EXTERNALSYM AddAce}
  963. function DeleteAce(pAcl: PACL; dwAceIndex: DWORD): BOOL; stdcall;
  964. {$EXTERNALSYM DeleteAce}
  965. function GetAce(pAcl: PACL; dwAceIndex: DWORD; var pAce: LPVOID): BOOL; stdcall;
  966. {$EXTERNALSYM GetAce}
  967. function AddAccessAllowedAce(pAcl: PACL; dwAceRevision, AccessMask: DWORD; pSid: PSID): BOOL; stdcall;
  968. {$EXTERNALSYM AddAccessAllowedAce}
  969. function AddAccessAllowedAceEx(pAcl: PACL; dwAceRevision, AceFlags,
  970.   AccessMask: DWORD; pSid: PSID): BOOL; stdcall;
  971. {$EXTERNALSYM AddAccessAllowedAceEx}
  972. function AddAccessDeniedAce(pAcl: PACL; dwAceRevision, AccessMask: DWORD; pSid: PSID): BOOL; stdcall;
  973. {$EXTERNALSYM AddAccessDeniedAce}
  974. function AddAccessDeniedAceEx(pAcl: PACL; dwAceRevision, AceFlags: DWORD;
  975.   AccessMask: DWORD; pSid: PSID): BOOL; stdcall;
  976. {$EXTERNALSYM AddAccessDeniedAceEx}
  977. function AddAuditAccessAce(pAcl: PACL; dwAceRevision, dwAccessMask: DWORD;
  978.   pSid: PSID; bAuditSuccess, bAuditFailure: BOOL): BOOL; stdcall;
  979. {$EXTERNALSYM AddAuditAccessAce}
  980. function AddAuditAccessAceEx(pAcl: PACL; dwAceRevision, AceFlags,
  981.   dwAccessMask: DWORD; pSid: PSID; bAuditSuccess, bAuditFailure: BOOL): BOOL; stdcall;
  982. {$EXTERNALSYM AddAuditAccessAceEx}
  983. function AddAccessAllowedObjectAce(pAcl: PACL; dwAceRevision, AceFlags,
  984.   AccessMask: DWORD; ObjectTypeGuid, InheritedObjectTypeGuid: LPGUID; pSid: PSID): BOOL; stdcall;
  985. {$EXTERNALSYM AddAccessAllowedObjectAce}
  986. function AddAccessDeniedObjectAce(pAcl: PACL; dwAceRevision, AceFlags,
  987.   AccessMask: DWORD; ObjectTypeGuid, InheritedObjectTypeGuid: LPGUID; pSid: PSID): BOOL; stdcall;
  988. {$EXTERNALSYM AddAccessDeniedObjectAce}
  989. function AddAuditAccessObjectAce(pAcl: PACL; dwAceRevision, AceFlags,
  990.   AccessMask: DWORD; ObjectTypeGuid, InheritedObjectTypeGuid: LPGUID; pSid: PSID;
  991.   bAuditSuccess, bAuditFailure: BOOL): BOOL; stdcall;
  992. {$EXTERNALSYM AddAuditAccessObjectAce}
  993. function FindFirstFreeAce(pAcl: PACL; var pAce: LPVOID): BOOL; stdcall;
  994. {$EXTERNALSYM FindFirstFreeAce}
  995. function InitializeSecurityDescriptor(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  996.   dwRevision: DWORD): BOOL; stdcall;
  997. {$EXTERNALSYM InitializeSecurityDescriptor}
  998. function IsValidSecurityDescriptor(pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  999. {$EXTERNALSYM IsValidSecurityDescriptor}
  1000. function GetSecurityDescriptorLength(pSecurityDescriptor: PSECURITY_DESCRIPTOR): DWORD; stdcall;
  1001. {$EXTERNALSYM GetSecurityDescriptorLength}
  1002. function GetSecurityDescriptorControl(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1003.   var pControl: SECURITY_DESCRIPTOR_CONTROL; var lpdwRevision: DWORD): BOOL; stdcall;
  1004. {$EXTERNALSYM GetSecurityDescriptorControl}
  1005. function SetSecurityDescriptorControl(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1006.   ControlBitsOfInterest, ControlBitsToSet: SECURITY_DESCRIPTOR_CONTROL): BOOL; stdcall;
  1007. {$EXTERNALSYM SetSecurityDescriptorControl}
  1008. function SetSecurityDescriptorDacl(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1009.   bDaclPresent: BOOL; pDacl: PACL; bDaclDefaulted: BOOL): BOOL; stdcall;
  1010. {$EXTERNALSYM SetSecurityDescriptorDacl}
  1011. function GetSecurityDescriptorDacl(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1012.   var lpbDaclPresent: BOOL; var pDacl: PACL; var lpbDaclDefaulted: BOOL): BOOL; stdcall;
  1013. {$EXTERNALSYM GetSecurityDescriptorDacl}
  1014. function SetSecurityDescriptorSacl(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1015.   bSaclPresent: BOOL; pSacl: PACL; bSaclDefaulted: BOOL): BOOL; stdcall;
  1016. {$EXTERNALSYM SetSecurityDescriptorSacl}
  1017. function GetSecurityDescriptorSacl(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1018.   var lpbSaclPresent: BOOL; var pSacl: PACL; var lpbSaclDefaulted: BOOL): BOOL; stdcall;
  1019. {$EXTERNALSYM GetSecurityDescriptorSacl}
  1020. function SetSecurityDescriptorOwner(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1021.   pOwner: PSID; bOwnerDefaulted: BOOL): BOOL; stdcall;
  1022. {$EXTERNALSYM SetSecurityDescriptorOwner}
  1023. function GetSecurityDescriptorOwner(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1024.   var pOwner: PSID; lpbOwnerDefaulted: PBOOL): BOOL; stdcall;
  1025. {$EXTERNALSYM GetSecurityDescriptorOwner}
  1026. function SetSecurityDescriptorGroup(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1027.   pGroup: PSID; bGroupDefaulted: BOOL): BOOL; stdcall;
  1028. {$EXTERNALSYM SetSecurityDescriptorGroup}
  1029. function GetSecurityDescriptorGroup(pSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1030.   var pGroup: PSID; lpbGroupDefaulted: PBOOL): BOOL; stdcall;
  1031. {$EXTERNALSYM GetSecurityDescriptorGroup}
  1032. function SetSecurityDescriptorRMControl(SecurityDescriptor: PSECURITY_DESCRIPTOR;
  1033.   RMControl: PUCHAR): DWORD; stdcall;
  1034. {$EXTERNALSYM SetSecurityDescriptorRMControl}
  1035. function GetSecurityDescriptorRMControl(SecurityDescriptor: PSECURITY_DESCRIPTOR;
  1036.   var RMControl: UCHAR): DWORD; stdcall;
  1037. {$EXTERNALSYM GetSecurityDescriptorRMControl}
  1038. function CreatePrivateObjectSecurity(ParentDescriptor, CreatorDescriptor: PSECURITY_DESCRIPTOR;
  1039.   var NewDescriptor: PSECURITY_DESCRIPTOR; IsDirectoryObject: BOOL; Token: HANDLE;
  1040.   const GenericMapping: GENERIC_MAPPING): BOOL; stdcall;
  1041. {$EXTERNALSYM CreatePrivateObjectSecurity}
  1042. function ConvertToAutoInheritPrivateObjectSecurity(ParentDescriptor,
  1043.   CurrentSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1044.   var NewSecurityDescriptor: PSECURITY_DESCRIPTOR; ObjectType: LPGUID;
  1045.   IsDirectoryObject: ByteBool; const GenericMapping: GENERIC_MAPPING): BOOL; stdcall;
  1046. {$EXTERNALSYM ConvertToAutoInheritPrivateObjectSecurity}
  1047. function CreatePrivateObjectSecurityEx(ParentDescriptor,
  1048.   CreatorDescriptor: PSECURITY_DESCRIPTOR;
  1049.   var NewDescriptor: PSECURITY_DESCRIPTOR; ObjectType: LPGUID;
  1050.   IsContainerObject: BOOL; AutoInheritFlags: ULONG; Token: HANDLE;
  1051.   const GenericMapping: GENERIC_MAPPING): BOOL; stdcall;
  1052. {$EXTERNALSYM CreatePrivateObjectSecurityEx}
  1053. function SetPrivateObjectSecurity(SecurityInformation: SECURITY_INFORMATION;
  1054.   ModificationDescriptor: PSECURITY_DESCRIPTOR;
  1055.   var ObjectsSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1056.   const GenericMapping: GENERIC_MAPPING; Token: HANDLE): BOOL; stdcall;
  1057. {$EXTERNALSYM SetPrivateObjectSecurity}
  1058. function SetPrivateObjectSecurityEx(SecurityInformation: SECURITY_INFORMATION;
  1059.   ModificationDescriptor: PSECURITY_DESCRIPTOR;
  1060.   var ObjectsSecurityDescriptor: PSECURITY_DESCRIPTOR; AutoInheritFlags: ULONG;
  1061.   const GenericMapping: GENERIC_MAPPING; Token: HANDLE): BOOL; stdcall;
  1062. {$EXTERNALSYM SetPrivateObjectSecurityEx}
  1063. function GetPrivateObjectSecurity(ObjectDescriptor: PSECURITY_DESCRIPTOR;
  1064.   SecurityInformation: SECURITY_INFORMATION;
  1065.   ResultantDescriptor: PSECURITY_DESCRIPTOR; DescriptorLength: DWORD;
  1066.   var ReturnLength: DWORD): BOOL; stdcall;
  1067. {$EXTERNALSYM GetPrivateObjectSecurity}
  1068. function DestroyPrivateObjectSecurity(var ObjectDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  1069. {$EXTERNALSYM DestroyPrivateObjectSecurity}
  1070. function MakeSelfRelativeSD(pAbsoluteSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1071.   pSelfRelativeSecurityDescriptor: PSECURITY_DESCRIPTOR; var lpdwBufferLength: DWORD): BOOL; stdcall;
  1072. {$EXTERNALSYM MakeSelfRelativeSD}
  1073. function MakeAbsoluteSD(pSelfRelativeSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1074.   pAbsoluteSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1075.   var lpdwAbsoluteSecurityDescriptorSize: DWORD; pDacl: PACL;
  1076.   var lpdwDaclSize: DWORD; pSacl: PACL; var lpdwSaclSize: DWORD; pOwner: PSID;
  1077.   var lpdwOwnerSize: DWORD; pPrimaryGroup: PSID; var lpdwPrimaryGroupSize: DWORD): BOOL; stdcall;
  1078. {$EXTERNALSYM MakeAbsoluteSD}
  1079. function MakeAbsoluteSD2(pSelfRelativeSecurityDescriptor: PSECURITY_DESCRIPTOR;
  1080.   var lpdwBufferSize: DWORD): BOOL; stdcall;
  1081. {$EXTERNALSYM MakeAbsoluteSD2}
  1082. function SetFileSecurityA(lpFileName: LPCSTR; SecurityInformation: SECURITY_INFORMATION;
  1083.   pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  1084. {$EXTERNALSYM SetFileSecurityA}
  1085. function SetFileSecurityW(lpFileName: LPCWSTR; SecurityInformation: SECURITY_INFORMATION;
  1086.   pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  1087. {$EXTERNALSYM SetFileSecurityW}
  1088. {$IFDEF UNICODE}
  1089. function SetFileSecurity(lpFileName: LPCWSTR; SecurityInformation: SECURITY_INFORMATION;
  1090.   pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  1091. {$EXTERNALSYM SetFileSecurityA}
  1092. {$ELSE}
  1093. function SetFileSecurity(lpFileName: LPCSTR; SecurityInformation: SECURITY_INFORMATION;
  1094.   pSecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  1095. {$EXTERNALSYM SetFileSecurityA}
  1096. {$ENDIF}
  1097. function GetFileSecurityA(lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION;
  1098.   pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD;
  1099.   var lpnLengthNeeded: DWORD): BOOL; stdcall;
  1100. {$EXTERNALSYM GetFileSecurityA}
  1101. function GetFileSecurityW(lpFileName: LPCWSTR; RequestedInformation: SECURITY_INFORMATION;
  1102.   pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD;
  1103.   var lpnLengthNeeded: DWORD): BOOL; stdcall;
  1104. {$EXTERNALSYM GetFileSecurityW}
  1105. {$IFDEF UNICODE}
  1106. function GetFileSecurity(lpFileName: LPCWSTR; RequestedInformation: SECURITY_INFORMATION;
  1107.   pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD;
  1108.   var lpnLengthNeeded: DWORD): BOOL; stdcall;
  1109. {$EXTERNALSYM GetFileSecurityA}
  1110. {$ELSE}
  1111. function GetFileSecurity(lpFileName: LPCSTR; RequestedInformation: SECURITY_INFORMATION;
  1112.   pSecurityDescriptor: PSECURITY_DESCRIPTOR; nLength: DWORD;
  1113.   var lpnLengthNeeded: DWORD): BOOL; stdcall;
  1114. {$EXTERNALSYM GetFileSecurityA}
  1115. {$ENDIF}
  1116. function SetKernelObjectSecurity(Handle: HANDLE; SecurityInformation: SECURITY_INFORMATION;
  1117.   SecurityDescriptor: PSECURITY_DESCRIPTOR): BOOL; stdcall;
  1118. {$EXTERNALSYM SetKernelObjectSecurity}
  1119. function FindFirstChangeNotificationA(lpPathName: LPCSTR; bWatchSubtree: Cardinal;
  1120.   dwNotifyFilter: DWORD): HANDLE; stdcall;
  1121. {$EXTERNALSYM FindFirstChangeNotificationA}
  1122. function FindFirstChangeNotificationW(lpPathName: LPCWSTR; bWatchSubtree: Cardinal;
  1123.   dwNotifyFilter: DWORD): HANDLE; stdcall;
  1124. {$EXTERNALSYM FindFirstChangeNotificationW}
  1125. {$IFDEF UNICODE}
  1126. function FindFirstChangeNotification(lpPathName: LPCWSTR; bWatchSubtree: Cardinal;
  1127.   dwNotifyFilter: DWORD): HANDLE; stdcall;
  1128. {$EXTERNALSYM FindFirstChangeNotification}
  1129. {$ELSE}
  1130. function FindFirstChangeNotification(lpPathName: LPCSTR; bWatchSubtree: Cardinal;
  1131.   dwNotifyFilter: DWORD): HANDLE; stdcall;
  1132. {$EXTERNALSYM FindFirstChangeNotification}
  1133. {$ENDIF}
  1134. function FindNextChangeNotification(hChangeHandle: HANDLE): BOOL; stdcall;
  1135. {$EXTERNALSYM FindNextChangeNotification}
  1136. function FindCloseChangeNotification(hChangeHandle: HANDLE): BOOL; stdcall;
  1137. {$EXTERNALSYM FindCloseChangeNotification}
  1138. function ReadDirectoryChangesW(hDirectory: HANDLE; lpBuffer: LPVOID;
  1139.   nBufferLength: DWORD; bWatchSubtree: BOOL; dwNotifyFilter: DWORD;
  1140.   lpBytesReturned: LPDWORD; lpOverlapped: LPOVERLAPPED;
  1141.   lpCompletionRoutine: LPOVERLAPPED_COMPLETION_ROUTINE): BOOL; stdcall;
  1142. {$EXTERNALSYM ReadDirectoryChangesW}
  1143. function VirtualLock(lpAddress: LPVOID; dwSize: SIZE_T): BOOL; stdcall;
  1144. {$EXTERNALSYM VirtualLock}
  1145. function VirtualUnlock(lpAddress: LPVOID; dwSize: SIZE_T): BOOL; stdcall;
  1146. {$EXTERNALSYM VirtualUnlock}
  1147. function MapViewOfFileEx(hFileMappingObject: HANDLE; dwDesiredAccess: DWORD;
  1148.   dwFileOffsetHigh: DWORD; dwFileOffsetLow: DWORD; dwNumberOfBytesToMap: SIZE_T;
  1149.   lpBaseAddress: LPVOID): LPVOID; stdcall;
  1150. {$EXTERNALSYM MapViewOfFileEx}
  1151. function SetPriorityClass(hProcess: HANDLE; dwPriorityClass: DWORD): BOOL; stdcall;
  1152. {$EXTERNALSYM SetPriorityClass}
  1153. function GetPriorityClass(hProcess: HANDLE): DWORD; stdcall;
  1154. {$EXTERNALSYM GetPriorityClass}
  1155. function IsBadReadPtr(lp: LPVOID; ucb: UINT_PTR): BOOL; stdcall;
  1156. {$EXTERNALSYM IsBadReadPtr}
  1157. function IsBadWritePtr(lp: LPVOID; ucb: UINT_PTR): BOOL; stdcall;
  1158. {$EXTERNALSYM IsBadWritePtr}
  1159. function IsBadHugeReadPtr(lp: LPVOID; ucb: UINT_PTR): BOOL; stdcall;
  1160. {$EXTERNALSYM IsBadHugeReadPtr}
  1161. function IsBadHugeWritePtr(lp: LPVOID; ucb: UINT_PTR): BOOL; stdcall;
  1162. {$EXTERNALSYM IsBadHugeWritePtr}
  1163. function IsBadCodePtr(lpfn: FARPROC): BOOL; stdcall;
  1164. {$EXTERNALSYM IsBadCodePtr}
  1165. function IsBadStringPtrA(lpsz: LPCSTR; ucchMax: UINT_PTR): BOOL; stdcall;
  1166. {$EXTERNALSYM IsBadStringPtrA}
  1167. function IsBadStringPtrW(lpsz: LPCWSTR; ucchMax: UINT_PTR): BOOL; stdcall;
  1168. {$EXTERNALSYM IsBadStringPtrW}
  1169. {$IFDEF UNICODE}
  1170. function IsBadStringPtr(lpsz: LPCWSTR; ucchMax: UINT_PTR): BOOL; stdcall;
  1171. {$EXTERNALSYM IsBadStringPtr}
  1172. {$ELSE}
  1173. function IsBadStringPtr(lpsz: LPCSTR; ucchMax: UINT_PTR): BOOL; stdcall;
  1174. {$EXTERNALSYM IsBadStringPtr}
  1175. {$ENDIF}
  1176. function LookupAccountSidA(lpSystemName: LPCSTR; Sid: PSID; Name: LPSTR;
  1177.   var cbName: DWORD; ReferencedDomainName: LPSTR; var cbReferencedDomainName: DWORD;
  1178.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1179. {$EXTERNALSYM LookupAccountSidA}
  1180. function LookupAccountSidW(lpSystemName: LPCWSTR; Sid: PSID; Name: LPWSTR;
  1181.   var cbName: DWORD; ReferencedDomainName: LPWSTR; var cbReferencedDomainName: DWORD;
  1182.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1183. {$EXTERNALSYM LookupAccountSidW}
  1184. {$IFDEF UNICODE}
  1185. function LookupAccountSid(lpSystemName: LPCWSTR; Sid: PSID; Name: LPWSTR;
  1186.   var cbName: DWORD; ReferencedDomainName: LPWSTR; var cbReferencedDomainName: DWORD;
  1187.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1188. {$EXTERNALSYM LookupAccountSid}
  1189. {$ELSE}
  1190. function LookupAccountSid(lpSystemName: LPCSTR; Sid: PSID; Name: LPSTR;
  1191.   var cbName: DWORD; ReferencedDomainName: LPSTR; var cbReferencedDomainName: DWORD;
  1192.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1193. {$EXTERNALSYM LookupAccountSid}
  1194. {$ENDIF}
  1195. function LookupAccountNameA(lpSystemName, lpAccountName: LPCSTR; Sid: PSID;
  1196.   var cbSid: DWORD; ReferencedDomainName: LPSTR; var cbReferencedDomainName: DWORD;
  1197.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1198. {$EXTERNALSYM LookupAccountNameA}
  1199. function LookupAccountNameW(lpSystemName, lpAccountName: LPCWSTR; Sid: PSID;
  1200.   var cbSid: DWORD; ReferencedDomainName: LPWSTR; var cbReferencedDomainName: DWORD;
  1201.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1202. {$EXTERNALSYM LookupAccountNameW}
  1203. {$IFDEF UNICODE}
  1204. function LookupAccountName(lpSystemName: LPCWSTR; lpAccountName: LPCWSTR; Sid: PSID;
  1205.   var cbSid: DWORD; ReferencedDomainName: LPWSTR; var cbReferencedDomainName: DWORD;
  1206.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1207. {$EXTERNALSYM LookupAccountName}
  1208. {$ELSE}
  1209. function LookupAccountName(lpSystemName: LPCSTR; lpAccountName: LPCSTR; Sid: PSID;
  1210.   var cbSid: DWORD; ReferencedDomainName: LPSTR; var cbReferencedDomainName: DWORD;
  1211.   var peUse: SID_NAME_USE): BOOL; stdcall;
  1212. {$EXTERNALSYM LookupAccountName}
  1213. {$ENDIF}
  1214. function LookupPrivilegeValueA(lpSystemName, lpName: LPCSTR; var lpLuid: LUID): BOOL; stdcall;
  1215. {$EXTERNALSYM LookupPrivilegeValueA}
  1216. function LookupPrivilegeValueW(lpSystemName, lpName: LPCWSTR; var lpLuid: LUID): BOOL; stdcall;
  1217. {$EXTERNALSYM LookupPrivilegeValueW}
  1218. {$IFDEF UNICODE}
  1219. function LookupPrivilegeValue(lpSystemName, lpName: LPCWSTR; var lpLuid: LUID): BOOL; stdcall;
  1220. {$EXTERNALSYM LookupPrivilegeValue}
  1221. {$ELSE}
  1222. function LookupPrivilegeValue(lpSystemName, lpName: LPCSTR; var lpLuid: LUID): BOOL; stdcall;
  1223. {$EXTERNALSYM LookupPrivilegeValue}
  1224. {$ENDIF}
  1225. function LookupPrivilegeNameA(lpSystemName: LPCSTR; const lpLuid: LUID;
  1226.   lpName: LPSTR; var cbName: DWORD): BOOL; stdcall;
  1227. {$EXTERNALSYM LookupPrivilegeNameA}
  1228. function LookupPrivilegeNameW(lpSystemName: LPCWSTR; const lpLuid: LUID;
  1229.   lpName: LPWSTR; var cbName: DWORD): BOOL; stdcall;
  1230. {$EXTERNALSYM LookupPrivilegeNameW}
  1231. {$IFDEF UNICODE}
  1232. function LookupPrivilegeName(lpSystemName: LPCWSTR; const lpLuid: LUID;
  1233.   lpName: LPWSTR; var cbName: DWORD): BOOL; stdcall;
  1234. {$EXTERNALSYM LookupPrivilegeName}
  1235. {$ELSE}
  1236. function LookupPrivilegeName(lpSystemName: LPCSTR; const lpLuid: LUID;
  1237.   lpName: LPSTR; var cbName: DWORD): BOOL; stdcall;
  1238. {$EXTERNALSYM LookupPrivilegeName}
  1239. {$ENDIF}
  1240. function LookupPrivilegeDisplayNameA(lpSystemName, lpName: LPCSTR;
  1241.   lpDisplayName: LPSTR; var cbDisplayName, lpLanguageId: DWORD): BOOL; stdcall;
  1242. {$EXTERNALSYM LookupPrivilegeDisplayNameA}
  1243. function LookupPrivilegeDisplayNameW(lpSystemName, lpName: LPCWSTR;
  1244.   lpDisplayName: LPWSTR; var cbDisplayName, lpLanguageId: DWORD): BOOL; stdcall;
  1245. {$EXTERNALSYM LookupPrivilegeDisplayNameW}
  1246. {$IFDEF UNICODE}
  1247. function LookupPrivilegeDisplayName(lpSystemName, lpName: LPCWSTR;
  1248.   lpDisplayName: LPWSTR; var cbDisplayName, lpLanguageId: DWORD): BOOL; stdcall;
  1249. {$EXTERNALSYM LookupPrivilegeDisplayName}
  1250. {$ELSE}
  1251. function LookupPrivilegeDisplayName(lpSystemName, lpName: LPCSTR;
  1252.   lpDisplayName: LPSTR; var cbDisplayName, lpLanguageId: DWORD): BOOL; stdcall;
  1253. {$EXTERNALSYM LookupPrivilegeDisplayName}
  1254. {$ENDIF}
  1255. function AllocateLocallyUniqueId(var Luid: LUID): BOOL; stdcall;
  1256. {$EXTERNALSYM AllocateLocallyUniqueId}
  1257. function BuildCommDCBA(lpDef: LPCSTR; var lpDCB: DCB): BOOL; stdcall;
  1258. {$EXTERNALSYM BuildCommDCBA}
  1259. function BuildCommDCBW(lpDef: LPCWSTR; var lpDCB: DCB): BOOL; stdcall;
  1260. {$EXTERNALSYM BuildCommDCBW}
  1261. {$IFDEF UNICODE}
  1262. function BuildCommDCB(lpDef: LPCWSTR; var lpDCB: DCB): BOOL; stdcall;
  1263. {$EXTERNALSYM BuildCommDCB}
  1264. {$ELSE}
  1265. function BuildCommDCB(lpDef: LPCSTR; var lpDCB: DCB): BOOL; stdcall;
  1266. {$EXTERNALSYM BuildCommDCB}
  1267. {$ENDIF}
  1268. function BuildCommDCBAndTimeoutsA(lpDef: LPCSTR; var lpDCB: DCB;
  1269.   var lpCommTimeouts: COMMTIMEOUTS): BOOL; stdcall;
  1270. {$EXTERNALSYM BuildCommDCBAndTimeoutsA}
  1271. function BuildCommDCBAndTimeoutsW(lpDef: LPCWSTR; var lpDCB: DCB;
  1272.   var lpCommTimeouts: COMMTIMEOUTS): BOOL; stdcall;
  1273. {$EXTERNALSYM BuildCommDCBAndTimeoutsW}
  1274. {$IFDEF UNICODE}
  1275. function BuildCommDCBAndTimeouts(lpDef: LPCWSTR; var lpDCB: DCB;
  1276.   var lpCommTimeouts: COMMTIMEOUTS): BOOL; stdcall;
  1277. {$EXTERNALSYM BuildCommDCBAndTimeouts}
  1278. {$ELSE}
  1279. function BuildCommDCBAndTimeouts(lpDef: LPCSTR; var lpDCB: DCB;
  1280.   var lpCommTimeouts: COMMTIMEOUTS): BOOL; stdcall;
  1281. {$EXTERNALSYM BuildCommDCBAndTimeouts}
  1282. {$ENDIF}
  1283. function CommConfigDialogA(lpszName: LPCSTR; hWnd: HWND; var lpCC: COMMCONFIG): BOOL; stdcall;
  1284. {$EXTERNALSYM CommConfigDialogA}
  1285. function CommConfigDialogW(lpszName: LPCWSTR; hWnd: HWND; var lpCC: COMMCONFIG): BOOL; stdcall;
  1286. {$EXTERNALSYM CommConfigDialogW}
  1287. {$IFDEF UNICODE}
  1288. function CommConfigDialog(lpszName: LPCWSTR; hWnd: HWND; var lpCC: COMMCONFIG): BOOL; stdcall;
  1289. {$EXTERNALSYM CommConfigDialog}
  1290. {$ELSE}
  1291. function CommConfigDialog(lpszName: LPCSTR; hWnd: HWND; var lpCC: COMMCONFIG): BOOL; stdcall;
  1292. {$EXTERNALSYM CommConfigDialog}
  1293. {$ENDIF}
  1294. function GetDefaultCommConfigA(lpszName: LPCSTR; var lpCC: COMMCONFIG;
  1295.   var lpdwSize: DWORD): BOOL; stdcall;
  1296. {$EXTERNALSYM GetDefaultCommConfigA}
  1297. function GetDefaultCommConfigW(lpszName: LPCWSTR; var lpCC: COMMCONFIG;
  1298.   var lpdwSize: DWORD): BOOL; stdcall;
  1299. {$EXTERNALSYM GetDefaultCommConfigW}
  1300. {$IFDEF UNICODE}
  1301. function GetDefaultCommConfig(lpszName: LPCWSTR; var lpCC: COMMCONFIG;
  1302.   var lpdwSize: DWORD): BOOL; stdcall;
  1303. {$EXTERNALSYM GetDefaultCommConfig}
  1304. {$ELSE}
  1305. function GetDefaultCommConfig(lpszName: LPCSTR; var lpCC: COMMCONFIG;
  1306.   var lpdwSize: DWORD): BOOL; stdcall;
  1307. {$EXTERNALSYM GetDefaultCommConfig}
  1308. {$ENDIF}
  1309. function SetDefaultCommConfigA(lpszName: LPCSTR; const lpCC: COMMCONFIG;
  1310.   dwSize: DWORD): BOOL; stdcall;
  1311. {$EXTERNALSYM SetDefaultCommConfigA}
  1312. function SetDefaultCommConfigW(lpszName: LPCWSTR; const lpCC: COMMCONFIG;
  1313.   dwSize: DWORD): BOOL; stdcall;
  1314. {$EXTERNALSYM SetDefaultCommConfigW}
  1315. {$IFDEF UNICODE}
  1316. function SetDefaultCommConfig(lpszName: LPCWSTR; const lpCC: COMMCONFIG;
  1317.   dwSize: DWORD): BOOL; stdcall;
  1318. {$EXTERNALSYM SetDefaultCommConfig}
  1319. {$ELSE}
  1320. function SetDefaultCommConfig(lpszName: LPCSTR; const lpCC: COMMCONFIG;
  1321.   dwSize: DWORD): BOOL; stdcall;
  1322. {$EXTERNALSYM SetDefaultCommConfig}
  1323. {$ENDIF}
  1324. const
  1325.   MAX_COMPUTERNAME_LENGTH = 15;
  1326.   {$EXTERNALSYM MAX_COMPUTERNAME_LENGTH}
  1327. function GetComputerNameA(lpBuffer: LPSTR; var nSize: DWORD): BOOL; stdcall;
  1328. {$EXTERNALSYM GetComputerNameA}
  1329. function GetComputerNameW(lpBuffer: LPWSTR; var nSize: DWORD): BOOL; stdcall;
  1330. {$EXTERNALSYM GetComputerNameW}
  1331. {$IFDEF UNICODE}
  1332. function GetComputerName(lpBuffer: LPWSTR; var nSize: DWORD): BOOL; stdcall;
  1333. {$EXTERNALSYM GetComputerNameA}
  1334. {$ELSE}
  1335. function GetComputerName(lpBuffer: LPSTR; var nSize: DWORD): BOOL; stdcall;
  1336. {$EXTERNALSYM GetComputerNameA}
  1337. {$ENDIF}
  1338. function SetComputerNameA(lpComputerName: LPCSTR): BOOL; stdcall;
  1339. {$EXTERNALSYM SetComputerNameA}
  1340. function SetComputerNameW(lpComputerName: LPCWSTR): BOOL; stdcall;
  1341. {$EXTERNALSYM SetComputerNameW}
  1342. {$IFDEF UNICODE}
  1343. function SetComputerName(lpComputerName: LPCWSTR): BOOL; stdcall;
  1344. {$EXTERNALSYM SetComputerNameA}
  1345. {$ELSE}
  1346. function SetComputerName(lpComputerName: LPCSTR): BOOL; stdcall;
  1347. {$EXTERNALSYM SetComputerNameA}
  1348. {$ENDIF}
  1349. type
  1350.   _COMPUTER_NAME_FORMAT = (
  1351.     ComputerNameNetBIOS,
  1352.     ComputerNameDnsHostname,
  1353.     ComputerNameDnsDomain,
  1354.     ComputerNameDnsFullyQualified,
  1355.     ComputerNamePhysicalNetBIOS,
  1356.     ComputerNamePhysicalDnsHostname,
  1357.     ComputerNamePhysicalDnsDomain,
  1358.     ComputerNamePhysicalDnsFullyQualified,
  1359.     ComputerNameMax);
  1360.   {$EXTERNALSYM _COMPUTER_NAME_FORMAT}
  1361.   COMPUTER_NAME_FORMAT = _COMPUTER_NAME_FORMAT;
  1362.   {$EXTERNALSYM COMPUTER_NAME_FORMAT}
  1363.   TComputerNameFormat = COMPUTER_NAME_FORMAT;
  1364. function GetComputerNameExA(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPSTR;
  1365.   var nSize: DWORD): BOOL; stdcall;
  1366. {$EXTERNALSYM GetComputerNameExA}
  1367. function GetComputerNameExW(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPWSTR;
  1368.   var nSize: DWORD): BOOL; stdcall;
  1369. {$EXTERNALSYM GetComputerNameExW}
  1370. {$IFDEF UNICODE}
  1371. function GetComputerNameEx(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPWSTR;
  1372.   varnSize: DWORD): BOOL; stdcall;
  1373. {$EXTERNALSYM GetComputerNameExA}
  1374. {$ELSE}
  1375. function GetComputerNameEx(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPSTR;
  1376.   var nSize: DWORD): BOOL; stdcall;
  1377. {$EXTERNALSYM GetComputerNameExA}
  1378. {$ENDIF}
  1379. function SetComputerNameExA(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPCSTR): BOOL; stdcall;
  1380. {$EXTERNALSYM SetComputerNameExA}
  1381. function SetComputerNameExW(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPCWSTR): BOOL; stdcall;
  1382. {$EXTERNALSYM SetComputerNameExW}
  1383. {$IFDEF UNICODE}
  1384. function SetComputerNameEx(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPCWSTR): BOOL; stdcall;
  1385. {$EXTERNALSYM SetComputerNameExA}
  1386. {$ELSE}
  1387. function SetComputerNameEx(NameType: COMPUTER_NAME_FORMAT; lpBuffer: LPCSTR): BOOL; stdcall;
  1388. {$EXTERNALSYM SetComputerNameExA}
  1389. {$ENDIF}
  1390. function AddLocalAlternateComputerNameA(lpDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1391. {$EXTERNALSYM AddLocalAlternateComputerNameA}
  1392. function AddLocalAlternateComputerNameW(lpDnsFQHostname: LPCWSTR; ulFlags: ULONG): DWORD; stdcall;
  1393. {$EXTERNALSYM AddLocalAlternateComputerNameW}
  1394. {$IFDEF UNICODE}
  1395. function AddLocalAlternateComputerName(lpDnsFQHostname: LPCWSTR; ulFlags: ULONG): DWORD; stdcall;
  1396. {$EXTERNALSYM AddLocalAlternateComputerName}
  1397. {$ELSE}
  1398. function AddLocalAlternateComputerName(lpDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1399. {$EXTERNALSYM AddLocalAlternateComputerName}
  1400. {$ENDIF}
  1401. function RemoveLocalAlternateComputerNameA(lpAltDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1402. {$EXTERNALSYM RemoveLocalAlternateComputerNameA}
  1403. function RemoveLocalAlternateComputerNameW(lpAltDnsFQHostname: LPCWSTR; ulFlags: ULONG): DWORD; stdcall;
  1404. {$EXTERNALSYM RemoveLocalAlternateComputerNameW}
  1405. {$IFDEF UNICODE}
  1406. function RemoveLocalAlternateComputerName(lpAltDnsFQHostname: LPCWSTR; ulFlags: ULONG): DWORD; stdcall;
  1407. {$EXTERNALSYM RemoveLocalAlternateComputerName}
  1408. {$ELSE}
  1409. function RemoveLocalAlternateComputerName(lpAltDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1410. {$EXTERNALSYM RemoveLocalAlternateComputerName}
  1411. {$ENDIF}
  1412. function SetLocalPrimaryComputerNameA(lpAltDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1413. {$EXTERNALSYM SetLocalPrimaryComputerNameA}
  1414. function SetLocalPrimaryComputerNameW(lpAltDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1415. {$EXTERNALSYM SetLocalPrimaryComputerNameW}
  1416. {$IFDEF UNICODE}
  1417. function SetLocalPrimaryComputerName(lpAltDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1418. {$EXTERNALSYM SetLocalPrimaryComputerName}
  1419. {$ELSE}
  1420. function SetLocalPrimaryComputerName(lpAltDnsFQHostname: LPCSTR; ulFlags: ULONG): DWORD; stdcall;
  1421. {$EXTERNALSYM SetLocalPrimaryComputerName}
  1422. {$ENDIF}
  1423. type
  1424.   _COMPUTER_NAME_TYPE = (
  1425.     PrimaryComputerName,
  1426.     AlternateComputerNames,
  1427.     AllComputerNames,
  1428.     ComputerNameTypeMax);
  1429.   {$EXTERNALSYM _COMPUTER_NAME_TYPE}
  1430.   COMPUTER_NAME_TYPE = _COMPUTER_NAME_TYPE;
  1431.   {$EXTERNALSYM COMPUTER_NAME_TYPE}
  1432.   TComputerNameType = COMPUTER_NAME_TYPE;
  1433. function EnumerateLocalComputerNamesA(NameType: COMPUTER_NAME_TYPE; ulFlags: ULONG;
  1434.   lpDnsFQHostname: LPSTR; var nSize: DWORD): DWORD; stdcall;
  1435. {$EXTERNALSYM EnumerateLocalComputerNamesA}
  1436. function EnumerateLocalComputerNamesW(NameType: COMPUTER_NAME_TYPE; ulFlags: ULONG;
  1437.   lpDnsFQHostname: LPWSTR; var nSize: DWORD): DWORD; stdcall;
  1438. {$EXTERNALSYM EnumerateLocalComputerNamesW}
  1439. {$IFDEF UNICODE}
  1440. function EnumerateLocalComputerNames(NameType: COMPUTER_NAME_TYPE; ulFlags: ULONG;
  1441.   lpDnsFQHostname: LPWSTR; var nSize: DWORD): DWORD; stdcall;
  1442. {$EXTERNALSYM EnumerateLocalComputerNames}
  1443. {$ELSE}
  1444. function EnumerateLocalComputerNames(NameType: COMPUTER_NAME_TYPE; ulFlags: ULONG;
  1445.   lpDnsFQHostname: LPSTR; var nSize: DWORD): DWORD; stdcall;
  1446. {$EXTERNALSYM EnumerateLocalComputerNames}
  1447. {$ENDIF}
  1448. function DnsHostnameToComputerNameA(Hostname, ComputerName: LPSTR; var nSize: DWORD): BOOL; stdcall;
  1449. {$EXTERNALSYM DnsHostnameToComputerNameA}
  1450. function DnsHostnameToComputerNameW(Hostname, ComputerName: LPWSTR; var nSize: DWORD): BOOL; stdcall;
  1451. {$EXTERNALSYM DnsHostnameToComputerNameW}
  1452. {$IFDEF UNICODE}
  1453. function DnsHostnameToComputerName(Hostname, ComputerName: LPWSTR; var nSize: DWORD): BOOL; stdcall;
  1454. {$EXTERNALSYM DnsHostnameToComputerNameA}
  1455. {$ELSE}
  1456. function DnsHostnameToComputerName(Hostname, ComputerName: LPSTR; var nSize: DWORD): BOOL; stdcall;
  1457. {$EXTERNALSYM DnsHostnameToComputerNameA}
  1458. {$ENDIF}
  1459. function GetUserNameA(lpBuffer: LPSTR; var nSize: DWORD): BOOL; stdcall;
  1460. {$EXTERNALSYM GetUserNameA}
  1461. function GetUserNameW(lpBuffer: LPWSTR; var nSize: DWORD): BOOL; stdcall;
  1462. {$EXTERNALSYM GetUserNameW}
  1463. {$IFDEF UNICODE}
  1464. function GetUserName(lpBuffer: LPWSTR; var nSize: DWORD): BOOL; stdcall;
  1465. {$EXTERNALSYM GetUserNameA}
  1466. {$ELSE}
  1467. function GetUserName(lpBuffer: LPSTR; var nSize: DWORD): BOOL; stdcall;
  1468. {$EXTERNALSYM GetUserNameA}
  1469. {$ENDIF}
  1470. //
  1471. // Logon Support APIs
  1472. //
  1473. const
  1474.   LOGON32_LOGON_INTERACTIVE       = 2;
  1475.   {$EXTERNALSYM LOGON32_LOGON_INTERACTIVE}
  1476.   LOGON32_LOGON_NETWORK           = 3;
  1477.   {$EXTERNALSYM LOGON32_LOGON_NETWORK}
  1478.   LOGON32_LOGON_BATCH             = 4;
  1479.   {$EXTERNALSYM LOGON32_LOGON_BATCH}
  1480.   LOGON32_LOGON_SERVICE           = 5;
  1481.   {$EXTERNALSYM LOGON32_LOGON_SERVICE}
  1482.   LOGON32_LOGON_UNLOCK            = 7;
  1483.   {$EXTERNALSYM LOGON32_LOGON_UNLOCK}
  1484.   LOGON32_LOGON_NETWORK_CLEARTEXT = 8;
  1485.   {$EXTERNALSYM LOGON32_LOGON_NETWORK_CLEARTEXT}
  1486.   LOGON32_LOGON_NEW_CREDENTIALS   = 9;
  1487.   {$EXTERNALSYM LOGON32_LOGON_NEW_CREDENTIALS}
  1488.   LOGON32_PROVIDER_DEFAULT = 0;
  1489.   {$EXTERNALSYM LOGON32_PROVIDER_DEFAULT}
  1490.   LOGON32_PROVIDER_WINNT35 = 1;
  1491.   {$EXTERNALSYM LOGON32_PROVIDER_WINNT35}
  1492.   LOGON32_PROVIDER_WINNT40 = 2;
  1493.   {$EXTERNALSYM LOGON32_PROVIDER_WINNT40}
  1494.   LOGON32_PROVIDER_WINNT50 = 3;
  1495.   {$EXTERNALSYM LOGON32_PROVIDER_WINNT50}
  1496. function LogonUserA(lpszUsername, lpszDomain, lpszPassword: LPCSTR;
  1497.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE): BOOL; stdcall;
  1498. {$EXTERNALSYM LogonUserA}
  1499. function LogonUserW(lpszUsername, lpszDomain, lpszPassword: LPCWSTR;
  1500.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE): BOOL; stdcall;
  1501. {$EXTERNALSYM LogonUserW}
  1502. {$IFDEF UNICODE}
  1503. function LogonUser(lpszUsername, lpszDomain, lpszPassword: LPCWSTR;
  1504.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE): BOOL; stdcall;
  1505. {$EXTERNALSYM LogonUserA}
  1506. {$ELSE}
  1507. function LogonUser(lpszUsername, lpszDomain, lpszPassword: LPCSTR;
  1508.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE): BOOL; stdcall;
  1509. {$EXTERNALSYM LogonUserA}
  1510. {$ENDIF}
  1511. function LogonUserExA(lpszUsername, lpszDomain, lpszPassword: LPCSTR;
  1512.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE; ppLogonSid: PPSID;
  1513.   ppProfileBuffer: PPVOID; pdwProfileLength: LPDWORD; pQuotaLimits: PQUOTA_LIMITS): BOOL; stdcall;
  1514. {$EXTERNALSYM LogonUserExA}
  1515. function LogonUserExW(lpszUsername, lpszDomain, lpszPassword: LPCWSTR;
  1516.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE; ppLogonSid: PPSID;
  1517.   ppProfileBuffer: PPVOID; pdwProfileLength: LPDWORD; pQuotaLimits: PQUOTA_LIMITS): BOOL; stdcall;
  1518. {$EXTERNALSYM LogonUserExW}
  1519. {$IFDEF UNICODE}
  1520. function LogonUserEx(lpszUsername, lpszDomain, lpszPassword: LPCWSTR;
  1521.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE; ppLogonSid: PPSID;
  1522.   ppProfileBuffer: PPVOID; pdwProfileLength: LPDWORD; pQuotaLimits: PQUOTA_LIMITS): BOOL; stdcall;
  1523. {$EXTERNALSYM LogonUserEx}
  1524. {$ELSE}
  1525. function LogonUserEx(lpszUsername, lpszDomain, lpszPassword: LPCSTR;
  1526.   dwLogonType, dwLogonProvider: DWORD; var phToken: HANDLE; ppLogonSid: PPSID;
  1527.   ppProfileBuffer: PPVOID; pdwProfileLength: LPDWORD; pQuotaLimits: PQUOTA_LIMITS): BOOL; stdcall;
  1528. {$EXTERNALSYM LogonUserEx}
  1529. {$ENDIF}
  1530. function ImpersonateLoggedOnUser(hToken: HANDLE): BOOL; stdcall;
  1531. {$EXTERNALSYM ImpersonateLoggedOnUser}
  1532. function CreateProcessAsUserA(hToken: HANDLE; lpApplicationName: LPCSTR;
  1533.   lpCommandLine: LPSTR; lpProcessAttributes: LPSECURITY_ATTRIBUTES;
  1534.   lpThreadAttributes: LPSECURITY_ATTRIBUTES; bInheritHandles: BOOL;
  1535.   dwCreationFlags: DWORD; lpEnvironment: LPVOID; lpCurrentDirectory: LPCSTR;
  1536.   const lpStartupInfo: STARTUPINFOA; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;
  1537. {$EXTERNALSYM CreateProcessAsUserA}
  1538. function CreateProcessAsUserW(hToken: HANDLE; lpApplicationName: LPCWSTR;
  1539.   lpCommandLine: LPWSTR; lpProcessAttributes: LPSECURITY_ATTRIBUTES;
  1540.   lpThreadAttributes: LPSECURITY_ATTRIBUTES; bInheritHandles: BOOL;
  1541.   dwCreationFlags: DWORD; lpEnvironment: LPVOID; lpCurrentDirectory: LPCWSTR;
  1542.   const lpStartupInfo: STARTUPINFOW; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;
  1543. {$EXTERNALSYM CreateProcessAsUserW}
  1544. {$IFDEF UNICODE}
  1545. function CreateProcessAsUser(hToken: HANDLE; lpApplicationName: LPCWSTR;
  1546.   lpCommandLine: LPWSTR; lpProcessAttributes: LPSECURITY_ATTRIBUTES;
  1547.   lpThreadAttributes: LPSECURITY_ATTRIBUTES; bInheritHandles: BOOL;
  1548.   dwCreationFlags: DWORD; lpEnvironment: LPVOID; lpCurrentDirectory: LPCWSTR;
  1549.   const lpStartupInfo: STARTUPINFOW; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;
  1550. {$EXTERNALSYM CreateProcessAsUserA}
  1551. {$ELSE}
  1552. function CreateProcessAsUser(hToken: HANDLE; lpApplicationName: LPCSTR;
  1553.   lpCommandLine: LPSTR; lpProcessAttributes: LPSECURITY_ATTRIBUTES;
  1554.   lpThreadAttributes: LPSECURITY_ATTRIBUTES; bInheritHandles: BOOL;
  1555.   dwCreationFlags: DWORD; lpEnvironment: LPVOID; lpCurrentDirectory: LPCSTR;
  1556.   const lpStartupInfo: STARTUPINFOA; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;
  1557. {$EXTERNALSYM CreateProcessAsUserA}
  1558. {$ENDIF}
  1559. //
  1560. // LogonFlags
  1561. //
  1562. const
  1563.   LOGON_WITH_PROFILE         = $00000001;
  1564.   {$EXTERNALSYM LOGON_WITH_PROFILE}
  1565.   LOGON_NETCREDENTIALS_ONLY  = $00000002;
  1566.   {$EXTERNALSYM LOGON_NETCREDENTIALS_ONLY}
  1567.   LOGON_ZERO_PASSWORD_BUFFER = DWORD($80000000);
  1568.   {$EXTERNALSYM LOGON_ZERO_PASSWORD_BUFFER}
  1569. function CreateProcessWithLogonW(lpUsername, lpDomain, lpPassword: LPCWSTR;
  1570.   dwLogonFlags: DWORD; lpApplicationName: LPCWSTR; lpCommandLine: LPWSTR;
  1571.   dwCreationFlags: DWORD; lpEnvironment: LPVOID; lpCurrentDirectory: LPCWSTR;
  1572.   const lpStartupInfo: STARTUPINFOW; var lpProcessInformation: PROCESS_INFORMATION): BOOL; stdcall;
  1573. {$EXTERNALSYM CreateProcessWithLogonW}
  1574. function CreateProcessWithTokenW(hToken: HANDLE; dwLogonFlags: DWORD; lpApplicationName: LPCWSTR; lpCommandLine: LPWSTR;
  1575.   dwCreationFlags: DWORD; lpEnvironment: LPVOID; lpCurrentDirectory: LPCWSTR; lpStartupInfo: LPSTARTUPINFOW;
  1576.   lpProcessInformation: LPPROCESS_INFORMATION): BOOL; stdcall;
  1577. {$EXTERNALSYM CreateProcessWithTokenW}
  1578. function ImpersonateAnonymousToken(ThreadHandle: HANDLE): BOOL; stdcall;
  1579. {$EXTERNALSYM ImpersonateAnonymousToken}
  1580. function DuplicateTokenEx(hExistingToken: HANDLE; dwDesiredAccess: DWORD;
  1581.   lpTokenAttributes: LPSECURITY_ATTRIBUTES; ImpersonationLevel: SECURITY_IMPERSONATION_LEVEL;
  1582.   TokenType: TOKEN_TYPE; var phNewToken: HANDLE): BOOL; stdcall;
  1583. {$EXTERNALSYM DuplicateTokenEx}
  1584. function CreateRestrictedToken(ExistingTokenHandle: HANDLE; Flags: DWORD;
  1585.   DisableSidCount: DWORD; SidsToDisable: PSID_AND_ATTRIBUTES;
  1586.   DeletePrivilegeCount: DWORD; PrivilegesToDelete: PLUID_AND_ATTRIBUTES;
  1587.   RestrictedSidCount: DWORD; SidsToRestrict: PSID_AND_ATTRIBUTES;
  1588.   var NewTokenHandle: HANDLE): BOOL; stdcall;
  1589. {$EXTERNALSYM CreateRestrictedToken}
  1590. function IsTokenRestricted(TokenHandle: HANDLE): BOOL; stdcall;
  1591. {$EXTERNALSYM IsTokenRestricted}
  1592. function CheckTokenMembership(TokenHandle: HANDLE; SidToCheck: PSID; var IsMember: BOOL): BOOL; stdcall;
  1593. {$EXTERNALSYM CheckTokenMembership}
  1594. function IsTokenUntrusted(TokenHandle: HANDLE): BOOL; stdcall;
  1595. {$EXTERNALSYM IsTokenUntrusted}
  1596. //
  1597. // Thread pool API's
  1598. //
  1599. type
  1600.   WAITORTIMERCALLBACK = WAITORTIMERCALLBACKFUNC;
  1601.   {$EXTERNALSYM WAITORTIMERCALLBACK}
  1602.   TWaitOrTimerCallback = WAITORTIMERCALLBACKFUNC;
  1603. function RegisterWaitForSingleObject(var phNewWaitObject: HANDLE; hObject: HANDLE;
  1604.   Callback: WAITORTIMERCALLBACK; Context: PVOID; dwMilliseconds, dwFlags: ULONG): BOOL; stdcall;
  1605. {$EXTERNALSYM RegisterWaitForSingleObject}
  1606. function RegisterWaitForSingleObjectEx(hObject: HANDLE;
  1607.   Callback: WAITORTIMERCALLBACK; Context: PVOID; dwMilliseconds, dwFlags: ULONG): HANDLE; stdcall;
  1608. {$EXTERNALSYM RegisterWaitForSingleObjectEx}
  1609. function UnregisterWait(WaitHandle: HANDLE): BOOL; stdcall;
  1610. {$EXTERNALSYM UnregisterWait}
  1611. function UnregisterWaitEx(WaitHandle, CompletionEvent: HANDLE): BOOL; stdcall;
  1612. {$EXTERNALSYM UnregisterWaitEx}
  1613. function QueueUserWorkItem(Function_: LPTHREAD_START_ROUTINE; Context: PVOID;
  1614.   Flags: ULONG): BOOL; stdcall;
  1615. {$EXTERNALSYM QueueUserWorkItem}
  1616. function BindIoCompletionCallback(FileHandle: HANDLE;
  1617.   Function_: LPOVERLAPPED_COMPLETION_ROUTINE; Flags: ULONG): BOOL; stdcall;
  1618. {$EXTERNALSYM BindIoCompletionCallback}
  1619. function CreateTimerQueue: HANDLE; stdcall;
  1620. {$EXTERNALSYM CreateTimerQueue}
  1621. function CreateTimerQueueTimer(var phNewTimer: HANDLE; TimerQueue: HANDLE;
  1622.   Callback: WAITORTIMERCALLBACK; Parameter: PVOID; DueTime, Period: DWORD;
  1623.   Flags: ULONG): BOOL; stdcall;
  1624. {$EXTERNALSYM CreateTimerQueueTimer}
  1625. function ChangeTimerQueueTimer(TimerQueue, Timer: HANDLE; DueTime, Period: ULONG): BOOL; stdcall;
  1626. {$EXTERNALSYM ChangeTimerQueueTimer}
  1627. function DeleteTimerQueueTimer(TimerQueue, Timer, CompletionEvent: HANDLE): BOOL; stdcall;
  1628. {$EXTERNALSYM DeleteTimerQueueTimer}
  1629. function DeleteTimerQueueEx(TimerQueue, CompletionEvent: HANDLE): BOOL; stdcall;
  1630. {$EXTERNALSYM DeleteTimerQueueEx}
  1631. function SetTimerQueueTimer(TimerQueue, Callback: WAITORTIMERCALLBACK;
  1632.   Parameter: PVOID; DueTime, Period: DWORD; PreferIo: BOOL): HANDLE; stdcall;
  1633. {$EXTERNALSYM SetTimerQueueTimer}
  1634. function CancelTimerQueueTimer(TimerQueue, Timer: HANDLE): BOOL; stdcall;
  1635. {$EXTERNALSYM CancelTimerQueueTimer}
  1636. function DeleteTimerQueue(TimerQueue: HANDLE): BOOL; stdcall;
  1637. {$EXTERNALSYM DeleteTimerQueue}
  1638. //
  1639. // Plug-and-Play API's
  1640. //
  1641. const
  1642.   HW_PROFILE_GUIDLEN = 39; // 36-characters plus NULL terminator
  1643.   {$EXTERNALSYM HW_PROFILE_GUIDLEN}
  1644.   MAX_PROFILE_LEN    = 80;
  1645.   {$EXTERNALSYM MAX_PROFILE_LEN}
  1646.   DOCKINFO_UNDOCKED      = ($1);
  1647.   {$EXTERNALSYM DOCKINFO_UNDOCKED}
  1648.   DOCKINFO_DOCKED        = ($2);
  1649.   {$EXTERNALSYM DOCKINFO_DOCKED}
  1650.   DOCKINFO_USER_SUPPLIED = ($4);
  1651.   {$EXTERNALSYM DOCKINFO_USER_SUPPLIED}
  1652.   DOCKINFO_USER_UNDOCKED = (DOCKINFO_USER_SUPPLIED or DOCKINFO_UNDOCKED);
  1653.   {$EXTERNALSYM DOCKINFO_USER_UNDOCKED}
  1654.   DOCKINFO_USER_DOCKED   = (DOCKINFO_USER_SUPPLIED or DOCKINFO_DOCKED);
  1655.   {$EXTERNALSYM DOCKINFO_USER_DOCKED}
  1656. type
  1657.   LPHW_PROFILE_INFOA = ^HW_PROFILE_INFOA;
  1658.   {$EXTERNALSYM LPHW_PROFILE_INFOA}
  1659.   tagHW_PROFILE_INFOA = record
  1660.     dwDockInfo: DWORD;
  1661.     szHwProfileGuid: array [0..HW_PROFILE_GUIDLEN - 1] of CHAR;
  1662.     szHwProfileName: array [0..MAX_PROFILE_LEN - 1] of CHAR;
  1663.   end;
  1664.   {$EXTERNALSYM tagHW_PROFILE_INFOA}
  1665.   HW_PROFILE_INFOA = tagHW_PROFILE_INFOA;
  1666.   {$EXTERNALSYM HW_PROFILE_INFOA}
  1667.   THWProfileInfoA = HW_PROFILE_INFOA;
  1668.   PHWProfileInfoA = LPHW_PROFILE_INFOA;
  1669.   LPHW_PROFILE_INFOW = ^HW_PROFILE_INFOW;
  1670.   {$EXTERNALSYM LPHW_PROFILE_INFOW}
  1671.   tagHW_PROFILE_INFOW = record
  1672.     dwDockInfo: DWORD;
  1673.     szHwProfileGuid: array [0..HW_PROFILE_GUIDLEN - 1] of WCHAR;
  1674.     szHwProfileName: array [0..MAX_PROFILE_LEN - 1] of WCHAR;
  1675.   end;
  1676.   {$EXTERNALSYM tagHW_PROFILE_INFOW}
  1677.   HW_PROFILE_INFOW = tagHW_PROFILE_INFOW;
  1678.   {$EXTERNALSYM HW_PROFILE_INFOW}
  1679.   THWProfileInfoW = HW_PROFILE_INFOW;
  1680.   PHWProfileInfoW = LPHW_PROFILE_INFOW;
  1681. {$IFDEF UNICODE}
  1682.   HW_PROFILE_INFO = HW_PROFILE_INFOW;
  1683.   {$EXTERNALSYM HW_PROFILE_INFO}
  1684.   LPHW_PROFILE_INFO = LPHW_PROFILE_INFOW;
  1685.   {$EXTERNALSYM LPHW_PROFILE_INFO}
  1686.   THWProfileInfo = THWProfileInfoW;
  1687.   PHWProfileInfo = PHWProfileInfoW;
  1688. {$ELSE}
  1689.   HW_PROFILE_INFO = HW_PROFILE_INFOA;
  1690.   {$EXTERNALSYM HW_PROFILE_INFO}
  1691.   LPHW_PROFILE_INFO = LPHW_PROFILE_INFOA;
  1692.   {$EXTERNALSYM LPHW_PROFILE_INFO}
  1693.   THWProfileInfo = THWProfileInfoA;
  1694.   PHWProfileInfo = PHWProfileInfoA;
  1695. {$ENDIF}
  1696. function GetCurrentHwProfileA(var lpHwProfileInfo: HW_PROFILE_INFOA): BOOL; stdcall;
  1697. {$EXTERNALSYM GetCurrentHwProfileA}
  1698. function GetCurrentHwProfileW(var lpHwProfileInfo: HW_PROFILE_INFOW): BOOL; stdcall;
  1699. {$EXTERNALSYM GetCurrentHwProfileW}
  1700. {$IFDEF UNICODE}
  1701. function GetCurrentHwProfile(var lpHwProfileInfo: HW_PROFILE_INFOW): BOOL; stdcall;
  1702. {$EXTERNALSYM GetCurrentHwProfileA}
  1703. {$ELSE}
  1704. function GetCurrentHwProfile(var lpHwProfileInfo: HW_PROFILE_INFOA): BOOL; stdcall;
  1705. {$EXTERNALSYM GetCurrentHwProfileA}
  1706. {$ENDIF}
  1707. //
  1708. // Performance counter API's
  1709. //
  1710. function QueryPerformanceCounter(var lpPerformanceCount: LARGE_INTEGER): BOOL; stdcall;
  1711. {$EXTERNALSYM QueryPerformanceCounter}
  1712. function QueryPerformanceFrequency(var lpFrequency: LARGE_INTEGER): BOOL; stdcall;
  1713. {$EXTERNALSYM QueryPerformanceFrequency}
  1714. function GetVersionExA(lpVersionInformation: LPOSVERSIONINFOA): BOOL; stdcall;
  1715. {$EXTERNALSYM GetVersionExA}
  1716. function GetVersionExW(lpVersionInformation: LPOSVERSIONINFOW): BOOL; stdcall;
  1717. {$EXTERNALSYM GetVersionExW}
  1718. {$IFDEF UNICODE}
  1719. function GetVersionEx(lpVersionInformation: LPOSVERSIONINFOW): BOOL; stdcall;
  1720. {$EXTERNALSYM GetVersionEx}
  1721. {$ELSE}
  1722. function GetVersionEx(lpVersionInformation: LPOSVERSIONINFOA): BOOL; stdcall;
  1723. {$EXTERNALSYM GetVersionEx}
  1724. {$ENDIF}
  1725. function VerifyVersionInfoA(var lpVersionInformation: OSVERSIONINFOEXA;
  1726.   dwTypeMask: DWORD; dwlConditionMask: DWORDLONG): BOOL; stdcall;
  1727. {$EXTERNALSYM VerifyVersionInfoA}
  1728. function VerifyVersionInfoW(var lpVersionInformation: OSVERSIONINFOEXW;
  1729.   dwTypeMask: DWORD; dwlConditionMask: DWORDLONG): BOOL; stdcall;
  1730. {$EXTERNALSYM VerifyVersionInfoW}
  1731. {$IFDEF UNICODE}
  1732. function VerifyVersionInfo(var lpVersionInformation: OSVERSIONINFOEXW;
  1733.   dwTypeMask: DWORD; dwlConditionMask: DWORDLONG): BOOL; stdcall;
  1734. {$EXTERNALSYM VerifyVersionInfo}
  1735. {$ELSE}
  1736. function VerifyVersionInfo(var lpVersionInformation: OSVERSIONINFOEXA;
  1737.   dwTypeMask: DWORD; dwlConditionMask: DWORDLONG): BOOL; stdcall;
  1738. {$EXTERNALSYM VerifyVersionInfo}
  1739. {$ENDIF}
  1740. // DOS and OS/2 Compatible Error Code definitions returned by the Win32 Base
  1741. // API functions.
  1742. //
  1743. // #include <winerror.h>
  1744. // Abnormal termination codes
  1745. const
  1746.   TC_NORMAL  = 0;
  1747.   {$EXTERNALSYM TC_NORMAL}
  1748.   TC_HARDERR = 1;
  1749.   {$EXTERNALSYM TC_HARDERR}
  1750.   TC_GP_TRAP = 2;
  1751.   {$EXTERNALSYM TC_GP_TRAP}
  1752.   TC_SIGNAL  = 3;
  1753.   {$EXTERNALSYM TC_SIGNAL}
  1754. //
  1755. // Power Management APIs
  1756. //
  1757.   AC_LINE_OFFLINE      = $00;
  1758.   {$EXTERNALSYM AC_LINE_OFFLINE}
  1759.   AC_LINE_ONLINE       = $01;
  1760.   {$EXTERNALSYM AC_LINE_ONLINE}
  1761.   AC_LINE_BACKUP_POWER = $02;
  1762.   {$EXTERNALSYM AC_LINE_BACKUP_POWER}
  1763.   AC_LINE_UNKNOWN      = $FF;
  1764.   {$EXTERNALSYM AC_LINE_UNKNOWN}
  1765.   BATTERY_FLAG_HIGH       = $01;
  1766.   {$EXTERNALSYM BATTERY_FLAG_HIGH}
  1767.   BATTERY_FLAG_LOW        = $02;
  1768.   {$EXTERNALSYM BATTERY_FLAG_LOW}
  1769.   BATTERY_FLAG_CRITICAL   = $04;
  1770.   {$EXTERNALSYM BATTERY_FLAG_CRITICAL}
  1771.   BATTERY_FLAG_CHARGING   = $08;
  1772.   {$EXTERNALSYM BATTERY_FLAG_CHARGING}
  1773.   BATTERY_FLAG_NO_BATTERY = $80;
  1774.   {$EXTERNALSYM BATTERY_FLAG_NO_BATTERY}
  1775.   BATTERY_FLAG_UNKNOWN    = $FF;
  1776.   {$EXTERNALSYM BATTERY_FLAG_UNKNOWN}
  1777.   BATTERY_PERCENTAGE_UNKNOWN = $FF;
  1778.   {$EXTERNALSYM BATTERY_PERCENTAGE_UNKNOWN}
  1779.   BATTERY_LIFE_UNKNOWN = DWORD($FFFFFFFF);
  1780.   {$EXTERNALSYM BATTERY_LIFE_UNKNOWN}
  1781. type
  1782.   LPSYSTEM_POWER_STATUS = ^SYSTEM_POWER_STATUS;
  1783.   {$EXTERNALSYM LPSYSTEM_POWER_STATUS}
  1784.   _SYSTEM_POWER_STATUS = record
  1785.     ACLineStatus: BYTE;
  1786.     BatteryFlag: BYTE;
  1787.     BatteryLifePercent: BYTE;
  1788.     Reserved1: BYTE;
  1789.     BatteryLifeTime: DWORD;
  1790.     BatteryFullLifeTime: DWORD;
  1791.   end;
  1792.   {$EXTERNALSYM _SYSTEM_POWER_STATUS}
  1793.   SYSTEM_POWER_STATUS = _SYSTEM_POWER_STATUS;
  1794.   {$EXTERNALSYM SYSTEM_POWER_STATUS}
  1795.   TSystemPowerStatus = SYSTEM_POWER_STATUS;
  1796.   PSystemPowerStatus = LPSYSTEM_POWER_STATUS;
  1797. function GetSystemPowerStatus(var lpSystemPowerStatus: SYSTEM_POWER_STATUS): BOOL; stdcall;
  1798. {$EXTERNALSYM GetSystemPowerStatus}
  1799. function SetSystemPowerState(fSuspend, fForce: BOOL): BOOL; stdcall;
  1800. {$EXTERNALSYM SetSystemPowerState}
  1801. //
  1802. // Very Large Memory API Subset
  1803. //
  1804. function AllocateUserPhysicalPages(hProcess: HANDLE; var NumberOfPages: ULONG_PTR;
  1805.   PageArray: PULONG_PTR): BOOL; stdcall;
  1806. {$EXTERNALSYM AllocateUserPhysicalPages}
  1807. function FreeUserPhysicalPages(hProcess: HANDLE; var NumberOfPages: ULONG_PTR;
  1808.   PageArray: PULONG_PTR): BOOL; stdcall;
  1809. {$EXTERNALSYM FreeUserPhysicalPages}
  1810. function MapUserPhysicalPages(VirtualAddress: PVOID; NumberOfPages: ULONG_PTR;
  1811.   PageArray: PULONG_PTR): BOOL; stdcall;
  1812. {$EXTERNALSYM MapUserPhysicalPages}
  1813. function MapUserPhysicalPagesScatter(VirtualAddresses: PVOID; NumberOfPages: ULONG_PTR;
  1814.   PageArray: PULONG_PTR): BOOL; stdcall;
  1815. {$EXTERNALSYM MapUserPhysicalPagesScatter}
  1816. function CreateJobObjectA(lpJobAttributes: LPSECURITY_ATTRIBUTES; lpName: LPCSTR): HANDLE; stdcall;
  1817. {$EXTERNALSYM CreateJobObjectA}
  1818. function CreateJobObjectW(lpJobAttributes: LPSECURITY_ATTRIBUTES; lpName: LPCWSTR): HANDLE; stdcall;
  1819. {$EXTERNALSYM CreateJobObjectW}
  1820. {$IFDEF UNICODE}
  1821. function CreateJobObject(lpJobAttributes: LPSECURITY_ATTRIBUTES; lpName: LPCWSTR): HANDLE; stdcall;
  1822. {$EXTERNALSYM CreateJobObject}
  1823. {$ELSE}
  1824. function CreateJobObject(lpJobAttributes: LPSECURITY_ATTRIBUTES; lpName: LPCSTR): HANDLE; stdcall;
  1825. {$EXTERNALSYM CreateJobObject}
  1826. {$ENDIF}
  1827. function OpenJobObjectA(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCSTR): HANDLE; stdcall;
  1828. {$EXTERNALSYM OpenJobObjectA}
  1829. function OpenJobObjectW(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCWSTR): HANDLE; stdcall;
  1830. {$EXTERNALSYM OpenJobObjectW}
  1831. {$IFDEF UNICODE}
  1832. function OpenJobObject(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCWSTR): HANDLE; stdcall;
  1833. {$EXTERNALSYM OpenJobObject}
  1834. {$ELSE}
  1835. function OpenJobObject(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCSTR): HANDLE; stdcall;
  1836. {$EXTERNALSYM OpenJobObject}
  1837. {$ENDIF}
  1838. function AssignProcessToJobObject(hJob, hProcess: HANDLE): BOOL; stdcall;
  1839. {$EXTERNALSYM AssignProcessToJobObject}
  1840. function TerminateJobObject(hJob: HANDLE; uExitCode: UINT): BOOL; stdcall;
  1841. {$EXTERNALSYM TerminateJobObject}
  1842. function QueryInformationJobObject(hJob: HANDLE; JobObjectInformationClass: JOBOBJECTINFOCLASS;
  1843.   lpJobObjectInformation: LPVOID; cbJobObjectInformationLength: DWORD;
  1844.   lpReturnLength: LPDWORD): BOOL; stdcall;
  1845. {$EXTERNALSYM QueryInformationJobObject}
  1846. function SetInformationJobObject(hJob: HANDLE; JobObjectInformationClass: JOBOBJECTINFOCLASS;
  1847.   lpJobObjectInformation: LPVOID; cbJobObjectInformationLength: DWORD): BOOL; stdcall;
  1848. {$EXTERNALSYM SetInformationJobObject}
  1849. function IsProcessInJob(ProcessHandle, JobHandle: HANDLE; var Result_: BOOL): BOOL; stdcall;
  1850. {$EXTERNALSYM IsProcessInJob}
  1851. function CreateJobSet(NumJob: ULONG; UserJobSet: PJOB_SET_ARRAY; Flags: ULONG): BOOL; stdcall;
  1852. {$EXTERNALSYM CreateJobSet}
  1853. function AddVectoredExceptionHandler(FirstHandler: ULONG;
  1854.   VectoredHandler: PVECTORED_EXCEPTION_HANDLER): PVOID; stdcall;
  1855. {$EXTERNALSYM AddVectoredExceptionHandler}
  1856. function RemoveVectoredExceptionHandler(VectoredHandlerHandle: PVOID): ULONG; stdcall;
  1857. {$EXTERNALSYM RemoveVectoredExceptionHandler}
  1858. //
  1859. // New Volume Mount Point API.
  1860. //
  1861. function FindFirstVolumeA(lpszVolumeName: LPSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1862. {$EXTERNALSYM FindFirstVolumeA}
  1863. function FindFirstVolumeW(lpszVolumeName: LPWSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1864. {$EXTERNALSYM FindFirstVolumeW}
  1865. {$IFDEF UNICODE}
  1866. function FindFirstVolume(lpszVolumeName: LPWSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1867. {$EXTERNALSYM FindFirstVolume}
  1868. {$ELSE}
  1869. function FindFirstVolume(lpszVolumeName: LPSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1870. {$EXTERNALSYM FindFirstVolume}
  1871. {$ENDIF}
  1872. function FindNextVolumeA(hFindVolume: HANDLE; lpszVolumeName: LPSTR;
  1873.   cchBufferLength: DWORD): BOOL; stdcall;
  1874. {$EXTERNALSYM FindNextVolumeA}
  1875. function FindNextVolumeW(hFindVolume: HANDLE; lpszVolumeName: LPWSTR;
  1876.   cchBufferLength: DWORD): BOOL; stdcall;
  1877. {$EXTERNALSYM FindNextVolumeW}
  1878. {$IFDEF UNICODE}
  1879. function FindNextVolume(hFindVolume: HANDLE; lpszVolumeName: LPWSTR;
  1880.   cchBufferLength: DWORD): BOOL; stdcall;
  1881. {$EXTERNALSYM FindNextVolume}
  1882. {$ELSE}
  1883. function FindNextVolume(hFindVolume: HANDLE; lpszVolumeName: LPSTR;
  1884.   cchBufferLength: DWORD): BOOL; stdcall;
  1885. {$EXTERNALSYM FindNextVolume}
  1886. {$ENDIF}
  1887. function FindVolumeClose(hFindVolume: HANDLE): BOOL; stdcall;
  1888. {$EXTERNALSYM FindVolumeClose}
  1889. function FindFirstVolumeMountPointA(lpszRootPathName: LPCSTR;
  1890.   lpszVolumeMountPoint: LPSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1891. {$EXTERNALSYM FindFirstVolumeMountPointA}
  1892. function FindFirstVolumeMountPointW(lpszRootPathName: LPCWSTR;
  1893.   lpszVolumeMountPoint: LPWSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1894. {$EXTERNALSYM FindFirstVolumeMountPointW}
  1895. {$IFDEF UNICODE}
  1896. function FindFirstVolumeMountPoint(lpszRootPathName: LPCWSTR;
  1897.   lpszVolumeMountPoint: LPWSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1898. {$EXTERNALSYM FindFirstVolumeMountPoint}
  1899. {$ELSE}
  1900. function FindFirstVolumeMountPoint(lpszRootPathName: LPCSTR;
  1901.   lpszVolumeMountPoint: LPSTR; cchBufferLength: DWORD): HANDLE; stdcall;
  1902. {$EXTERNALSYM FindFirstVolumeMountPoint}
  1903. {$ENDIF}
  1904. function FindNextVolumeMountPointA(hFindVolumeMountPoint: HANDLE;
  1905.   lpszVolumeMountPoint: LPSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1906. {$EXTERNALSYM FindNextVolumeMountPointA}
  1907. function FindNextVolumeMountPointW(hFindVolumeMountPoint: HANDLE;
  1908.   lpszVolumeMountPoint: LPWSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1909. {$EXTERNALSYM FindNextVolumeMountPointW}
  1910. {$IFDEF UNICODE}
  1911. function FindNextVolumeMountPoint(hFindVolumeMountPoint: HANDLE;
  1912.   lpszVolumeMountPoint: LPWSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1913. {$EXTERNALSYM FindNextVolumeMountPoint}
  1914. {$ELSE}
  1915. function FindNextVolumeMountPoint(hFindVolumeMountPoint: HANDLE;
  1916.   lpszVolumeMountPoint: LPSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1917. {$EXTERNALSYM FindNextVolumeMountPoint}
  1918. {$ENDIF}
  1919. function FindVolumeMountPointClose(hFindVolumeMountPoint: HANDLE): BOOL; stdcall;
  1920. {$EXTERNALSYM FindVolumeMountPointClose}
  1921. function SetVolumeMountPointA(lpszVolumeMountPoint, lpszVolumeName: LPCSTR): BOOL; stdcall;
  1922. {$EXTERNALSYM SetVolumeMountPointA}
  1923. function SetVolumeMountPointW(lpszVolumeMountPoint, lpszVolumeName: LPCWSTR): BOOL; stdcall;
  1924. {$EXTERNALSYM SetVolumeMountPointW}
  1925. {$IFDEF UNICODE}
  1926. function SetVolumeMountPoint(lpszVolumeMountPoint, lpszVolumeName: LPCWSTR): BOOL; stdcall;
  1927. {$EXTERNALSYM SetVolumeMountPoint}
  1928. {$ELSE}
  1929. function SetVolumeMountPoint(lpszVolumeMountPoint, lpszVolumeName: LPCSTR): BOOL; stdcall;
  1930. {$EXTERNALSYM SetVolumeMountPoint}
  1931. {$ENDIF}
  1932. function DeleteVolumeMountPointA(lpszVolumeMountPoint: LPCSTR): BOOL; stdcall;
  1933. {$EXTERNALSYM DeleteVolumeMountPointA}
  1934. function DeleteVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR): BOOL; stdcall;
  1935. {$EXTERNALSYM DeleteVolumeMountPointW}
  1936. {$IFDEF UNICODE}
  1937. function DeleteVolumeMountPoint(lpszVolumeMountPoint: LPCWSTR): BOOL; stdcall;
  1938. {$EXTERNALSYM DeleteVolumeMountPoint}
  1939. {$ELSE}
  1940. function DeleteVolumeMountPoint(lpszVolumeMountPoint: LPCSTR): BOOL; stdcall;
  1941. {$EXTERNALSYM DeleteVolumeMountPoint}
  1942. {$ENDIF}
  1943. function GetVolumeNameForVolumeMountPointA(lpszVolumeMountPoint: LPCSTR;
  1944.   lpszVolumeName: LPSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1945. {$EXTERNALSYM GetVolumeNameForVolumeMountPointA}
  1946. function GetVolumeNameForVolumeMountPointW(lpszVolumeMountPoint: LPCWSTR;
  1947.   lpszVolumeName: LPWSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1948. {$EXTERNALSYM GetVolumeNameForVolumeMountPointW}
  1949. {$IFDEF UNICODE}
  1950. function GetVolumeNameForVolumeMountPoint(lpszVolumeMountPoint: LPCWSTR;
  1951.   lpszVolumeName: LPWSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1952. {$EXTERNALSYM GetVolumeNameForVolumeMountPoint}
  1953. {$ELSE}
  1954. function GetVolumeNameForVolumeMountPoint(lpszVolumeMountPoint: LPCSTR;
  1955.   lpszVolumeName: LPSTR; cchBufferLength: DWORD): BOOL; stdcall;
  1956. {$EXTERNALSYM GetVolumeNameForVolumeMountPoint}
  1957. {$ENDIF}
  1958. function GetVolumePathNameA(lpszFileName: LPCSTR; lpszVolumePathName: LPSTR;
  1959.   cchBufferLength: DWORD): BOOL; stdcall;
  1960. {$EXTERNALSYM GetVolumePathNameA}
  1961. function GetVolumePathNameW(lpszFileName: LPCWSTR; lpszVolumePathName: LPWSTR;
  1962.   cchBufferLength: DWORD): BOOL; stdcall;
  1963. {$EXTERNALSYM GetVolumePathNameW}
  1964. {$IFDEF UNICODE}
  1965. function GetVolumePathName(lpszFileName: LPCWSTR; lpszVolumePathName: LPWSTR;
  1966.   cchBufferLength: DWORD): BOOL; stdcall;
  1967. {$EXTERNALSYM GetVolumePathName}
  1968. {$ELSE}
  1969. function GetVolumePathName(lpszFileName: LPCSTR; lpszVolumePathName: LPSTR;
  1970.   cchBufferLength: DWORD): BOOL; stdcall;
  1971. {$EXTERNALSYM GetVolumePathName}
  1972. {$ENDIF}
  1973. function GetVolumePathNamesForVolumeNameA(lpszVolumeName, lpszVolumePathNames: LPCSTR;
  1974.   cchBufferLength: DWORD; var lpcchReturnLength: DWORD): BOOL; stdcall;
  1975. {$EXTERNALSYM GetVolumePathNamesForVolumeNameA}
  1976. function GetVolumePathNamesForVolumeNameW(lpszVolumeName, lpszVolumePathNames: LPCWSTR;
  1977.   cchBufferLength: DWORD; var lpcchReturnLength: DWORD): BOOL; stdcall;
  1978. {$EXTERNALSYM GetVolumePathNamesForVolumeNameW}
  1979. {$IFDEF UNICODE}
  1980. function GetVolumePathNamesForVolumeName(lpszVolumeName, lpszVolumePathNames: LPCWSTR;
  1981.   cchBufferLength: DWORD; var lpcchReturnLength: DWORD): BOOL; stdcall;
  1982. {$EXTERNALSYM GetVolumePathNamesForVolumeName}
  1983. {$ELSE}
  1984. function GetVolumePathNamesForVolumeName(lpszVolumeName, lpszVolumePathNames: LPCSTR;
  1985.   cchBufferLength: DWORD; var lpcchReturnLength: DWORD): BOOL; stdcall;
  1986. {$EXTERNALSYM GetVolumePathNamesForVolumeName}
  1987. {$ENDIF}
  1988. const
  1989.   ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID  = ($00000001);
  1990.   {$EXTERNALSYM ACTCTX_FLAG_PROCESSOR_ARCHITECTURE_VALID}
  1991.   ACTCTX_FLAG_LANGID_VALID                  = ($00000002);
  1992.   {$EXTERNALSYM ACTCTX_FLAG_LANGID_VALID}
  1993.   ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID      = ($00000004);
  1994.   {$EXTERNALSYM ACTCTX_FLAG_ASSEMBLY_DIRECTORY_VALID}
  1995.   ACTCTX_FLAG_RESOURCE_NAME_VALID           = ($00000008);
  1996.   {$EXTERNALSYM ACTCTX_FLAG_RESOURCE_NAME_VALID}
  1997.   ACTCTX_FLAG_SET_PROCESS_DEFAULT           = ($00000010);
  1998.   {$EXTERNALSYM ACTCTX_FLAG_SET_PROCESS_DEFAULT}
  1999.   ACTCTX_FLAG_APPLICATION_NAME_VALID        = ($00000020);
  2000.   {$EXTERNALSYM ACTCTX_FLAG_APPLICATION_NAME_VALID}
  2001.   ACTCTX_FLAG_SOURCE_IS_ASSEMBLYREF         = ($00000040);
  2002.   {$EXTERNALSYM ACTCTX_FLAG_SOURCE_IS_ASSEMBLYREF}
  2003.   ACTCTX_FLAG_HMODULE_VALID                 = ($00000080);
  2004.   {$EXTERNALSYM ACTCTX_FLAG_HMODULE_VALID}
  2005. type
  2006.   tagACTCTXA = record
  2007.     cbSize: ULONG;
  2008.     dwFlags: DWORD;
  2009.     lpSource: LPCSTR;
  2010.     wProcessorArchitecture: USHORT;
  2011.     wLangId: LANGID;
  2012.     lpAssemblyDirectory: LPCSTR;
  2013.     lpResourceName: LPCSTR;
  2014.     lpApplicationName: LPCSTR;
  2015.     hModule: HMODULE;
  2016.   end;
  2017.   {$EXTERNALSYM tagACTCTXA}
  2018.   ACTCTXA = tagACTCTXA;
  2019.   {$EXTERNALSYM ACTCTXA}
  2020.   PACTCTXA = ^ACTCTXA;
  2021.   {$EXTERNALSYM PACTCTXA}
  2022.   TActCtxA = ACTCTXA;
  2023.   tagACTCTXW = record
  2024.     cbSize: ULONG;
  2025.     dwFlags: DWORD;
  2026.     lpSource: LPCWSTR;
  2027.     wProcessorArchitecture: USHORT;
  2028.     wLangId: LANGID;
  2029.     lpAssemblyDirectory: LPCWSTR;
  2030.     lpResourceName: LPCWSTR;
  2031.     lpApplicationName: LPCWSTR;
  2032.     hModule: HMODULE;
  2033.   end;
  2034.   {$EXTERNALSYM tagACTCTXW}
  2035.   ACTCTXW = tagACTCTXW;
  2036.   {$EXTERNALSYM ACTCTXW}
  2037.   PACTCTXW = ^ACTCTXW;
  2038.   {$EXTERNALSYM PACTCTXW}
  2039.   TActCtxW = ACTCTXW;
  2040. {$IFDEF UNICODE}
  2041.   ACTCTX = ACTCTXW;
  2042.   {$EXTERNALSYM ACTCTX}
  2043.   PACTCTX = PACTCTXW;
  2044.   {$EXTERNALSYM PACTCTX}
  2045.   TActCtx = TActCtxW;
  2046. {$ELSE}
  2047.   ACTCTX = ACTCTXA;
  2048.   {$EXTERNALSYM ACTCTX}
  2049.   PACTCTX = PACTCTXA;
  2050.   {$EXTERNALSYM PACTCTX}
  2051.   TActCtx = TActCtxA;  
  2052. {$ENDIF}
  2053. function CreateActCtxA(var pActCtx: ACTCTXA): HANDLE; stdcall;
  2054. {$EXTERNALSYM CreateActCtxA}
  2055. function CreateActCtxW(var pActCtx: ACTCTXW): HANDLE; stdcall;
  2056. {$EXTERNALSYM CreateActCtxW}
  2057. {$IFDEF UNICODE}
  2058. function CreateActCtx(var pActCtx: ACTCTXW): HANDLE; stdcall;
  2059. {$EXTERNALSYM CreateActCtx}
  2060. {$ELSE}
  2061. function CreateActCtx(var pActCtx: ACTCTXA): HANDLE; stdcall;
  2062. {$EXTERNALSYM CreateActCtx}
  2063. {$ENDIF}
  2064. procedure AddRefActCtx(hActCtx: HANDLE); stdcall;
  2065. {$EXTERNALSYM AddRefActCtx}
  2066. procedure ReleaseActCtx(hActCtx: HANDLE); stdcall;
  2067. {$EXTERNALSYM ReleaseActCtx}
  2068. function ZombifyActCtx(hActCtx: HANDLE): BOOL; stdcall;
  2069. {$EXTERNALSYM ZombifyActCtx}
  2070. function ActivateActCtx(hActCtx: HANDLE; var lpCookie: ULONG_PTR): BOOL; stdcall;
  2071. {$EXTERNALSYM ActivateActCtx}
  2072. const
  2073.   DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION = ($00000001);
  2074.   {$EXTERNALSYM DEACTIVATE_ACTCTX_FLAG_FORCE_EARLY_DEACTIVATION}
  2075. function DeactivateActCtx(dwFlags: DWORD; ulCookie: ULONG_PTR): BOOL; stdcall;
  2076. {$EXTERNALSYM DeactivateActCtx}
  2077. function GetCurrentActCtx(var lphActCtx: HANDLE): BOOL; stdcall;
  2078. {$EXTERNALSYM GetCurrentActCtx}
  2079. type
  2080.   tagACTCTX_SECTION_KEYED_DATA_2600 = record
  2081.     cbSize: ULONG;
  2082.     ulDataFormatVersion: ULONG;
  2083.     lpData: PVOID;
  2084.     ulLength: ULONG;
  2085.     lpSectionGlobalData: PVOID;
  2086.     ulSectionGlobalDataLength: ULONG;
  2087.     lpSectionBase: PVOID;
  2088.     ulSectionTotalLength: ULONG;
  2089.     hActCtx: HANDLE;
  2090.     ulAssemblyRosterIndex: ULONG;
  2091.   end;
  2092.   {$EXTERNALSYM tagACTCTX_SECTION_KEYED_DATA_2600}
  2093.   ACTCTX_SECTION_KEYED_DATA_2600 = tagACTCTX_SECTION_KEYED_DATA_2600;
  2094.   {$EXTERNALSYM ACTCTX_SECTION_KEYED_DATA_2600}
  2095.   PACTCTX_SECTION_KEYED_DATA_2600 = ^ACTCTX_SECTION_KEYED_DATA_2600;
  2096.   {$EXTERNALSYM PACTCTX_SECTION_KEYED_DATA_2600}
  2097.   PCACTCTX_SECTION_KEYED_DATA_2600 = ^ACTCTX_SECTION_KEYED_DATA_2600;
  2098.   {$EXTERNALSYM PCACTCTX_SECTION_KEYED_DATA_2600}
  2099.   TActCtxSectionKeyedData2600 = ACTCTX_SECTION_KEYED_DATA_2600;
  2100.   PActCtxSectionKeyedData2600 = PACTCTX_SECTION_KEYED_DATA_2600;
  2101.   tagACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = record
  2102.     lpInformation: PVOID;
  2103.     lpSectionBase: PVOID;
  2104.     ulSectionLength: ULONG;
  2105.     lpSectionGlobalDataBase: PVOID;
  2106.     ulSectionGlobalDataLength: ULONG;
  2107.   end;
  2108.   {$EXTERNALSYM tagACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA}
  2109.   ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = tagACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2110.   {$EXTERNALSYM ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA}
  2111.   PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = ^ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2112.   {$EXTERNALSYM PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA}
  2113.   PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA = ^ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2114.   {$EXTERNALSYM PCACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA}
  2115.   TActCtxSectionKeyedDataAssemblyMetadata = ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2116.   PActCtxSectionKeyedDataAssemblyMetadata = PACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2117.   
  2118.   tagACTCTX_SECTION_KEYED_DATA = record
  2119.     cbSize: ULONG;
  2120.     ulDataFormatVersion: ULONG;
  2121.     lpData: PVOID;
  2122.     ulLength: ULONG;
  2123.     lpSectionGlobalData: PVOID;
  2124.     ulSectionGlobalDataLength: ULONG;
  2125.     lpSectionBase: PVOID;
  2126.     ulSectionTotalLength: ULONG;
  2127.     hActCtx: HANDLE;
  2128.     ulAssemblyRosterIndex: ULONG;
  2129.     // 2600 stops here
  2130.     ulFlags: ULONG;
  2131.     AssemblyMetadata: ACTCTX_SECTION_KEYED_DATA_ASSEMBLY_METADATA;
  2132.   end;
  2133.   {$EXTERNALSYM tagACTCTX_SECTION_KEYED_DATA}
  2134.   ACTCTX_SECTION_KEYED_DATA = tagACTCTX_SECTION_KEYED_DATA;
  2135.   {$EXTERNALSYM ACTCTX_SECTION_KEYED_DATA}
  2136.   PACTCTX_SECTION_KEYED_DATA = ^ACTCTX_SECTION_KEYED_DATA;
  2137.   {$EXTERNALSYM PACTCTX_SECTION_KEYED_DATA}
  2138.   PCACTCTX_SECTION_KEYED_DATA = ^ACTCTX_SECTION_KEYED_DATA;
  2139.   {$EXTERNALSYM PCACTCTX_SECTION_KEYED_DATA}
  2140.   TActCtxSectionKeyedData = ACTCTX_SECTION_KEYED_DATA;
  2141.   PActCtxSectionKeyedData = PACTCTX_SECTION_KEYED_DATA;
  2142. const
  2143.   FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX = ($00000001);
  2144.   {$EXTERNALSYM FIND_ACTCTX_SECTION_KEY_RETURN_HACTCTX}
  2145.   FIND_ACTCTX_SECTION_KEY_RETURN_FLAGS   = ($00000002);
  2146.   {$EXTERNALSYM FIND_ACTCTX_SECTION_KEY_RETURN_FLAGS}
  2147.   FIND_ACTCTX_SECTION_KEY_RETURN_ASSEMBLY_METADATA = ($00000004);
  2148.   {$EXTERNALSYM FIND_ACTCTX_SECTION_KEY_RETURN_ASSEMBLY_METADATA}
  2149. function FindActCtxSectionStringA(dwFlags: DWORD; const lpExtensionGuid: TGUID;
  2150.   ulSectionId: ULONG; lpStringToFind: LPCSTR; ReturnedData: PACTCTX_SECTION_KEYED_DATA): BOOL; stdcall;
  2151. {$EXTERNALSYM FindActCtxSectionStringA}
  2152. function FindActCtxSectionStringW(dwFlags: DWORD; const lpExtensionGuid: TGUID;
  2153.   ulSectionId: ULONG; lpStringToFind: LPCWSTR; ReturnedData: PACTCTX_SECTION_KEYED_DATA): BOOL; stdcall;
  2154. {$EXTERNALSYM FindActCtxSectionStringW}
  2155. {$IFDEF UNICODE}
  2156. function FindActCtxSectionString(dwFlags: DWORD; const lpExtensionGuid: TGUID;
  2157.   ulSectionId: ULONG; lpStringToFind: LPCWSTR; ReturnedData: PACTCTX_SECTION_KEYED_DATA): BOOL; stdcall;
  2158. {$EXTERNALSYM FindActCtxSectionString}
  2159. {$ELSE}
  2160. function FindActCtxSectionString(dwFlags: DWORD; const lpExtensionGuid: TGUID;
  2161.   ulSectionId: ULONG; lpStringToFind: LPCSTR; ReturnedData: PACTCTX_SECTION_KEYED_DATA): BOOL; stdcall;
  2162. {$EXTERNALSYM FindActCtxSectionString}
  2163. {$ENDIF}
  2164. function FindActCtxSectionGuid(dwFlags: DWORD; const lpExtensionGuid: TGUID;
  2165.   ulSectionId: ULONG; const lpGuidToFind: TGUID; ReturnedData: PACTCTX_SECTION_KEYED_DATA): BOOL; stdcall;
  2166. {$EXTERNALSYM FindActCtxSectionGuid}
  2167. type
  2168.   _ACTIVATION_CONTEXT_BASIC_INFORMATION = record
  2169.     hActCtx: HANDLE;
  2170.     dwFlags: DWORD;
  2171.   end;
  2172.   {$EXTERNALSYM _ACTIVATION_CONTEXT_BASIC_INFORMATION}
  2173.   ACTIVATION_CONTEXT_BASIC_INFORMATION = _ACTIVATION_CONTEXT_BASIC_INFORMATION;
  2174.   {$EXTERNALSYM ACTIVATION_CONTEXT_BASIC_INFORMATION}
  2175.   PACTIVATION_CONTEXT_BASIC_INFORMATION = ^ACTIVATION_CONTEXT_BASIC_INFORMATION;
  2176.   {$EXTERNALSYM PACTIVATION_CONTEXT_BASIC_INFORMATION}
  2177.   TActivationContextBasicInformation = ACTIVATION_CONTEXT_BASIC_INFORMATION;
  2178.   PActivationContextBasicInformation = PACTIVATION_CONTEXT_BASIC_INFORMATION;
  2179.   PCACTIVATION_CONTEXT_BASIC_INFORMATION = ^_ACTIVATION_CONTEXT_BASIC_INFORMATION;
  2180.   {$EXTERNALSYM PCACTIVATION_CONTEXT_BASIC_INFORMATION}
  2181. const
  2182.   ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED = 1;
  2183.   {$EXTERNALSYM ACTIVATION_CONTEXT_BASIC_INFORMATION_DEFINED}
  2184.   QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX = ($00000004);
  2185.   {$EXTERNALSYM QUERY_ACTCTX_FLAG_USE_ACTIVE_ACTCTX}
  2186.   QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE = ($00000008);
  2187.   {$EXTERNALSYM QUERY_ACTCTX_FLAG_ACTCTX_IS_HMODULE}
  2188.   QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS = ($00000010);
  2189.   {$EXTERNALSYM QUERY_ACTCTX_FLAG_ACTCTX_IS_ADDRESS}
  2190.   QUERY_ACTCTX_FLAG_NO_ADDREF         = ($80000000);
  2191.   {$EXTERNALSYM QUERY_ACTCTX_FLAG_NO_ADDREF}
  2192. //
  2193. // switch (ulInfoClass)
  2194. //
  2195. //  case ActivationContextBasicInformation:
  2196. //    pvSubInstance == NULL
  2197. //    pvBuffer is of type PACTIVATION_CONTEXT_BASIC_INFORMATION
  2198. //
  2199. //  case ActivationContextDetailedInformation:
  2200. //    pvSubInstance == NULL
  2201. //    pvBuffer is of type PACTIVATION_CONTEXT_DETAILED_INFORMATION
  2202. //
  2203. //  case AssemblyDetailedInformationInActivationContext:
  2204. //    pvSubInstance is of type PULONG
  2205. //      *pvSubInstance < ACTIVATION_CONTEXT_DETAILED_INFORMATION::ulAssemblyCount
  2206. //    pvBuffer is of type PACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION
  2207. //
  2208. //  case FileInformationInAssemblyOfAssemblyInActivationContext:
  2209. //    pvSubInstance is of type PACTIVATION_CONTEXT_QUERY_INDEX
  2210. //      pvSubInstance->ulAssemblyIndex < ACTIVATION_CONTEXT_DETAILED_INFORMATION::ulAssemblyCount
  2211. //      pvSubInstance->ulFileIndexInAssembly < ACTIVATION_CONTEXT_ASSEMBLY_DETAILED_INFORMATION::ulFileCount
  2212. //    pvBuffer is of type PASSEMBLY_FILE_DETAILED_INFORMATION
  2213. //
  2214. // String are placed after the structs.
  2215. //
  2216.   
  2217. function QueryActCtxW(dwFlags: DWORD; hActCtx: HANDLE; pvSubInstance: PVOID;
  2218.   ulInfoClass: ULONG; pvBuffer: PVOID; cbBuffer: SIZE_T;
  2219.   pcbWrittenOrRequired: PSIZE_T): BOOL; stdcall;
  2220. {$EXTERNALSYM QueryActCtxW}
  2221. type
  2222.   PQUERYACTCTXW_FUNC = function (dwFlags: DWORD; hActCtx: HANDLE;
  2223.     pvSubInstance: PVOID; ulInfoClass: ULONG; pvBuffer: PVOID; cbBuffer: SIZE_T;
  2224.     pcbWrittenOrRequired: PSIZE_T): BOOL; stdcall;
  2225.   {$EXTERNALSYM PQUERYACTCTXW_FUNC}
  2226. function ProcessIdToSessionId(dwProcessId: DWORD; var pSessionId: DWORD): BOOL; stdcall;
  2227. {$EXTERNALSYM ProcessIdToSessionId}
  2228. function WTSGetActiveConsoleSessionId: DWORD; stdcall;
  2229. {$EXTERNALSYM WTSGetActiveConsoleSessionId}
  2230. function IsWow64Process(hProcess: HANDLE; var Wow64Process: BOOL): BOOL; stdcall;
  2231. {$EXTERNALSYM IsWow64Process}
  2232. function GetLogicalProcessorInformation(Buffer: PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; ReturnedLength: PDWORD): BOOL; stdcall;
  2233. {$EXTERNALSYM GetLogicalProcessorInformation}
  2234. //
  2235. // NUMA Information routines.
  2236. //
  2237. function GetNumaHighestNodeNumber(var HighestNodeNumber: ULONG): BOOL; stdcall;
  2238. {$EXTERNALSYM GetNumaHighestNodeNumber}
  2239. function GetNumaProcessorNode(Processor: UCHAR; var NodeNumber: UCHAR): BOOL; stdcall;
  2240. {$EXTERNALSYM GetNumaProcessorNode}
  2241. function GetNumaNodeProcessorMask(Node: UCHAR; ProcessorMask: ULONGLONG): BOOL; stdcall;
  2242. {$EXTERNALSYM GetNumaNodeProcessorMask}
  2243. function GetNumaAvailableMemoryNode(Node: UCHAR; var AvailableBytes: ULONGLONG): BOOL; stdcall;
  2244. {$EXTERNALSYM GetNumaAvailableMemoryNode}
  2245. implementation
  2246. const
  2247.   kernel32 = 'kernel32.dll';
  2248.   advapi32 = 'advapi32.dll';
  2249. procedure MoveMemory(Destination, Source: PVOID; Length: SIZE_T);
  2250. begin
  2251.   Move(Source^, Destination^, Length);
  2252. end;
  2253. procedure CopyMemory(Destination, Source: PVOID; Length: SIZE_T);
  2254. begin
  2255.   Move(Source^, Destination^, Length);
  2256. end;
  2257. procedure FillMemory(Destination: PVOID; Length: SIZE_T; Fill: BYTE);
  2258. begin
  2259.   FillChar(Destination^, Length, Fill);
  2260. end;
  2261. procedure ZeroMemory(Destination: PVOID; Length: SIZE_T);
  2262. begin
  2263.   FillChar(Destination^, Length, 0);
  2264. end;
  2265. function FreeModule(hLibModule: HMODULE): BOOL;
  2266. begin
  2267.   Result := FreeLibrary(hLibModule);
  2268. end;
  2269. function MakeProcInstance(lpProc: FARPROC; hInstance: HINSTANCE): FARPROC;
  2270. begin
  2271.   Result := lpProc;
  2272. end;
  2273. procedure FreeProcInstance(lpProc: FARPROC);
  2274. begin
  2275.   { nothing }
  2276. end;
  2277. function GlobalLRUNewest(h: HANDLE): HANDLE;
  2278. begin
  2279.   Result := H;
  2280. end;
  2281. function GlobalLRUOldest(h: HANDLE): HANDLE;
  2282. begin
  2283.   Result := H;
  2284. end;
  2285. function GlobalDiscard(h: HANDLE): HANDLE;
  2286. begin
  2287.  Result := GlobalReAlloc(h, 0, GMEM_MOVEABLE);
  2288. end;
  2289. function LocalDiscard(h: HLOCAL): HLOCAL;
  2290. begin
  2291.   Result := LocalReAlloc(h, 0, LMEM_MOVEABLE);
  2292. end;
  2293. function GetFreeSpace(w: WORD): DWORD;
  2294. begin
  2295.   Result := $100000;
  2296. end;
  2297. function InterlockedExchangePointer(var Target: PVOID; Value: PVOID): PVOID;
  2298. begin
  2299.   Result := PVOID(InterlockedExchange(LONG(Target), LONG(Value)));
  2300. end;
  2301. function InterlockedCompareExchangePointer(var Destination: PVOID; Exchange, Comperand: PVOID): PVOID;
  2302. begin
  2303.   Result := PVOID(InterlockedCompareExchange(LONG(Destination), LONG(Exchange), LONG(Comperand)));
  2304. end;
  2305. function UnlockResource(hResData: HANDLE): BOOL;
  2306. begin
  2307.   Result := False;
  2308. end;
  2309. function HasOverlappedIoCompleted(const lpOverlapped: OVERLAPPED): BOOL;
  2310. begin
  2311.   Result := lpOverlapped.Internal <> STATUS_PENDING;
  2312. end;
  2313. {$IFDEF DYNAMIC_LINK}
  2314. var
  2315.   _InterlockedIncrement: Pointer;
  2316. function InterlockedIncrement;
  2317. begin
  2318.   GetProcedureAddress(_InterlockedIncrement, kernel32, 'InterlockedIncrement');
  2319.   asm
  2320.     mov esp, ebp
  2321.     pop ebp
  2322.     jmp [_InterlockedIncrement]
  2323.   end;
  2324. end;
  2325. {$ELSE}
  2326. function InterlockedIncrement; external kernel32 name 'InterlockedIncrement';
  2327. {$ENDIF DYNAMIC_LINK}
  2328. {$IFDEF DYNAMIC_LINK}
  2329. var
  2330.   _InterlockedDecrement: Pointer;
  2331. function InterlockedDecrement;
  2332. begin
  2333.   GetProcedureAddress(_InterlockedDecrement, kernel32, 'InterlockedDecrement');
  2334.   asm
  2335.     mov esp, ebp
  2336.     pop ebp
  2337.     jmp [_InterlockedDecrement]
  2338.   end;
  2339. end;
  2340. {$ELSE}
  2341. function InterlockedDecrement; external kernel32 name 'InterlockedDecrement';
  2342. {$ENDIF DYNAMIC_LINK}
  2343. {$IFDEF DYNAMIC_LINK}
  2344. var
  2345.   _InterlockedExchange: Pointer;
  2346. function InterlockedExchange;
  2347. begin
  2348.   GetProcedureAddress(_InterlockedExchange, kernel32, 'InterlockedExchange');
  2349.   asm
  2350.     mov esp, ebp
  2351.     pop ebp
  2352.     jmp [_InterlockedExchange]
  2353.   end;
  2354. end;
  2355. {$ELSE}
  2356. function InterlockedExchange; external kernel32 name 'InterlockedExchange';
  2357. {$ENDIF DYNAMIC_LINK}
  2358. {$IFDEF DYNAMIC_LINK}
  2359. var
  2360.   _InterlockedExchangeAdd: Pointer;
  2361. function InterlockedExchangeAdd;
  2362. begin
  2363.   GetProcedureAddress(_InterlockedExchangeAdd, kernel32, 'InterlockedExchangeAdd');
  2364.   asm
  2365.     mov esp, ebp
  2366.     pop ebp
  2367.     jmp [_InterlockedExchangeAdd]
  2368.   end;
  2369. end;
  2370. {$ELSE}
  2371. function InterlockedExchangeAdd; external kernel32 name 'InterlockedExchangeAdd';
  2372. {$ENDIF DYNAMIC_LINK}
  2373. {$IFDEF DYNAMIC_LINK}
  2374. var
  2375.   _InterlockedCompareExchange: Pointer;
  2376. function InterlockedCompareExchange;
  2377. begin
  2378.   GetProcedureAddress(_InterlockedCompareExchange, kernel32, 'InterlockedCompareExchange');
  2379.   asm
  2380.     mov esp, ebp
  2381.     pop ebp
  2382.     jmp [_InterlockedCompareExchange]
  2383.   end;
  2384. end;
  2385. {$ELSE}
  2386. function InterlockedCompareExchange; external kernel32 name 'InterlockedCompareExchange';
  2387. {$ENDIF DYNAMIC_LINK}
  2388. {$IFDEF DYNAMIC_LINK}
  2389. var
  2390.   _InitializeSListHead: Pointer;
  2391. procedure InitializeSListHead;
  2392. begin
  2393.   GetProcedureAddress(_InitializeSListHead, kernel32, 'InitializeSListHead');
  2394.   asm
  2395.     mov esp, ebp
  2396.     pop ebp
  2397.     jmp [_InitializeSListHead]
  2398.   end;
  2399. end;
  2400. {$ELSE}
  2401. procedure InitializeSListHead; external kernel32 name 'InitializeSListHead';
  2402. {$ENDIF DYNAMIC_LINK}
  2403. {$IFDEF DYNAMIC_LINK}
  2404. var
  2405.   _InterlockedPopEntrySList: Pointer;
  2406. function InterlockedPopEntrySList;
  2407. begin
  2408.   GetProcedureAddress(_InterlockedPopEntrySList, kernel32, 'InterlockedPopEntrySList');
  2409.   asm
  2410.     mov esp, ebp
  2411.     pop ebp
  2412.     jmp [_InterlockedPopEntrySList]
  2413.   end;
  2414. end;
  2415. {$ELSE}
  2416. function InterlockedPopEntrySList; external kernel32 name 'InterlockedPopEntrySList';
  2417. {$ENDIF DYNAMIC_LINK}
  2418. {$IFDEF DYNAMIC_LINK}
  2419. var
  2420.   _InterlockedPushEntrySList: Pointer;
  2421. function InterlockedPushEntrySList;
  2422. begin
  2423.   GetProcedureAddress(_InterlockedPushEntrySList, kernel32, 'InterlockedPushEntrySList');
  2424.   asm
  2425.     mov esp, ebp
  2426.     pop ebp
  2427.     jmp [_InterlockedPushEntrySList]
  2428.   end;
  2429. end;
  2430. {$ELSE}
  2431. function InterlockedPushEntrySList; external kernel32 name 'InterlockedPushEntrySList';
  2432. {$ENDIF DYNAMIC_LINK}
  2433. {$IFDEF DYNAMIC_LINK}
  2434. var
  2435.   _InterlockedFlushSList: Pointer;
  2436. function InterlockedFlushSList;
  2437. begin
  2438.   GetProcedureAddress(_InterlockedFlushSList, kernel32, 'InterlockedFlushSList');
  2439.   asm
  2440.     mov esp, ebp
  2441.     pop ebp
  2442.     jmp [_InterlockedFlushSList]
  2443.   end;
  2444. end;
  2445. {$ELSE}
  2446. function InterlockedFlushSList; external kernel32 name 'InterlockedFlushSList';
  2447. {$ENDIF DYNAMIC_LINK}
  2448. {$IFDEF DYNAMIC_LINK}
  2449. var
  2450.   _QueryDepthSList: Pointer;
  2451. function QueryDepthSList;
  2452. begin
  2453.   GetProcedureAddress(_QueryDepthSList, kernel32, 'QueryDepthSList');
  2454.   asm
  2455.     mov esp, ebp
  2456.     pop ebp
  2457.     jmp [_QueryDepthSList]
  2458.   end;
  2459. end;
  2460. {$ELSE}
  2461. function QueryDepthSList; external kernel32 name 'QueryDepthSList';
  2462. {$ENDIF DYNAMIC_LINK}
  2463. {$IFDEF DYNAMIC_LINK}
  2464. var
  2465.   _FreeResource: Pointer;
  2466. function FreeResource;
  2467. begin
  2468.   GetProcedureAddress(_FreeResource, kernel32, 'FreeResource');
  2469.   asm
  2470.     mov esp, ebp
  2471.     pop ebp
  2472.     jmp [_FreeResource]
  2473.   end;
  2474. end;
  2475. {$ELSE}
  2476. function FreeResource; external kernel32 name 'FreeResource';
  2477. {$ENDIF DYNAMIC_LINK}
  2478. {$IFDEF DYNAMIC_LINK}
  2479. var
  2480.   _LockResource: Pointer;
  2481. function LockResource;
  2482. begin
  2483.   GetProcedureAddress(_LockResource, kernel32, 'LockResource');
  2484.   asm
  2485.     mov esp, ebp
  2486.     pop ebp
  2487.     jmp [_LockResource]
  2488.   end;
  2489. end;
  2490. {$ELSE}
  2491. function LockResource; external kernel32 name 'LockResource';
  2492. {$ENDIF DYNAMIC_LINK}
  2493. {$IFDEF DYNAMIC_LINK}
  2494. var
  2495.   _FreeLibrary: Pointer;
  2496. function FreeLibrary;
  2497. begin
  2498.   GetProcedureAddress(_FreeLibrary, kernel32, 'FreeLibrary');
  2499.   asm
  2500.     mov esp, ebp
  2501.     pop ebp
  2502.     jmp [_FreeLibrary]
  2503.   end;
  2504. end;
  2505. {$ELSE}
  2506. function FreeLibrary; external kernel32 name 'FreeLibrary';
  2507. {$ENDIF DYNAMIC_LINK}
  2508. {$IFDEF DYNAMIC_LINK}
  2509. var
  2510.   _FreeLibraryAndExitThread: Pointer;
  2511. procedure FreeLibraryAndExitThread;
  2512. begin
  2513.   GetProcedureAddress(_FreeLibraryAndExitThread, kernel32, 'FreeLibraryAndExitThread');
  2514.   asm
  2515.     mov esp, ebp
  2516.     pop ebp
  2517.     jmp [_FreeLibraryAndExitThread]
  2518.   end;
  2519. end;
  2520. {$ELSE}
  2521. procedure FreeLibraryAndExitThread; external kernel32 name 'FreeLibraryAndExitThread';
  2522. {$ENDIF DYNAMIC_LINK}
  2523. {$IFDEF DYNAMIC_LINK}
  2524. var
  2525.   _DisableThreadLibraryCalls: Pointer;
  2526. function DisableThreadLibraryCalls;
  2527. begin
  2528.   GetProcedureAddress(_DisableThreadLibraryCalls, kernel32, 'DisableThreadLibraryCalls');
  2529.   asm
  2530.     mov esp, ebp
  2531.     pop ebp
  2532.     jmp [_DisableThreadLibraryCalls]
  2533.   end;
  2534. end;
  2535. {$ELSE}
  2536. function DisableThreadLibraryCalls; external kernel32 name 'DisableThreadLibraryCalls';
  2537. {$ENDIF DYNAMIC_LINK}
  2538. // MVB TODO Dynamic linking for GetProcAddress doesn't make much sense, does it? Same for LoadLibrary.
  2539. {$IFDEF DYNAMIC_LINK}
  2540. var
  2541.   _GetProcAddress: Pointer;
  2542. function GetProcAddress;
  2543. begin
  2544.   GetProcedureAddress(_GetProcAddress, kernel32, 'GetProcAddress');
  2545.   asm
  2546.     mov esp, ebp
  2547.     pop ebp
  2548.     jmp [_GetProcAddress]
  2549.   end;
  2550. end;
  2551. {$ELSE}
  2552. function GetProcAddress; external kernel32 name 'GetProcAddress';
  2553. {$ENDIF DYNAMIC_LINK}
  2554. {$IFDEF DYNAMIC_LINK}
  2555. var
  2556.   _GetVersion: Pointer;
  2557. function GetVersion;
  2558. begin
  2559.   GetProcedureAddress(_GetVersion, kernel32, 'GetVersion');
  2560.   asm
  2561.     mov esp, ebp
  2562.     pop ebp
  2563.     jmp [_GetVersion]
  2564.   end;
  2565. end;
  2566. {$ELSE}
  2567. function GetVersion; external kernel32 name 'GetVersion';
  2568. {$ENDIF DYNAMIC_LINK}
  2569. {$IFDEF DYNAMIC_LINK}
  2570. var
  2571.   _GlobalAlloc: Pointer;
  2572. function GlobalAlloc;
  2573. begin
  2574.   GetProcedureAddress(_GlobalAlloc, kernel32, 'GlobalAlloc');
  2575.   asm
  2576.     mov esp, ebp
  2577.     pop ebp
  2578.     jmp [_GlobalAlloc]
  2579.   end;
  2580. end;
  2581. {$ELSE}
  2582. function GlobalAlloc; external kernel32 name 'GlobalAlloc';
  2583. {$ENDIF DYNAMIC_LINK}
  2584. {$IFDEF DYNAMIC_LINK}
  2585. var
  2586.   _GlobalReAlloc: Pointer;
  2587. function GlobalReAlloc;
  2588. begin
  2589.   GetProcedureAddress(_GlobalReAlloc, kernel32, 'GlobalReAlloc');
  2590.   asm
  2591.     mov esp, ebp
  2592.     pop ebp
  2593.     jmp [_GlobalReAlloc]
  2594.   end;
  2595. end;
  2596. {$ELSE}
  2597. function GlobalReAlloc; external kernel32 name 'GlobalReAlloc';
  2598. {$ENDIF DYNAMIC_LINK}
  2599. {$IFDEF DYNAMIC_LINK}
  2600. var
  2601.   _GlobalSize: Pointer;
  2602. function GlobalSize;
  2603. begin
  2604.   GetProcedureAddress(_GlobalSize, kernel32, 'GlobalSize');
  2605.   asm
  2606.     mov esp, ebp
  2607.     pop ebp
  2608.     jmp [_GlobalSize]
  2609.   end;
  2610. end;
  2611. {$ELSE}
  2612. function GlobalSize; external kernel32 name 'GlobalSize';
  2613. {$ENDIF DYNAMIC_LINK}
  2614. {$IFDEF DYNAMIC_LINK}
  2615. var
  2616.   _GlobalFlags: Pointer;
  2617. function GlobalFlags;
  2618. begin
  2619.   GetProcedureAddress(_GlobalFlags, kernel32, 'GlobalFlags');
  2620.   asm
  2621.     mov esp, ebp
  2622.     pop ebp
  2623.     jmp [_GlobalFlags]
  2624.   end;
  2625. end;
  2626. {$ELSE}
  2627. function GlobalFlags; external kernel32 name 'GlobalFlags';
  2628. {$ENDIF DYNAMIC_LINK}
  2629. {$IFDEF DYNAMIC_LINK}
  2630. var
  2631.   _GlobalLock: Pointer;
  2632. function GlobalLock;
  2633. begin
  2634.   GetProcedureAddress(_GlobalLock, kernel32, 'GlobalLock');
  2635.   asm
  2636.     mov esp, ebp
  2637.     pop ebp
  2638.     jmp [_GlobalLock]
  2639.   end;
  2640. end;
  2641. {$ELSE}
  2642. function GlobalLock; external kernel32 name 'GlobalLock';
  2643. {$ENDIF DYNAMIC_LINK}
  2644. {$IFDEF DYNAMIC_LINK}
  2645. var
  2646.   _GlobalHandle: Pointer;
  2647. function GlobalHandle;
  2648. begin
  2649.   GetProcedureAddress(_GlobalHandle, kernel32, 'GlobalHandle');
  2650.   asm
  2651.     mov esp, ebp
  2652.     pop ebp
  2653.     jmp [_GlobalHandle]
  2654.   end;
  2655. end;
  2656. {$ELSE}
  2657. function GlobalHandle; external kernel32 name 'GlobalHandle';
  2658. {$ENDIF DYNAMIC_LINK}
  2659. {$IFDEF DYNAMIC_LINK}
  2660. var
  2661.   _GlobalUnlock: Pointer;
  2662. function GlobalUnlock;
  2663. begin
  2664.   GetProcedureAddress(_GlobalUnlock, kernel32, 'GlobalUnlock');
  2665.   asm
  2666.     mov esp, ebp
  2667.     pop ebp
  2668.     jmp [_GlobalUnlock]
  2669.   end;
  2670. end;
  2671. {$ELSE}
  2672. function GlobalUnlock; external kernel32 name 'GlobalUnlock';
  2673. {$ENDIF DYNAMIC_LINK}
  2674. {$IFDEF DYNAMIC_LINK}
  2675. var
  2676.   _GlobalFree: Pointer;
  2677. function GlobalFree;
  2678. begin
  2679.   GetProcedureAddress(_GlobalFree, kernel32, 'GlobalFree');
  2680.   asm
  2681.     mov esp, ebp
  2682.     pop ebp
  2683.     jmp [_GlobalFree]
  2684.   end;
  2685. end;
  2686. {$ELSE}
  2687. function GlobalFree; external kernel32 name 'GlobalFree';
  2688. {$ENDIF DYNAMIC_LINK}
  2689. {$IFDEF DYNAMIC_LINK}
  2690. var
  2691.   _GlobalCompact: Pointer;
  2692. function GlobalCompact;
  2693. begin
  2694.   GetProcedureAddress(_GlobalCompact, kernel32, 'GlobalCompact');
  2695.   asm
  2696.     mov esp, ebp
  2697.     pop ebp
  2698.     jmp [_GlobalCompact]
  2699.   end;
  2700. end;
  2701. {$ELSE}
  2702. function GlobalCompact; external kernel32 name 'GlobalCompact';
  2703. {$ENDIF DYNAMIC_LINK}
  2704. {$IFDEF DYNAMIC_LINK}
  2705. var
  2706.   _GlobalFix: Pointer;
  2707. procedure GlobalFix;
  2708. begin
  2709.   GetProcedureAddress(_GlobalFix, kernel32, 'GlobalFix');
  2710.   asm
  2711.     mov esp, ebp
  2712.     pop ebp
  2713.     jmp [_GlobalFix]
  2714.   end;
  2715. end;
  2716. {$ELSE}
  2717. procedure GlobalFix; external kernel32 name 'GlobalFix';
  2718. {$ENDIF DYNAMIC_LINK}
  2719. {$IFDEF DYNAMIC_LINK}
  2720. var
  2721.   _GlobalUnfix: Pointer;
  2722. procedure GlobalUnfix;
  2723. begin
  2724.   GetProcedureAddress(_GlobalUnfix, kernel32, 'GlobalUnfix');
  2725.   asm
  2726.     mov esp, ebp
  2727.     pop ebp
  2728.     jmp [_GlobalUnfix]
  2729.   end;
  2730. end;
  2731. {$ELSE}
  2732. procedure GlobalUnfix; external kernel32 name 'GlobalUnfix';
  2733. {$ENDIF DYNAMIC_LINK}
  2734. {$IFDEF DYNAMIC_LINK}
  2735. var
  2736.   _GlobalWire: Pointer;
  2737. function GlobalWire;
  2738. begin
  2739.   GetProcedureAddress(_GlobalWire, kernel32, 'GlobalWire');
  2740.   asm
  2741.     mov esp, ebp
  2742.     pop ebp
  2743.     jmp [_GlobalWire]
  2744.   end;
  2745. end;
  2746. {$ELSE}
  2747. function GlobalWire; external kernel32 name 'GlobalWire';
  2748. {$ENDIF DYNAMIC_LINK}
  2749. {$IFDEF DYNAMIC_LINK}
  2750. var
  2751.   _GlobalUnWire: Pointer;
  2752. function GlobalUnWire;
  2753. begin
  2754.   GetProcedureAddress(_GlobalUnWire, kernel32, 'GlobalUnWire');
  2755.   asm
  2756.     mov esp, ebp
  2757.     pop ebp
  2758.     jmp [_GlobalUnWire]
  2759.   end;
  2760. end;
  2761. {$ELSE}
  2762. function GlobalUnWire; external kernel32 name 'GlobalUnWire';
  2763. {$ENDIF DYNAMIC_LINK}
  2764. {$IFDEF DYNAMIC_LINK}
  2765. var
  2766.   _GlobalMemoryStatus: Pointer;
  2767. procedure GlobalMemoryStatus;
  2768. begin
  2769.   GetProcedureAddress(_GlobalMemoryStatus, kernel32, 'GlobalMemoryStatus');
  2770.   asm
  2771.     mov esp, ebp
  2772.     pop ebp
  2773.     jmp [_GlobalMemoryStatus]
  2774.   end;
  2775. end;
  2776. {$ELSE}
  2777. procedure GlobalMemoryStatus; external kernel32 name 'GlobalMemoryStatus';
  2778. {$ENDIF DYNAMIC_LINK}
  2779. {$IFDEF DYNAMIC_LINK}
  2780. var
  2781.   _GlobalMemoryStatusEx: Pointer;
  2782. function GlobalMemoryStatusEx;
  2783. begin
  2784.   GetProcedureAddress(_GlobalMemoryStatusEx, kernel32, 'GlobalMemoryStatusEx');
  2785.   asm
  2786.     mov esp, ebp
  2787.     pop ebp
  2788.     jmp [_GlobalMemoryStatusEx]
  2789.   end;
  2790. end;
  2791. {$ELSE}
  2792. function GlobalMemoryStatusEx; external kernel32 name 'GlobalMemoryStatusEx';
  2793. {$ENDIF DYNAMIC_LINK}
  2794. {$IFDEF DYNAMIC_LINK}
  2795. var
  2796.   _LocalAlloc: Pointer;
  2797. function LocalAlloc;
  2798. begin
  2799.   GetProcedureAddress(_LocalAlloc, kernel32, 'LocalAlloc');
  2800.   asm
  2801.     mov esp, ebp
  2802.     pop ebp
  2803.     jmp [_LocalAlloc]
  2804.   end;
  2805. end;
  2806. {$ELSE}
  2807. function LocalAlloc; external kernel32 name 'LocalAlloc';
  2808. {$ENDIF DYNAMIC_LINK}
  2809. {$IFDEF DYNAMIC_LINK}
  2810. var
  2811.   _LocalReAlloc: Pointer;
  2812. function LocalReAlloc;
  2813. begin
  2814.   GetProcedureAddress(_LocalReAlloc, kernel32, 'LocalReAlloc');
  2815.   asm
  2816.     mov esp, ebp
  2817.     pop ebp
  2818.     jmp [_LocalReAlloc]
  2819.   end;
  2820. end;
  2821. {$ELSE}
  2822. function LocalReAlloc; external kernel32 name 'LocalReAlloc';
  2823. {$ENDIF DYNAMIC_LINK}
  2824. {$IFDEF DYNAMIC_LINK}
  2825. var
  2826.   _LocalLock: Pointer;
  2827. function LocalLock;
  2828. begin
  2829.   GetProcedureAddress(_LocalLock, kernel32, 'LocalLock');
  2830.   asm
  2831.     mov esp, ebp
  2832.     pop ebp
  2833.     jmp [_LocalLock]
  2834.   end;
  2835. end;
  2836. {$ELSE}
  2837. function LocalLock; external kernel32 name 'LocalLock';
  2838. {$ENDIF DYNAMIC_LINK}
  2839. {$IFDEF DYNAMIC_LINK}
  2840. var
  2841.   _LocalHandle: Pointer;
  2842. function LocalHandle;
  2843. begin
  2844.   GetProcedureAddress(_LocalHandle, kernel32, 'LocalHandle');
  2845.   asm
  2846.     mov esp, ebp
  2847.     pop ebp
  2848.     jmp [_LocalHandle]
  2849.   end;
  2850. end;
  2851. {$ELSE}
  2852. function LocalHandle; external kernel32 name 'LocalHandle';
  2853. {$ENDIF DYNAMIC_LINK}
  2854. {$IFDEF DYNAMIC_LINK}
  2855. var
  2856.   _LocalUnlock: Pointer;
  2857. function LocalUnlock;
  2858. begin
  2859.   GetProcedureAddress(_LocalUnlock, kernel32, 'LocalUnlock');
  2860.   asm
  2861.     mov esp, ebp
  2862.     pop ebp
  2863.     jmp [_LocalUnlock]
  2864.   end;
  2865. end;
  2866. {$ELSE}
  2867. function LocalUnlock; external kernel32 name 'LocalUnlock';
  2868. {$ENDIF DYNAMIC_LINK}
  2869. {$IFDEF DYNAMIC_LINK}
  2870. var
  2871.   _LocalSize: Pointer;
  2872. function LocalSize;
  2873. begin
  2874.   GetProcedureAddress(_LocalSize, kernel32, 'LocalSize');
  2875.   asm
  2876.     mov esp, ebp
  2877.     pop ebp
  2878.     jmp [_LocalSize]
  2879.   end;
  2880. end;
  2881. {$ELSE}
  2882. function LocalSize; external kernel32 name 'LocalSize';
  2883. {$ENDIF DYNAMIC_LINK}
  2884. {$IFDEF DYNAMIC_LINK}
  2885. var
  2886.   _LocalFlags: Pointer;
  2887. function LocalFlags;
  2888. begin
  2889.   GetProcedureAddress(_LocalFlags, kernel32, 'LocalFlags');
  2890.   asm
  2891.     mov esp, ebp
  2892.     pop ebp
  2893.     jmp [_LocalFlags]
  2894.   end;
  2895. end;
  2896. {$ELSE}
  2897. function LocalFlags; external kernel32 name 'LocalFlags';
  2898. {$ENDIF DYNAMIC_LINK}
  2899. {$IFDEF DYNAMIC_LINK}
  2900. var
  2901.   _LocalFree: Pointer;
  2902. function LocalFree;
  2903. begin
  2904.   GetProcedureAddress(_LocalFree, kernel32, 'LocalFree');
  2905.   asm
  2906.     mov esp, ebp
  2907.     pop ebp
  2908.     jmp [_LocalFree]
  2909.   end;
  2910. end;
  2911. {$ELSE}
  2912. function LocalFree; external kernel32 name 'LocalFree';
  2913. {$ENDIF DYNAMIC_LINK}
  2914. {$IFDEF DYNAMIC_LINK}
  2915. var
  2916.   _LocalShrink: Pointer;
  2917. function LocalShrink;
  2918. begin
  2919.   GetProcedureAddress(_LocalShrink, kernel32, 'LocalShrink');
  2920.   asm
  2921.     mov esp, ebp
  2922.     pop ebp
  2923.     jmp [_LocalShrink]
  2924.   end;
  2925. end;
  2926. {$ELSE}
  2927. function LocalShrink; external kernel32 name 'LocalShrink';
  2928. {$ENDIF DYNAMIC_LINK}
  2929. {$IFDEF DYNAMIC_LINK}
  2930. var
  2931.   _LocalCompact: Pointer;
  2932. function LocalCompact;
  2933. begin
  2934.   GetProcedureAddress(_LocalCompact, kernel32, 'LocalCompact');
  2935.   asm
  2936.     mov esp, ebp
  2937.     pop ebp
  2938.     jmp [_LocalCompact]
  2939.   end;
  2940. end;
  2941. {$ELSE}
  2942. function LocalCompact; external kernel32 name 'LocalCompact';
  2943. {$ENDIF DYNAMIC_LINK}
  2944. {$IFDEF DYNAMIC_LINK}
  2945. var
  2946.   _FlushInstructionCache: Pointer;
  2947. function FlushInstructionCache;
  2948. begin
  2949.   GetProcedureAddress(_FlushInstructionCache, kernel32, 'FlushInstructionCache');
  2950.   asm
  2951.     mov esp, ebp
  2952.     pop ebp
  2953.     jmp [_FlushInstructionCache]
  2954.   end;
  2955. end;
  2956. {$ELSE}
  2957. function FlushInstructionCache; external kernel32 name 'FlushInstructionCache';
  2958. {$ENDIF DYNAMIC_LINK}
  2959. {$IFDEF DYNAMIC_LINK}
  2960. var
  2961.   _VirtualAlloc: Pointer;
  2962. function VirtualAlloc;
  2963. begin
  2964.   GetProcedureAddress(_VirtualAlloc, kernel32, 'VirtualAlloc');
  2965.   asm
  2966.     mov esp, ebp
  2967.     pop ebp
  2968.     jmp [_VirtualAlloc]
  2969.   end;
  2970. end;
  2971. {$ELSE}
  2972. function VirtualAlloc; external kernel32 name 'VirtualAlloc';
  2973. {$ENDIF DYNAMIC_LINK}
  2974. {$IFDEF DYNAMIC_LINK}
  2975. var
  2976.   _VirtualFree: Pointer;
  2977. function VirtualFree;
  2978. begin
  2979.   GetProcedureAddress(_VirtualFree, kernel32, 'VirtualFree');
  2980.   asm
  2981.     mov esp, ebp
  2982.     pop ebp
  2983.     jmp [_VirtualFree]
  2984.   end;
  2985. end;
  2986. {$ELSE}
  2987. function VirtualFree; external kernel32 name 'VirtualFree';
  2988. {$ENDIF DYNAMIC_LINK}
  2989. {$IFDEF DYNAMIC_LINK}
  2990. var
  2991.   _VirtualProtect: Pointer;
  2992. function VirtualProtect;
  2993. begin
  2994.   GetProcedureAddress(_VirtualProtect, kernel32, 'VirtualProtect');
  2995.   asm
  2996.     mov esp, ebp
  2997.     pop ebp
  2998.     jmp [_VirtualProtect]
  2999.   end;
  3000. end;
  3001. {$ELSE}
  3002. function VirtualProtect; external kernel32 name 'VirtualProtect';
  3003. {$ENDIF DYNAMIC_LINK}
  3004. {$IFDEF DYNAMIC_LINK}
  3005. var
  3006.   _VirtualQuery: Pointer;
  3007. function VirtualQuery;
  3008. begin
  3009.   GetProcedureAddress(_VirtualQuery, kernel32, 'VirtualQuery');
  3010.   asm
  3011.     mov esp, ebp
  3012.     pop ebp
  3013.     jmp [_VirtualQuery]
  3014.   end;
  3015. end;
  3016. {$ELSE}
  3017. function VirtualQuery; external kernel32 name 'VirtualQuery';
  3018. {$ENDIF DYNAMIC_LINK}
  3019. {$IFDEF DYNAMIC_LINK}
  3020. var
  3021.   _VirtualAllocEx: Pointer;
  3022. function VirtualAllocEx;
  3023. begin
  3024.   GetProcedureAddress(_VirtualAllocEx, kernel32, 'VirtualAllocEx');
  3025.   asm
  3026.     mov esp, ebp
  3027.     pop ebp
  3028.     jmp [_VirtualAllocEx]
  3029.   end;
  3030. end;
  3031. {$ELSE}
  3032. function VirtualAllocEx; external kernel32 name 'VirtualAllocEx';
  3033. {$ENDIF DYNAMIC_LINK}
  3034. {$IFDEF DYNAMIC_LINK}
  3035. var
  3036.   _GetWriteWatch: Pointer;
  3037. function GetWriteWatch;
  3038. begin
  3039.   GetProcedureAddress(_GetWriteWatch, kernel32, 'GetWriteWatch');
  3040.   asm
  3041.     mov esp, ebp
  3042.     pop ebp
  3043.     jmp [_GetWriteWatch]
  3044.   end;
  3045. end;
  3046. {$ELSE}
  3047. function GetWriteWatch; external kernel32 name 'GetWriteWatch';
  3048. {$ENDIF DYNAMIC_LINK}
  3049. {$IFDEF DYNAMIC_LINK}
  3050. var
  3051.   _ResetWriteWatch: Pointer;
  3052. function ResetWriteWatch;
  3053. begin
  3054.   GetProcedureAddress(_ResetWriteWatch, kernel32, 'ResetWriteWatch');
  3055.   asm
  3056.     mov esp, ebp
  3057.     pop ebp
  3058.     jmp [_ResetWriteWatch]
  3059.   end;
  3060. end;
  3061. {$ELSE}
  3062. function ResetWriteWatch; external kernel32 name 'ResetWriteWatch';
  3063. {$ENDIF DYNAMIC_LINK}
  3064. {$IFDEF DYNAMIC_LINK}
  3065. var
  3066.   _GetLargePageMinimum: Pointer;
  3067. function GetLargePageMinimum;
  3068. begin
  3069.   GetProcedureAddress(_GetLargePageMinimum, kernel32, 'GetLargePageMinimum');
  3070.   asm
  3071.     mov esp, ebp
  3072.     pop ebp
  3073.     jmp [_GetLargePageMinimum]
  3074.   end;
  3075. end;
  3076. {$ELSE}
  3077. function GetLargePageMinimum; external kernel32 name 'GetLargePageMinimum';
  3078. {$ENDIF DYNAMIC_LINK}
  3079. {$IFDEF DYNAMIC_LINK}
  3080. var
  3081.   _VirtualFreeEx: Pointer;
  3082. function VirtualFreeEx;
  3083. begin
  3084.   GetProcedureAddress(_VirtualFreeEx, kernel32, 'VirtualFreeEx');
  3085.   asm
  3086.     mov esp, ebp
  3087.     pop ebp
  3088.     jmp [_VirtualFreeEx]
  3089.   end;
  3090. end;
  3091. {$ELSE}
  3092. function VirtualFreeEx; external kernel32 name 'VirtualFreeEx';
  3093. {$ENDIF DYNAMIC_LINK}
  3094. {$IFDEF DYNAMIC_LINK}
  3095. var
  3096.   _VirtualProtectEx: Pointer;
  3097. function VirtualProtectEx;
  3098. begin
  3099.   GetProcedureAddress(_VirtualProtectEx, kernel32, 'VirtualProtectEx');
  3100.   asm
  3101.     mov esp, ebp
  3102.     pop ebp
  3103.     jmp [_VirtualProtectEx]
  3104.   end;
  3105. end;
  3106. {$ELSE}
  3107. function VirtualProtectEx; external kernel32 name 'VirtualProtectEx';
  3108. {$ENDIF DYNAMIC_LINK}
  3109. {$IFDEF DYNAMIC_LINK}
  3110. var
  3111.   _VirtualQueryEx: Pointer;
  3112. function VirtualQueryEx;
  3113. begin
  3114.   GetProcedureAddress(_VirtualQueryEx, kernel32, 'VirtualQueryEx');
  3115.   asm
  3116.     mov esp, ebp
  3117.     pop ebp
  3118.     jmp [_VirtualQueryEx]
  3119.   end;
  3120. end;
  3121. {$ELSE}
  3122. function VirtualQueryEx; external kernel32 name 'VirtualQueryEx';
  3123. {$ENDIF DYNAMIC_LINK}
  3124. {$IFDEF DYNAMIC_LINK}
  3125. var
  3126.   _HeapCreate: Pointer;
  3127. function HeapCreate;
  3128. begin
  3129.   GetProcedureAddress(_HeapCreate, kernel32, 'HeapCreate');
  3130.   asm
  3131.     mov esp, ebp
  3132.     pop ebp
  3133.     jmp [_HeapCreate]
  3134.   end;
  3135. end;
  3136. {$ELSE}
  3137. function HeapCreate; external kernel32 name 'HeapCreate';
  3138. {$ENDIF DYNAMIC_LINK}
  3139. {$IFDEF DYNAMIC_LINK}
  3140. var
  3141.   _HeapDestroy: Pointer;
  3142. function HeapDestroy;
  3143. begin
  3144.   GetProcedureAddress(_HeapDestroy, kernel32, 'HeapDestroy');
  3145.   asm
  3146.     mov esp, ebp
  3147.     pop ebp
  3148.     jmp [_HeapDestroy]
  3149.   end;
  3150. end;
  3151. {$ELSE}
  3152. function HeapDestroy; external kernel32 name 'HeapDestroy';
  3153. {$ENDIF DYNAMIC_LINK}
  3154. {$IFDEF DYNAMIC_LINK}
  3155. var
  3156.   _HeapAlloc: Pointer;
  3157. function HeapAlloc;
  3158. begin
  3159.   GetProcedureAddress(_HeapAlloc, kernel32, 'HeapAlloc');
  3160.   asm
  3161.     mov esp, ebp
  3162.     pop ebp
  3163.     jmp [_HeapAlloc]
  3164.   end;
  3165. end;
  3166. {$ELSE}
  3167. function HeapAlloc; external kernel32 name 'HeapAlloc';
  3168. {$ENDIF DYNAMIC_LINK}
  3169. {$IFDEF DYNAMIC_LINK}
  3170. var
  3171.   _HeapReAlloc: Pointer;
  3172. function HeapReAlloc;
  3173. begin
  3174.   GetProcedureAddress(_HeapReAlloc, kernel32, 'HeapReAlloc');
  3175.   asm
  3176.     mov esp, ebp
  3177.     pop ebp
  3178.     jmp [_HeapReAlloc]
  3179.   end;
  3180. end;
  3181. {$ELSE}
  3182. function HeapReAlloc; external kernel32 name 'HeapReAlloc';
  3183. {$ENDIF DYNAMIC_LINK}
  3184. {$IFDEF DYNAMIC_LINK}
  3185. var
  3186.   _HeapFree: Pointer;
  3187. function HeapFree;
  3188. begin
  3189.   GetProcedureAddress(_HeapFree, kernel32, 'HeapFree');
  3190.   asm
  3191.     mov esp, ebp
  3192.     pop ebp
  3193.     jmp [_HeapFree]
  3194.   end;
  3195. end;
  3196. {$ELSE}
  3197. function HeapFree; external kernel32 name 'HeapFree';
  3198. {$ENDIF DYNAMIC_LINK}
  3199. {$IFDEF DYNAMIC_LINK}
  3200. var
  3201.   _HeapSize: Pointer;
  3202. function HeapSize;
  3203. begin
  3204.   GetProcedureAddress(_HeapSize, kernel32, 'HeapSize');
  3205.   asm
  3206.     mov esp, ebp
  3207.     pop ebp
  3208.     jmp [_HeapSize]
  3209.   end;
  3210. end;
  3211. {$ELSE}
  3212. function HeapSize; external kernel32 name 'HeapSize';
  3213. {$ENDIF DYNAMIC_LINK}
  3214. {$IFDEF DYNAMIC_LINK}
  3215. var
  3216.   _HeapValidate: Pointer;
  3217. function HeapValidate;
  3218. begin
  3219.   GetProcedureAddress(_HeapValidate, kernel32, 'HeapValidate');
  3220.   asm
  3221.     mov esp, ebp
  3222.     pop ebp
  3223.     jmp [_HeapValidate]
  3224.   end;
  3225. end;
  3226. {$ELSE}
  3227. function HeapValidate; external kernel32 name 'HeapValidate';
  3228. {$ENDIF DYNAMIC_LINK}
  3229. {$IFDEF DYNAMIC_LINK}
  3230. var
  3231.   _HeapCompact: Pointer;
  3232. function HeapCompact;
  3233. begin
  3234.   GetProcedureAddress(_HeapCompact, kernel32, 'HeapCompact');
  3235.   asm
  3236.     mov esp, ebp
  3237.     pop ebp
  3238.     jmp [_HeapCompact]
  3239.   end;
  3240. end;
  3241. {$ELSE}
  3242. function HeapCompact; external kernel32 name 'HeapCompact';
  3243. {$ENDIF DYNAMIC_LINK}
  3244. {$IFDEF DYNAMIC_LINK}
  3245. var
  3246.   _GetProcessHeap: Pointer;
  3247. function GetProcessHeap;
  3248. begin
  3249.   GetProcedureAddress(_GetProcessHeap, kernel32, 'GetProcessHeap');
  3250.   asm
  3251.     mov esp, ebp
  3252.     pop ebp
  3253.     jmp [_GetProcessHeap]
  3254.   end;
  3255. end;
  3256. {$ELSE}
  3257. function GetProcessHeap; external kernel32 name 'GetProcessHeap';
  3258. {$ENDIF DYNAMIC_LINK}
  3259. {$IFDEF DYNAMIC_LINK}
  3260. var
  3261.   _GetProcessHeaps: Pointer;
  3262. function GetProcessHeaps;
  3263. begin
  3264.   GetProcedureAddress(_GetProcessHeaps, kernel32, 'GetProcessHeaps');
  3265.   asm
  3266.     mov esp, ebp
  3267.     pop ebp
  3268.     jmp [_GetProcessHeaps]
  3269.   end;
  3270. end;
  3271. {$ELSE}
  3272. function GetProcessHeaps; external kernel32 name 'GetProcessHeaps';
  3273. {$ENDIF DYNAMIC_LINK}
  3274. {$IFDEF DYNAMIC_LINK}
  3275. var
  3276.   _HeapLock: Pointer;
  3277. function HeapLock;
  3278. begin
  3279.   GetProcedureAddress(_HeapLock, kernel32, 'HeapLock');
  3280.   asm
  3281.     mov esp, ebp
  3282.     pop ebp
  3283.     jmp [_HeapLock]
  3284.   end;
  3285. end;
  3286. {$ELSE}
  3287. function HeapLock; external kernel32 name 'HeapLock';
  3288. {$ENDIF DYNAMIC_LINK}
  3289. {$IFDEF DYNAMIC_LINK}
  3290. var
  3291.   _HeapUnlock: Pointer;
  3292. function HeapUnlock;
  3293. begin
  3294.   GetProcedureAddress(_HeapUnlock, kernel32, 'HeapUnlock');
  3295.   asm
  3296.     mov esp, ebp
  3297.     pop ebp
  3298.     jmp [_HeapUnlock]
  3299.   end;
  3300. end;
  3301. {$ELSE}
  3302. function HeapUnlock; external kernel32 name 'HeapUnlock';
  3303. {$ENDIF DYNAMIC_LINK}
  3304. {$IFDEF DYNAMIC_LINK}
  3305. var
  3306.   _HeapWalk: Pointer;
  3307. function HeapWalk;
  3308. begin
  3309.   GetProcedureAddress(_HeapWalk, kernel32, 'HeapWalk');
  3310.   asm
  3311.     mov esp, ebp
  3312.     pop ebp
  3313.     jmp [_HeapWalk]
  3314.   end;
  3315. end;
  3316. {$ELSE}
  3317. function HeapWalk; external kernel32 name 'HeapWalk';
  3318. {$ENDIF DYNAMIC_LINK}
  3319. {$IFDEF DYNAMIC_LINK}
  3320. var
  3321.   _HeapSetInformation: Pointer;
  3322. function HeapSetInformation;
  3323. begin
  3324.   GetProcedureAddress(_HeapSetInformation, kernel32, 'HeapSetInformation');
  3325.   asm
  3326.     mov esp, ebp
  3327.     pop ebp
  3328.     jmp [_HeapSetInformation]
  3329.   end;
  3330. end;
  3331. {$ELSE}
  3332. function HeapSetInformation; external kernel32 name 'HeapSetInformation';
  3333. {$ENDIF DYNAMIC_LINK}
  3334. {$IFDEF DYNAMIC_LINK}
  3335. var
  3336.   _HeapQueryInformation: Pointer;
  3337. function HeapQueryInformation;
  3338. begin
  3339.   GetProcedureAddress(_HeapQueryInformation, kernel32, 'HeapQueryInformation');
  3340.   asm
  3341.     mov esp, ebp
  3342.     pop ebp
  3343.     jmp [_HeapQueryInformation]
  3344.   end;
  3345. end;
  3346. {$ELSE}
  3347. function HeapQueryInformation; external kernel32 name 'HeapQueryInformation';
  3348. {$ENDIF DYNAMIC_LINK}
  3349. {$IFDEF DYNAMIC_LINK}
  3350. var
  3351.   _GetBinaryTypeA: Pointer;
  3352. function GetBinaryTypeA;
  3353. begin
  3354.   GetProcedureAddress(_GetBinaryTypeA, kernel32, 'GetBinaryTypeA');
  3355.   asm
  3356.     mov esp, ebp
  3357.     pop ebp
  3358.     jmp [_GetBinaryTypeA]
  3359.   end;
  3360. end;
  3361. {$ELSE}
  3362. function GetBinaryTypeA; external kernel32 name 'GetBinaryTypeA';
  3363. {$ENDIF DYNAMIC_LINK}
  3364. {$IFDEF DYNAMIC_LINK}
  3365. var
  3366.   _GetBinaryTypeW: Pointer;
  3367. function GetBinaryTypeW;
  3368. begin
  3369.   GetProcedureAddress(_GetBinaryTypeW, kernel32, 'GetBinaryTypeW');
  3370.   asm
  3371.     mov esp, ebp
  3372.     pop ebp
  3373.     jmp [_GetBinaryTypeW]
  3374.   end;
  3375. end;
  3376. {$ELSE}
  3377. function GetBinaryTypeW; external kernel32 name 'GetBinaryTypeW';
  3378. {$ENDIF DYNAMIC_LINK}
  3379. {$IFDEF UNICODE}
  3380. {$IFDEF DYNAMIC_LINK}
  3381. var
  3382.   _GetBinaryType: Pointer;
  3383. function GetBinaryType;
  3384. begin
  3385.   GetProcedureAddress(_GetBinaryType, kernel32, 'GetBinaryTypeW');
  3386.   asm
  3387.     mov esp, ebp
  3388.     pop ebp
  3389.     jmp [_GetBinaryType]
  3390.   end;
  3391. end;
  3392. {$ELSE}
  3393. function GetBinaryType; external kernel32 name 'GetBinaryTypeW';
  3394. {$ENDIF DYNAMIC_LINK}
  3395. {$ELSE}
  3396. {$IFDEF DYNAMIC_LINK}
  3397. var
  3398.   _GetBinaryType: Pointer;
  3399. function GetBinaryType;
  3400. begin
  3401.   GetProcedureAddress(_GetBinaryType, kernel32, 'GetBinaryTypeA');
  3402.   asm
  3403.     mov esp, ebp
  3404.     pop ebp
  3405.     jmp [_GetBinaryType]
  3406.   end;
  3407. end;
  3408. {$ELSE}
  3409. function GetBinaryType; external kernel32 name 'GetBinaryTypeA';
  3410. {$ENDIF DYNAMIC_LINK}
  3411. {$ENDIF}
  3412. {$IFDEF DYNAMIC_LINK}
  3413. var
  3414.   _GetShortPathNameA: Pointer;
  3415. function GetShortPathNameA;
  3416. begin
  3417.   GetProcedureAddress(_GetShortPathNameA, kernel32, 'GetShortPathNameA');
  3418.   asm
  3419.     mov esp, ebp
  3420.     pop ebp
  3421.     jmp [_GetShortPathNameA]
  3422.   end;
  3423. end;
  3424. {$ELSE}
  3425. function GetShortPathNameA; external kernel32 name 'GetShortPathNameA';
  3426. {$ENDIF DYNAMIC_LINK}
  3427. {$IFDEF DYNAMIC_LINK}
  3428. var
  3429.   _GetShortPathNameW: Pointer;
  3430. function GetShortPathNameW;
  3431. begin
  3432.   GetProcedureAddress(_GetShortPathNameW, kernel32, 'GetShortPathNameW');
  3433.   asm
  3434.     mov esp, ebp
  3435.     pop ebp
  3436.     jmp [_GetShortPathNameW]
  3437.   end;
  3438. end;
  3439. {$ELSE}
  3440. function GetShortPathNameW; external kernel32 name 'GetShortPathNameW';
  3441. {$ENDIF DYNAMIC_LINK}
  3442. {$IFDEF UNICODE}
  3443. {$IFDEF DYNAMIC_LINK}
  3444. var
  3445.   _GetShortPathName: Pointer;
  3446. function GetShortPathName;
  3447. begin
  3448.   GetProcedureAddress(_GetShortPathName, kernel32, 'GetShortPathNameW');
  3449.   asm
  3450.     mov esp, ebp
  3451.     pop ebp
  3452.     jmp [_GetShortPathName]
  3453.   end;
  3454. end;
  3455. {$ELSE}
  3456. function GetShortPathName; external kernel32 name 'GetShortPathNameW';
  3457. {$ENDIF DYNAMIC_LINK}
  3458. {$ELSE}
  3459. {$IFDEF DYNAMIC_LINK}
  3460. var
  3461.   _GetShortPathName: Pointer;
  3462. function GetShortPathName;
  3463. begin
  3464.   GetProcedureAddress(_GetShortPathName, kernel32, 'GetShortPathNameA');
  3465.   asm
  3466.     mov esp, ebp
  3467.     pop ebp
  3468.     jmp [_GetShortPathName]
  3469.   end;
  3470. end;
  3471. {$ELSE}
  3472. function GetShortPathName; external kernel32 name 'GetShortPathNameA';
  3473. {$ENDIF DYNAMIC_LINK}
  3474. {$ENDIF}
  3475. {$IFDEF DYNAMIC_LINK}
  3476. var
  3477.   _GetLongPathNameA: Pointer;
  3478. function GetLongPathNameA;
  3479. begin
  3480.   GetProcedureAddress(_GetLongPathNameA, kernel32, 'GetLongPathNameA');
  3481.   asm
  3482.     mov esp, ebp
  3483.     pop ebp
  3484.     jmp [_GetLongPathNameA]
  3485.   end;
  3486. end;
  3487. {$ELSE}
  3488. function GetLongPathNameA; external kernel32 name 'GetLongPathNameA';
  3489. {$ENDIF DYNAMIC_LINK}
  3490. {$IFDEF DYNAMIC_LINK}
  3491. var
  3492.   _GetLongPathNameW: Pointer;
  3493. function GetLongPathNameW;
  3494. begin
  3495.   GetProcedureAddress(_GetLongPathNameW, kernel32, 'GetLongPathNameW');
  3496.   asm
  3497.     mov esp, ebp
  3498.     pop ebp
  3499.     jmp [_GetLongPathNameW]
  3500.   end;
  3501. end;
  3502. {$ELSE}
  3503. function GetLongPathNameW; external kernel32 name 'GetLongPathNameW';
  3504. {$ENDIF DYNAMIC_LINK}
  3505. {$IFDEF UNICODE}
  3506. {$IFDEF DYNAMIC_LINK}
  3507. var
  3508.   _GetLongPathName: Pointer;
  3509. function GetLongPathName;
  3510. begin
  3511.   GetProcedureAddress(_GetLongPathName, kernel32, 'GetLongPathNameW');
  3512.   asm
  3513.     mov esp, ebp
  3514.     pop ebp
  3515.     jmp [_GetLongPathName]
  3516.   end;
  3517. end;
  3518. {$ELSE}
  3519. function GetLongPathName; external kernel32 name 'GetLongPathNameW';
  3520. {$ENDIF DYNAMIC_LINK}
  3521. {$ELSE}
  3522. {$IFDEF DYNAMIC_LINK}
  3523. var
  3524.   _GetLongPathName: Pointer;
  3525. function GetLongPathName;
  3526. begin
  3527.   GetProcedureAddress(_GetLongPathName, kernel32, 'GetLongPathNameA');
  3528.   asm
  3529.     mov esp, ebp
  3530.     pop ebp
  3531.     jmp [_GetLongPathName]
  3532.   end;
  3533. end;
  3534. {$ELSE}
  3535. function GetLongPathName; external kernel32 name 'GetLongPathNameA';
  3536. {$ENDIF DYNAMIC_LINK}
  3537. {$ENDIF}
  3538. {$IFDEF DYNAMIC_LINK}
  3539. var
  3540.   _GetProcessAffinityMask: Pointer;
  3541. function GetProcessAffinityMask;
  3542. begin
  3543.   GetProcedureAddress(_GetProcessAffinityMask, kernel32, 'GetProcessAffinityMask');
  3544.   asm
  3545.     mov esp, ebp
  3546.     pop ebp
  3547.     jmp [_GetProcessAffinityMask]
  3548.   end;
  3549. end;
  3550. {$ELSE}
  3551. function GetProcessAffinityMask; external kernel32 name 'GetProcessAffinityMask';
  3552. {$ENDIF DYNAMIC_LINK}
  3553. {$IFDEF DYNAMIC_LINK}
  3554. var
  3555.   _SetProcessAffinityMask: Pointer;
  3556. function SetProcessAffinityMask;
  3557. begin
  3558.   GetProcedureAddress(_SetProcessAffinityMask, kernel32, 'SetProcessAffinityMask');
  3559.   asm
  3560.     mov esp, ebp
  3561.     pop ebp
  3562.     jmp [_SetProcessAffinityMask]
  3563.   end;
  3564. end;
  3565. {$ELSE}
  3566. function SetProcessAffinityMask; external kernel32 name 'SetProcessAffinityMask';
  3567. {$ENDIF DYNAMIC_LINK}
  3568. {$IFDEF DYNAMIC_LINK}
  3569. var
  3570.   _GetProcessTimes: Pointer;
  3571. function GetProcessTimes;
  3572. begin
  3573.   GetProcedureAddress(_GetProcessTimes, kernel32, 'GetProcessTimes');
  3574.   asm
  3575.     mov esp, ebp
  3576.     pop ebp
  3577.     jmp [_GetProcessTimes]
  3578.   end;
  3579. end;
  3580. {$ELSE}
  3581. function GetProcessTimes; external kernel32 name 'GetProcessTimes';
  3582. {$ENDIF DYNAMIC_LINK}
  3583. {$IFDEF DYNAMIC_LINK}
  3584. var
  3585.   _GetProcessIoCounters: Pointer;
  3586. function GetProcessIoCounters;
  3587. begin
  3588.   GetProcedureAddress(_GetProcessIoCounters, kernel32, 'GetProcessIoCounters');
  3589.   asm
  3590.     mov esp, ebp
  3591.     pop ebp
  3592.     jmp [_GetProcessIoCounters]
  3593.   end;
  3594. end;
  3595. {$ELSE}
  3596. function GetProcessIoCounters; external kernel32 name 'GetProcessIoCounters';
  3597. {$ENDIF DYNAMIC_LINK}
  3598. {$IFDEF DYNAMIC_LINK}
  3599. var
  3600.   _GetProcessWorkingSetSize: Pointer;
  3601. function GetProcessWorkingSetSize;
  3602. begin
  3603.   GetProcedureAddress(_GetProcessWorkingSetSize, kernel32, 'GetProcessWorkingSetSize');
  3604.   asm
  3605.     mov esp, ebp
  3606.     pop ebp
  3607.     jmp [_GetProcessWorkingSetSize]
  3608.   end;
  3609. end;
  3610. {$ELSE}
  3611. function GetProcessWorkingSetSize; external kernel32 name 'GetProcessWorkingSetSize';
  3612. {$ENDIF DYNAMIC_LINK}
  3613. {$IFDEF DYNAMIC_LINK}
  3614. var
  3615.   _SetProcessWorkingSetSize: Pointer;
  3616. function SetProcessWorkingSetSize;
  3617. begin
  3618.   GetProcedureAddress(_SetProcessWorkingSetSize, kernel32, 'SetProcessWorkingSetSize');
  3619.   asm
  3620.     mov esp, ebp
  3621.     pop ebp
  3622.     jmp [_SetProcessWorkingSetSize]
  3623.   end;
  3624. end;
  3625. {$ELSE}
  3626. function SetProcessWorkingSetSize; external kernel32 name 'SetProcessWorkingSetSize';
  3627. {$ENDIF DYNAMIC_LINK}
  3628. {$IFDEF DYNAMIC_LINK}
  3629. var
  3630.   _OpenProcess: Pointer;
  3631. function OpenProcess;
  3632. begin
  3633.   GetProcedureAddress(_OpenProcess, kernel32, 'OpenProcess');
  3634.   asm
  3635.     mov esp, ebp
  3636.     pop ebp
  3637.     jmp [_OpenProcess]
  3638.   end;
  3639. end;
  3640. {$ELSE}
  3641. function OpenProcess; external kernel32 name 'OpenProcess';
  3642. {$ENDIF DYNAMIC_LINK}
  3643. {$IFDEF DYNAMIC_LINK}
  3644. var
  3645.   _GetCurrentProcess: Pointer;
  3646. function GetCurrentProcess;
  3647. begin
  3648.   GetProcedureAddress(_GetCurrentProcess, kernel32, 'GetCurrentProcess');
  3649.   asm
  3650.     mov esp, ebp
  3651.     pop ebp
  3652.     jmp [_GetCurrentProcess]
  3653.   end;
  3654. end;
  3655. {$ELSE}
  3656. function GetCurrentProcess; external kernel32 name 'GetCurrentProcess';
  3657. {$ENDIF DYNAMIC_LINK}
  3658. {$IFDEF DYNAMIC_LINK}
  3659. var
  3660.   _GetCurrentProcessId: Pointer;
  3661. function GetCurrentProcessId;
  3662. begin
  3663.   GetProcedureAddress(_GetCurrentProcessId, kernel32, 'GetCurrentProcessId');
  3664.   asm
  3665.     mov esp, ebp
  3666.     pop ebp
  3667.     jmp [_GetCurrentProcessId]
  3668.   end;
  3669. end;
  3670. {$ELSE}
  3671. function GetCurrentProcessId; external kernel32 name 'GetCurrentProcessId';
  3672. {$ENDIF DYNAMIC_LINK}
  3673. {$IFDEF DYNAMIC_LINK}
  3674. var
  3675.   _ExitProcess: Pointer;
  3676. procedure ExitProcess;
  3677. begin
  3678.   GetProcedureAddress(_ExitProcess, kernel32, 'ExitProcess');
  3679.   asm
  3680.     mov esp, ebp
  3681.     pop ebp
  3682.     jmp [_ExitProcess]
  3683.   end;
  3684. end;
  3685. {$ELSE}
  3686. procedure ExitProcess; external kernel32 name 'ExitProcess';
  3687. {$ENDIF DYNAMIC_LINK}
  3688. {$IFDEF DYNAMIC_LINK}
  3689. var
  3690.   _TerminateProcess: Pointer;
  3691. function TerminateProcess;
  3692. begin
  3693.   GetProcedureAddress(_TerminateProcess, kernel32, 'TerminateProcess');
  3694.   asm
  3695.     mov esp, ebp
  3696.     pop ebp
  3697.     jmp [_TerminateProcess]
  3698.   end;
  3699. end;
  3700. {$ELSE}
  3701. function TerminateProcess; external kernel32 name 'TerminateProcess';
  3702. {$ENDIF DYNAMIC_LINK}
  3703. {$IFDEF DYNAMIC_LINK}
  3704. var
  3705.   _GetExitCodeProcess: Pointer;
  3706. function GetExitCodeProcess;
  3707. begin
  3708.   GetProcedureAddress(_GetExitCodeProcess, kernel32, 'GetExitCodeProcess');
  3709.   asm
  3710.     mov esp, ebp
  3711.     pop ebp
  3712.     jmp [_GetExitCodeProcess]
  3713.   end;
  3714. end;
  3715. {$ELSE}
  3716. function GetExitCodeProcess; external kernel32 name 'GetExitCodeProcess';
  3717. {$ENDIF DYNAMIC_LINK}
  3718. {$IFDEF DYNAMIC_LINK}
  3719. var
  3720.   _FatalExit: Pointer;
  3721. procedure FatalExit;
  3722. begin
  3723.   GetProcedureAddress(_FatalExit, kernel32, 'FatalExit');
  3724.   asm
  3725.     mov esp, ebp
  3726.     pop ebp
  3727.     jmp [_FatalExit]
  3728.   end;
  3729. end;
  3730. {$ELSE}
  3731. procedure FatalExit; external kernel32 name 'FatalExit';
  3732. {$ENDIF DYNAMIC_LINK}
  3733. {$IFNDEF UNICODE}
  3734. {$IFDEF DYNAMIC_LINK}
  3735. var
  3736.   _GetEnvironmentStrings: Pointer;
  3737. function GetEnvironmentStrings;
  3738. begin
  3739.   GetProcedureAddress(_GetEnvironmentStrings, kernel32, 'GetEnvironmentStringsA');
  3740.   asm
  3741.     mov esp, ebp
  3742.     pop ebp
  3743.     jmp [_GetEnvironmentStrings]
  3744.   end;
  3745. end;
  3746. {$ELSE}
  3747. function GetEnvironmentStrings; external kernel32 name 'GetEnvironmentStringsA';
  3748. {$ENDIF DYNAMIC_LINK}
  3749. {$ENDIF}
  3750. {$IFDEF DYNAMIC_LINK}
  3751. var
  3752.   _GetEnvironmentStringsW: Pointer;
  3753. function GetEnvironmentStringsW;
  3754. begin
  3755.   GetProcedureAddress(_GetEnvironmentStringsW, kernel32, 'GetEnvironmentStringsW');
  3756.   asm
  3757.     mov esp, ebp
  3758.     pop ebp
  3759.     jmp [_GetEnvironmentStringsW]
  3760.   end;
  3761. end;
  3762. {$ELSE}
  3763. function GetEnvironmentStringsW; external kernel32 name 'GetEnvironmentStringsW';
  3764. {$ENDIF DYNAMIC_LINK}
  3765. {$IFDEF UNICODE}
  3766. {$IFDEF DYNAMIC_LINK}
  3767. var
  3768.   _GetEnvironmentStrings: Pointer;
  3769. function GetEnvironmentStrings;
  3770. begin
  3771.   GetProcedureAddress(_GetEnvironmentStrings, kernel32, 'GetEnvironmentStringsW');
  3772.   asm
  3773.     mov esp, ebp
  3774.     pop ebp
  3775.     jmp [_GetEnvironmentStrings]
  3776.   end;
  3777. end;
  3778. {$ELSE}
  3779. function GetEnvironmentStrings; external kernel32 name 'GetEnvironmentStringsW';
  3780. {$ENDIF DYNAMIC_LINK}
  3781. {$ELSE}
  3782. {$IFDEF DYNAMIC_LINK}
  3783. var
  3784.   _GetEnvironmentStringsA: Pointer;
  3785. function GetEnvironmentStringsA;
  3786. begin
  3787.   GetProcedureAddress(_GetEnvironmentStringsA, kernel32, 'GetEnvironmentStringsA');
  3788.   asm
  3789.     mov esp, ebp
  3790.     pop ebp
  3791.     jmp [_GetEnvironmentStringsA]
  3792.   end;
  3793. end;
  3794. {$ELSE}
  3795. function GetEnvironmentStringsA; external kernel32 name 'GetEnvironmentStringsA';
  3796. {$ENDIF DYNAMIC_LINK}
  3797. {$ENDIF}
  3798. {$IFDEF DYNAMIC_LINK}
  3799. var
  3800.   _FreeEnvironmentStringsA: Pointer;
  3801. function FreeEnvironmentStringsA;
  3802. begin
  3803.   GetProcedureAddress(_FreeEnvironmentStringsA, kernel32, 'FreeEnvironmentStringsA');
  3804.   asm
  3805.     mov esp, ebp
  3806.     pop ebp
  3807.     jmp [_FreeEnvironmentStringsA]
  3808.   end;
  3809. end;
  3810. {$ELSE}
  3811. function FreeEnvironmentStringsA; external kernel32 name 'FreeEnvironmentStringsA';
  3812. {$ENDIF DYNAMIC_LINK}
  3813. {$IFDEF DYNAMIC_LINK}
  3814. var
  3815.   _FreeEnvironmentStringsW: Pointer;
  3816. function FreeEnvironmentStringsW;
  3817. begin
  3818.   GetProcedureAddress(_FreeEnvironmentStringsW, kernel32, 'FreeEnvironmentStringsW');
  3819.   asm
  3820.     mov esp, ebp
  3821.     pop ebp
  3822.     jmp [_FreeEnvironmentStringsW]
  3823.   end;
  3824. end;
  3825. {$ELSE}
  3826. function FreeEnvironmentStringsW; external kernel32 name 'FreeEnvironmentStringsW';
  3827. {$ENDIF DYNAMIC_LINK}
  3828. {$IFDEF UNICODE}
  3829. {$IFDEF DYNAMIC_LINK}
  3830. var
  3831.   _FreeEnvironmentStrings: Pointer;
  3832. function FreeEnvironmentStrings;
  3833. begin
  3834.   GetProcedureAddress(_FreeEnvironmentStrings, kernel32, 'FreeEnvironmentStringsW');
  3835.   asm
  3836.     mov esp, ebp
  3837.     pop ebp
  3838.     jmp [_FreeEnvironmentStrings]
  3839.   end;
  3840. end;
  3841. {$ELSE}
  3842. function FreeEnvironmentStrings; external kernel32 name 'FreeEnvironmentStringsW';
  3843. {$ENDIF DYNAMIC_LINK}
  3844. {$ELSE}
  3845. {$IFDEF DYNAMIC_LINK}
  3846. var
  3847.   _FreeEnvironmentStrings: Pointer;
  3848. function FreeEnvironmentStrings;
  3849. begin
  3850.   GetProcedureAddress(_FreeEnvironmentStrings, kernel32, 'FreeEnvironmentStringsA');
  3851.   asm
  3852.     mov esp, ebp
  3853.     pop ebp
  3854.     jmp [_FreeEnvironmentStrings]
  3855.   end;
  3856. end;
  3857. {$ELSE}
  3858. function FreeEnvironmentStrings; external kernel32 name 'FreeEnvironmentStringsA';
  3859. {$ENDIF DYNAMIC_LINK}
  3860. {$ENDIF}
  3861. {$IFDEF DYNAMIC_LINK}
  3862. var
  3863.   _RaiseException: Pointer;
  3864. procedure RaiseException;
  3865. begin
  3866.   GetProcedureAddress(_RaiseException, kernel32, 'RaiseException');
  3867.   asm
  3868.     mov esp, ebp
  3869.     pop ebp
  3870.     jmp [_RaiseException]
  3871.   end;
  3872. end;
  3873. {$ELSE}
  3874. procedure RaiseException; external kernel32 name 'RaiseException';
  3875. {$ENDIF DYNAMIC_LINK}
  3876. {$IFDEF DYNAMIC_LINK}
  3877. var
  3878.   _UnhandledExceptionFilter: Pointer;
  3879. function UnhandledExceptionFilter;
  3880. begin
  3881.   GetProcedureAddress(_UnhandledExceptionFilter, kernel32, 'UnhandledExceptionFilter');
  3882.   asm
  3883.     mov esp, ebp
  3884.     pop ebp
  3885.     jmp [_UnhandledExceptionFilter]
  3886.   end;
  3887. end;
  3888. {$ELSE}
  3889. function UnhandledExceptionFilter; external kernel32 name 'UnhandledExceptionFilter';
  3890. {$ENDIF DYNAMIC_LINK}
  3891. {$IFDEF DYNAMIC_LINK}
  3892. var
  3893.   _SetUnhandledExceptionFilter: Pointer;
  3894. function SetUnhandledExceptionFilter;
  3895. begin
  3896.   GetProcedureAddress(_SetUnhandledExceptionFilter, kernel32, 'SetUnhandledExceptionFilter');
  3897.   asm
  3898.     mov esp, ebp
  3899.     pop ebp
  3900.     jmp [_SetUnhandledExceptionFilter]
  3901.   end;
  3902. end;
  3903. {$ELSE}
  3904. function SetUnhandledExceptionFilter; external kernel32 name 'SetUnhandledExceptionFilter';
  3905. {$ENDIF DYNAMIC_LINK}
  3906. {$IFDEF DYNAMIC_LINK}
  3907. var
  3908.   _CreateFiber: Pointer;
  3909. function CreateFiber;
  3910. begin
  3911.   GetProcedureAddress(_CreateFiber, kernel32, 'CreateFiber');
  3912.   asm
  3913.     mov esp, ebp
  3914.     pop ebp
  3915.     jmp [_CreateFiber]