jwapsapi.pas 22 KB

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