Windows NT 4.0 source code leak
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.

376 lines
11 KiB

4 years ago
  1. /* SCCSID = @(#)except32.h 13.10 90/09/28 */
  2. /*************************** START OF SPECIFICATION *****************
  3. *
  4. * Source File Name: bsexcpt.h
  5. *
  6. * Descriptive Name: Thread Exception Constants and Structure Definitions.
  7. *
  8. * Copyright: Microsoft Corp. 1989
  9. * Copyright: IBM Corp. 1989
  10. *
  11. * Function: This file provides constants and data structure
  12. * definitions required by application programs to use 32 bit
  13. * thread exceptions management facility.
  14. *
  15. * Notes: None.
  16. *
  17. *************************** END OF SPECIFICATION *******************/
  18. /*
  19. * User Exception Handler Return Codes:
  20. */
  21. #define XCPT_CONTINUE_SEARCH 0x00000000 /* exception not handled */
  22. #define XCPT_CONTINUE_EXECUTION 0xFFFFFFFF /* exception handled */
  23. #define XCPT_CONTINUE_STOP 0x00716668 /* exception handled by */
  24. /* debugger (VIA DosDebug) */
  25. /*
  26. * fHandlerFlags values (see ExceptionStructure):
  27. *
  28. * The user may only set (but not clear) the EH_NONCONTINUABLE flag.
  29. * All other flags are set by the system.
  30. *
  31. */
  32. #define EH_NONCONTINUABLE 0x1 /* Noncontinuable exception */
  33. #define EH_UNWINDING 0x2 /* Unwind is in progress */
  34. #define EH_EXIT_UNWIND 0x4 /* Exit unwind is in progress */
  35. #define EH_STACK_INVALID 0x8 /* Stack out of limits or unaligned */
  36. #define EH_NESTED_CALL 0x10 /* Nested exception handler call */
  37. /*
  38. * Unwind all exception handlers (see DosUnwindException API)
  39. */
  40. #define UNWIND_ALL 0
  41. /*
  42. * Exception values are 32 bit values layed out as follows:
  43. *
  44. * 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
  45. * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
  46. * +---+-+-------------------------+-------------------------------+
  47. * |Sev|C| Facility | Code |
  48. * +---+-+-------------------------+-------------------------------+
  49. *
  50. * where
  51. *
  52. * Sev - is the severity code
  53. * 00 - Success
  54. * 01 - Informational
  55. * 10 - Warning
  56. * 11 - Error
  57. *
  58. * C - is the Customer code flag
  59. *
  60. * Facility - is the facility code
  61. *
  62. * Code - is the facility's status code
  63. *
  64. * Exceptions specific to Cruiser (e.g. XCPT_SIGNAL) will be marked
  65. * with a facility code of 1.
  66. *
  67. * System defined exceptions have a facility code of zero.
  68. *
  69. * Each exception may also have several pieces of additional information.
  70. * These are stored in the ExceptionInformation fields of the
  71. * ExceptionReportRecord. They are documented here with the exceptions
  72. * only for ease of reference.
  73. */
  74. #define XCPT_FATAL_EXCEPTION 0xC0000000
  75. #define XCPT_SEVERITY_CODE 0xC0000000
  76. #define XCPT_CUSTOMER_CODE 0x20000000
  77. #define XCPT_FACILITY_CODE 0x1FFF0000
  78. #define XCPT_EXCEPTION_CODE 0x0000FFFF
  79. /*
  80. * Violation flags in ExceptionInformation
  81. */
  82. #define XCPT_UNKNOWN_ACCESS 0x00000000 /* Unknown access */
  83. #define XCPT_READ_ACCESS 0x00000001 /* Read access */
  84. #define XCPT_WRITE_ACCESS 0x00000002 /* Write access */
  85. #define XCPT_EXECUTE_ACCESS 0x00000004 /* Execute access */
  86. #define XCPT_SPACE_ACCESS 0x00000008 /* Address space access */
  87. #define XCPT_LIMIT_ACCESS 0x00000010 /* Address space limit violation */
  88. #define XCPT_DATA_UNKNOWN 0xFFFFFFFF
  89. /*
  90. * Signal subtypes for XCPT_SIGNAL
  91. */
  92. #define XCPT_SIGNAL_INTR 1
  93. #define XCPT_SIGNAL_KILLPROC 3
  94. #define XCPT_SIGNAL_BREAK 4
  95. /*
  96. * Portable non-fatal software generated exceptions
  97. */
  98. #define XCPT_GUARD_PAGE_VIOLATION 0x80000001
  99. /* ExceptionInformation[ 0 ] - Access Code: XCPT_READ_ACCESS
  100. XCPT_WRITE_ACCESS */
  101. /* ExceptionInformation[ 1 ] - FaultAddr */
  102. #define XCPT_UNABLE_TO_GROW_STACK 0x80010001
  103. /*
  104. * Portable fatal hardware generated exceptions
  105. */
  106. #define XCPT_DATATYPE_MISALIGNMENT 0xC000009E
  107. /* ExceptionInformation[ 0 ] - Access Code: XCPT_READ_ACCESS
  108. XCPT_WRITE_ACCESS */
  109. /* ExceptionInformation[ 1 ] - Alignment */
  110. /* ExceptionInformation[ 2 ] - FaultAddr */
  111. #define XCPT_BREAKPOINT 0xC000009F
  112. #define XCPT_SINGLE_STEP 0xC00000A0
  113. #define XCPT_ACCESS_VIOLATION 0xC0000005
  114. /* ExceptionInformation[ 0 ] - Access Code: XCPT_READ_ACCESS
  115. XCPT_WRITE_ACCESS
  116. XCPT_SPACE_ACCESS
  117. XCPT_LIMIT_ACCESS
  118. XCPT_UNKNOWN_ACCESS */
  119. /* ExceptionInformation[ 1 ] - FaultAddr (XCPT_READ_ACCESS/XCPT_WRITE_ACCESS)
  120. Selector (XCPT_SPACE_ACCESS)
  121. -1 (XCPT_LIMIT_ACCESS) */
  122. #define XCPT_ILLEGAL_INSTRUCTION 0xC000001C
  123. #define XCPT_FLOAT_DENORMAL_OPERAND 0xC0000094
  124. #define XCPT_FLOAT_DIVIDE_BY_ZERO 0xC0000095
  125. #define XCPT_FLOAT_INEXACT_RESULT 0xC0000096
  126. #define XCPT_FLOAT_INVALID_OPERATION 0xC0000097
  127. #define XCPT_FLOAT_OVERFLOW 0xC0000098
  128. #define XCPT_FLOAT_STACK_CHECK 0xC0000099
  129. #define XCPT_FLOAT_UNDERFLOW 0xC000009A
  130. #define XCPT_INTEGER_DIVIDE_BY_ZERO 0xC000009B
  131. #define XCPT_INTEGER_OVERFLOW 0xC000009C
  132. #define XCPT_PRIVILEGED_INSTRUCTION 0xC000009D
  133. /*
  134. * Portable fatal software generated exceptions
  135. */
  136. #define XCPT_IN_PAGE_ERROR 0xC0000006
  137. /* ExceptionInformation[ 0 ] - FaultAddr */
  138. #define XCPT_PROCESS_TERMINATE 0xC0010001
  139. #define XCPT_ASYNC_PROCESS_TERMINATE 0xC0010002
  140. /* ExceptionInfo[0] - TID of 'terminator' thread */
  141. #define XCPT_NONCONTINUABLE_EXCEPTION 0xC0000024
  142. #define XCPT_INVALID_DISPOSITION 0xC0000025
  143. /*
  144. * Non-portable fatal exceptions
  145. */
  146. #define XCPT_INVALID_LOCK_SEQUENCE 0xC000001D
  147. #define XCPT_ARRAY_BOUNDS_EXCEEDED 0xC0000093
  148. #define XCPT_B1NPX_ERRATA_02 0xC0010004
  149. /*
  150. * Misc exceptions
  151. */
  152. #define XCPT_UNWIND 0xC0000026
  153. #define XCPT_BAD_STACK 0xC0000027
  154. #define XCPT_INVALID_UNWIND_TARGET 0xC0000028
  155. /*
  156. * Signal Exceptions
  157. */
  158. #define XCPT_SIGNAL 0xC0010003
  159. /* ExceptionInfo[0] - signal number */
  160. /*
  161. * Exception Context.
  162. *
  163. * This is the machine specific register contents for the thread
  164. * at the time of the exception. Note that only the register sets
  165. * specified by ContextFlags contain valid data. Conversely, only
  166. * registers specified in ContextFlags will be restored if an exception
  167. * is handled.
  168. */
  169. /*
  170. * The following flags control the contents of the CONTEXT structure.
  171. */
  172. #define CONTEXT_CONTROL 0x00000001L /* SS:ESP, CS:EIP, EFLAGS, */
  173. /* EBP */
  174. #define CONTEXT_INTEGER 0x00000002L /* EAX, EBX, ECX, EDX, ESI, */
  175. /* EDI */
  176. #define CONTEXT_SEGMENTS 0x00000004L /* DS, ES, FS, GS */
  177. #define CONTEXT_FLOATING_POINT 0x00000008L /* 387 state */
  178. #define CONTEXT_FULL (CONTEXT_CONTROL | CONTEXT_INTEGER | \
  179. CONTEXT_SEGMENTS | CONTEXT_FLOATING_POINT)
  180. /* XLATOFF */
  181. #pragma pack(1)
  182. /* XLATON */
  183. struct _fpreg { /* coprocessor stack register element */
  184. ULONG losig;
  185. ULONG hisig;
  186. USHORT signexp;
  187. };
  188. typedef struct _fpreg FPREG;
  189. /* XLATOFF */
  190. #pragma pack()
  191. /* XLATON */
  192. struct _CONTEXT { /* Ex */
  193. /*
  194. * The flags values within this flag control the contents of
  195. * a CONTEXT record.
  196. *
  197. * If the context record is used as an input parameter, then
  198. * for each portion of the context record controlled by a flag
  199. * whose value is set, it is assumed that that portion of the
  200. * context record contains valid context. If the context record
  201. * is being used to modify a thread's context, then only that
  202. * portion of the thread's context will be modified.
  203. *
  204. * If the context record is used as an Input/Output parameter to
  205. * capture the context of a thread, then only those portions of the
  206. * thread's context corresponding to set flags will be returned.
  207. */
  208. ULONG ContextFlags;
  209. /*
  210. * This section is specified/returned if the
  211. * ContextFlags word contains the flag CONTEXT_FLOATING_POINT.
  212. */
  213. ULONG ctx_env[7];
  214. struct _fpreg ctx_stack[8];
  215. /*
  216. * This section is specified/returned if the
  217. * ContextFlags word contains the flag CONTEXT_SEGMENTS.
  218. */
  219. ULONG ctx_SegGs;
  220. ULONG ctx_SegFs;
  221. ULONG ctx_SegEs;
  222. ULONG ctx_SegDs;
  223. /*
  224. * This section is specified/returned if the
  225. * ContextFlags word contains the flag CONTEXT_INTEGER.
  226. */
  227. ULONG ctx_RegEdi;
  228. ULONG ctx_RegEsi;
  229. ULONG ctx_RegEax;
  230. ULONG ctx_RegEbx;
  231. ULONG ctx_RegEcx;
  232. ULONG ctx_RegEdx;
  233. /*
  234. * This section is specified/returned if the
  235. * ContextFlags word contains the flag CONTEXT_CONTROL.
  236. */
  237. ULONG ctx_RegEbp;
  238. ULONG ctx_RegEip;
  239. ULONG ctx_SegCs;
  240. ULONG ctx_EFlags;
  241. ULONG ctx_RegEsp;
  242. ULONG ctx_SegSs;
  243. };
  244. typedef struct _CONTEXT CONTEXTRECORD;
  245. typedef struct _CONTEXT *PCONTEXTRECORD;
  246. /*
  247. * ExceptionReportRecord
  248. *
  249. * This structure contains machine independant information about an
  250. * exception/unwind. No system exception will ever have more than
  251. * EXCEPTION_MAXIMUM_PARAMETERS parameters. User exceptions are not
  252. * bound to this limit.
  253. */
  254. #define EXCEPTION_MAXIMUM_PARAMETERS 4 /* Enough for all system exceptions. */
  255. struct _EXCEPTIONREPORTRECORD {
  256. ULONG ExceptionNum; /* exception number */
  257. ULONG fHandlerFlags;
  258. struct _EXCEPTIONREPORTRECORD *NestedExceptionReportRecord;
  259. PVOID ExceptionAddress;
  260. ULONG cParameters; /* Size of Exception Specific Info */
  261. ULONG ExceptionInfo[EXCEPTION_MAXIMUM_PARAMETERS];
  262. /* Exception Specfic Info */
  263. };
  264. typedef struct _EXCEPTIONREPORTRECORD EXCEPTIONREPORTRECORD;
  265. typedef struct _EXCEPTIONREPORTRECORD *PEXCEPTIONREPORTRECORD;
  266. /*
  267. * ExceptionRegistrationRecord
  268. *
  269. * These are linked together to form a chain of exception handlers that
  270. * will be dispatched to upon receipt of an exception.
  271. *
  272. * NOTE: Exception handlers should *NOT* be Registered directly from a
  273. * high level language, such as 'C'. This is the responsibility of
  274. * the language runtime.
  275. */
  276. /* XLATOFF */
  277. struct _EXCEPTIONREGISTRATIONRECORD {
  278. struct _EXCEPTIONREGISTRATIONRECORD *prev_structure;
  279. ULONG (_cdecl * ExceptionHandler)(PEXCEPTIONREPORTRECORD,
  280. struct _EXCEPTIONREGISTRATIONRECORD *,
  281. PCONTEXTRECORD,
  282. PVOID);
  283. };
  284. typedef struct _EXCEPTIONREGISTRATIONRECORD EXCEPTIONREGISTRATIONRECORD;
  285. typedef struct _EXCEPTIONREGISTRATIONRECORD *PEXCEPTIONREGISTRATIONRECORD;
  286. /* XLATON */
  287. /* ASM
  288. _EXCEPTIONREGISTRATIONRECORD STRUC
  289. prev_structure DD ?
  290. ExceptionHandler DD ?
  291. _EXCEPTIONREGISTRATIONRECORD ENDS
  292. EXCEPTIONREGISTRATIONRECORD struc
  293. db size _EXCEPTIONREGISTRATIONRECORD dup(?)
  294. EXCEPTIONREGISTRATIONRECORD ends
  295. PEXCEPTIONREGISTRATIONRECORD struc
  296. dd ?
  297. PEXCEPTIONREGISTRATIONRECORD ends
  298. */
  299. /*
  300. * End of exception chain marker.
  301. */
  302. /* XLATOFF */
  303. #define END_OF_CHAIN ((PEXCEPTIONREGISTRATIONRECORD) -1)
  304. /* XLATON */
  305. /* ASM
  306. END_OF_CHAIN EQU -1
  307. */