~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/dlls/msvcrt/cppexcept.h

Version: ~ [ wine-1.1.40 ] ~ [ wine-1.1.39 ] ~ [ wine-1.1.38 ] ~ [ wine-1.1.37 ] ~ [ wine-1.1.36 ] ~ [ wine-1.1.35 ] ~ [ wine-1.1.34 ] ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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)(void);
 28 
 29 /* type_info object, see cpp.c for implementation */
 30 typedef struct __type_info
 31 {
 32   const 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 /* exception object */
 38 typedef struct __exception
 39 {
 40   const vtable_ptr *vtable;
 41   char             *name;    /* Name of this exception, always a new copy for each object */
 42   int               do_free; /* Whether to free 'name' in our dtor */
 43 } exception;
 44 
 45 /* the exception frame used by CxxFrameHandler */
 46 typedef struct __cxx_exception_frame
 47 {
 48     EXCEPTION_REGISTRATION_RECORD  frame;    /* the standard exception frame */
 49     int                            trylevel;
 50     DWORD                          ebp;
 51 } cxx_exception_frame;
 52 
 53 /* info about a single catch {} block */
 54 typedef struct __catchblock_info
 55 {
 56     UINT             flags;         /* flags (see below) */
 57     const type_info *type_info;     /* C++ type caught by this block */
 58     int              offset;        /* stack offset to copy exception object to */
 59     void           (*handler)(void);/* catch block handler code */
 60 } catchblock_info;
 61 #define TYPE_FLAG_CONST      1
 62 #define TYPE_FLAG_VOLATILE   2
 63 #define TYPE_FLAG_REFERENCE  8
 64 
 65 /* info about a single try {} block */
 66 typedef struct __tryblock_info
 67 {
 68     int                    start_level;      /* start trylevel of that block */
 69     int                    end_level;        /* end trylevel of that block */
 70     int                    catch_level;      /* initial trylevel of the catch block */
 71     int                    catchblock_count; /* count of catch blocks in array */
 72     const catchblock_info *catchblock;       /* array of catch blocks */
 73 } tryblock_info;
 74 
 75 /* info about the unwind handler for a given trylevel */
 76 typedef struct __unwind_info
 77 {
 78     int    prev;          /* prev trylevel unwind handler, to run after this one */
 79     void (*handler)(void);/* unwind handler */
 80 } unwind_info;
 81 
 82 /* descriptor of all try blocks of a given function */
 83 typedef struct __cxx_function_descr
 84 {
 85     UINT                 magic;          /* must be CXX_FRAME_MAGIC */
 86     UINT                 unwind_count;   /* number of unwind handlers */
 87     const unwind_info   *unwind_table;   /* array of unwind handlers */
 88     UINT                 tryblock_count; /* number of try blocks */
 89     const tryblock_info *tryblock;       /* array of try blocks */
 90     UINT                 unknown[3];
 91 } cxx_function_descr;
 92 
 93 typedef void (*cxx_copy_ctor)(void);
 94 
 95 /* offsets for computing the this pointer */
 96 typedef struct
 97 {
 98     int         this_offset;   /* offset of base class this pointer from start of object */
 99     int         vbase_descr;   /* offset of virtual base class descriptor */
100     int         vbase_offset;  /* offset of this pointer offset in virtual base class descriptor */
101 } this_ptr_offsets;
102 
103 /* complete information about a C++ type */
104 typedef struct __cxx_type_info
105 {
106     UINT             flags;        /* flags (see CLASS_* flags below) */
107     const type_info *type_info;    /* C++ type info */
108     this_ptr_offsets offsets;      /* offsets for computing the this pointer */
109     unsigned int     size;         /* object size */
110     cxx_copy_ctor    copy_ctor;    /* copy constructor */
111 } cxx_type_info;
112 #define CLASS_IS_SIMPLE_TYPE          1
113 #define CLASS_HAS_VIRTUAL_BASE_CLASS  4
114 
115 /* table of C++ types that apply for a given object */
116 typedef struct __cxx_type_info_table
117 {
118     UINT                 count;     /* number of types */
119     const cxx_type_info *info[3];   /* variable length, we declare it large enough for static RTTI */
120 } cxx_type_info_table;
121 
122 typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*,
123                                          PCONTEXT, EXCEPTION_REGISTRATION_RECORD**,
124                                          const cxx_function_descr*, int nested_trylevel,
125                                          EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 );
126 
127 /* type information for an exception object */
128 typedef struct __cxx_exception_type
129 {
130     UINT                       flags;            /* TYPE_FLAG flags */
131     void                     (*destructor)(void);/* exception object destructor */
132     cxx_exc_custom_handler     custom_handler;   /* custom handler for this exception */
133     const cxx_type_info_table *type_info_table;  /* list of types for this exception object */
134 } cxx_exception_type;
135 
136 void CDECL _CxxThrowException(exception*,const cxx_exception_type*);
137 int CDECL _XcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
138 int CDECL __CppXcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
139 
140 static inline const char *dbgstr_type_info( const type_info *info )
141 {
142     if (!info) return "{}";
143     return wine_dbg_sprintf( "{vtable=%p name=%s (%s)}",
144                              info->vtable, info->mangled, info->name ? info->name : "" );
145 }
146 
147 /* compute the this pointer for a base class of a given type */
148 static inline void *get_this_pointer( const this_ptr_offsets *off, void *object )
149 {
150     void *this_ptr;
151     int *offset_ptr;
152 
153     if (!object) return NULL;
154     this_ptr = (char *)object + off->this_offset;
155     if (off->vbase_descr >= 0)
156     {
157         /* move this ptr to vbase descriptor */
158         this_ptr = (char *)this_ptr + off->vbase_descr;
159         /* and fetch additional offset from vbase descriptor */
160         offset_ptr = (int *)(*(char **)this_ptr + off->vbase_offset);
161         this_ptr = (char *)this_ptr + *offset_ptr;
162     }
163     return this_ptr;
164 }
165 
166 #endif /* __MSVCRT_CPPEXCEPT_H */
167 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.