| 1 | /* | 
|---|
| 2 | * msvcrt C++ exception handling | 
|---|
| 3 | * | 
|---|
| 4 | * Copyright 2002 Alexandre Julliard | 
|---|
| 5 | * | 
|---|
| 6 | * This library is free software; you can redistribute it and/or | 
|---|
| 7 | * modify it under the terms of the GNU Lesser General Public | 
|---|
| 8 | * License as published by the Free Software Foundation; either | 
|---|
| 9 | * version 2.1 of the License, or (at your option) any later version. | 
|---|
| 10 | * | 
|---|
| 11 | * This library is distributed in the hope that it will be useful, | 
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 14 | * Lesser General Public License for more details. | 
|---|
| 15 | * | 
|---|
| 16 | * You should have received a copy of the GNU Lesser General Public | 
|---|
| 17 | * License along with this library; if not, write to the Free Software | 
|---|
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
|---|
| 19 | */ | 
|---|
| 20 |  | 
|---|
| 21 | #ifndef __MSVCRT_CPPEXCEPT_H | 
|---|
| 22 | #define __MSVCRT_CPPEXCEPT_H | 
|---|
| 23 |  | 
|---|
| 24 | #define CXX_FRAME_MAGIC    0x19930520 | 
|---|
| 25 | #define CXX_EXCEPTION      0xe06d7363 | 
|---|
| 26 |  | 
|---|
| 27 | typedef void (*vtable_ptr)(); | 
|---|
| 28 |  | 
|---|
| 29 | /* type_info object, see cpp.c for inplementation */ | 
|---|
| 30 | typedef struct __type_info | 
|---|
| 31 | { | 
|---|
| 32 | vtable_ptr *vtable; | 
|---|
| 33 | char *name;        /* Unmangled name, allocated lazily */ | 
|---|
| 34 | char  mangled[32]; /* Variable length, but we declare it large enough for static RTTI */ | 
|---|
| 35 | } type_info; | 
|---|
| 36 |  | 
|---|
| 37 | /* the exception frame used by CxxFrameHandler */ | 
|---|
| 38 | typedef struct __cxx_exception_frame | 
|---|
| 39 | { | 
|---|
| 40 | EXCEPTION_FRAME  frame;    /* the standard exception frame */ | 
|---|
| 41 | int              trylevel; | 
|---|
| 42 | DWORD            ebp; | 
|---|
| 43 | } cxx_exception_frame; | 
|---|
| 44 |  | 
|---|
| 45 | /* info about a single catch {} block */ | 
|---|
| 46 | typedef struct __catchblock_info | 
|---|
| 47 | { | 
|---|
| 48 | UINT       flags;         /* flags (see below) */ | 
|---|
| 49 | type_info *type_info;     /* C++ type caught by this block */ | 
|---|
| 50 | int        offset;        /* stack offset to copy exception object to */ | 
|---|
| 51 | void     (*handler)();    /* catch block handler code */ | 
|---|
| 52 | } catchblock_info; | 
|---|
| 53 | #define TYPE_FLAG_CONST      1 | 
|---|
| 54 | #define TYPE_FLAG_VOLATILE   2 | 
|---|
| 55 | #define TYPE_FLAG_REFERENCE  8 | 
|---|
| 56 |  | 
|---|
| 57 | /* info about a single try {} block */ | 
|---|
| 58 | typedef struct __tryblock_info | 
|---|
| 59 | { | 
|---|
| 60 | int              start_level;      /* start trylevel of that block */ | 
|---|
| 61 | int              end_level;        /* end trylevel of that block */ | 
|---|
| 62 | int              catch_level;      /* initial trylevel of the catch block */ | 
|---|
| 63 | int              catchblock_count; /* count of catch blocks in array */ | 
|---|
| 64 | catchblock_info *catchblock;       /* array of catch blocks */ | 
|---|
| 65 | } tryblock_info; | 
|---|
| 66 |  | 
|---|
| 67 | /* info about the unwind handler for a given trylevel */ | 
|---|
| 68 | typedef struct __unwind_info | 
|---|
| 69 | { | 
|---|
| 70 | int    prev;          /* prev trylevel unwind handler, to run after this one */ | 
|---|
| 71 | void (*handler)();    /* unwind handler */ | 
|---|
| 72 | } unwind_info; | 
|---|
| 73 |  | 
|---|
| 74 | /* descriptor of all try blocks of a given function */ | 
|---|
| 75 | typedef struct __cxx_function_descr | 
|---|
| 76 | { | 
|---|
| 77 | UINT           magic;          /* must be CXX_FRAME_MAGIC */ | 
|---|
| 78 | UINT           unwind_count;   /* number of unwind handlers */ | 
|---|
| 79 | unwind_info   *unwind_table;   /* array of unwind handlers */ | 
|---|
| 80 | UINT           tryblock_count; /* number of try blocks */ | 
|---|
| 81 | tryblock_info *tryblock;       /* array of try blocks */ | 
|---|
| 82 | UINT           unknown[3]; | 
|---|
| 83 | } cxx_function_descr; | 
|---|
| 84 |  | 
|---|
| 85 | typedef void (*cxx_copy_ctor)(void); | 
|---|
| 86 |  | 
|---|
| 87 | /* complete information about a C++ type */ | 
|---|
| 88 | typedef struct __cxx_type_info | 
|---|
| 89 | { | 
|---|
| 90 | UINT        flags;         /* flags (see CLASS_* flags below) */ | 
|---|
| 91 | type_info  *type_info;     /* C++ type info */ | 
|---|
| 92 | int         this_offset;   /* offset of base class this pointer from start of object */ | 
|---|
| 93 | int         vbase_descr;   /* offset of virtual base class descriptor */ | 
|---|
| 94 | int         vbase_offset;  /* offset of this pointer offset in virtual base class descriptor */ | 
|---|
| 95 | size_t      size;          /* object size */ | 
|---|
| 96 | cxx_copy_ctor copy_ctor;   /* copy constructor */ | 
|---|
| 97 | } cxx_type_info; | 
|---|
| 98 | #define CLASS_IS_SIMPLE_TYPE          1 | 
|---|
| 99 | #define CLASS_HAS_VIRTUAL_BASE_CLASS  4 | 
|---|
| 100 |  | 
|---|
| 101 | /* table of C++ types that apply for a given object */ | 
|---|
| 102 | typedef struct __cxx_type_info_table | 
|---|
| 103 | { | 
|---|
| 104 | UINT                 count;     /* number of types */ | 
|---|
| 105 | const cxx_type_info *info[3];   /* variable length, we declare it large enough for static RTTI */ | 
|---|
| 106 | } cxx_type_info_table; | 
|---|
| 107 |  | 
|---|
| 108 | typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*, | 
|---|
| 109 | PCONTEXT, struct __EXCEPTION_FRAME**, | 
|---|
| 110 | cxx_function_descr*, int nested_trylevel, | 
|---|
| 111 | EXCEPTION_FRAME *nested_frame, DWORD unknown3 ); | 
|---|
| 112 |  | 
|---|
| 113 | /* type information for an exception object */ | 
|---|
| 114 | typedef struct __cxx_exception_type | 
|---|
| 115 | { | 
|---|
| 116 | UINT                       flags;            /* TYPE_FLAG flags */ | 
|---|
| 117 | void                     (*destructor)();    /* exception object destructor */ | 
|---|
| 118 | cxx_exc_custom_handler     custom_handler;   /* custom handler for this exception */ | 
|---|
| 119 | const cxx_type_info_table *type_info_table;  /* list of types for this exception object */ | 
|---|
| 120 | } cxx_exception_type; | 
|---|
| 121 |  | 
|---|
| 122 | void _CxxThrowException(void*,const cxx_exception_type*); | 
|---|
| 123 |  | 
|---|
| 124 | #endif /* __MSVCRT_CPPEXCEPT_H */ | 
|---|