ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cppexcept.h
Go to the documentation of this file.
00001 /*
00002  * msvcrt C++ exception handling
00003  *
00004  * Copyright 2002 Alexandre Julliard
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
00019  */
00020 
00021 #ifndef __MSVCRT_CPPEXCEPT_H
00022 #define __MSVCRT_CPPEXCEPT_H
00023 
00024 #include <pseh/pseh2.h>
00025 
00026 #define CXX_FRAME_MAGIC_VC6 0x19930520
00027 #define CXX_FRAME_MAGIC_VC7 0x19930521
00028 #define CXX_FRAME_MAGIC_VC8 0x19930522
00029 #define CXX_EXCEPTION       0xe06d7363
00030 
00031 /* Macros to define assembler functions somewhat portably */
00032 
00033 #define EH_NONCONTINUABLE   0x01
00034 #define EH_UNWINDING        0x02
00035 #define EH_EXIT_UNWIND      0x04
00036 #define EH_STACK_INVALID    0x08
00037 #define EH_NESTED_CALL      0x10
00038 
00039 typedef void (*vtable_ptr)();
00040 
00041 /* type_info object, see cpp.c for inplementation */
00042 typedef struct __type_info
00043 {
00044   const vtable_ptr *vtable;
00045   char              *name;        /* Unmangled name, allocated lazily */
00046   char               mangled[32]; /* Variable length, but we declare it large enough for static RTTI */
00047 } type_info;
00048 
00049 /* exception object */
00050 typedef struct __exception
00051 {
00052   const vtable_ptr *vtable;
00053   char             *name;    /* Name of this exception, always a new copy for each object */
00054   int               do_free; /* Whether to free 'name' in our dtor */
00055 } exception;
00056 
00057 /* the exception frame used by CxxFrameHandler */
00058 typedef struct __cxx_exception_frame
00059 {
00060     EXCEPTION_REGISTRATION_RECORD  frame;    /* the standard exception frame */
00061     int                            trylevel;
00062     DWORD                          ebp;
00063 } cxx_exception_frame;
00064 
00065 /* info about a single catch {} block */
00066 typedef struct __catchblock_info
00067 {
00068     UINT             flags;         /* flags (see below) */
00069     const type_info *type_info;     /* C++ type caught by this block */
00070     int              offset;        /* stack offset to copy exception object to */
00071     void           (*handler)(void);/* catch block handler code */
00072 } catchblock_info;
00073 #define TYPE_FLAG_CONST      1
00074 #define TYPE_FLAG_VOLATILE   2
00075 #define TYPE_FLAG_REFERENCE  8
00076 
00077 /* info about a single try {} block */
00078 typedef struct __tryblock_info
00079 {
00080     int                    start_level;      /* start trylevel of that block */
00081     int                    end_level;        /* end trylevel of that block */
00082     int                    catch_level;      /* initial trylevel of the catch block */
00083     int                    catchblock_count; /* count of catch blocks in array */
00084     const catchblock_info *catchblock;       /* array of catch blocks */
00085 } tryblock_info;
00086 
00087 /* info about the unwind handler for a given trylevel */
00088 typedef struct __unwind_info
00089 {
00090     int    prev;          /* prev trylevel unwind handler, to run after this one */
00091     void (*handler)(void);/* unwind handler */
00092 } unwind_info;
00093 
00094 /* descriptor of all try blocks of a given function */
00095 typedef struct __cxx_function_descr
00096 {
00097     UINT                 magic;          /* must be CXX_FRAME_MAGIC */
00098     UINT                 unwind_count;   /* number of unwind handlers */
00099     const unwind_info   *unwind_table;   /* array of unwind handlers */
00100     UINT                 tryblock_count; /* number of try blocks */
00101     const tryblock_info *tryblock;       /* array of try blocks */
00102     UINT                 ipmap_count;
00103     const void          *ipmap;
00104     const void          *expect_list;    /* expected exceptions list when magic >= VC7 */
00105     UINT                 flags;          /* flags when magic >= VC8 */
00106 } cxx_function_descr;
00107 
00108 #define FUNC_DESCR_SYNCHRONOUS  1        /* synchronous exceptions only (built with /EHs) */
00109 
00110 typedef void (*cxx_copy_ctor)(void);
00111 
00112 /* offsets for computing the this pointer */
00113 typedef struct
00114 {
00115     int         this_offset;   /* offset of base class this pointer from start of object */
00116     int         vbase_descr;   /* offset of virtual base class descriptor */
00117     int         vbase_offset;  /* offset of this pointer offset in virtual base class descriptor */
00118 } this_ptr_offsets;
00119 
00120 /* complete information about a C++ type */
00121 typedef struct __cxx_type_info
00122 {
00123     UINT             flags;        /* flags (see CLASS_* flags below) */
00124     const type_info *type_info;    /* C++ type info */
00125     this_ptr_offsets offsets;      /* offsets for computing the this pointer */
00126     unsigned int     size;         /* object size */
00127     cxx_copy_ctor    copy_ctor;    /* copy constructor */
00128 } cxx_type_info;
00129 #define CLASS_IS_SIMPLE_TYPE          1
00130 #define CLASS_HAS_VIRTUAL_BASE_CLASS  4
00131 
00132 /* table of C++ types that apply for a given object */
00133 typedef struct __cxx_type_info_table
00134 {
00135     UINT                 count;     /* number of types */
00136     const cxx_type_info *info[3];   /* variable length, we declare it large enough for static RTTI */
00137 } cxx_type_info_table;
00138 
00139 typedef DWORD (*cxx_exc_custom_handler)( PEXCEPTION_RECORD, cxx_exception_frame*,
00140                                          PCONTEXT, EXCEPTION_REGISTRATION_RECORD**,
00141                                          const cxx_function_descr*, int nested_trylevel,
00142                                          EXCEPTION_REGISTRATION_RECORD *nested_frame, DWORD unknown3 );
00143 
00144 /* type information for an exception object */
00145 typedef struct __cxx_exception_type
00146 {
00147     UINT                       flags;            /* TYPE_FLAG flags */
00148     void                     (*destructor)(void);/* exception object destructor */
00149     cxx_exc_custom_handler     custom_handler;   /* custom handler for this exception */
00150     const cxx_type_info_table *type_info_table;  /* list of types for this exception object */
00151 } cxx_exception_type;
00152 
00153 void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
00154 int CDECL _XcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
00155 int CDECL __CppXcptFilter(NTSTATUS, PEXCEPTION_POINTERS);
00156 
00157 static inline const char *dbgstr_type_info( const type_info *info )
00158 {
00159     if (!info) return "{}";
00160     return wine_dbg_sprintf( "{vtable=%p name=%s (%s)}",
00161                              info->vtable, info->mangled, info->name ? info->name : "" );
00162 }
00163 
00164 /* compute the this pointer for a base class of a given type */
00165 static inline void *get_this_pointer( const this_ptr_offsets *off, void *object )
00166 {
00167     void *this_ptr;
00168     int *offset_ptr;
00169 
00170     if (!object) return NULL;
00171     this_ptr = (char *)object + off->this_offset;
00172     if (off->vbase_descr >= 0)
00173     {
00174         /* move this ptr to vbase descriptor */
00175         this_ptr = (char *)this_ptr + off->vbase_descr;
00176         /* and fetch additional offset from vbase descriptor */
00177         offset_ptr = (int *)(*(char **)this_ptr + off->vbase_offset);
00178         this_ptr = (char *)this_ptr + *offset_ptr;
00179     }
00180     return this_ptr;
00181 }
00182 
00183 #endif /* __MSVCRT_CPPEXCEPT_H */

Generated on Sun May 27 2012 04:36:28 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.