Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

316 lines
8.6 KiB

  1. /*****************************************************************************\
  2. * *
  3. * tlhelp32.h - WIN32 tool help functions, types, and definitions *
  4. * *
  5. * Version 1.0 *
  6. * *
  7. * NOTE: windows.h/winbase.h must be #included first *
  8. * *
  9. * Copyright (c) Microsoft Corp. All rights reserved. *
  10. * *
  11. \*****************************************************************************/
  12. #ifndef _INC_TOOLHELP32
  13. #define _INC_TOOLHELP32
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" { /* Assume C declarations for C++ */
  19. #endif /* __cplusplus */
  20. #define MAX_MODULE_NAME32 255
  21. /****** Shapshot function **********************************************/
  22. HANDLE
  23. WINAPI
  24. CreateToolhelp32Snapshot(
  25. DWORD dwFlags,
  26. DWORD th32ProcessID
  27. );
  28. //
  29. // The th32ProcessID argument is only used if TH32CS_SNAPHEAPLIST or
  30. // TH32CS_SNAPMODULE is specified. th32ProcessID == 0 means the current
  31. // process.
  32. //
  33. // NOTE that all of the snapshots are global except for the heap and module
  34. // lists which are process specific. To enumerate the heap or module
  35. // state for all WIN32 processes call with TH32CS_SNAPALL and the
  36. // current process. Then for each process in the TH32CS_SNAPPROCESS
  37. // list that isn't the current process, do a call with just
  38. // TH32CS_SNAPHEAPLIST and/or TH32CS_SNAPMODULE.
  39. //
  40. // dwFlags
  41. //
  42. #define TH32CS_SNAPHEAPLIST 0x00000001
  43. #define TH32CS_SNAPPROCESS 0x00000002
  44. #define TH32CS_SNAPTHREAD 0x00000004
  45. #define TH32CS_SNAPMODULE 0x00000008
  46. #define TH32CS_SNAPMODULE32 0x00000010
  47. #define TH32CS_SNAPALL (TH32CS_SNAPHEAPLIST | TH32CS_SNAPPROCESS | TH32CS_SNAPTHREAD | TH32CS_SNAPMODULE)
  48. #define TH32CS_INHERIT 0x80000000
  49. //
  50. // Use CloseHandle to destroy the snapshot
  51. //
  52. /****** heap walking ***************************************************/
  53. typedef struct tagHEAPLIST32
  54. {
  55. SIZE_T dwSize;
  56. DWORD th32ProcessID; // owning process
  57. ULONG_PTR th32HeapID; // heap (in owning process's context!)
  58. DWORD dwFlags;
  59. } HEAPLIST32;
  60. typedef HEAPLIST32 * PHEAPLIST32;
  61. typedef HEAPLIST32 * LPHEAPLIST32;
  62. //
  63. // dwFlags
  64. //
  65. #define HF32_DEFAULT 1 // process's default heap
  66. #define HF32_SHARED 2 // is shared heap
  67. BOOL
  68. WINAPI
  69. Heap32ListFirst(
  70. HANDLE hSnapshot,
  71. LPHEAPLIST32 lphl
  72. );
  73. BOOL
  74. WINAPI
  75. Heap32ListNext(
  76. HANDLE hSnapshot,
  77. LPHEAPLIST32 lphl
  78. );
  79. typedef struct tagHEAPENTRY32
  80. {
  81. SIZE_T dwSize;
  82. HANDLE hHandle; // Handle of this heap block
  83. ULONG_PTR dwAddress; // Linear address of start of block
  84. SIZE_T dwBlockSize; // Size of block in bytes
  85. DWORD dwFlags;
  86. DWORD dwLockCount;
  87. DWORD dwResvd;
  88. DWORD th32ProcessID; // owning process
  89. ULONG_PTR th32HeapID; // heap block is in
  90. } HEAPENTRY32;
  91. typedef HEAPENTRY32 * PHEAPENTRY32;
  92. typedef HEAPENTRY32 * LPHEAPENTRY32;
  93. //
  94. // dwFlags
  95. //
  96. #define LF32_FIXED 0x00000001
  97. #define LF32_FREE 0x00000002
  98. #define LF32_MOVEABLE 0x00000004
  99. BOOL
  100. WINAPI
  101. Heap32First(
  102. LPHEAPENTRY32 lphe,
  103. DWORD th32ProcessID,
  104. ULONG_PTR th32HeapID
  105. );
  106. BOOL
  107. WINAPI
  108. Heap32Next(
  109. LPHEAPENTRY32 lphe
  110. );
  111. BOOL
  112. WINAPI
  113. Toolhelp32ReadProcessMemory(
  114. DWORD th32ProcessID,
  115. LPCVOID lpBaseAddress,
  116. LPVOID lpBuffer,
  117. SIZE_T cbRead,
  118. SIZE_T *lpNumberOfBytesRead
  119. );
  120. /***** Process walking *************************************************/
  121. typedef struct tagPROCESSENTRY32W
  122. {
  123. DWORD dwSize;
  124. DWORD cntUsage;
  125. DWORD th32ProcessID; // this process
  126. ULONG_PTR th32DefaultHeapID;
  127. DWORD th32ModuleID; // associated exe
  128. DWORD cntThreads;
  129. DWORD th32ParentProcessID; // this process's parent process
  130. LONG pcPriClassBase; // Base priority of process's threads
  131. DWORD dwFlags;
  132. WCHAR szExeFile[MAX_PATH]; // Path
  133. } PROCESSENTRY32W;
  134. typedef PROCESSENTRY32W * PPROCESSENTRY32W;
  135. typedef PROCESSENTRY32W * LPPROCESSENTRY32W;
  136. BOOL
  137. WINAPI
  138. Process32FirstW(
  139. HANDLE hSnapshot,
  140. LPPROCESSENTRY32W lppe
  141. );
  142. BOOL
  143. WINAPI
  144. Process32NextW(
  145. HANDLE hSnapshot,
  146. LPPROCESSENTRY32W lppe
  147. );
  148. typedef struct tagPROCESSENTRY32
  149. {
  150. DWORD dwSize;
  151. DWORD cntUsage;
  152. DWORD th32ProcessID; // this process
  153. ULONG_PTR th32DefaultHeapID;
  154. DWORD th32ModuleID; // associated exe
  155. DWORD cntThreads;
  156. DWORD th32ParentProcessID; // this process's parent process
  157. LONG pcPriClassBase; // Base priority of process's threads
  158. DWORD dwFlags;
  159. CHAR szExeFile[MAX_PATH]; // Path
  160. } PROCESSENTRY32;
  161. typedef PROCESSENTRY32 * PPROCESSENTRY32;
  162. typedef PROCESSENTRY32 * LPPROCESSENTRY32;
  163. BOOL
  164. WINAPI
  165. Process32First(
  166. HANDLE hSnapshot,
  167. LPPROCESSENTRY32 lppe
  168. );
  169. BOOL
  170. WINAPI
  171. Process32Next(
  172. HANDLE hSnapshot,
  173. LPPROCESSENTRY32 lppe
  174. );
  175. #ifdef UNICODE
  176. #define Process32First Process32FirstW
  177. #define Process32Next Process32NextW
  178. #define PROCESSENTRY32 PROCESSENTRY32W
  179. #define PPROCESSENTRY32 PPROCESSENTRY32W
  180. #define LPPROCESSENTRY32 LPPROCESSENTRY32W
  181. #endif // !UNICODE
  182. /***** Thread walking **************************************************/
  183. typedef struct tagTHREADENTRY32
  184. {
  185. DWORD dwSize;
  186. DWORD cntUsage;
  187. DWORD th32ThreadID; // this thread
  188. DWORD th32OwnerProcessID; // Process this thread is associated with
  189. LONG tpBasePri;
  190. LONG tpDeltaPri;
  191. DWORD dwFlags;
  192. } THREADENTRY32;
  193. typedef THREADENTRY32 * PTHREADENTRY32;
  194. typedef THREADENTRY32 * LPTHREADENTRY32;
  195. BOOL
  196. WINAPI
  197. Thread32First(
  198. HANDLE hSnapshot,
  199. LPTHREADENTRY32 lpte
  200. );
  201. BOOL
  202. WINAPI
  203. Thread32Next(
  204. HANDLE hSnapshot,
  205. LPTHREADENTRY32 lpte
  206. );
  207. /***** Module walking *************************************************/
  208. typedef struct tagMODULEENTRY32W
  209. {
  210. DWORD dwSize;
  211. DWORD th32ModuleID; // This module
  212. DWORD th32ProcessID; // owning process
  213. DWORD GlblcntUsage; // Global usage count on the module
  214. DWORD ProccntUsage; // Module usage count in th32ProcessID's context
  215. BYTE * modBaseAddr; // Base address of module in th32ProcessID's context
  216. DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr
  217. HMODULE hModule; // The hModule of this module in th32ProcessID's context
  218. WCHAR szModule[MAX_MODULE_NAME32 + 1];
  219. WCHAR szExePath[MAX_PATH];
  220. } MODULEENTRY32W;
  221. typedef MODULEENTRY32W * PMODULEENTRY32W;
  222. typedef MODULEENTRY32W * LPMODULEENTRY32W;
  223. BOOL
  224. WINAPI
  225. Module32FirstW(
  226. HANDLE hSnapshot,
  227. LPMODULEENTRY32W lpme
  228. );
  229. BOOL
  230. WINAPI
  231. Module32NextW(
  232. HANDLE hSnapshot,
  233. LPMODULEENTRY32W lpme
  234. );
  235. typedef struct tagMODULEENTRY32
  236. {
  237. DWORD dwSize;
  238. DWORD th32ModuleID; // This module
  239. DWORD th32ProcessID; // owning process
  240. DWORD GlblcntUsage; // Global usage count on the module
  241. DWORD ProccntUsage; // Module usage count in th32ProcessID's context
  242. BYTE * modBaseAddr; // Base address of module in th32ProcessID's context
  243. DWORD modBaseSize; // Size in bytes of module starting at modBaseAddr
  244. HMODULE hModule; // The hModule of this module in th32ProcessID's context
  245. char szModule[MAX_MODULE_NAME32 + 1];
  246. char szExePath[MAX_PATH];
  247. } MODULEENTRY32;
  248. typedef MODULEENTRY32 * PMODULEENTRY32;
  249. typedef MODULEENTRY32 * LPMODULEENTRY32;
  250. //
  251. // NOTE CAREFULLY that the modBaseAddr and hModule fields are valid ONLY
  252. // in th32ProcessID's process context.
  253. //
  254. BOOL
  255. WINAPI
  256. Module32First(
  257. HANDLE hSnapshot,
  258. LPMODULEENTRY32 lpme
  259. );
  260. BOOL
  261. WINAPI
  262. Module32Next(
  263. HANDLE hSnapshot,
  264. LPMODULEENTRY32 lpme
  265. );
  266. #ifdef UNICODE
  267. #define Module32First Module32FirstW
  268. #define Module32Next Module32NextW
  269. #define MODULEENTRY32 MODULEENTRY32W
  270. #define PMODULEENTRY32 PMODULEENTRY32W
  271. #define LPMODULEENTRY32 LPMODULEENTRY32W
  272. #endif // !UNICODE
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276. #endif // _INC_TOOLHELP32