2 * msvcrt C++ exception handling
4 * Copyright 2002 Alexandre Julliard
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.
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.
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #ifndef __MSVCRT_CPPEXCEPT_H
22 #define __MSVCRT_CPPEXCEPT_H
24 #define CXX_FRAME_MAGIC_VC6 0x19930520
25 #define CXX_FRAME_MAGIC_VC7 0x19930521
26 #define CXX_FRAME_MAGIC_VC8 0x19930522
27 #define CXX_EXCEPTION 0xe06d7363
29 typedef void (*vtable_ptr
)(void);
31 /* type_info object, see cpp.c for implementation */
32 typedef struct __type_info
34 const vtable_ptr
*vtable
;
35 char *name
; /* Unmangled name, allocated lazily */
36 char mangled
[32]; /* Variable length, but we declare it large enough for static RTTI */
39 /* exception object */
40 typedef struct __exception
42 const vtable_ptr
*vtable
;
43 char *name
; /* Name of this exception, always a new copy for each object */
44 int do_free
; /* Whether to free 'name' in our dtor */
47 typedef void (*cxx_copy_ctor
)(void);
49 /* offsets for computing the this pointer */
52 int this_offset
; /* offset of base class this pointer from start of object */
53 int vbase_descr
; /* offset of virtual base class descriptor */
54 int vbase_offset
; /* offset of this pointer offset in virtual base class descriptor */
57 /* complete information about a C++ type */
58 typedef struct __cxx_type_info
60 UINT flags
; /* flags (see CLASS_* flags below) */
61 const type_info
*type_info
; /* C++ type info */
62 this_ptr_offsets offsets
; /* offsets for computing the this pointer */
63 unsigned int size
; /* object size */
64 cxx_copy_ctor copy_ctor
; /* copy constructor */
66 #define CLASS_IS_SIMPLE_TYPE 1
67 #define CLASS_HAS_VIRTUAL_BASE_CLASS 4
69 /* table of C++ types that apply for a given object */
70 typedef struct __cxx_type_info_table
72 UINT count
; /* number of types */
73 const cxx_type_info
*info
[3]; /* variable length, we declare it large enough for static RTTI */
74 } cxx_type_info_table
;
76 struct __cxx_exception_frame
;
77 struct __cxx_function_descr
;
79 typedef DWORD (*cxx_exc_custom_handler
)( PEXCEPTION_RECORD
, struct __cxx_exception_frame
*,
80 PCONTEXT
, EXCEPTION_REGISTRATION_RECORD
**,
81 const struct __cxx_function_descr
*, int nested_trylevel
,
82 EXCEPTION_REGISTRATION_RECORD
*nested_frame
, DWORD unknown3
);
84 /* type information for an exception object */
85 typedef struct __cxx_exception_type
87 UINT flags
; /* TYPE_FLAG flags */
88 void (*destructor
)(void);/* exception object destructor */
89 cxx_exc_custom_handler custom_handler
; /* custom handler for this exception */
90 const cxx_type_info_table
*type_info_table
; /* list of types for this exception object */
93 void WINAPI
_CxxThrowException(exception
*,const cxx_exception_type
*);
94 int CDECL
_XcptFilter(NTSTATUS
, PEXCEPTION_POINTERS
);
96 static inline const char *dbgstr_type_info( const type_info
*info
)
98 if (!info
) return "{}";
99 return wine_dbg_sprintf( "{vtable=%p name=%s (%s)}",
100 info
->vtable
, info
->mangled
, info
->name
? info
->name
: "" );
103 /* compute the this pointer for a base class of a given type */
104 static inline void *get_this_pointer( const this_ptr_offsets
*off
, void *object
)
109 if (!object
) return NULL
;
110 this_ptr
= (char *)object
+ off
->this_offset
;
111 if (off
->vbase_descr
>= 0)
113 /* move this ptr to vbase descriptor */
114 this_ptr
= (char *)this_ptr
+ off
->vbase_descr
;
115 /* and fetch additional offset from vbase descriptor */
116 offset_ptr
= (int *)(*(char **)this_ptr
+ off
->vbase_offset
);
117 this_ptr
= (char *)this_ptr
+ *offset_ptr
;
122 #endif /* __MSVCRT_CPPEXCEPT_H */