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.

365 lines
7.0 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntxcapi.h
  5. Abstract:
  6. This module contains procedure prototypes and data structures
  7. that support structured exception handling.
  8. Author:
  9. Mark Lucovsky (markl) 29-Jun-1989
  10. Revision History:
  11. --*/
  12. #ifndef _NTXCAPI_
  13. #define _NTXCAPI_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. // begin_ntddk begin_wdm
  21. //
  22. // Exception flag definitions.
  23. //
  24. // begin_winnt
  25. #define EXCEPTION_NONCONTINUABLE 0x1 // Noncontinuable exception
  26. // end_winnt
  27. // end_ntddk end_wdm
  28. #define EXCEPTION_UNWINDING 0x2 // Unwind is in progress
  29. #define EXCEPTION_EXIT_UNWIND 0x4 // Exit unwind is in progress
  30. #define EXCEPTION_STACK_INVALID 0x8 // Stack out of limits or unaligned
  31. #define EXCEPTION_NESTED_CALL 0x10 // Nested exception handler call
  32. #define EXCEPTION_TARGET_UNWIND 0x20 // Target unwind in progress
  33. #define EXCEPTION_COLLIDED_UNWIND 0x40 // Collided exception handler call
  34. #define EXCEPTION_UNWIND (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND | \
  35. EXCEPTION_TARGET_UNWIND | EXCEPTION_COLLIDED_UNWIND)
  36. #define IS_UNWINDING(Flag) ((Flag & EXCEPTION_UNWIND) != 0)
  37. #define IS_DISPATCHING(Flag) ((Flag & EXCEPTION_UNWIND) == 0)
  38. #define IS_TARGET_UNWIND(Flag) (Flag & EXCEPTION_TARGET_UNWIND)
  39. // begin_ntddk begin_wdm begin_nthal
  40. //
  41. // Define maximum number of exception parameters.
  42. //
  43. // begin_winnt
  44. #define EXCEPTION_MAXIMUM_PARAMETERS 15 // maximum number of exception parameters
  45. //
  46. // Exception record definition.
  47. //
  48. typedef struct _EXCEPTION_RECORD {
  49. NTSTATUS ExceptionCode;
  50. ULONG ExceptionFlags;
  51. struct _EXCEPTION_RECORD *ExceptionRecord;
  52. PVOID ExceptionAddress;
  53. ULONG NumberParameters;
  54. ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  55. } EXCEPTION_RECORD;
  56. typedef EXCEPTION_RECORD *PEXCEPTION_RECORD;
  57. typedef struct _EXCEPTION_RECORD32 {
  58. NTSTATUS ExceptionCode;
  59. ULONG ExceptionFlags;
  60. ULONG ExceptionRecord;
  61. ULONG ExceptionAddress;
  62. ULONG NumberParameters;
  63. ULONG ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  64. } EXCEPTION_RECORD32, *PEXCEPTION_RECORD32;
  65. typedef struct _EXCEPTION_RECORD64 {
  66. NTSTATUS ExceptionCode;
  67. ULONG ExceptionFlags;
  68. ULONG64 ExceptionRecord;
  69. ULONG64 ExceptionAddress;
  70. ULONG NumberParameters;
  71. ULONG __unusedAlignment;
  72. ULONG64 ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  73. } EXCEPTION_RECORD64, *PEXCEPTION_RECORD64;
  74. //
  75. // Typedef for pointer returned by exception_info()
  76. //
  77. typedef struct _EXCEPTION_POINTERS {
  78. PEXCEPTION_RECORD ExceptionRecord;
  79. PCONTEXT ContextRecord;
  80. } EXCEPTION_POINTERS, *PEXCEPTION_POINTERS;
  81. // end_winnt
  82. // end_ntddk end_wdm end_nthal
  83. //
  84. // Define IEEE exception information.
  85. //
  86. // Define 32-, 64-, 80-, and 128-bit IEEE floating operand structures.
  87. //
  88. typedef struct _FP_32 {
  89. ULONG W[1];
  90. } FP_32, *PFP_32;
  91. typedef struct _FP_64 {
  92. ULONG W[2];
  93. } FP_64, *PFP_64;
  94. typedef struct _FP_80 {
  95. ULONG W[3];
  96. } FP_80, *PFP_80;
  97. typedef struct _FP_128 {
  98. ULONG W[4];
  99. } FP_128, *PFP_128;
  100. //
  101. // Define IEEE compare result values.
  102. //
  103. typedef enum _FP_IEEE_COMPARE_RESULT {
  104. FpCompareEqual,
  105. FpCompareGreater,
  106. FpCompareLess,
  107. FpCompareUnordered
  108. } FP_IEEE_COMPARE_RESULT;
  109. //
  110. // Define IEEE format and result precision values.
  111. //
  112. typedef enum _FP__IEEE_FORMAT {
  113. FpFormatFp32,
  114. FpFormatFp64,
  115. FpFormatFp80,
  116. FpFormatFp128,
  117. FpFormatI16,
  118. FpFormatI32,
  119. FpFormatI64,
  120. FpFormatU16,
  121. FpFormatU32,
  122. FpFormatU64,
  123. FpFormatCompare,
  124. FpFormatString
  125. } FP_IEEE_FORMAT;
  126. //
  127. // Define IEEE operation code values.
  128. //
  129. typedef enum _FP_IEEE_OPERATION_CODE {
  130. FpCodeUnspecified,
  131. FpCodeAdd,
  132. FpCodeSubtract,
  133. FpCodeMultiply,
  134. FpCodeDivide,
  135. FpCodeSquareRoot,
  136. FpCodeRemainder,
  137. FpCodeCompare,
  138. FpCodeConvert,
  139. FpCodeRound,
  140. FpCodeTruncate,
  141. FpCodeFloor,
  142. FpCodeCeil,
  143. FpCodeAcos,
  144. FpCodeAsin,
  145. FpCodeAtan,
  146. FpCodeAtan2,
  147. FpCodeCabs,
  148. FpCodeCos,
  149. FpCodeCosh,
  150. FpCodeExp,
  151. FpCodeFabs,
  152. FpCodeFmod,
  153. FpCodeFrexp,
  154. FpCodeHypot,
  155. FpCodeLdexp,
  156. FpCodeLog,
  157. FpCodeLog10,
  158. FpCodeModf,
  159. FpCodePow,
  160. FpCodeSin,
  161. FpCodeSinh,
  162. FpCodeTan,
  163. FpCodeTanh,
  164. FpCodeY0,
  165. FpCodeY1,
  166. FpCodeYn
  167. } FP_OPERATION_CODE;
  168. //
  169. // Define IEEE rounding modes.
  170. //
  171. typedef enum _FP__IEEE_ROUNDING_MODE {
  172. FpRoundNearest,
  173. FpRoundMinusInfinity,
  174. FpRoundPlusInfinity,
  175. FpRoundChopped
  176. } FP_IEEE_ROUNDING_MODE;
  177. //
  178. // Define IEEE floating exception operand structure.
  179. //
  180. typedef struct _FP_IEEE_VALUE {
  181. union {
  182. SHORT I16Value;
  183. USHORT U16Value;
  184. LONG I32Value;
  185. ULONG U32Value;
  186. PVOID StringValue;
  187. ULONG CompareValue;
  188. FP_32 Fp32Value;
  189. LARGE_INTEGER I64Value;
  190. ULARGE_INTEGER U64Value;
  191. FP_64 Fp64Value;
  192. FP_80 Fp80Value;
  193. FP_128 Fp128Value;
  194. } Value;
  195. struct {
  196. ULONG RoundingMode : 2;
  197. ULONG Inexact : 1;
  198. ULONG Underflow : 1;
  199. ULONG Overflow : 1;
  200. ULONG ZeroDivide : 1;
  201. ULONG InvalidOperation : 1;
  202. ULONG OperandValid : 1;
  203. ULONG Format : 4;
  204. ULONG Precision : 4;
  205. ULONG Operation : 12;
  206. ULONG Spare : 3;
  207. ULONG HardwareException : 1;
  208. } Control;
  209. } FP_IEEE_VALUE, *PFP_IEEE_VALUE;
  210. //
  211. // Define IEEE exception infomation structure.
  212. //
  213. #include "pshpack4.h"
  214. typedef struct _FP_IEEE_RECORD {
  215. FP_IEEE_VALUE Operand1;
  216. FP_IEEE_VALUE Operand2;
  217. FP_IEEE_VALUE Result;
  218. } FP_IEEE_RECORD, *PFP_IEEE_RECORD;
  219. #include "poppack.h"
  220. //
  221. // Exception dispatcher routine definition.
  222. //
  223. NTSYSAPI
  224. BOOLEAN
  225. NTAPI
  226. RtlDispatchException (
  227. IN PEXCEPTION_RECORD ExceptionRecord,
  228. IN PCONTEXT ContextRecord
  229. );
  230. //
  231. // Exception handling procedure prototypes.
  232. //
  233. NTSYSAPI
  234. VOID
  235. NTAPI
  236. RtlRaiseStatus (
  237. IN NTSTATUS Status
  238. );
  239. NTSYSAPI
  240. VOID
  241. NTAPI
  242. RtlRaiseException (
  243. IN PEXCEPTION_RECORD
  244. );
  245. NTSYSAPI
  246. VOID
  247. NTAPI
  248. RtlUnwind (
  249. IN PVOID TargetFrame OPTIONAL,
  250. IN PVOID TargetIp OPTIONAL,
  251. IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
  252. IN PVOID ReturnValue
  253. );
  254. #if defined(_AMD64_)
  255. NTSYSAPI
  256. VOID
  257. NTAPI
  258. RtlUnwindEx (
  259. IN PVOID TargetFrame OPTIONAL,
  260. IN PVOID TargetIp OPTIONAL,
  261. IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
  262. IN PVOID ReturnValue,
  263. IN PCONTEXT ContextRecord,
  264. IN PUNWIND_HISTORY_TABLE HistoryTable OPTIONAL
  265. );
  266. #elif defined(_IA64_)
  267. NTSYSAPI
  268. VOID
  269. NTAPI
  270. RtlUnwind2 (
  271. IN FRAME_POINTERS TargetFrame OPTIONAL,
  272. IN PVOID TargetIp OPTIONAL,
  273. IN PEXCEPTION_RECORD ExceptionRecord OPTIONAL,
  274. IN PVOID ReturnValue,
  275. IN PCONTEXT ContextRecord
  276. );
  277. #endif
  278. //
  279. // Continue execution.
  280. //
  281. NTSYSCALLAPI
  282. NTSTATUS
  283. NTAPI
  284. NtContinue (
  285. IN PCONTEXT ContextRecord,
  286. IN BOOLEAN TestAlert
  287. );
  288. //
  289. // Raise exception.
  290. //
  291. NTSYSCALLAPI
  292. NTSTATUS
  293. NTAPI
  294. NtRaiseException (
  295. IN PEXCEPTION_RECORD ExceptionRecord,
  296. IN PCONTEXT ContextRecord,
  297. IN BOOLEAN FirstChance
  298. );
  299. #ifdef __cplusplus
  300. }
  301. #endif
  302. #endif //_NTXCAPI_