jwapsapi.pas 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. {******************************************************************************}
  2. { }
  3. { Process Status API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: psapi.h, released June 2000. The original Pascal }
  9. { code is: PsApi.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. // $Id: JwaPsApi.pas,v 1.10 2005/09/06 16:36:50 marquardt Exp $
  43. unit JwaPsApi;
  44. {$WEAKPACKAGEUNIT}
  45. {$HPPEMIT ''}
  46. {$HPPEMIT '#include <psapi.h>'}
  47. {$HPPEMIT ''}
  48. {$I jediapilib.inc}
  49. interface
  50. uses
  51. JwaWindows;
  52. function EnumProcesses(lpidProcess: LPDWORD; cb: DWORD; var cbNeeded: DWORD): BOOL; stdcall;
  53. {$EXTERNALSYM EnumProcesses}
  54. function EnumProcessModules(hProcess: HANDLE; lphModule: PHMODULE; cb: DWORD;
  55. var lpcbNeeded: DWORD): BOOL; stdcall;
  56. {$EXTERNALSYM EnumProcessModules}
  57. function GetModuleBaseNameA(hProcess: HANDLE; hModule: HMODULE; lpBaseName: LPSTR;
  58. nSize: DWORD): DWORD; stdcall;
  59. {$EXTERNALSYM GetModuleBaseNameA}
  60. function GetModuleBaseNameW(hProcess: HANDLE; hModule: HMODULE; lpBaseName: LPWSTR;
  61. nSize: DWORD): DWORD; stdcall;
  62. {$EXTERNALSYM GetModuleBaseNameW}
  63. function GetModuleBaseName(hProcess: HANDLE; hModule: HMODULE; lpBaseName: LPTSTR;
  64. nSize: DWORD): DWORD; stdcall;
  65. {$EXTERNALSYM GetModuleBaseName}
  66. function GetModuleFileNameExA(hProcess: HANDLE; hModule: HMODULE; lpFilename: LPSTR;
  67. nSize: DWORD): DWORD; stdcall;
  68. {$EXTERNALSYM GetModuleFileNameExA}
  69. function GetModuleFileNameExW(hProcess: HANDLE; hModule: HMODULE; lpFilename: LPWSTR;
  70. nSize: DWORD): DWORD; stdcall;
  71. {$EXTERNALSYM GetModuleFileNameExW}
  72. function GetModuleFileNameEx(hProcess: HANDLE; hModule: HMODULE; lpFilename: LPTSTR;
  73. nSize: DWORD): DWORD; stdcall;
  74. {$EXTERNALSYM GetModuleFileNameEx}
  75. type
  76. LPMODULEINFO = ^MODULEINFO;
  77. {$EXTERNALSYM LPMODULEINFO}
  78. _MODULEINFO = packed record
  79. lpBaseOfDll: LPVOID;
  80. SizeOfImage: DWORD;
  81. EntryPoint: LPVOID;
  82. end;
  83. {$EXTERNALSYM _MODULEINFO}
  84. MODULEINFO = _MODULEINFO;
  85. {$EXTERNALSYM MODULEINFO}
  86. TModuleInfo = MODULEINFO;
  87. PModuleInfo = LPMODULEINFO;
  88. function GetModuleInformation(hProcess: HANDLE; hModule: HMODULE;
  89. var lpmodinfo: MODULEINFO; cb: DWORD): BOOL; stdcall;
  90. {$EXTERNALSYM GetModuleInformation}
  91. function EmptyWorkingSet(hProcess: HANDLE): BOOL; stdcall;
  92. {$EXTERNALSYM EmptyWorkingSet}
  93. function QueryWorkingSet(hProcess: HANDLE; pv: PVOID; cb: DWORD): BOOL; stdcall;
  94. {$EXTERNALSYM QueryWorkingSet}
  95. function InitializeProcessForWsWatch(hProcess: HANDLE): BOOL; stdcall;
  96. {$EXTERNALSYM InitializeProcessForWsWatch}
  97. type
  98. PPSAPI_WS_WATCH_INFORMATION = ^PSAPI_WS_WATCH_INFORMATION;
  99. {$EXTERNALSYM PPSAPI_WS_WATCH_INFORMATION}
  100. _PSAPI_WS_WATCH_INFORMATION = packed record
  101. FaultingPc: LPVOID;
  102. FaultingVa: LPVOID;
  103. end;
  104. {$EXTERNALSYM _PSAPI_WS_WATCH_INFORMATION}
  105. PSAPI_WS_WATCH_INFORMATION = _PSAPI_WS_WATCH_INFORMATION;
  106. {$EXTERNALSYM PSAPI_WS_WATCH_INFORMATION}
  107. TPsApiWsWatchInformation = PSAPI_WS_WATCH_INFORMATION;
  108. PPsApiWsWatchInformation = PPSAPI_WS_WATCH_INFORMATION;
  109. function GetWsChanges(hProcess: HANDLE; var lpWatchInfo: PSAPI_WS_WATCH_INFORMATION;
  110. cb: DWORD): BOOL; stdcall;
  111. {$EXTERNALSYM GetWsChanges}
  112. function GetMappedFileNameW(hProcess: HANDLE; lpv: LPVOID; lpFilename: LPWSTR;
  113. nSize: DWORD): DWORD; stdcall;
  114. {$EXTERNALSYM GetMappedFileNameW}
  115. function GetMappedFileNameA(hProcess: HANDLE; lpv: LPVOID; lpFilename: LPSTR;
  116. nSize: DWORD): DWORD; stdcall;
  117. {$EXTERNALSYM GetMappedFileNameA}
  118. function GetMappedFileName(hProcess: HANDLE; lpv: LPVOID; lpFilename: LPTSTR;
  119. nSize: DWORD): DWORD; stdcall;
  120. {$EXTERNALSYM GetMappedFileName}
  121. function EnumDeviceDrivers(lpImageBase: LPLPVOID; cb: DWORD; var lpcbNeeded: DWORD): BOOL; stdcall;
  122. {$EXTERNALSYM EnumDeviceDrivers}
  123. function GetDeviceDriverBaseNameA(ImageBase: LPVOID; lpBaseName: LPSTR;
  124. nSize: DWORD): DWORD; stdcall;
  125. {$EXTERNALSYM GetDeviceDriverBaseNameA}
  126. function GetDeviceDriverBaseNameW(ImageBase: LPVOID; lpBaseName: LPWSTR;
  127. nSize: DWORD): DWORD; stdcall;
  128. {$EXTERNALSYM GetDeviceDriverBaseNameW}
  129. function GetDeviceDriverBaseName(ImageBase: LPVOID; lpBaseName: LPTSTR;
  130. nSize: DWORD): DWORD; stdcall;
  131. {$EXTERNALSYM GetDeviceDriverBaseName}
  132. function GetDeviceDriverFileNameA(ImageBase: LPVOID; lpFilename: LPSTR;
  133. nSize: DWORD): DWORD; stdcall;
  134. {$EXTERNALSYM GetDeviceDriverFileNameA}
  135. function GetDeviceDriverFileNameW(ImageBase: LPVOID; lpFilename: LPWSTR;
  136. nSize: DWORD): DWORD; stdcall;
  137. {$EXTERNALSYM GetDeviceDriverFileNameW}
  138. function GetDeviceDriverFileName(ImageBase: LPVOID; lpFilename: LPTSTR;
  139. nSize: DWORD): DWORD; stdcall;
  140. {$EXTERNALSYM GetDeviceDriverFileName}
  141. // Structure for GetProcessMemoryInfo()
  142. type
  143. PPROCESS_MEMORY_COUNTERS = ^PROCESS_MEMORY_COUNTERS;
  144. {$EXTERNALSYM PPROCESS_MEMORY_COUNTERS}
  145. _PROCESS_MEMORY_COUNTERS = packed record
  146. cb: DWORD;
  147. PageFaultCount: DWORD;
  148. PeakWorkingSetSize: SIZE_T;
  149. WorkingSetSize: SIZE_T;
  150. QuotaPeakPagedPoolUsage: SIZE_T;
  151. QuotaPagedPoolUsage: SIZE_T;
  152. QuotaPeakNonPagedPoolUsage: SIZE_T;
  153. QuotaNonPagedPoolUsage: SIZE_T;
  154. PagefileUsage: SIZE_T;
  155. PeakPagefileUsage: SIZE_T;
  156. end;
  157. {$EXTERNALSYM _PROCESS_MEMORY_COUNTERS}
  158. PROCESS_MEMORY_COUNTERS = _PROCESS_MEMORY_COUNTERS;
  159. {$EXTERNALSYM PROCESS_MEMORY_COUNTERS}
  160. TProcessMemoryCounters = PROCESS_MEMORY_COUNTERS;
  161. PProcessMemoryCounters = PPROCESS_MEMORY_COUNTERS;
  162. _PROCESS_MEMORY_COUNTERS_EX = record
  163. cb: DWORD;
  164. PageFaultCount: DWORD;
  165. PeakWorkingSetSize: SIZE_T;
  166. WorkingSetSize: SIZE_T;
  167. QuotaPeakPagedPoolUsage: SIZE_T;
  168. QuotaPagedPoolUsage: SIZE_T;
  169. QuotaPeakNonPagedPoolUsage: SIZE_T;
  170. QuotaNonPagedPoolUsage: SIZE_T;
  171. PagefileUsage: SIZE_T;
  172. PeakPagefileUsage: SIZE_T;
  173. PrivateUsage: SIZE_T;
  174. end;
  175. {$EXTERNALSYM _PROCESS_MEMORY_COUNTERS_EX}
  176. PROCESS_MEMORY_COUNTERS_EX = _PROCESS_MEMORY_COUNTERS_EX;
  177. {$EXTERNALSYM PROCESS_MEMORY_COUNTERS_EX}
  178. PPROCESS_MEMORY_COUNTERS_EX = ^PROCESS_MEMORY_COUNTERS_EX;
  179. {$EXTERNALSYM PPROCESS_MEMORY_COUNTERS_EX}
  180. TProcessMemoryCountersEx = PROCESS_MEMORY_COUNTERS_EX;
  181. function GetProcessMemoryInfo(Process: HANDLE;
  182. var ppsmemCounters: PROCESS_MEMORY_COUNTERS; cb: DWORD): BOOL; stdcall;
  183. {$EXTERNALSYM GetProcessMemoryInfo}
  184. type
  185. _PERFORMANCE_INFORMATION = record
  186. cb: DWORD;
  187. CommitTotal: SIZE_T;
  188. CommitLimit: SIZE_T;
  189. CommitPeak: SIZE_T;
  190. PhysicalTotal: SIZE_T;
  191. PhysicalAvailable: SIZE_T;
  192. SystemCache: SIZE_T;
  193. KernelTotal: SIZE_T;
  194. KernelPaged: SIZE_T;
  195. KernelNonpaged: SIZE_T;
  196. PageSize: SIZE_T;
  197. HandleCount: DWORD;
  198. ProcessCount: DWORD;
  199. ThreadCount: DWORD;
  200. end;
  201. {$EXTERNALSYM _PERFORMANCE_INFORMATION}
  202. PERFORMANCE_INFORMATION = _PERFORMANCE_INFORMATION;
  203. {$EXTERNALSYM PERFORMANCE_INFORMATION}
  204. PPERFORMANCE_INFORMATION = ^PERFORMANCE_INFORMATION;
  205. {$EXTERNALSYM PPERFORMANCE_INFORMATION}
  206. TPerformanceInformation = PERFORMANCE_INFORMATION;
  207. PPerformanceInformation = PPERFORMANCE_INFORMATION;
  208. { MVB:
  209. Please note that this function, unlike what the Platform SDK documents, is _not_ available for Windows 2000!!!
  210. It is available starting with Windows XP and Windows.NET Server.
  211. If needed, you can relatively easily clone the functionality of this function by using the performance monitor
  212. API (either through the HKEY_PERFORMANCE_DATA registry interface or using the Performance Data Helper API)
  213. }
  214. function GetPerformanceInfo(pPerformanceInformation: PPERFORMANCE_INFORMATION;
  215. cb: DWORD): BOOL; stdcall;
  216. {$EXTERNALSYM GetPerformanceInfo}
  217. type
  218. _ENUM_PAGE_FILE_INFORMATION = record
  219. cb: DWORD;
  220. Reserved: DWORD;
  221. TotalSize: SIZE_T;
  222. TotalInUse: SIZE_T;
  223. PeakUsage: SIZE_T;
  224. end;
  225. {$EXTERNALSYM _ENUM_PAGE_FILE_INFORMATION}
  226. ENUM_PAGE_FILE_INFORMATION = _ENUM_PAGE_FILE_INFORMATION;
  227. {$EXTERNALSYM ENUM_PAGE_FILE_INFORMATION}
  228. PENUM_PAGE_FILE_INFORMATION = ^ENUM_PAGE_FILE_INFORMATION;
  229. TEnumPageFileInformation = ENUM_PAGE_FILE_INFORMATION;
  230. PEnumPageFileInformation = PENUM_PAGE_FILE_INFORMATION;
  231. type
  232. PENUM_PAGE_FILE_CALLBACKW = function(pContext: LPVOID;
  233. pPageFileInfo: PENUM_PAGE_FILE_INFORMATION; lpFilename: LPCWSTR): BOOL; stdcall;
  234. {$EXTERNALSYM PENUM_PAGE_FILE_CALLBACKW}
  235. PENUM_PAGE_FILE_CALLBACKA = function(pContext: LPVOID;
  236. pPageFileInfo: PENUM_PAGE_FILE_INFORMATION; lpFilename: LPCSTR): BOOL; stdcall;
  237. {$EXTERNALSYM PENUM_PAGE_FILE_CALLBACKA}
  238. {$IFDEF UNICODE}
  239. PENUM_PAGE_FILE_CALLBACK = PENUM_PAGE_FILE_CALLBACKW;
  240. {$EXTERNALSYM PENUM_PAGE_FILE_CALLBACK}
  241. {$ELSE}
  242. PENUM_PAGE_FILE_CALLBACK = PENUM_PAGE_FILE_CALLBACKA;
  243. {$EXTERNALSYM PENUM_PAGE_FILE_CALLBACK}
  244. {$ENDIF UNICODE}
  245. function EnumPageFilesW(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKW; pContext: LPVOID): BOOL; stdcall;
  246. {$EXTERNALSYM EnumPageFilesW}
  247. function EnumPageFilesA(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACKA; pContext: LPVOID): BOOL; stdcall;
  248. {$EXTERNALSYM EnumPageFilesA}
  249. function EnumPageFiles(pCallBackRoutine: PENUM_PAGE_FILE_CALLBACK; pContext: LPVOID): BOOL; stdcall;
  250. {$EXTERNALSYM EnumPageFiles}
  251. function GetProcessImageFileNameA(hProcess: HANDLE; lpImageFileName: LPSTR;
  252. nSize: DWORD): DWORD; stdcall;
  253. {$EXTERNALSYM GetProcessImageFileNameA}
  254. function GetProcessImageFileNameW(hProcess: HANDLE; lpImageFileName: LPWSTR;
  255. nSize: DWORD): DWORD; stdcall;
  256. {$EXTERNALSYM GetProcessImageFileNameW}
  257. function GetProcessImageFileName(hProcess: HANDLE; lpImageFileName: LPTSTR;
  258. nSize: DWORD): DWORD; stdcall;
  259. {$EXTERNALSYM GetProcessImageFileName}
  260. implementation
  261. uses
  262. JwaWinDLLNames;
  263. {$IFDEF DYNAMIC_LINK}
  264. var
  265. _EnumProcesses: Pointer;
  266. function EnumProcesses;
  267. begin
  268. GetProcedureAddress(_EnumProcesses, PsapiLib, 'EnumProcesses');
  269. asm
  270. MOV ESP, EBP
  271. POP EBP
  272. JMP [_EnumProcesses]
  273. end;
  274. end;
  275. var
  276. _EnumProcessModules: Pointer;
  277. function EnumProcessModules;
  278. begin
  279. GetProcedureAddress(_EnumProcessModules, PsapiLib, 'EnumProcessModules');
  280. asm
  281. MOV ESP, EBP
  282. POP EBP
  283. JMP [_EnumProcessModules]
  284. end;
  285. end;
  286. var
  287. _GetModuleBaseNameA: Pointer;
  288. function GetModuleBaseNameA;
  289. begin
  290. GetProcedureAddress(_GetModuleBaseNameA, PsapiLib, 'GetModuleBaseNameA');
  291. asm
  292. MOV ESP, EBP
  293. POP EBP
  294. JMP [_GetModuleBaseNameA]
  295. end;
  296. end;
  297. var
  298. _GetModuleBaseNameW: Pointer;
  299. function GetModuleBaseNameW;
  300. begin
  301. GetProcedureAddress(_GetModuleBaseNameW, PsapiLib, 'GetModuleBaseNameW');
  302. asm
  303. MOV ESP, EBP
  304. POP EBP
  305. JMP [_GetModuleBaseNameW]
  306. end;
  307. end;
  308. var
  309. _GetModuleBaseName: Pointer;
  310. function GetModuleBaseName;
  311. begin
  312. GetProcedureAddress(_GetModuleBaseName, PsapiLib, 'GetModuleBaseName' + AWSuffix);
  313. asm
  314. MOV ESP, EBP
  315. POP EBP
  316. JMP [_GetModuleBaseName]
  317. end;
  318. end;
  319. var
  320. _GetModuleFileNameExA: Pointer;
  321. function GetModuleFileNameExA;
  322. begin
  323. GetProcedureAddress(_GetModuleFileNameExA, PsapiLib, 'GetModuleFileNameExA');
  324. asm
  325. MOV ESP, EBP
  326. POP EBP
  327. JMP [_GetModuleFileNameExA]
  328. end;
  329. end;
  330. var
  331. _GetModuleFileNameExW: Pointer;
  332. function GetModuleFileNameExW;
  333. begin
  334. GetProcedureAddress(_GetModuleFileNameExW, PsapiLib, 'GetModuleFileNameExW');
  335. asm
  336. MOV ESP, EBP
  337. POP EBP
  338. JMP [_GetModuleFileNameExW]
  339. end;
  340. end;
  341. var
  342. _GetModuleFileNameEx: Pointer;
  343. function GetModuleFileNameEx;
  344. begin
  345. GetProcedureAddress(_GetModuleFileNameEx, PsapiLib, 'GetModuleFileNameEx' + AWSuffix);
  346. asm
  347. MOV ESP, EBP
  348. POP EBP
  349. JMP [_GetModuleFileNameEx]
  350. end;
  351. end;
  352. var
  353. _GetModuleInformation: Pointer;
  354. function GetModuleInformation;
  355. begin
  356. GetProcedureAddress(_GetModuleInformation, PsapiLib, 'GetModuleInformation');
  357. asm
  358. MOV ESP, EBP
  359. POP EBP
  360. JMP [_GetModuleInformation]
  361. end;
  362. end;
  363. var
  364. _EmptyWorkingSet: Pointer;
  365. function EmptyWorkingSet;
  366. begin
  367. GetProcedureAddress(_EmptyWorkingSet, PsapiLib, 'EmptyWorkingSet');
  368. asm
  369. MOV ESP, EBP
  370. POP EBP
  371. JMP [_EmptyWorkingSet]
  372. end;
  373. end;
  374. var
  375. _QueryWorkingSet: Pointer;
  376. function QueryWorkingSet;
  377. begin
  378. GetProcedureAddress(_QueryWorkingSet, PsapiLib, 'QueryWorkingSet');
  379. asm
  380. MOV ESP, EBP
  381. POP EBP
  382. JMP [_QueryWorkingSet]
  383. end;
  384. end;
  385. var
  386. _InitializeProcessForWsWatch: Pointer;
  387. function InitializeProcessForWsWatch;
  388. begin
  389. GetProcedureAddress(_InitializeProcessForWsWatch, PsapiLib, 'InitializeProcessForWsWatch');
  390. asm
  391. MOV ESP, EBP
  392. POP EBP
  393. JMP [_InitializeProcessForWsWatch]
  394. end;
  395. end;
  396. var
  397. _GetWsChanges: Pointer;
  398. function GetWsChanges;
  399. begin
  400. GetProcedureAddress(_GetWsChanges, PsapiLib, 'GetWsChanges');
  401. asm
  402. MOV ESP, EBP
  403. POP EBP
  404. JMP [_GetWsChanges]
  405. end;
  406. end;
  407. var
  408. _GetMappedFileNameW: Pointer;
  409. function GetMappedFileNameW;
  410. begin
  411. GetProcedureAddress(_GetMappedFileNameW, PsapiLib, 'GetMappedFileNameW');
  412. asm
  413. MOV ESP, EBP
  414. POP EBP
  415. JMP [_GetMappedFileNameW]
  416. end;
  417. end;
  418. var
  419. _GetMappedFileNameA: Pointer;
  420. function GetMappedFileNameA;
  421. begin
  422. GetProcedureAddress(_GetMappedFileNameA, PsapiLib, 'GetMappedFileNameA');
  423. asm
  424. MOV ESP, EBP
  425. POP EBP
  426. JMP [_GetMappedFileNameA]
  427. end;
  428. end;
  429. var
  430. _GetMappedFileName: Pointer;
  431. function GetMappedFileName;
  432. begin
  433. GetProcedureAddress(_GetMappedFileName, PsapiLib, 'GetMappedFileName' + AWSuffix);
  434. asm
  435. MOV ESP, EBP
  436. POP EBP
  437. JMP [_GetMappedFileName]
  438. end;
  439. end;
  440. var
  441. _EnumDeviceDrivers: Pointer;
  442. function EnumDeviceDrivers;
  443. begin
  444. GetProcedureAddress(_EnumDeviceDrivers, PsapiLib, 'EnumDeviceDrivers');
  445. asm
  446. MOV ESP, EBP
  447. POP EBP
  448. JMP [_EnumDeviceDrivers]
  449. end;
  450. end;
  451. var
  452. _GetDeviceDriverBaseNameA: Pointer;
  453. function GetDeviceDriverBaseNameA;
  454. begin
  455. GetProcedureAddress(_GetDeviceDriverBaseNameA, PsapiLib, 'GetDeviceDriverBaseNameA');
  456. asm
  457. MOV ESP, EBP
  458. POP EBP
  459. JMP [_GetDeviceDriverBaseNameA]
  460. end;
  461. end;
  462. var
  463. _GetDeviceDriverBaseNameW: Pointer;
  464. function GetDeviceDriverBaseNameW;
  465. begin
  466. GetProcedureAddress(_GetDeviceDriverBaseNameW, PsapiLib, 'GetDeviceDriverBaseNameW');
  467. asm
  468. MOV ESP, EBP
  469. POP EBP
  470. JMP [_GetDeviceDriverBaseNameW]
  471. end;
  472. end;
  473. var
  474. _GetDeviceDriverBaseName: Pointer;
  475. function GetDeviceDriverBaseName;
  476. begin
  477. GetProcedureAddress(_GetDeviceDriverBaseName, PsapiLib, 'GetDeviceDriverBaseName' + AWSuffix);
  478. asm
  479. MOV ESP, EBP
  480. POP EBP
  481. JMP [_GetDeviceDriverBaseName]
  482. end;
  483. end;
  484. var
  485. _GetDeviceDriverFileNameA: Pointer;
  486. function GetDeviceDriverFileNameA;
  487. begin
  488. GetProcedureAddress(_GetDeviceDriverFileNameA, PsapiLib, 'GetDeviceDriverFileNameA');
  489. asm
  490. MOV ESP, EBP
  491. POP EBP
  492. JMP [_GetDeviceDriverFileNameA]
  493. end;
  494. end;
  495. var
  496. _GetDeviceDriverFileNameW: Pointer;
  497. function GetDeviceDriverFileNameW;
  498. begin
  499. GetProcedureAddress(_GetDeviceDriverFileNameW, PsapiLib, 'GetDeviceDriverFileNameW');
  500. asm
  501. MOV ESP, EBP
  502. POP EBP
  503. JMP [_GetDeviceDriverFileNameW]
  504. end;
  505. end;
  506. var
  507. _GetDeviceDriverFileName: Pointer;
  508. function GetDeviceDriverFileName;
  509. begin
  510. GetProcedureAddress(_GetDeviceDriverFileName, PsapiLib, 'GetDeviceDriverFileName' + AWSuffix);
  511. asm
  512. MOV ESP, EBP
  513. POP EBP
  514. JMP [_GetDeviceDriverFileName]
  515. end;
  516. end;
  517. var
  518. _GetProcessMemoryInfo: Pointer;
  519. function GetProcessMemoryInfo;
  520. begin
  521. GetProcedureAddress(_GetProcessMemoryInfo, PsapiLib, 'GetProcessMemoryInfo');
  522. asm
  523. MOV ESP, EBP
  524. POP EBP
  525. JMP [_GetProcessMemoryInfo]
  526. end;
  527. end;
  528. var
  529. _GetPerformanceInfo: Pointer;
  530. function GetPerformanceInfo;
  531. begin
  532. GetProcedureAddress(_GetPerformanceInfo, PsapiLib, 'GetPerformanceInfo');
  533. asm
  534. MOV ESP, EBP
  535. POP EBP
  536. JMP [_GetPerformanceInfo]
  537. end;
  538. end;
  539. var
  540. _EnumPageFilesW: Pointer;
  541. function EnumPageFilesW;
  542. begin
  543. GetProcedureAddress(_EnumPageFilesW, PsapiLib, 'EnumPageFilesA');
  544. asm
  545. MOV ESP, EBP
  546. POP EBP
  547. JMP [_EnumPageFilesW]
  548. end;
  549. end;
  550. var
  551. _EnumPageFilesA: Pointer;
  552. function EnumPageFilesA;
  553. begin
  554. GetProcedureAddress(_EnumPageFilesA, PsapiLib, 'EnumPageFilesW');
  555. asm
  556. MOV ESP, EBP
  557. POP EBP
  558. JMP [_EnumPageFilesA]
  559. end;
  560. end;
  561. var
  562. _EnumPageFiles: Pointer;
  563. function EnumPageFiles;
  564. begin
  565. GetProcedureAddress(_EnumPageFiles, PsapiLib, 'EnumPageFiles' + AWSuffix);
  566. asm
  567. MOV ESP, EBP
  568. POP EBP
  569. JMP [_EnumPageFiles]
  570. end;
  571. end;
  572. var
  573. _GetProcessImageFileNameA: Pointer;
  574. function GetProcessImageFileNameA;
  575. begin
  576. GetProcedureAddress(_GetProcessImageFileNameA, PsapiLib, 'GetProcessImageFileNameA');
  577. asm
  578. MOV ESP, EBP
  579. POP EBP
  580. JMP [_GetProcessImageFileNameA]
  581. end;
  582. end;
  583. var
  584. _GetProcessImageFileNameW: Pointer;
  585. function GetProcessImageFileNameW;
  586. begin
  587. GetProcedureAddress(_GetProcessImageFileNameW, PsapiLib, 'GetProcessImageFileNameW');
  588. asm
  589. MOV ESP, EBP
  590. POP EBP
  591. JMP [_GetProcessImageFileNameW]
  592. end;
  593. end;
  594. var
  595. _GetProcessImageFileName: Pointer;
  596. function GetProcessImageFileName;
  597. begin
  598. GetProcedureAddress(_GetProcessImageFileName, PsapiLib, 'GetProcessImageFileName' + AWSuffix);
  599. asm
  600. MOV ESP, EBP
  601. POP EBP
  602. JMP [_GetProcessImageFileName]
  603. end;
  604. end;
  605. {$ELSE}
  606. function EnumProcesses; external PsapiLib name 'EnumProcesses';
  607. function EnumProcessModules; external PsapiLib name 'EnumProcessModules';
  608. function GetModuleBaseNameA; external PsapiLib name 'GetModuleBaseNameA';
  609. function GetModuleBaseNameW; external PsapiLib name 'GetModuleBaseNameW';
  610. function GetModuleBaseName; external PsapiLib name 'GetModuleBaseName' + AWSuffix;
  611. function GetModuleFileNameExA; external PsapiLib name 'GetModuleFileNameExA';
  612. function GetModuleFileNameExW; external PsapiLib name 'GetModuleFileNameExW';
  613. function GetModuleFileNameEx; external PsapiLib name 'GetModuleFileNameEx' + AWSuffix;
  614. function GetModuleInformation; external PsapiLib name 'GetModuleInformation';
  615. function EmptyWorkingSet; external PsapiLib name 'EmptyWorkingSet';
  616. function QueryWorkingSet; external PsapiLib name 'QueryWorkingSet';
  617. function InitializeProcessForWsWatch; external PsapiLib name 'InitializeProcessForWsWatch';
  618. function GetWsChanges; external PsapiLib name 'GetWsChanges';
  619. function GetMappedFileNameW; external PsapiLib name 'GetMappedFileNameW';
  620. function GetMappedFileNameA; external PsapiLib name 'GetMappedFileNameA';
  621. function GetMappedFileName; external PsapiLib name 'GetMappedFileName' + AWSuffix;
  622. function EnumDeviceDrivers; external PsapiLib name 'EnumDeviceDrivers';
  623. function GetDeviceDriverBaseNameA; external PsapiLib name 'GetDeviceDriverBaseNameA';
  624. function GetDeviceDriverBaseNameW; external PsapiLib name 'GetDeviceDriverBaseNameW';
  625. function GetDeviceDriverBaseName; external PsapiLib name 'GetDeviceDriverBaseName' + AWSuffix;
  626. function GetDeviceDriverFileNameA; external PsapiLib name 'GetDeviceDriverFileNameA';
  627. function GetDeviceDriverFileNameW; external PsapiLib name 'GetDeviceDriverFileNameW';
  628. function GetDeviceDriverFileName; external PsapiLib name 'GetDeviceDriverFileName' + AWSuffix;
  629. function GetProcessMemoryInfo; external PsapiLib name 'GetProcessMemoryInfo';
  630. function GetPerformanceInfo; external PsapiLib name 'GetPerformanceInfo';
  631. function EnumPageFilesW; external PsapiLib name 'EnumPageFilesA';
  632. function EnumPageFilesA; external PsapiLib name 'EnumPageFilesW';
  633. function EnumPageFiles; external PsapiLib name 'EnumPageFiles' + AWSuffix;
  634. function GetProcessImageFileNameA; external PsapiLib name 'GetProcessImageFileNameA';
  635. function GetProcessImageFileNameW; external PsapiLib name 'GetProcessImageFileNameW';
  636. function GetProcessImageFileName; external PsapiLib name 'GetProcessImageFileName' + AWSuffix;
  637. {$ENDIF DYNAMIC_LINK}
  638. end.