home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 19.ddi / GENINC32.PAK / EXCPT.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  12.0 KB  |  404 lines

  1. /***
  2. *excpt.h - defines exception values, types and routines
  3. *
  4. *Purpose:
  5. *   This file contains the definitions and prototypes for the compiler-
  6. *   dependent intrinsics, support functions and keywords which implement
  7. *   the structured exception handling extensions.
  8. *
  9. ****/
  10.  
  11. /*
  12.  *      C/C++ Run Time Library - Version 6.0
  13.  *
  14.  *      Copyright (c) 1990, 1993 by Borland International
  15.  *      All Rights Reserved.
  16.  *
  17.  */
  18.  
  19.  
  20.  
  21. #ifndef __EXCPT_H
  22. #define __EXCPT_H
  23.  
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27.  
  28. #if defined(__BORLANDC__) && !defined(__FLAT__)
  29.  
  30. #if !defined(__WINDOWS_H)
  31. typedef unsigned char       BYTE;
  32. typedef unsigned long       DWORD;
  33. typedef void __far *        LPVOID;
  34. typedef unsigned int        UINT;
  35. typedef DWORD  __far *      LPDWORD;
  36. #define WINAPI              _far _pascal
  37. #endif
  38.  
  39. /* From WINNT.H */
  40.  
  41. //
  42. //  Define the size of the 80387 save area, which is in the context frame.
  43. //
  44.  
  45. #define SIZE_OF_80387_REGISTERS      80
  46.  
  47. typedef struct _FLOATING_SAVE_AREA {
  48.     DWORD   ControlWord;
  49.     DWORD   StatusWord;
  50.     DWORD   TagWord;
  51.     DWORD   ErrorOffset;
  52.     DWORD   ErrorSelector;
  53.     DWORD   DataOffset;
  54.     DWORD   DataSelector;
  55.     BYTE    RegisterArea[SIZE_OF_80387_REGISTERS];
  56.     DWORD   Cr0NpxState;
  57. } FLOATING_SAVE_AREA;
  58.  
  59. //
  60. // Context Frame
  61. //
  62. //  This frame has a several purposes: 1) it is used as an argument to
  63. //  NtContinue, 2) is is used to constuct a call frame for APC delivery,
  64. //  and 3) it is used in the user level thread creation routines.
  65. //
  66. //  The layout of the record conforms to a standard call frame.
  67. //
  68.  
  69. typedef struct _CONTEXT {
  70.  
  71.     //
  72.     // The flags values within this flag control the contents of
  73.     // a CONTEXT record.
  74.     //
  75.     // If the context record is used as an input parameter, then
  76.     // for each portion of the context record controlled by a flag
  77.     // whose value is set, it is assumed that that portion of the
  78.     // context record contains valid context. If the context record
  79.     // is being used to modify a threads context, then only that
  80.     // portion of the threads context will be modified.
  81.     //
  82.     // If the context record is used as an IN OUT parameter to capture
  83.     // the context of a thread, then only those portions of the thread's
  84.     // context corresponding to set flags will be returned.
  85.     //
  86.     // The context record is never used as an OUT only parameter.
  87.     //
  88.  
  89.     DWORD ContextFlags;
  90.  
  91.     //
  92.     // This section is specified/returned if CONTEXT_DEBUG_REGISTERS is
  93.     // set in ContextFlags.  Note that CONTEXT_DEBUG_REGISTERS is NOT
  94.     // included in CONTEXT_FULL.
  95.     //
  96.  
  97.     DWORD   Dr0;
  98.     DWORD   Dr1;
  99.     DWORD   Dr2;
  100.     DWORD   Dr3;
  101.     DWORD   Dr6;
  102.     DWORD   Dr7;
  103.  
  104.     //
  105.     // This section is specified/returned if the
  106.     // ContextFlags word contians the flag CONTEXT_FLOATING_POINT.
  107.     //
  108.  
  109.     FLOATING_SAVE_AREA FloatSave;
  110.  
  111.     //
  112.     // This section is specified/returned if the
  113.     // ContextFlags word contians the flag CONTEXT_SEGMENTS.
  114.     //
  115.  
  116.     DWORD   SegGs;
  117.     DWORD   SegFs;
  118.     DWORD   SegEs;
  119.     DWORD   SegDs;
  120.  
  121.     //
  122.     // This section is specified/returned if the
  123.     // ContextFlags word contians the flag CONTEXT_INTEGER.
  124.     //
  125.  
  126.     DWORD   Edi;
  127.     DWORD   Esi;
  128.     DWORD   Ebx;
  129.     DWORD   Edx;
  130.     DWORD   Ecx;
  131.     DWORD   Eax;
  132.  
  133.     //
  134.     // This section is specified/returned if the
  135.     // ContextFlags word contians the flag CONTEXT_CONTROL.
  136.     //
  137.  
  138.     DWORD   Ebp;
  139.     DWORD   Eip;
  140.     DWORD   SegCs;              // MUST BE SANITIZED
  141.     DWORD   EFlags;             // MUST BE SANITIZED
  142.     DWORD   Esp;
  143.     DWORD   SegSs;
  144.  
  145. } CONTEXT;
  146.  
  147.  
  148. typedef CONTEXT *PCONTEXT;
  149.  
  150. /* From WINNT.H */
  151. #define STATUS_WAIT_0                    ((DWORD   )0x00000000L)
  152. #define STATUS_ABANDONED_WAIT_0          ((DWORD   )0x00000080L)
  153. #define STATUS_USER_APC                  ((DWORD   )0x000000C0L)
  154. #define STATUS_TIMEOUT                   ((DWORD   )0x00000102L)
  155. #define STATUS_PENDING                   ((DWORD   )0x00000103L)
  156. #define STATUS_DATATYPE_MISALIGNMENT     ((DWORD   )0x80000002L)
  157. #define STATUS_BREAKPOINT                ((DWORD   )0x80000003L)
  158. #define STATUS_SINGLE_STEP               ((DWORD   )0x80000004L)
  159. #define STATUS_ACCESS_VIOLATION          ((DWORD   )0xC0000005L)
  160. #define STATUS_IN_PAGE_ERROR             ((DWORD   )0xC0000006L)
  161. #define STATUS_NO_MEMORY                 ((DWORD   )0xC0000017L)
  162. #define STATUS_ILLEGAL_INSTRUCTION       ((DWORD   )0xC000001DL)
  163. #define STATUS_NONCONTINUABLE_EXCEPTION  ((DWORD   )0xC0000025L)
  164. #define STATUS_INVALID_DISPOSITION       ((DWORD   )0xC0000026L)
  165. #define STATUS_ARRAY_BOUNDS_EXCEEDED     ((DWORD   )0xC000008CL)
  166. #define STATUS_FLOAT_DENORMAL_OPERAND    ((DWORD   )0xC000008DL)
  167. #define STATUS_FLOAT_DIVIDE_BY_ZERO      ((DWORD   )0xC000008EL)
  168. #define STATUS_FLOAT_INEXACT_RESULT      ((DWORD   )0xC000008FL)
  169. #define STATUS_FLOAT_INVALID_OPERATION   ((DWORD   )0xC0000090L)
  170. #define STATUS_FLOAT_OVERFLOW            ((DWORD   )0xC0000091L)
  171. #define STATUS_FLOAT_STACK_CHECK         ((DWORD   )0xC0000092L)
  172. #define STATUS_FLOAT_UNDERFLOW           ((DWORD   )0xC0000093L)
  173. #define STATUS_INTEGER_DIVIDE_BY_ZERO    ((DWORD   )0xC0000094L)
  174. #define STATUS_INTEGER_OVERFLOW          ((DWORD   )0xC0000095L)
  175. #define STATUS_PRIVILEGED_INSTRUCTION    ((DWORD   )0xC0000096L)
  176. #define STATUS_STACK_OVERFLOW            ((DWORD   )0xC00000FDL)
  177. #define STATUS_CONTROL_C_EXIT            ((DWORD   )0xC000013AL)
  178.  
  179. /* From WINNT.H */
  180. #define EXCEPTION_CONTINUABLE        0      // Continuable exception
  181. #define EXCEPTION_NONCONTINUABLE     0x1    // Noncontinuable exception
  182. #define EXCEPTION_MAXIMUM_PARAMETERS 15     // maximum number of exception parameters
  183.  
  184. //
  185. // Exception record definition.
  186. //
  187.  
  188. typedef struct _EXCEPTION_RECORD {
  189.     DWORD ExceptionCode;
  190.     DWORD ExceptionFlags;
  191.     struct _EXCEPTION_RECORD __ss *ExceptionRecord;
  192.     LPVOID ExceptionAddress;
  193.     UINT NumberParameters;
  194.     DWORD ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
  195. } EXCEPTION_RECORD;
  196.  
  197. typedef EXCEPTION_RECORD __ss *PEXCEPTION_RECORD;
  198.  
  199. //
  200. // Typedef for pointer returned by exception_info()
  201. //
  202.  
  203. typedef struct _EXCEPTION_POINTERS {
  204.     PEXCEPTION_RECORD ExceptionRecord;
  205.     PCONTEXT ContextRecord;
  206. } EXCEPTION_POINTERS, __ss *PEXCEPTION_POINTERS;
  207.  
  208.  
  209. /* From WINBASE.H */
  210. #define EXCEPTION_ACCESS_VIOLATION      STATUS_ACCESS_VIOLATION
  211. #define EXCEPTION_DATATYPE_MISALIGNMENT STATUS_DATATYPE_MISALIGNMENT
  212. #define EXCEPTION_BREAKPOINT            STATUS_BREAKPOINT
  213. #define EXCEPTION_SINGLE_STEP           STATUS_SINGLE_STEP
  214. #define EXCEPTION_ARRAY_BOUNDS_EXCEEDED STATUS_ARRAY_BOUNDS_EXCEEDED
  215. #define EXCEPTION_FLT_DENORMAL_OPERAND  STATUS_FLOAT_DENORMAL_OPERAND
  216. #define EXCEPTION_FLT_DIVIDE_BY_ZERO    STATUS_FLOAT_DIVIDE_BY_ZERO
  217. #define EXCEPTION_FLT_INEXACT_RESULT    STATUS_FLOAT_INEXACT_RESULT
  218. #define EXCEPTION_FLT_INVALID_OPERATION STATUS_FLOAT_INVALID_OPERATION
  219. #define EXCEPTION_FLT_OVERFLOW          STATUS_FLOAT_OVERFLOW
  220. #define EXCEPTION_FLT_STACK_CHECK       STATUS_FLOAT_STACK_CHECK
  221. #define EXCEPTION_FLT_UNDERFLOW         STATUS_FLOAT_UNDERFLOW
  222. #define EXCEPTION_INT_DIVIDE_BY_ZERO    STATUS_INTEGER_DIVIDE_BY_ZERO
  223. #define EXCEPTION_INT_OVERFLOW          STATUS_INTEGER_OVERFLOW
  224. #define EXCEPTION_PRIV_INSTRUCTION      STATUS_PRIVILEGED_INSTRUCTION
  225. #define EXCEPTION_IN_PAGE_ERROR         STATUS_IN_PAGE_ERROR
  226.  
  227. void
  228. __cdecl __far
  229. RaiseException(
  230.     DWORD dwExceptionCode,
  231.     DWORD dwExceptionFlags,
  232.     DWORD nNumberOfArguments,
  233.     const LPDWORD lpArguments
  234.     );
  235.  
  236. long
  237. WINAPI
  238. UnhandledExceptionFilter(PEXCEPTION_POINTERS ExceptionInfo);
  239.  
  240. typedef long (WINAPI *PTOP_LEVEL_EXCEPTION_FILTER)(
  241.    PEXCEPTION_POINTERS ExceptionInfo
  242.    );
  243. typedef PTOP_LEVEL_EXCEPTION_FILTER LPTOP_LEVEL_EXCEPTION_FILTER;
  244.  
  245. LPTOP_LEVEL_EXCEPTION_FILTER
  246. WINAPI
  247. SetUnhandledExceptionFilter(
  248.    LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
  249.    );
  250.  
  251. #endif  /* __BORLANDC__ && !__FLAT__ */
  252.  
  253.  
  254. /*
  255.  * Conditional macro definition for function calling type and variable type
  256.  * qualifiers.
  257.  */
  258. #if   ( (_MSC_VER >= 800) && (_M_IX86 >= 300) ) || defined(__BORLANDC__)
  259.  
  260. /*
  261.  * Definitions for MS C8-32 (386/486) compiler
  262.  */
  263. #define _CRTAPI1 __cdecl
  264. #define _CRTAPI2 __cdecl
  265.  
  266. #else
  267.  
  268. /*
  269.  * Other compilers (e.g., MIPS)
  270.  */
  271. #define _CRTAPI1
  272. #define _CRTAPI2
  273.  
  274. #endif
  275.  
  276.  
  277. /*
  278.  * Exception disposition return values.
  279.  */
  280. typedef enum _EXCEPTION_DISPOSITION {
  281.     ExceptionContinueExecution,
  282.     ExceptionContinueSearch,
  283.     ExceptionNestedException,
  284.     ExceptionCollidedUnwind
  285. } EXCEPTION_DISPOSITION;
  286.  
  287.  
  288. /*
  289.  * Prototype for SEH support function.
  290.  */
  291.  
  292. #if defined(_M_IX86)
  293.  
  294. /*
  295.  * Declarations to keep MS C 8 (386/486) compiler happy
  296.  */
  297. struct _EXCEPTION_RECORD;
  298. struct _CONTEXT;
  299.  
  300. EXCEPTION_DISPOSITION _CRTAPI2 _except_handler (
  301.         struct _EXCEPTION_RECORD *ExceptionRecord,
  302.         void *EstablisherFrame,
  303.         struct _CONTEXT *ContextRecord,
  304.         void *DispatcherContext
  305.         );
  306.  
  307. #elif defined(_M_MRX000) || defined(_MIPS_) || defined(_ALPHA_)
  308.  
  309. /*
  310.  * Declarations to keep MIPS and ALPHA compiler happy
  311.  */
  312. typedef struct _EXCEPTION_POINTERS *Exception_info_ptr;
  313. struct _EXCEPTION_RECORD;
  314. struct _CONTEXT;
  315. struct _DISPATCHER_CONTEXT;
  316.  
  317.  
  318. EXCEPTION_DISPOSITION __C_specific_handler (
  319.         struct _EXCEPTION_RECORD *ExceptionRecord,
  320.         void *EstablisherFrame,
  321.         struct _CONTEXT *ContextRecord,
  322.         struct _DISPATCHER_CONTEXT *DispatcherContext
  323.         );
  324.  
  325. #endif
  326.  
  327.  
  328. /*
  329.  * Keywords and intrinsics for SEH
  330.  */
  331.  
  332. #if     ( _MSC_VER >= 800 )
  333. /*
  334.  * MS C8-32 (386/486)
  335.  */
  336. #define try                             __try
  337. #define except                          __except
  338. #define finally                         __finally
  339. #define leave                           __leave
  340. #define GetExceptionCode                _exception_code
  341. #define exception_code                  _exception_code
  342. #define GetExceptionInformation         (struct _EXCEPTION_POINTERS *)_exception_info
  343. #define exception_info                  (struct _EXCEPTION_POINTERS *)_exception_info
  344. #define AbnormalTermination             _abnormal_termination
  345. #define abnormal_termination            _abnormal_termination
  346.  
  347. unsigned long _CRTAPI1 _exception_code(void);
  348. void *        _CRTAPI1 _exception_info(void);
  349. int           _CRTAPI1 _abnormal_termination(void);
  350.  
  351. #elif   ( __BORLANDC__ )
  352. /*
  353.  * Borland C++
  354.  */
  355. #ifndef __cplusplus
  356. #  define try                       __try
  357. #  define finally                   __finally
  358. #  define AbnormalTermination()     __abnormal_termination
  359. #  define abnormal_termination()    __abnormal_termination
  360. #endif
  361.  
  362. #  define except                    __except
  363. #  define GetExceptionCode()        __exception_code
  364. #  define exception_code()          __exception_code
  365. #  define GetExceptionInformation() ((PEXCEPTION_POINTERS)__exception_info)
  366. #  define exception_info()          ((PEXCEPTION_POINTERS)__exception_info)
  367.  
  368.  
  369. #elif defined(_M_MRX000) || defined(_MIPS_) || defined(_ALPHA_)
  370. /*
  371.  * MIPS or ALPHA compiler
  372.  */
  373. #define try                             __builtin_try
  374. #define except                          __builtin_except
  375. #define finally                         __builtin_finally
  376. #define leave                           __builtin_leave
  377. #define GetExceptionCode()              __exception_code
  378. #define exception_code()                __exception_code
  379. #define GetExceptionInformation()       (struct _EXCEPTION_POINTERS *)__exception_info
  380. #define exception_info()                (struct _EXCEPTION_POINTERS *)__exception_info
  381. #define AbnormalTermination()           __abnormal_termination
  382. #define abnormal_termination()          __abnormal_termination
  383.  
  384. extern unsigned long __exception_code;
  385. extern int           __exception_info;
  386. extern int           __abnormal_termination;
  387.  
  388. #endif
  389.  
  390.  
  391. /*
  392.  * Legal values for expression in except().
  393.  */
  394.  
  395. #define EXCEPTION_EXECUTE_HANDLER        1
  396. #define EXCEPTION_CONTINUE_SEARCH        0
  397. #define EXCEPTION_CONTINUE_EXECUTION    -1
  398.  
  399. #ifdef __cplusplus
  400. }
  401. #endif
  402.  
  403. #endif  /* __EXCPT_H */
  404.