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.

521 lines
16 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-1994, 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_PATH16 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_ICON 24
  166. #define LT_USER_QMSG 26
  167. #define LT_USER_VWININFO 27
  168. #define LT_USER_SMS 28
  169. #define LT_USER_PROCESSINFO 29
  170. #define LT_USER_ATTACHINFO 30
  171. #define LT_USER_SYSCOLORTEMP 31
  172. #define LT_USER_HANDLETABLE 32
  173. #define LT_USER_SWITCHWNDINFO 33
  174. #define LT_USER_HOOKMSG 34
  175. #define LT_USER_MAX 34
  176. BOOL WINAPI LocalInfo(LOCALINFO FAR* lpLocal, HGLOBAL hHeap);
  177. BOOL WINAPI LocalFirst(LOCALENTRY FAR* lpLocal, HGLOBAL hHeap);
  178. BOOL WINAPI LocalNext(LOCALENTRY FAR* lpLocal);
  179. /****** Local 32-bit heap walking ********************************************/
  180. typedef HANDLE HLOCAL32;
  181. typedef struct tagLOCAL32INFO
  182. {
  183. DWORD dwSize;
  184. DWORD dwMemReserved;
  185. DWORD dwMemCommitted;
  186. DWORD dwTotalFree;
  187. DWORD dwLargestFreeBlock;
  188. DWORD dwcFreeHandles;
  189. } LOCAL32INFO;
  190. typedef struct tagLOCAL32ENTRY
  191. {
  192. DWORD dwSize;
  193. HLOCAL32 hHandle;
  194. DWORD dwAddress;
  195. DWORD dwSizeBlock;
  196. WORD wFlags;
  197. WORD wType;
  198. WORD hHeap;
  199. WORD wHeapType;
  200. DWORD dwNext;
  201. DWORD dwNextAlt;
  202. } LOCAL32ENTRY;
  203. /* LOCAL32ENTRY.wHeapType flags same as LOCALENTRY.wHeapType flags */
  204. /* LOCAL32ENTRY.wFlags same as LOCALENTRY.wFlags */
  205. /* LOCAL32ENTRY.wType same as LOCALENTRY.wType */
  206. BOOL WINAPI Local32Info(LOCAL32INFO FAR* lpli32, HGLOBAL hHeap);
  207. BOOL WINAPI Local32First(LOCAL32ENTRY FAR* lple32, HGLOBAL hHeap);
  208. BOOL WINAPI Local32Next(LOCAL32ENTRY FAR* lple32);
  209. /****** Stack Tracing ********************************************************/
  210. typedef struct tagSTACKTRACEENTRY
  211. {
  212. DWORD dwSize;
  213. HTASK hTask;
  214. WORD wSS;
  215. WORD wBP;
  216. WORD wCS;
  217. WORD wIP;
  218. HMODULE hModule;
  219. WORD wSegment;
  220. WORD wFlags;
  221. } STACKTRACEENTRY;
  222. /* STACKTRACEENTRY.wFlags values */
  223. #define FRAME_FAR 0
  224. #define FRAME_NEAR 1
  225. BOOL WINAPI StackTraceFirst(STACKTRACEENTRY FAR* lpStackTrace, HTASK hTask);
  226. BOOL WINAPI StackTraceCSIPFirst(STACKTRACEENTRY FAR* lpStackTrace,
  227. WORD wSS, WORD wCS, WORD wIP, WORD wBP);
  228. BOOL WINAPI StackTraceNext(STACKTRACEENTRY FAR* lpStackTrace);
  229. /****** Module list walking **************************************************/
  230. typedef struct tagMODULEENTRY
  231. {
  232. DWORD dwSize;
  233. char szModule[MAX_MODULE_NAME + 1];
  234. HMODULE hModule;
  235. WORD wcUsage;
  236. char szExePath[MAX_PATH16 + 1];
  237. WORD wNext;
  238. } MODULEENTRY;
  239. BOOL WINAPI ModuleFirst(MODULEENTRY FAR* lpModule);
  240. BOOL WINAPI ModuleNext(MODULEENTRY FAR* lpModule);
  241. HMODULE WINAPI ModuleFindName(MODULEENTRY FAR* lpModule, LPCSTR lpstrName);
  242. HMODULE WINAPI ModuleFindHandle(MODULEENTRY FAR* lpModule, HMODULE hModule);
  243. /****** Task list walking *****************************************************/
  244. typedef struct tagTASKENTRY
  245. {
  246. DWORD dwSize;
  247. HTASK hTask;
  248. HTASK hTaskParent;
  249. HINSTANCE hInst;
  250. HMODULE hModule;
  251. WORD wSS;
  252. WORD wSP;
  253. WORD wStackTop;
  254. WORD wStackMinimum;
  255. WORD wStackBottom;
  256. WORD wcEvents;
  257. HGLOBAL hQueue;
  258. char szModule[MAX_MODULE_NAME + 1];
  259. WORD wPSPOffset;
  260. HANDLE hNext;
  261. } TASKENTRY;
  262. BOOL WINAPI TaskFirst(TASKENTRY FAR* lpTask);
  263. BOOL WINAPI TaskNext(TASKENTRY FAR* lpTask);
  264. BOOL WINAPI TaskFindHandle(TASKENTRY FAR* lpTask, HTASK hTask);
  265. DWORD WINAPI TaskSetCSIP(HTASK hTask, WORD wCS, WORD wIP);
  266. DWORD WINAPI TaskGetCSIP(HTASK hTask);
  267. BOOL WINAPI TaskSwitch(HTASK hTask, DWORD dwNewCSIP);
  268. /****** Window Class enumeration **********************************************/
  269. typedef struct tagCLASSENTRY
  270. {
  271. DWORD dwSize;
  272. HMODULE hInst; /* This is really an hModule */
  273. char szClassName[MAX_CLASSNAME + 1];
  274. WORD wNext;
  275. } CLASSENTRY;
  276. BOOL WINAPI ClassFirst(CLASSENTRY FAR* lpClass);
  277. BOOL WINAPI ClassNext(CLASSENTRY FAR* lpClass);
  278. /****** Information functions *************************************************/
  279. typedef struct tagMEMMANINFO
  280. {
  281. DWORD dwSize;
  282. DWORD dwLargestFreeBlock;
  283. DWORD dwMaxPagesAvailable;
  284. DWORD dwMaxPagesLockable;
  285. DWORD dwTotalLinearSpace;
  286. DWORD dwTotalUnlockedPages;
  287. DWORD dwFreePages;
  288. DWORD dwTotalPages;
  289. DWORD dwFreeLinearSpace;
  290. DWORD dwSwapFilePages;
  291. WORD wPageSize;
  292. } MEMMANINFO;
  293. BOOL WINAPI MemManInfo(MEMMANINFO FAR* lpEnhMode);
  294. typedef struct tagSYSHEAPINFO
  295. {
  296. DWORD dwSize;
  297. WORD wUserFreePercent;
  298. WORD wGDIFreePercent;
  299. HGLOBAL hUserSegment;
  300. HGLOBAL hGDISegment;
  301. HGLOBAL hWndSegment;
  302. HGLOBAL hMenuSegment;
  303. HGLOBAL hGDI32Segment;
  304. } SYSHEAPINFO;
  305. BOOL WINAPI SystemHeapInfo(SYSHEAPINFO FAR* lpSysHeap);
  306. /****** Interrupt Handling ****************************************************/
  307. /* Hooked interrupts */
  308. #define INT_DIV0 0
  309. #define INT_1 1
  310. #define INT_3 3
  311. #define INT_UDINSTR 6
  312. #define INT_STKFAULT 12
  313. #define INT_GPFAULT 13
  314. #define INT_BADPAGEFAULT 14
  315. #define INT_CTLALTSYSRQ 256
  316. /* TOOLHELP Interrupt callbacks registered with InterruptRegister should
  317. * always be written in assembly language. The stack frame is not
  318. * compatible with high level language conventions.
  319. *
  320. * This stack frame looks as follows to the callback. All registers
  321. * should be preserved across this callback to allow restarting fault.
  322. * ------------
  323. * | Flags | [SP + 0Eh]
  324. * | CS | [SP + 0Ch]
  325. * | IP | [SP + 0Ah]
  326. * | Handle | [SP + 08h]
  327. * |Exception#| [SP + 06h]
  328. * | AX | [SP + 04h] AX Saved to allow MakeProcInstance
  329. * | Ret CS | [SP + 02h]
  330. * SP---> | Ret IP | [SP + 00h]
  331. * ------------
  332. */
  333. BOOL WINAPI InterruptRegister(HTASK hTask, FARPROC lpfnIntCallback);
  334. BOOL WINAPI InterruptUnRegister(HTASK hTask);
  335. /* Notifications:
  336. * When a notification callback is called, two parameters are passed
  337. * in: a WORD, wID, and another DWORD, dwData. wID is one of
  338. * the values NFY_* below. Callback routines should ignore unrecog-
  339. * nized values to preserve future compatibility. Callback routines
  340. * are also passed a dwData value. This may contain data or may be
  341. * a FAR pointer to a structure, or may not be used depending on
  342. * which notification is being received.
  343. *
  344. * In all cases, if the return value of the callback is TRUE, the
  345. * notification will NOT be passed on to other callbacks. It has
  346. * been handled. This should be used sparingly and only with certain
  347. * notifications. Callbacks almost always return FALSE.
  348. */
  349. /* NFY_UNKNOWN: An unknown notification has been returned from KERNEL. Apps
  350. * should ignore these.
  351. */
  352. #define NFY_UNKNOWN 0
  353. /* NFY_LOADSEG: dwData points to a NFYLOADSEG structure */
  354. #define NFY_LOADSEG 1
  355. typedef struct tagNFYLOADSEG
  356. {
  357. DWORD dwSize;
  358. WORD wSelector;
  359. WORD wSegNum;
  360. WORD wType; /* Low bit set if data seg, clear if code seg */
  361. WORD wcInstance; /* Instance count ONLY VALID FOR DATA SEG */
  362. LPCSTR lpstrModuleName;
  363. } NFYLOADSEG;
  364. /* NFY_FREESEG: LOWORD(dwData) is the selector of the segment being freed */
  365. #define NFY_FREESEG 2
  366. /* NFY_STARTDLL: dwData points to a NFYLOADSEG structure */
  367. #define NFY_STARTDLL 3
  368. typedef struct tagNFYSTARTDLL
  369. {
  370. DWORD dwSize;
  371. HMODULE hModule;
  372. WORD wCS;
  373. WORD wIP;
  374. } NFYSTARTDLL;
  375. /* NFY_STARTTASK: dwData is the CS:IP of the start address of the task */
  376. #define NFY_STARTTASK 4
  377. /* NFY_EXITTASK: The low byte of dwData contains the program exit code */
  378. #define NFY_EXITTASK 5
  379. /* NFY_DELMODULE: LOWORD(dwData) is the handle of the module to be freed */
  380. #define NFY_DELMODULE 6
  381. /* NFY_RIP: dwData points to a NFYRIP structure */
  382. #define NFY_RIP 7
  383. typedef struct tagNFYRIP
  384. {
  385. DWORD dwSize;
  386. WORD wIP;
  387. WORD wCS;
  388. WORD wSS;
  389. WORD wBP;
  390. WORD wExitCode;
  391. } NFYRIP;
  392. /* NFY_TASKIN: No data. Callback should do GetCurrentTask() */
  393. #define NFY_TASKIN 8
  394. /* NFY_TASKOUT: No data. Callback should do GetCurrentTask() */
  395. #define NFY_TASKOUT 9
  396. /* NFY_INCHAR: Return value from callback is used. If NULL, mapped to 'i' */
  397. #define NFY_INCHAR 10
  398. /* NFY_OUTSTR: dwData points to the string to be displayed */
  399. #define NFY_OUTSTR 11
  400. /* NFY_LOGERROR: dwData points to a NFYLOGERROR struct */
  401. #define NFY_LOGERROR 12
  402. typedef struct tagNFYLOGERROR
  403. {
  404. DWORD dwSize;
  405. UINT wErrCode;
  406. void FAR* lpInfo; /* Error code-dependent */
  407. } NFYLOGERROR;
  408. /* NFY_LOGPARAMERROR: dwData points to a NFYLOGPARAMERROR struct */
  409. #define NFY_LOGPARAMERROR 13
  410. typedef struct tagNFYLOGPARAMERROR
  411. {
  412. DWORD dwSize;
  413. UINT wErrCode;
  414. FARPROC lpfnErrorAddr;
  415. void FAR* FAR* lpBadParam;
  416. } NFYLOGPARAMERROR;
  417. /* NotifyRegister() flags */
  418. #define NF_NORMAL 0
  419. #define NF_TASKSWITCH 1
  420. #define NF_RIP 2
  421. typedef BOOL (CALLBACK* LPFNNOTIFYCALLBACK)(WORD wID, DWORD dwData);
  422. BOOL WINAPI NotifyRegister(HTASK hTask, LPFNNOTIFYCALLBACK lpfn, WORD wFlags);
  423. BOOL WINAPI NotifyUnRegister(HTASK hTask);
  424. /****** Miscellaneous *********************************************************/
  425. void WINAPI TerminateApp(HTASK hTask, WORD wFlags);
  426. /* TerminateApp() flag values */
  427. #define UAE_BOX 0
  428. #define NO_UAE_BOX 1
  429. DWORD WINAPI MemoryRead(WORD wSel, DWORD dwOffset, void FAR* lpBuffer, DWORD dwcb);
  430. DWORD WINAPI MemoryWrite(WORD wSel, DWORD dwOffset, void FAR* lpBuffer, DWORD dwcb);
  431. typedef struct tagTIMERINFO
  432. {
  433. DWORD dwSize;
  434. DWORD dwmsSinceStart;
  435. DWORD dwmsThisVM;
  436. } TIMERINFO;
  437. BOOL WINAPI TimerCount(TIMERINFO FAR* lpTimer);
  438. #ifdef __cplusplus
  439. }
  440. #endif /* __cplusplus */
  441. #ifndef RC_INVOKED
  442. #pragma pack() /* Revert to default packing */
  443. #endif
  444. #endif /* !_INC_TOOLHELP */