ReactOS 0.4.16-dev-2104-gb84fa49
cpp.c File Reference
#include <stdarg.h>
#include <stdbool.h>
#include "windef.h"
#include "winternl.h"
#include "winbase.h"
#include "winver.h"
#include "imagehlp.h"
#include "wine/exception.h"
#include "wine/debug.h"
#include "msvcrt.h"
#include "mtdll.h"
#include "cppexcept.h"
Include dependency graph for cpp.c:

Go to the source code of this file.

Classes

struct  __type_info_node
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msvcrt)
 
static const vtable_ptrget_vtable (void *obj)
 
static const rtti_object_locatorget_obj_locator (void *cppobj)
 
static uintptr_t get_obj_locator_base (const rtti_object_locator *ptr)
 
static void dump_obj_locator (const rtti_object_locator *ptr)
 
exception __thiscall exception_ctor (exception *_this, const char **name)
 
exception __thiscall exception_ctor_noalloc (exception *_this, char **name, int noalloc)
 
exception __thiscall exception_default_ctor (exception *_this)
 
exception __thiscall exception_opequals (exception *_this, const exception *rhs)
 
void *__thiscall exception_scalar_dtor (exception *_this, unsigned int flags)
 
bad_typeid *__thiscall bad_typeid_copy_ctor (bad_typeid *_this, const bad_typeid *rhs)
 
bad_typeid *__thiscall bad_typeid_ctor (bad_typeid *_this, const char *name)
 
bad_typeid *__thiscall bad_typeid_default_ctor (bad_typeid *_this)
 
void __thiscall bad_typeid_dtor (bad_typeid *_this)
 
bad_typeid *__thiscall bad_typeid_opequals (bad_typeid *_this, const bad_typeid *rhs)
 
void *__thiscall bad_typeid_vector_dtor (bad_typeid *_this, unsigned int flags)
 
void *__thiscall bad_typeid_scalar_dtor (bad_typeid *_this, unsigned int flags)
 
__non_rtti_object *__thiscall __non_rtti_object_copy_ctor (__non_rtti_object *_this, const __non_rtti_object *rhs)
 
__non_rtti_object *__thiscall __non_rtti_object_ctor (__non_rtti_object *_this, const char *name)
 
void __thiscall __non_rtti_object_dtor (__non_rtti_object *_this)
 
__non_rtti_object *__thiscall __non_rtti_object_opequals (__non_rtti_object *_this, const __non_rtti_object *rhs)
 
void *__thiscall __non_rtti_object_vector_dtor (__non_rtti_object *_this, unsigned int flags)
 
void *__thiscall __non_rtti_object_scalar_dtor (__non_rtti_object *_this, unsigned int flags)
 
bad_cast *__thiscall bad_cast_ctor (bad_cast *_this, const char **name)
 
bad_cast *__thiscall bad_cast_copy_ctor (bad_cast *_this, const bad_cast *rhs)
 
bad_cast *__thiscall bad_cast_ctor_charptr (bad_cast *_this, const char *name)
 
bad_cast *__thiscall bad_cast_default_ctor (bad_cast *_this)
 
void __thiscall bad_cast_dtor (bad_cast *_this)
 
bad_cast *__thiscall bad_cast_opequals (bad_cast *_this, const bad_cast *rhs)
 
void *__thiscall bad_cast_vector_dtor (bad_cast *_this, unsigned int flags)
 
void *__thiscall bad_cast_scalar_dtor (bad_cast *_this, unsigned int flags)
 
int __thiscall type_info_opequals_equals (type_info *_this, const type_info *rhs)
 
int __thiscall type_info_opnot_equals (type_info *_this, const type_info *rhs)
 
int __thiscall type_info_before (type_info *_this, const type_info *rhs)
 
void __thiscall type_info_dtor (type_info *_this)
 
const char *__thiscall type_info_name (type_info *_this)
 
const char *__thiscall type_info_raw_name (type_info *_this)
 
 __ASM_VTABLE (bad_typeid, VTABLE_ADD_FUNC(exception_what))
 
 __ASM_VTABLE (bad_cast, VTABLE_ADD_FUNC(exception_what))
 
 __ASM_VTABLE (__non_rtti_object, VTABLE_ADD_FUNC(exception_what))
 
__ASM_BLOCK_END DEFINE_CXX_DATA2 (__non_rtti_object, &bad_typeid_cxx_type_info, &exception_cxx_type_info, __non_rtti_object_dtor) void msvcrt_init_exception(void *base)
 
void throw_exception (const char *msg)
 
terminate_function CDECL set_terminate (terminate_function func)
 
terminate_function CDECL _get_terminate (void)
 
unexpected_function CDECL set_unexpected (unexpected_function func)
 
unexpected_function CDECL _get_unexpected (void)
 
_se_translator_function CDECL _set_se_translator (_se_translator_function func)
 
void CDECL terminate (void)
 
void CDECL unexpected (void)
 
const type_info *CDECL __RTtypeid (void *cppobj)
 
void *CDECL __RTDynamicCast (void *cppobj, int unknown, type_info *src, type_info *dst, int do_throw)
 
void *CDECL __RTCastToVoid (void *cppobj)
 
void WINAPI _CxxThrowException (void *object, const cxx_exception_type *type)
 

Variables

const vtable_ptr bad_typeid_vtable
 
const vtable_ptr bad_cast_vtable
 
const vtable_ptr __non_rtti_object_vtable
 
const vtable_ptr type_info_vtable
 

Function Documentation

◆ __ASM_VTABLE() [1/3]

__ASM_VTABLE ( __non_rtti_object  ,
VTABLE_ADD_FUNC(exception_what  
)

◆ __ASM_VTABLE() [2/3]

__ASM_VTABLE ( bad_cast  ,
VTABLE_ADD_FUNC(exception_what  
)

◆ __ASM_VTABLE() [3/3]

__ASM_VTABLE ( bad_typeid  ,
VTABLE_ADD_FUNC(exception_what  
)

◆ __non_rtti_object_copy_ctor()

__non_rtti_object *__thiscall __non_rtti_object_copy_ctor ( __non_rtti_object _this,
const __non_rtti_object rhs 
)

Definition at line 251 of file cpp.c.

253{
254 TRACE("(%p %p)\n", _this, rhs);
255 return __exception_copy_ctor(_this, rhs, &__non_rtti_object_vtable);
256}
const vtable_ptr __non_rtti_object_vtable
#define TRACE(s)
Definition: solgame.cpp:4

◆ __non_rtti_object_ctor()

__non_rtti_object *__thiscall __non_rtti_object_ctor ( __non_rtti_object _this,
const char name 
)

Definition at line 262 of file cpp.c.

264{
265 TRACE("(%p %s)\n", _this, name);
266 return __exception_ctor(_this, name, &__non_rtti_object_vtable);
267}
Definition: name.c:39

Referenced by __RTCastToVoid(), __RTDynamicCast(), and __RTtypeid().

◆ __non_rtti_object_dtor()

void __thiscall __non_rtti_object_dtor ( __non_rtti_object _this)

Definition at line 273 of file cpp.c.

274{
275 TRACE("(%p)\n", _this);
276 bad_typeid_dtor(_this);
277}
void __thiscall bad_typeid_dtor(bad_typeid *_this)
Definition: cpp.c:195

Referenced by __non_rtti_object_scalar_dtor(), and __non_rtti_object_vector_dtor().

◆ __non_rtti_object_opequals()

__non_rtti_object *__thiscall __non_rtti_object_opequals ( __non_rtti_object _this,
const __non_rtti_object rhs 
)

Definition at line 283 of file cpp.c.

285{
286 TRACE("(%p %p)\n", _this, rhs);
287 bad_typeid_opequals(_this, rhs);
288 return _this;
289}
bad_typeid *__thiscall bad_typeid_opequals(bad_typeid *_this, const bad_typeid *rhs)
Definition: cpp.c:205

◆ __non_rtti_object_scalar_dtor()

void *__thiscall __non_rtti_object_scalar_dtor ( __non_rtti_object _this,
unsigned int  flags 
)

Definition at line 318 of file cpp.c.

319{
320 TRACE("(%p %x)\n", _this, flags);
322 if (flags & 1) operator_delete(_this);
323 return _this;
324}
void __thiscall __non_rtti_object_dtor(__non_rtti_object *_this)
Definition: cpp.c:273
void CDECL DECLSPEC_HOTPATCH operator_delete(void *mem)
Definition: heap.c:177
GLbitfield flags
Definition: glext.h:7161

◆ __non_rtti_object_vector_dtor()

void *__thiscall __non_rtti_object_vector_dtor ( __non_rtti_object _this,
unsigned int  flags 
)

Definition at line 295 of file cpp.c.

296{
297 TRACE("(%p %x)\n", _this, flags);
298 if (flags & 2)
299 {
300 /* we have an array, with the number of elements stored before the first object */
301 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
302
303 for (i = *ptr - 1; i >= 0; i--) __non_rtti_object_dtor(_this + i);
305 }
306 else
307 {
309 if (flags & 1) operator_delete(_this);
310 }
311 return _this;
312}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static PVOID ptr
Definition: dispmode.c:27
int32_t INT_PTR
Definition: typedefs.h:64

◆ __RTCastToVoid()

void *CDECL __RTCastToVoid ( void cppobj)

Definition at line 865 of file cpp.c.

866{
867 void *ret;
868
869 if (!cppobj) return NULL;
870
871 __TRY
872 {
873 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
874 ret = (char *)cppobj - obj_locator->base_class_offset;
875 }
877 {
879 __non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
880 _CxxThrowException( &e, &__non_rtti_object_exception_type );
881 }
883 return ret;
884}
#define NULL
Definition: types.h:112
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
void WINAPI _CxxThrowException(void *object, const cxx_exception_type *type)
Definition: cpp.c:890
__non_rtti_object *__thiscall __non_rtti_object_ctor(__non_rtti_object *_this, const char *name)
Definition: cpp.c:262
static const rtti_object_locator * get_obj_locator(void *cppobj)
Definition: cpp.c:62
return ret
Definition: mutex.c:146
#define e
Definition: ke_i.h:82
#define __non_rtti_object
Definition: msvc_fwd_decl.h:4
int base_class_offset
Definition: cxx.h:427

◆ __RTDynamicCast()

void *CDECL __RTDynamicCast ( void cppobj,
int  unknown,
type_info src,
type_info dst,
int  do_throw 
)

Definition at line 784 of file cpp.c.

787{
788 void *ret;
789
790 if (!cppobj) return NULL;
791
792 TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n",
793 cppobj, unknown, src, dbgstr_type_info(src), dst, dbgstr_type_info(dst), do_throw);
794
795 /* To cast an object at runtime:
796 * 1.Find out the true type of the object from the typeinfo at vtable[-1]
797 * 2.Search for the destination type in the class hierarchy
798 * 3.If destination type is found, return base object address + dest offset
799 * Otherwise, fail the cast
800 *
801 * FIXME: the unknown parameter doesn't seem to be used for anything
802 */
803 __TRY
804 {
805 int i;
806 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
807 uintptr_t base = get_obj_locator_base( obj_locator );
808 const rtti_object_hierarchy *obj_bases = rtti_rva( obj_locator->type_hierarchy, base );
809 const rtti_base_array *base_array = rtti_rva( obj_bases->base_classes, base );
810
811 if (TRACE_ON(msvcrt)) dump_obj_locator(obj_locator);
812
813 ret = NULL;
814 for (i = 0; i < obj_bases->array_len; i++)
815 {
816 const rtti_base_descriptor *base_desc = rtti_rva( base_array->bases[i], base );
817 const type_info *typ = rtti_rva( base_desc->type_descriptor, base );
818
819 if (!strcmp(typ->mangled, dst->mangled))
820 {
821 /* compute the correct this pointer for that base class */
822 void *this_ptr = (char *)cppobj - obj_locator->base_class_offset;
823 ret = get_this_pointer( &base_desc->offsets, this_ptr );
824 break;
825 }
826 }
827 /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned
828 * to a reference, since references cannot be NULL.
829 */
830 if (!ret && do_throw)
831 {
832 const char *msg = "Bad dynamic_cast!";
833 bad_cast e;
834 bad_cast_ctor( &e, &msg );
835 _CxxThrowException( &e, &bad_cast_exception_type );
836 }
837 }
839 {
841 __non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
842 _CxxThrowException( &e, &__non_rtti_object_exception_type );
843 }
845 return ret;
846}
#define msg(x)
Definition: auth_time.c:54
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define TRACE_ON(x)
Definition: compat.h:75
bad_cast *__thiscall bad_cast_ctor(bad_cast *_this, const char **name)
Definition: cpp.c:331
static void dump_obj_locator(const rtti_object_locator *ptr)
Definition: cpp.c:76
static uintptr_t get_obj_locator_base(const rtti_object_locator *ptr)
Definition: cpp.c:68
static const char * dbgstr_type_info(const type_info *info)
Definition: cppexcept.h:169
static void * get_this_pointer(const this_ptr_offsets *off, void *object)
Definition: cppexcept.h:177
static void * rtti_rva(unsigned int rva, uintptr_t base)
Definition: cxx.h:469
unsigned int uintptr_t
Definition: corecrt.h:185
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
#define bad_cast
Definition: msvc_fwd_decl.h:2
char mangled[128]
Definition: cxx.h:335
unsigned int bases[10]
Definition: cxx.h:413
unsigned int type_descriptor
Definition: cxx.h:405
this_ptr_offsets offsets
Definition: cxx.h:407
unsigned int base_classes
Definition: cxx.h:421
unsigned int type_hierarchy
Definition: cxx.h:430

◆ __RTtypeid()

const type_info *CDECL __RTtypeid ( void cppobj)

Definition at line 734 of file cpp.c.

735{
736 const type_info *ret;
737
738 if (!cppobj)
739 {
741 bad_typeid_ctor( &e, "Attempted a typeid of NULL pointer!" );
742 _CxxThrowException( &e, &bad_typeid_exception_type );
743 }
744
745 __TRY
746 {
747 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
748 uintptr_t base = get_obj_locator_base( obj_locator );
749
750 ret = rtti_rva( obj_locator->type_descriptor, base );
751 }
753 {
755 __non_rtti_object_ctor( &e, "Bad read pointer - no RTTI data!" );
756 _CxxThrowException( &e, &__non_rtti_object_exception_type );
757 }
759 return ret;
760}
bad_typeid *__thiscall bad_typeid_ctor(bad_typeid *_this, const char *name)
Definition: cpp.c:176
#define bad_typeid
Definition: msvc_fwd_decl.h:3
unsigned int type_descriptor
Definition: cxx.h:429

◆ _CxxThrowException()

void WINAPI _CxxThrowException ( void object,
const cxx_exception_type type 
)

Definition at line 890 of file cpp.c.

891{
893
895 args[1] = (ULONG_PTR)object;
896 args[2] = (ULONG_PTR)type;
899}
VOID WINAPI RaiseException(_In_ DWORD dwExceptionCode, _In_ DWORD dwExceptionFlags, _In_ DWORD nNumberOfArguments, _In_opt_ const ULONG_PTR *lpArguments)
Definition: except.c:700
#define CXX_EXCEPTION
Definition: cppexcept.h:34
#define CXX_FRAME_MAGIC_VC6
Definition: cppexcept.h:31
#define CXX_EXCEPTION_PARAMS
Definition: cppexcept.h:89
static uintptr_t rtti_rva_base(const void *ptr)
Definition: cxx.h:463
#define ULONG_PTR
Definition: config.h:101
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
Definition: match.c:390
#define EXCEPTION_NONCONTINUABLE
Definition: stubs.h:23
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by __ExceptionPtrRethrow(), __RTCastToVoid(), __RTDynamicCast(), __RTtypeid(), and throw_exception().

◆ _get_terminate()

terminate_function CDECL _get_terminate ( void  )

Definition at line 636 of file cpp.c.

637{
639 TRACE("returning %p\n", data->terminate_handler);
640 return data->terminate_handler;
641}
thread_data_t *CDECL msvcrt_get_thread_data(void)
Definition: thread.c:45
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

◆ _get_unexpected()

unexpected_function CDECL _get_unexpected ( void  )

Definition at line 666 of file cpp.c.

667{
669 TRACE("returning %p\n", data->unexpected_handler);
670 return data->unexpected_handler;
671}

◆ _set_se_translator()

Definition at line 676 of file cpp.c.

677{
679 _se_translator_function previous = data->se_translator;
680 TRACE("(%p) returning %p\n",func,previous);
681 data->se_translator = func;
682 return previous;
683}
void(__cdecl * _se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info)
Definition: eh.h:37
GLenum func
Definition: glext.h:6028

◆ bad_cast_copy_ctor()

bad_cast *__thiscall bad_cast_copy_ctor ( bad_cast _this,
const bad_cast rhs 
)

Definition at line 341 of file cpp.c.

342{
343 TRACE("(%p %p)\n", _this, rhs);
344 return __exception_copy_ctor(_this, rhs, &bad_cast_vtable);
345}
const vtable_ptr bad_cast_vtable

◆ bad_cast_ctor()

bad_cast *__thiscall bad_cast_ctor ( bad_cast _this,
const char **  name 
)

Definition at line 331 of file cpp.c.

332{
333 TRACE("(%p %s)\n", _this, *name);
334 return __exception_ctor(_this, *name, &bad_cast_vtable);
335}

Referenced by __RTDynamicCast().

◆ bad_cast_ctor_charptr()

bad_cast *__thiscall bad_cast_ctor_charptr ( bad_cast _this,
const char name 
)

Definition at line 351 of file cpp.c.

352{
353 TRACE("(%p %s)\n", _this, name);
354 return __exception_ctor(_this, name, &bad_cast_vtable);
355}

Referenced by bad_cast_default_ctor().

◆ bad_cast_default_ctor()

bad_cast *__thiscall bad_cast_default_ctor ( bad_cast _this)

Definition at line 361 of file cpp.c.

362{
363 return bad_cast_ctor_charptr( _this, "bad cast" );
364}
bad_cast *__thiscall bad_cast_ctor_charptr(bad_cast *_this, const char *name)
Definition: cpp.c:351

◆ bad_cast_dtor()

void __thiscall bad_cast_dtor ( bad_cast _this)

Definition at line 370 of file cpp.c.

371{
372 TRACE("(%p)\n", _this);
373 exception_dtor(_this);
374}
void __thiscall exception_dtor(exception *_this)

Referenced by bad_cast_scalar_dtor(), and bad_cast_vector_dtor().

◆ bad_cast_opequals()

bad_cast *__thiscall bad_cast_opequals ( bad_cast _this,
const bad_cast rhs 
)

Definition at line 380 of file cpp.c.

381{
382 TRACE("(%p %p)\n", _this, rhs);
383 exception_opequals(_this, rhs);
384 return _this;
385}
exception __thiscall exception_opequals(exception *_this, const exception *rhs)
Definition: cpp.c:138

◆ bad_cast_scalar_dtor()

void *__thiscall bad_cast_scalar_dtor ( bad_cast _this,
unsigned int  flags 
)

Definition at line 414 of file cpp.c.

415{
416 TRACE("(%p %x)\n", _this, flags);
417 bad_cast_dtor(_this);
418 if (flags & 1) operator_delete(_this);
419 return _this;
420}
void __thiscall bad_cast_dtor(bad_cast *_this)
Definition: cpp.c:370

◆ bad_cast_vector_dtor()

void *__thiscall bad_cast_vector_dtor ( bad_cast _this,
unsigned int  flags 
)

Definition at line 391 of file cpp.c.

392{
393 TRACE("(%p %x)\n", _this, flags);
394 if (flags & 2)
395 {
396 /* we have an array, with the number of elements stored before the first object */
397 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
398
399 for (i = *ptr - 1; i >= 0; i--) bad_cast_dtor(_this + i);
401 }
402 else
403 {
404 bad_cast_dtor(_this);
405 if (flags & 1) operator_delete(_this);
406 }
407 return _this;
408}

◆ bad_typeid_copy_ctor()

bad_typeid *__thiscall bad_typeid_copy_ctor ( bad_typeid _this,
const bad_typeid rhs 
)

Definition at line 166 of file cpp.c.

167{
168 TRACE("(%p %p)\n", _this, rhs);
169 return __exception_copy_ctor(_this, rhs, &bad_typeid_vtable);
170}
const vtable_ptr bad_typeid_vtable

◆ bad_typeid_ctor()

bad_typeid *__thiscall bad_typeid_ctor ( bad_typeid _this,
const char name 
)

Definition at line 176 of file cpp.c.

177{
178 TRACE("(%p %s)\n", _this, name);
179 return __exception_ctor(_this, name, &bad_typeid_vtable);
180}

Referenced by __RTtypeid(), and bad_typeid_default_ctor().

◆ bad_typeid_default_ctor()

bad_typeid *__thiscall bad_typeid_default_ctor ( bad_typeid _this)

Definition at line 186 of file cpp.c.

187{
188 return bad_typeid_ctor( _this, "bad typeid" );
189}

◆ bad_typeid_dtor()

void __thiscall bad_typeid_dtor ( bad_typeid _this)

Definition at line 195 of file cpp.c.

196{
197 TRACE("(%p)\n", _this);
198 exception_dtor(_this);
199}

Referenced by __non_rtti_object_dtor(), bad_typeid_scalar_dtor(), and bad_typeid_vector_dtor().

◆ bad_typeid_opequals()

bad_typeid *__thiscall bad_typeid_opequals ( bad_typeid _this,
const bad_typeid rhs 
)

Definition at line 205 of file cpp.c.

206{
207 TRACE("(%p %p)\n", _this, rhs);
208 exception_opequals(_this, rhs);
209 return _this;
210}

Referenced by __non_rtti_object_opequals().

◆ bad_typeid_scalar_dtor()

void *__thiscall bad_typeid_scalar_dtor ( bad_typeid _this,
unsigned int  flags 
)

Definition at line 239 of file cpp.c.

240{
241 TRACE("(%p %x)\n", _this, flags);
242 bad_typeid_dtor(_this);
243 if (flags & 1) operator_delete(_this);
244 return _this;
245}

◆ bad_typeid_vector_dtor()

void *__thiscall bad_typeid_vector_dtor ( bad_typeid _this,
unsigned int  flags 
)

Definition at line 216 of file cpp.c.

217{
218 TRACE("(%p %x)\n", _this, flags);
219 if (flags & 2)
220 {
221 /* we have an array, with the number of elements stored before the first object */
222 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
223
224 for (i = *ptr - 1; i >= 0; i--) bad_typeid_dtor(_this + i);
226 }
227 else
228 {
229 bad_typeid_dtor(_this);
230 if (flags & 1) operator_delete(_this);
231 }
232 return _this;
233}

◆ DEFINE_CXX_DATA2()

__ASM_BLOCK_END DEFINE_CXX_DATA2 ( __non_rtti_object  ,
bad_typeid_cxx_type_info,
exception_cxx_type_info,
__non_rtti_object_dtor   
)

Definition at line 568 of file cpp.c.

575{
576#ifdef RTTI_USE_RVA
577 init_type_info_rtti(base);
578 init_exception_rtti(base);
579#if _MSVCR_VER >= 80
580 init_exception_old_rtti(base);
581 init_bad_alloc_rtti(base);
582#endif
583 init_bad_typeid_rtti(base);
584 init_bad_cast_rtti(base);
585 init___non_rtti_object_rtti(base);
586
587 init_exception_cxx(base);
588 init_bad_typeid_cxx(base);
589 init_bad_cast_cxx(base);
590 init___non_rtti_object_cxx(base);
591#if _MSVCR_VER >= 80
592 init_bad_alloc_cxx(base);
593#endif
594#endif
595}

◆ dump_obj_locator()

static void dump_obj_locator ( const rtti_object_locator ptr)
static

Definition at line 76 of file cpp.c.

77{
78 int i;
80 const rtti_object_hierarchy *h = rtti_rva( ptr->type_hierarchy, base );
81 const type_info *type_descriptor = rtti_rva( ptr->type_descriptor, base );
82
83 TRACE( "%p: sig=%08x base_offset=%08x flags=%08x type=%p %s hierarchy=%p\n",
84 ptr, ptr->signature, ptr->base_class_offset, ptr->flags,
85 type_descriptor, dbgstr_type_info(type_descriptor), h );
86 TRACE( " hierarchy: sig=%08x attr=%08x len=%d base classes=%p\n",
87 h->signature, h->attributes, h->array_len, rtti_rva(h->base_classes, base) );
88 for (i = 0; i < h->array_len; i++)
89 {
90 const rtti_base_array *base_array = rtti_rva( h->base_classes, base );
91 const rtti_base_descriptor *bases = rtti_rva( base_array->bases[i], base );
92
93 TRACE( " base class %p: num %d off %d,%d,%d attr %08x type %p %s\n",
94 bases, bases->num_base_classes, bases->offsets.this_offset,
95 bases->offsets.vbase_descr, bases->offsets.vbase_offset, bases->attributes,
96 rtti_rva( bases->type_descriptor, base ),
97 dbgstr_type_info((const type_info*)(base + bases->type_descriptor)) );
98 }
99}
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
unsigned int attributes
Definition: cxx.h:408
int num_base_classes
Definition: cxx.h:406
int this_offset
Definition: cxx.h:341
int vbase_offset
Definition: cxx.h:343
int vbase_descr
Definition: cxx.h:342

Referenced by __RTDynamicCast().

◆ exception_ctor()

exception __thiscall exception_ctor ( exception _this,
const char **  name 
)

Definition at line 105 of file cpp.c.

106{
107 TRACE("(%p,%s)\n", _this, *name);
108 return __exception_ctor(_this, *name, &exception_vtable);
109}

Referenced by __ExceptionPtrRethrow().

◆ exception_ctor_noalloc()

exception __thiscall exception_ctor_noalloc ( exception _this,
char **  name,
int  noalloc 
)

Definition at line 115 of file cpp.c.

116{
117 TRACE("(%p,%s)\n", _this, *name);
118 _this->vtable = &exception_vtable;
119 _this->name = *name;
120 _this->do_free = FALSE;
121 return _this;
122}
#define FALSE
Definition: types.h:117
char * name
Definition: cxx.h:326
const vtable_ptr * vtable
Definition: cxx.h:325
int do_free
Definition: cxx.h:327

◆ exception_default_ctor()

exception __thiscall exception_default_ctor ( exception _this)

Definition at line 128 of file cpp.c.

129{
130 TRACE("(%p)\n", _this);
131 return __exception_ctor(_this, NULL, &exception_vtable);
132}

◆ exception_opequals()

exception __thiscall exception_opequals ( exception _this,
const exception rhs 
)

Definition at line 138 of file cpp.c.

139{
140 TRACE("(%p %p)\n", _this, rhs);
141 if (_this != rhs)
142 {
143 exception_dtor(_this);
144 exception_copy_ctor(_this, rhs);
145 }
146 TRACE("name = %s\n", _this->name);
147 return _this;
148}
exception *__thiscall exception_copy_ctor(exception *_this, const exception *rhs)

Referenced by bad_cast_opequals(), and bad_typeid_opequals().

◆ exception_scalar_dtor()

void *__thiscall exception_scalar_dtor ( exception _this,
unsigned int  flags 
)

Definition at line 154 of file cpp.c.

155{
156 TRACE("(%p %x)\n", _this, flags);
157 exception_dtor(_this);
158 if (flags & 1) operator_delete(_this);
159 return _this;
160}

◆ get_obj_locator()

static const rtti_object_locator * get_obj_locator ( void cppobj)
inlinestatic

Definition at line 62 of file cpp.c.

63{
64 const vtable_ptr *vtable = get_vtable( cppobj );
65 return (const rtti_object_locator *)vtable[-1];
66}
static const vtable_ptr * get_vtable(void *obj)
Definition: cpp.c:57
void(* vtable_ptr)(void)
Definition: cxx.h:322
static void * vtable[]
Definition: typelib.c:1231

Referenced by __RTCastToVoid(), __RTDynamicCast(), __RTtypeid(), and test_rtti().

◆ get_obj_locator_base()

static uintptr_t get_obj_locator_base ( const rtti_object_locator ptr)
static

Definition at line 68 of file cpp.c.

69{
70#ifdef RTTI_USE_RVA
71 if (ptr->signature) return (uintptr_t)ptr - ptr->object_locator;
72#endif
73 return rtti_rva_base( ptr );
74}

Referenced by __RTDynamicCast(), __RTtypeid(), and dump_obj_locator().

◆ get_vtable()

static const vtable_ptr * get_vtable ( void obj)
inlinestatic

Definition at line 57 of file cpp.c.

58{
59 return *(const vtable_ptr **)obj;
60}

Referenced by get_obj_locator().

◆ set_terminate()

terminate_function CDECL set_terminate ( terminate_function  func)

Definition at line 624 of file cpp.c.

625{
627 terminate_function previous = data->terminate_handler;
628 TRACE("(%p) returning %p\n",func,previous);
629 data->terminate_handler = func;
630 return previous;
631}
void(__cdecl * terminate_function)(void)
Definition: eh.h:34

Referenced by main(), and Terminate1().

◆ set_unexpected()

unexpected_function CDECL set_unexpected ( unexpected_function  func)

Definition at line 654 of file cpp.c.

655{
657 unexpected_function previous = data->unexpected_handler;
658 TRACE("(%p) returning %p\n",func,previous);
659 data->unexpected_handler = func;
660 return previous;
661}
void(__cdecl * unexpected_function)(void)
Definition: eh.h:36

◆ terminate()

◆ throw_exception()

void throw_exception ( const char msg)

Definition at line 606 of file cpp.c.

607{
608 exception e;
609 __exception_ctor(&e, msg, &exception_vtable);
610 _CxxThrowException(&e, &exception_exception_type);
611}

◆ type_info_before()

int __thiscall type_info_before ( type_info _this,
const type_info rhs 
)

Definition at line 448 of file cpp.c.

449{
450 int ret = strcmp(_this->mangled + 1, rhs->mangled + 1) < 0;
451 TRACE("(%p %p) returning %d\n", _this, rhs, ret);
452 return ret;
453}

◆ type_info_dtor()

void __thiscall type_info_dtor ( type_info _this)

Definition at line 459 of file cpp.c.

460{
461 TRACE("(%p)\n", _this);
462 free(_this->name);
463}
#define free
Definition: debug_ros.c:5
char * name
Definition: cxx.h:334

◆ type_info_name()

const char *__thiscall type_info_name ( type_info _this)

Definition at line 469 of file cpp.c.

470{
471 if (!_this->name)
472 {
473 /* Create and set the demangled name */
474 /* Note: mangled name in type_info struct always starts with a '.', while
475 * it isn't valid for mangled name.
476 * Is this '.' really part of the mangled name, or has it some other meaning ?
477 */
478 char* name = __unDName(0, _this->mangled + 1, 0,
480 if (name)
481 {
482 unsigned int len = strlen(name);
483
484 /* It seems _unDName may leave blanks at the end of the demangled name */
485 while (len && name[--len] == ' ')
486 name[len] = '\0';
487
488 if (InterlockedCompareExchangePointer((void**)&_this->name, name, NULL))
489 {
490 /* Another thread set this member since we checked above - use it */
491 free(name);
492 }
493 }
494 }
495 TRACE("(%p) returning %s\n", _this, _this->name);
496 return _this->name;
497}
#define UNDNAME_32_BIT_DECODE
Definition: dbghelp.h:1264
#define UNDNAME_NO_ARGUMENTS
Definition: dbghelp.h:1266
#define malloc
Definition: debug_ros.c:4
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
char *__cdecl __unDName(char *, const char *, int, malloc_func_t, free_func_t, unsigned short int)
Definition: undname.c:1783
GLenum GLsizei len
Definition: glext.h:6722
#define InterlockedCompareExchangePointer
Definition: interlocked.h:144

◆ type_info_opequals_equals()

int __thiscall type_info_opequals_equals ( type_info _this,
const type_info rhs 
)

Definition at line 426 of file cpp.c.

427{
428 int ret = !strcmp(_this->mangled + 1, rhs->mangled + 1);
429 TRACE("(%p %p) returning %d\n", _this, rhs, ret);
430 return ret;
431}

◆ type_info_opnot_equals()

int __thiscall type_info_opnot_equals ( type_info _this,
const type_info rhs 
)

Definition at line 437 of file cpp.c.

438{
439 int ret = !!strcmp(_this->mangled + 1, rhs->mangled + 1);
440 TRACE("(%p %p) returning %d\n", _this, rhs, ret);
441 return ret;
442}

◆ type_info_raw_name()

const char *__thiscall type_info_raw_name ( type_info _this)

Definition at line 503 of file cpp.c.

504{
505 TRACE("(%p) returning %s\n", _this, _this->mangled);
506 return _this->mangled;
507}

◆ unexpected()

void CDECL unexpected ( void  )

Definition at line 708 of file cpp.c.

709{
711 if (data->unexpected_handler) data->unexpected_handler();
712 terminate();
713}
void CDECL terminate(void)
Definition: cpp.c:698

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msvcrt  )

Variable Documentation

◆ __non_rtti_object_vtable

const vtable_ptr __non_rtti_object_vtable
extern

◆ bad_cast_vtable

const vtable_ptr bad_cast_vtable
extern

◆ bad_typeid_vtable

const vtable_ptr bad_typeid_vtable
extern

◆ type_info_vtable

const vtable_ptr type_info_vtable
extern