Source code of Windows XP (NT5)
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.

469 lines
14 KiB

  1. /*****************************************************************************\
  2. * *
  3. * toolhelp.h - toolhelp.dll functions, types, and definitions *
  4. * *
  5. * Version 1.0 *
  6. * *
  7. * NOTE: windows.h must be #included first *
  8. * *
  9. * Copyright (c) 1992, Microsoft Corp. All rights reserved. *
  10. * *
  11. \*****************************************************************************/
  12. #ifndef _INC_TOOLHELP
  13. #define _INC_TOOLHELP
  14. #ifndef RC_INVOKED
  15. #pragma pack(1) /* Assume byte packing throughout */
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" { /* Assume C declarations for C++ */
  19. #endif /* __cplusplus */
  20. #ifndef _INC_WINDOWS /* If included with 3.0 headers... */
  21. #define LPCSTR LPSTR
  22. #define WINAPI FAR PASCAL
  23. #define CALLBACK FAR PASCAL
  24. #define UINT WORD
  25. #define HMODULE HANDLE
  26. #define HINSTANCE HANDLE
  27. #define HLOCAL HANDLE
  28. #define HGLOBAL HANDLE
  29. #define HTASK HANDLE
  30. #endif /* _INC_WINDOWS */
  31. /****** General symbols ******************************************************/
  32. #define MAX_DATA 11
  33. #define MAX_PATH 255
  34. #define MAX_MODULE_NAME 8 + 1
  35. #define MAX_CLASSNAME 255
  36. /****** Global heap walking ***************************************************/
  37. typedef struct tagGLOBALINFO
  38. {
  39. DWORD dwSize;
  40. WORD wcItems;
  41. WORD wcItemsFree;
  42. WORD wcItemsLRU;
  43. } GLOBALINFO;
  44. typedef struct tagGLOBALENTRY
  45. {
  46. DWORD dwSize;
  47. DWORD dwAddress;
  48. DWORD dwBlockSize;
  49. HGLOBAL hBlock;
  50. WORD wcLock;
  51. WORD wcPageLock;
  52. WORD wFlags;
  53. BOOL wHeapPresent;
  54. HGLOBAL hOwner;
  55. WORD wType;
  56. WORD wData;
  57. DWORD dwNext;
  58. DWORD dwNextAlt;
  59. } GLOBALENTRY;
  60. /* GlobalFirst()/GlobalNext() flags */
  61. #define GLOBAL_ALL 0
  62. #define GLOBAL_LRU 1
  63. #define GLOBAL_FREE 2
  64. /* GLOBALENTRY.wType entries */
  65. #define GT_UNKNOWN 0
  66. #define GT_DGROUP 1
  67. #define GT_DATA 2
  68. #define GT_CODE 3
  69. #define GT_TASK 4
  70. #define GT_RESOURCE 5
  71. #define GT_MODULE 6
  72. #define GT_FREE 7
  73. #define GT_INTERNAL 8
  74. #define GT_SENTINEL 9
  75. #define GT_BURGERMASTER 10
  76. /* If GLOBALENTRY.wType==GT_RESOURCE, the following is GLOBALENTRY.wData: */
  77. #define GD_USERDEFINED 0
  78. #define GD_CURSORCOMPONENT 1
  79. #define GD_BITMAP 2
  80. #define GD_ICONCOMPONENT 3
  81. #define GD_MENU 4
  82. #define GD_DIALOG 5
  83. #define GD_STRING 6
  84. #define GD_FONTDIR 7
  85. #define GD_FONT 8
  86. #define GD_ACCELERATORS 9
  87. #define GD_RCDATA 10
  88. #define GD_ERRTABLE 11
  89. #define GD_CURSOR 12
  90. #define GD_ICON 14
  91. #define GD_NAMETABLE 15
  92. #define GD_MAX_RESOURCE 15
  93. /* GLOBALENTRY.wFlags */
  94. #define GF_PDB_OWNER 0x0100 /* Low byte is KERNEL flags */
  95. BOOL WINAPI GlobalInfo(GLOBALINFO FAR* lpGlobalInfo);
  96. BOOL WINAPI GlobalFirst(GLOBALENTRY FAR* lpGlobal, WORD wFlags);
  97. BOOL WINAPI GlobalNext(GLOBALENTRY FAR* lpGlobal, WORD wFlags);
  98. BOOL WINAPI GlobalEntryHandle(GLOBALENTRY FAR* lpGlobal, HGLOBAL hItem);
  99. BOOL WINAPI GlobalEntryModule(GLOBALENTRY FAR* lpGlobal, HMODULE hModule, WORD wSeg);
  100. WORD WINAPI GlobalHandleToSel(HGLOBAL hMem);
  101. /****** Local heap walking ***************************************************/
  102. typedef struct tagLOCALINFO
  103. {
  104. DWORD dwSize;
  105. WORD wcItems;
  106. } LOCALINFO;
  107. typedef struct tagLOCALENTRY
  108. {
  109. DWORD dwSize;
  110. HLOCAL hHandle;
  111. WORD wAddress;
  112. WORD wSize;
  113. WORD wFlags;
  114. WORD wcLock;
  115. WORD wType;
  116. WORD hHeap;
  117. WORD wHeapType;
  118. WORD wNext;
  119. } LOCALENTRY;
  120. /* LOCALENTRY.wHeapType flags */
  121. #define NORMAL_HEAP 0
  122. #define USER_HEAP 1
  123. #define GDI_HEAP 2
  124. /* LOCALENTRY.wFlags */
  125. #define LF_FIXED 1
  126. #define LF_FREE 2
  127. #define LF_MOVEABLE 4
  128. /* LOCALENTRY.wType */
  129. #define LT_NORMAL 0
  130. #define LT_FREE 0xff
  131. #define LT_GDI_PEN 1 /* LT_GDI_* is for GDI's heap */
  132. #define LT_GDI_BRUSH 2
  133. #define LT_GDI_FONT 3
  134. #define LT_GDI_PALETTE 4
  135. #define LT_GDI_BITMAP 5
  136. #define LT_GDI_RGN 6
  137. #define LT_GDI_DC 7
  138. #define LT_GDI_DISABLED_DC 8
  139. #define LT_GDI_METADC 9
  140. #define LT_GDI_METAFILE 10
  141. #define LT_GDI_MAX LT_GDI_METAFILE
  142. #define LT_USER_CLASS 1 /* LT_USER_* is for USER's heap */
  143. #define LT_USER_WND 2
  144. #define LT_USER_STRING 3
  145. #define LT_USER_MENU 4
  146. #define LT_USER_CLIP 5
  147. #define LT_USER_CBOX 6
  148. #define LT_USER_PALETTE 7
  149. #define LT_USER_ED 8
  150. #define LT_USER_BWL 9
  151. #define LT_USER_OWNERDRAW 10
  152. #define LT_USER_SPB 11
  153. #define LT_USER_CHECKPOINT 12
  154. #define LT_USER_DCE 13
  155. #define LT_USER_MWP 14
  156. #define LT_USER_PROP 15
  157. #define LT_USER_LBIV 16
  158. #define LT_USER_MISC 17
  159. #define LT_USER_ATOMS 18
  160. #define LT_USER_LOCKINPUTSTATE 19
  161. #define LT_USER_HOOKLIST 20
  162. #define LT_USER_USERSEEUSERDOALLOC 21
  163. #define LT_USER_HOTKEYLIST 22
  164. #define LT_USER_POPUPMENU 23
  165. #define LT_USER_HANDLETABLE 32
  166. #define LT_USER_MAX LT_USER_HANDLETABLE
  167. BOOL WINAPI LocalInfo(LOCALINFO FAR* lpLocal, HGLOBAL hHeap);
  168. BOOL WINAPI LocalFirst(LOCALENTRY FAR* lpLocal, HGLOBAL hHeap);
  169. BOOL WINAPI LocalNext(LOCALENTRY FAR* lpLocal);
  170. /****** Stack Tracing ********************************************************/
  171. typedef struct tagSTACKTRACEENTRY
  172. {
  173. DWORD dwSize;
  174. HTASK hTask;
  175. WORD wSS;
  176. WORD wBP;
  177. WORD wCS;
  178. WORD wIP;
  179. HMODULE hModule;
  180. WORD wSegment;
  181. WORD wFlags;
  182. } STACKTRACEENTRY;
  183. /* STACKTRACEENTRY.wFlags values */
  184. #define FRAME_FAR 0
  185. #define FRAME_NEAR 1
  186. BOOL WINAPI StackTraceFirst(STACKTRACEENTRY FAR* lpStackTrace, HTASK hTask);
  187. BOOL WINAPI StackTraceCSIPFirst(STACKTRACEENTRY FAR* lpStackTrace,
  188. WORD wSS, WORD wCS, WORD wIP, WORD wBP);
  189. BOOL WINAPI StackTraceNext(STACKTRACEENTRY FAR* lpStackTrace);
  190. /****** Module list walking **************************************************/
  191. typedef struct tagMODULEENTRY
  192. {
  193. DWORD dwSize;
  194. char szModule[MAX_MODULE_NAME + 1];
  195. HMODULE hModule;
  196. WORD wcUsage;
  197. char szExePath[MAX_PATH + 1];
  198. WORD wNext;
  199. } MODULEENTRY;
  200. BOOL WINAPI ModuleFirst(MODULEENTRY FAR* lpModule);
  201. BOOL WINAPI ModuleNext(MODULEENTRY FAR* lpModule);
  202. HMODULE WINAPI ModuleFindName(MODULEENTRY FAR* lpModule, LPCSTR lpstrName);
  203. HMODULE WINAPI ModuleFindHandle(MODULEENTRY FAR* lpModule, HMODULE hModule);
  204. /****** Task list walking *****************************************************/
  205. typedef struct tagTASKENTRY
  206. {
  207. DWORD dwSize;
  208. HTASK hTask;
  209. HTASK hTaskParent;
  210. HINSTANCE hInst;
  211. HMODULE hModule;
  212. WORD wSS;
  213. WORD wSP;
  214. WORD wStackTop;
  215. WORD wStackMinimum;
  216. WORD wStackBottom;
  217. WORD wcEvents;
  218. HGLOBAL hQueue;
  219. char szModule[MAX_MODULE_NAME + 1];
  220. WORD wPSPOffset;
  221. HANDLE hNext;
  222. } TASKENTRY;
  223. BOOL WINAPI TaskFirst(TASKENTRY FAR* lpTask);
  224. BOOL WINAPI TaskNext(TASKENTRY FAR* lpTask);
  225. BOOL WINAPI TaskFindHandle(TASKENTRY FAR* lpTask, HTASK hTask);
  226. DWORD WINAPI TaskSetCSIP(HTASK hTask, WORD wCS, WORD wIP);
  227. DWORD WINAPI TaskGetCSIP(HTASK hTask);
  228. BOOL WINAPI TaskSwitch(HTASK hTask, DWORD dwNewCSIP);
  229. /****** Window Class enumeration **********************************************/
  230. typedef struct tagCLASSENTRY
  231. {
  232. DWORD dwSize;
  233. HMODULE hInst; /* This is really an hModule */
  234. char szClassName[MAX_CLASSNAME + 1];
  235. WORD wNext;
  236. } CLASSENTRY;
  237. BOOL WINAPI ClassFirst(CLASSENTRY FAR* lpClass);
  238. BOOL WINAPI ClassNext(CLASSENTRY FAR* lpClass);
  239. /****** Information functions *************************************************/
  240. typedef struct tagMEMMANINFO
  241. {
  242. DWORD dwSize;
  243. DWORD dwLargestFreeBlock;
  244. DWORD dwMaxPagesAvailable;
  245. DWORD dwMaxPagesLockable;
  246. DWORD dwTotalLinearSpace;
  247. DWORD dwTotalUnlockedPages;
  248. DWORD dwFreePages;
  249. DWORD dwTotalPages;
  250. DWORD dwFreeLinearSpace;
  251. DWORD dwSwapFilePages;
  252. WORD wPageSize;
  253. } MEMMANINFO;
  254. BOOL WINAPI MemManInfo(MEMMANINFO FAR* lpEnhMode);
  255. typedef struct tagSYSHEAPINFO
  256. {
  257. DWORD dwSize;
  258. WORD wUserFreePercent;
  259. WORD wGDIFreePercent;
  260. HGLOBAL hUserSegment;
  261. HGLOBAL hGDISegment;
  262. } SYSHEAPINFO;
  263. BOOL WINAPI SystemHeapInfo(SYSHEAPINFO FAR* lpSysHeap);
  264. /****** Interrupt Handling ****************************************************/
  265. /* Hooked interrupts */
  266. #define INT_DIV0 0
  267. #define INT_1 1
  268. #define INT_3 3
  269. #define INT_UDINSTR 6
  270. #define INT_STKFAULT 12
  271. #define INT_GPFAULT 13
  272. #define INT_BADPAGEFAULT 14
  273. #define INT_CTLALTSYSRQ 256
  274. /* TOOLHELP Interrupt callbacks registered with InterruptRegister should
  275. * always be written in assembly language. The stack frame is not
  276. * compatible with high level language conventions.
  277. *
  278. * This stack frame looks as follows to the callback. All registers
  279. * should be preserved across this callback to allow restarting fault.
  280. * ------------
  281. * | Flags | [SP + 0Eh]
  282. * | CS | [SP + 0Ch]
  283. * | IP | [SP + 0Ah]
  284. * | Handle | [SP + 08h]
  285. * |Exception#| [SP + 06h]
  286. * | AX | [SP + 04h] AX Saved to allow MakeProcInstance
  287. * | Ret CS | [SP + 02h]
  288. * SP---> | Ret IP | [SP + 00h]
  289. * ------------
  290. */
  291. BOOL WINAPI InterruptRegister(HTASK hTask, FARPROC lpfnIntCallback);
  292. BOOL WINAPI InterruptUnRegister(HTASK hTask);
  293. /* Notifications:
  294. * When a notification callback is called, two parameters are passed
  295. * in: a WORD, wID, and another DWORD, dwData. wID is one of
  296. * the values NFY_* below. Callback routines should ignore unrecog-
  297. * nized values to preserve future compatibility. Callback routines
  298. * are also passed a dwData value. This may contain data or may be
  299. * a FAR pointer to a structure, or may not be used depending on
  300. * which notification is being received.
  301. *
  302. * In all cases, if the return value of the callback is TRUE, the
  303. * notification will NOT be passed on to other callbacks. It has
  304. * been handled. This should be used sparingly and only with certain
  305. * notifications. Callbacks almost always return FALSE.
  306. */
  307. /* NFY_UNKNOWN: An unknown notification has been returned from KERNEL. Apps
  308. * should ignore these.
  309. */
  310. #define NFY_UNKNOWN 0
  311. /* NFY_LOADSEG: dwData points to a NFYLOADSEG structure */
  312. #define NFY_LOADSEG 1
  313. typedef struct tagNFYLOADSEG
  314. {
  315. DWORD dwSize;
  316. WORD wSelector;
  317. WORD wSegNum;
  318. WORD wType; /* Low bit set if data seg, clear if code seg */
  319. WORD wcInstance; /* Instance count ONLY VALID FOR DATA SEG */
  320. LPCSTR lpstrModuleName;
  321. } NFYLOADSEG;
  322. /* NFY_FREESEG: LOWORD(dwData) is the selector of the segment being freed */
  323. #define NFY_FREESEG 2
  324. /* NFY_STARTDLL: dwData points to a NFYLOADSEG structure */
  325. #define NFY_STARTDLL 3
  326. typedef struct tagNFYSTARTDLL
  327. {
  328. DWORD dwSize;
  329. HMODULE hModule;
  330. WORD wCS;
  331. WORD wIP;
  332. } NFYSTARTDLL;
  333. /* NFY_STARTTASK: dwData is the CS:IP of the start address of the task */
  334. #define NFY_STARTTASK 4
  335. /* NFY_EXITTASK: The low byte of dwData contains the program exit code */
  336. #define NFY_EXITTASK 5
  337. /* NFY_DELMODULE: LOWORD(dwData) is the handle of the module to be freed */
  338. #define NFY_DELMODULE 6
  339. /* NFY_RIP: dwData points to a NFYRIP structure */
  340. #define NFY_RIP 7
  341. typedef struct tagNFYRIP
  342. {
  343. DWORD dwSize;
  344. WORD wIP;
  345. WORD wCS;
  346. WORD wSS;
  347. WORD wBP;
  348. WORD wExitCode;
  349. } NFYRIP;
  350. /* NFY_TASKIN: No data. Callback should do GetCurrentTask() */
  351. #define NFY_TASKIN 8
  352. /* NFY_TASKOUT: No data. Callback should do GetCurrentTask() */
  353. #define NFY_TASKOUT 9
  354. /* NFY_INCHAR: Return value from callback is used. If NULL, mapped to 'i' */
  355. #define NFY_INCHAR 10
  356. /* NFY_OUTSTR: dwData points to the string to be displayed */
  357. #define NFY_OUTSTR 11
  358. /* NFY_LOGERROR: dwData points to a NFYLOGERROR struct */
  359. #define NFY_LOGERROR 12
  360. typedef struct tagNFYLOGERROR
  361. {
  362. DWORD dwSize;
  363. UINT wErrCode;
  364. void FAR* lpInfo; /* Error code-dependent */
  365. } NFYLOGERROR;
  366. /* NFY_LOGPARAMERROR: dwData points to a NFYLOGPARAMERROR struct */
  367. #define NFY_LOGPARAMERROR 13
  368. typedef struct tagNFYLOGPARAMERROR
  369. {
  370. DWORD dwSize;
  371. UINT wErrCode;
  372. FARPROC lpfnErrorAddr;
  373. void FAR* FAR* lpBadParam;
  374. } NFYLOGPARAMERROR;
  375. /* NotifyRegister() flags */
  376. #define NF_NORMAL 0
  377. #define NF_TASKSWITCH 1
  378. #define NF_RIP 2
  379. typedef BOOL (CALLBACK* LPFNNOTIFYCALLBACK)(WORD wID, DWORD dwData);
  380. BOOL WINAPI NotifyRegister(HTASK hTask, LPFNNOTIFYCALLBACK lpfn, WORD wFlags);
  381. BOOL WINAPI NotifyUnRegister(HTASK hTask);
  382. /****** Miscellaneous *********************************************************/
  383. void WINAPI TerminateApp(HTASK hTask, WORD wFlags);
  384. /* TerminateApp() flag values */
  385. #define UAE_BOX 0
  386. #define NO_UAE_BOX 1
  387. DWORD WINAPI MemoryRead(WORD wSel, DWORD dwOffset, void FAR* lpBuffer, DWORD dwcb);
  388. DWORD WINAPI MemoryWrite(WORD wSel, DWORD dwOffset, void FAR* lpBuffer, DWORD dwcb);
  389. typedef struct tagTIMERINFO
  390. {
  391. DWORD dwSize;
  392. DWORD dwmsSinceStart;
  393. DWORD dwmsThisVM;
  394. } TIMERINFO;
  395. BOOL WINAPI TimerCount(TIMERINFO FAR* lpTimer);
  396. #ifdef __cplusplus
  397. }
  398. #endif /* __cplusplus */
  399. #ifndef RC_INVOKED
  400. #pragma pack() /* Revert to default packing */
  401. #endif
  402. #endif /* !_INC_TOOLHELP */