ReactOS 0.4.15-dev-6068-g8061a6f
cpp.c File Reference
#include "config.h"
#include "wine/port.h"
#include <stdarg.h>
#include "windef.h"
#include "winternl.h"
#include "wine/exception.h"
#include "wine/debug.h"
#include "msvcrt.h"
#include "cppexcept.h"
#include "mtdll.h"
#include "cxx.h"
Include dependency graph for cpp.c:

Go to the source code of this file.

Classes

struct  __type_info_node
 
struct  exception_ptr
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msvcrt)
 
static const vtable_ptrget_vtable (void *obj)
 
static const rtti_object_locatorget_obj_locator (void *cppobj)
 
static void dump_obj_locator (const rtti_object_locator *ptr)
 
static void EXCEPTION_ctor (exception *_this, const char **name)
 
exception __thiscall MSVCRT_exception_ctor (exception *_this, const char **name)
 
exception __thiscall MSVCRT_exception_ctor_noalloc (exception *_this, char **name, int noalloc)
 
exception __thiscall MSVCRT_exception_copy_ctor (exception *_this, const exception *rhs)
 
exception __thiscall MSVCRT_exception_default_ctor (exception *_this)
 
void __thiscall MSVCRT_exception_dtor (exception *_this)
 
exception __thiscall MSVCRT_exception_opequals (exception *_this, const exception *rhs)
 
void *__thiscall MSVCRT_exception_vector_dtor (exception *_this, unsigned int flags)
 
void *__thiscall MSVCRT_exception_scalar_dtor (exception *_this, unsigned int flags)
 
const char *__thiscall MSVCRT_what_exception (exception *_this)
 
bad_typeid *__thiscall MSVCRT_bad_typeid_copy_ctor (bad_typeid *_this, const bad_typeid *rhs)
 
bad_typeid *__thiscall MSVCRT_bad_typeid_ctor (bad_typeid *_this, const char *name)
 
bad_typeid *__thiscall MSVCRT_bad_typeid_default_ctor (bad_typeid *_this)
 
void __thiscall MSVCRT_bad_typeid_dtor (bad_typeid *_this)
 
bad_typeid *__thiscall MSVCRT_bad_typeid_opequals (bad_typeid *_this, const bad_typeid *rhs)
 
void *__thiscall MSVCRT_bad_typeid_vector_dtor (bad_typeid *_this, unsigned int flags)
 
void *__thiscall MSVCRT_bad_typeid_scalar_dtor (bad_typeid *_this, unsigned int flags)
 
__non_rtti_object *__thiscall MSVCRT___non_rtti_object_copy_ctor (__non_rtti_object *_this, const __non_rtti_object *rhs)
 
__non_rtti_object *__thiscall MSVCRT___non_rtti_object_ctor (__non_rtti_object *_this, const char *name)
 
void __thiscall MSVCRT___non_rtti_object_dtor (__non_rtti_object *_this)
 
__non_rtti_object *__thiscall MSVCRT___non_rtti_object_opequals (__non_rtti_object *_this, const __non_rtti_object *rhs)
 
void *__thiscall MSVCRT___non_rtti_object_vector_dtor (__non_rtti_object *_this, unsigned int flags)
 
void *__thiscall MSVCRT___non_rtti_object_scalar_dtor (__non_rtti_object *_this, unsigned int flags)
 
bad_cast *__thiscall MSVCRT_bad_cast_ctor (bad_cast *_this, const char **name)
 
bad_cast *__thiscall MSVCRT_bad_cast_copy_ctor (bad_cast *_this, const bad_cast *rhs)
 
bad_cast *__thiscall MSVCRT_bad_cast_ctor_charptr (bad_cast *_this, const char *name)
 
bad_cast *__thiscall MSVCRT_bad_cast_default_ctor (bad_cast *_this)
 
void __thiscall MSVCRT_bad_cast_dtor (bad_cast *_this)
 
bad_cast *__thiscall MSVCRT_bad_cast_opequals (bad_cast *_this, const bad_cast *rhs)
 
void *__thiscall MSVCRT_bad_cast_vector_dtor (bad_cast *_this, unsigned int flags)
 
void *__thiscall MSVCRT_bad_cast_scalar_dtor (bad_cast *_this, unsigned int flags)
 
int __thiscall MSVCRT_type_info_opequals_equals (type_info *_this, const type_info *rhs)
 
int __thiscall MSVCRT_type_info_opnot_equals (type_info *_this, const type_info *rhs)
 
int __thiscall MSVCRT_type_info_before (type_info *_this, const type_info *rhs)
 
void __thiscall MSVCRT_type_info_dtor (type_info *_this)
 
const char *__thiscall MSVCRT_type_info_name (type_info *_this)
 
const char *__thiscall MSVCRT_type_info_raw_name (type_info *_this)
 
void *__thiscall MSVCRT_type_info_vector_dtor (type_info *_this, unsigned int flags)
 
void __asm_dummy_vtables (void)
 
void msvcrt_init_exception (void *base)
 
MSVCRT_terminate_function CDECL MSVCRT_set_terminate (MSVCRT_terminate_function func)
 
MSVCRT_terminate_function CDECL MSVCRT__get_terminate (void)
 
MSVCRT_unexpected_function CDECL MSVCRT_set_unexpected (MSVCRT_unexpected_function func)
 
MSVCRT_unexpected_function CDECL MSVCRT__get_unexpected (void)
 
MSVCRT__se_translator_function CDECL MSVCRT__set_se_translator (MSVCRT__se_translator_function func)
 
void CDECL MSVCRT_terminate (void)
 
void CDECL MSVCRT_unexpected (void)
 
const type_info *CDECL MSVCRT___RTtypeid (void *cppobj)
 
void *CDECL MSVCRT___RTDynamicCast (void *cppobj, int unknown, type_info *src, type_info *dst, int do_throw)
 
void *CDECL MSVCRT___RTCastToVoid (void *cppobj)
 
void WINAPI _CxxThrowException (exception *object, const cxx_exception_type *type)
 
void __cdecl __ExceptionPtrRethrow (const exception_ptr *ep)
 

Variables

const vtable_ptr MSVCRT_exception_vtable
 
const vtable_ptr MSVCRT_bad_typeid_vtable
 
const vtable_ptr MSVCRT_bad_cast_vtable
 
const vtable_ptr MSVCRT___non_rtti_object_vtable
 
const vtable_ptr MSVCRT_type_info_vtable
 

Function Documentation

◆ __asm_dummy_vtables()

void __asm_dummy_vtables ( void  )

Definition at line 1000 of file cpp.c.

1000 {
1001#endif
1002
1008#if _MSVCR_VER >= 80
1009__ASM_VTABLE(exception_old,
1012__ASM_VTABLE(bad_alloc,
1015#endif
1016__ASM_VTABLE(bad_typeid,
1019__ASM_VTABLE(bad_cast,
1022__ASM_VTABLE(__non_rtti_object,
1025#if _MSVCR_VER >= 100
1026__ASM_VTABLE(scheduler_resource_allocation_error,
1029__ASM_VTABLE(improper_lock,
1032__ASM_VTABLE(invalid_scheduler_policy_key,
1035__ASM_VTABLE(invalid_scheduler_policy_value,
1038__ASM_VTABLE(invalid_scheduler_policy_thread_specification,
1041__ASM_VTABLE(improper_scheduler_attach,
1044__ASM_VTABLE(improper_scheduler_detach,
1047#endif
1048
1049#ifndef __GNUC__
1050}
#define __ASM_VTABLE(name, funcs)
Definition: cxx.h:37
#define VTABLE_ADD_FUNC(name)
Definition: cxx.h:35
void *__thiscall MSVCRT_bad_cast_vector_dtor(bad_cast *_this, unsigned int flags)
Definition: cpp.c:517
void *__thiscall MSVCRT_exception_vector_dtor(exception *_this, unsigned int flags)
Definition: cpp.c:233
void *__thiscall MSVCRT___non_rtti_object_vector_dtor(__non_rtti_object *_this, unsigned int flags)
Definition: cpp.c:415
const char *__thiscall MSVCRT_what_exception(exception *_this)
Definition: cpp.c:268
void *__thiscall MSVCRT_type_info_vector_dtor(type_info *_this, unsigned int flags)
Definition: cpp.c:637
void *__thiscall MSVCRT_bad_typeid_vector_dtor(bad_typeid *_this, unsigned int flags)
Definition: cpp.c:332

◆ __ExceptionPtrRethrow()

void __cdecl __ExceptionPtrRethrow ( const exception_ptr ep)

Definition at line 1808 of file cpp.c.

1809{
1810 TRACE("(%p)\n", ep);
1811
1812 if (!ep->rec)
1813 {
1814 static const char *exception_msg = "bad exception";
1815 exception e;
1816
1817 MSVCRT_exception_ctor(&e, &exception_msg);
1818 _CxxThrowException(&e, &exception_exception_type);
1819 return;
1820 }
1821
1824}
VOID WINAPI RaiseException(IN DWORD dwExceptionCode, IN DWORD dwExceptionFlags, IN DWORD nNumberOfArguments, IN CONST ULONG_PTR *lpArguments OPTIONAL)
Definition: except.c:700
#define e
Definition: ke_i.h:82
#define EH_UNWINDING
Definition: exception.h:17
void WINAPI _CxxThrowException(exception *object, const cxx_exception_type *type)
Definition: cpp.c:1574
exception __thiscall MSVCRT_exception_ctor(exception *_this, const char **name)
Definition: cpp.c:149
#define TRACE(s)
Definition: solgame.cpp:4
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
DWORD ExceptionFlags
Definition: compat.h:209
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
EXCEPTION_RECORD * rec
Definition: cpp.c:1708

◆ _CxxThrowException()

void WINAPI _CxxThrowException ( exception object,
const cxx_exception_type type 
)

Definition at line 1574 of file cpp.c.

1575{
1576 ULONG_PTR args[3];
1577
1579 args[1] = (ULONG_PTR)object;
1580 args[2] = (ULONG_PTR)type;
1582}
#define ULONG_PTR
Definition: config.h:101
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define CXX_EXCEPTION
Definition: cppexcept.h:27
#define CXX_FRAME_MAGIC_VC6
Definition: cppexcept.h:24
Definition: match.c:390
#define EH_NONCONTINUABLE
Definition: stubs.h:9
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by __ExceptionPtrRethrow(), MSVCRT___RTCastToVoid(), MSVCRT___RTDynamicCast(), and MSVCRT___RTtypeid().

◆ dump_obj_locator()

static void dump_obj_locator ( const rtti_object_locator ptr)
static

Definition at line 67 of file cpp.c.

68{
69 int i;
70 const rtti_object_hierarchy *h = ptr->type_hierarchy;
71
72 TRACE( "%p: sig=%08x base_offset=%08x flags=%08x type=%p %s hierarchy=%p\n",
73 ptr, ptr->signature, ptr->base_class_offset, ptr->flags,
74 ptr->type_descriptor, dbgstr_type_info(ptr->type_descriptor), ptr->type_hierarchy );
75 TRACE( " hierarchy: sig=%08x attr=%08x len=%d base classes=%p\n",
76 h->signature, h->attributes, h->array_len, h->base_classes );
77 for (i = 0; i < h->array_len; i++)
78 {
79 TRACE( " base class %p: num %d off %d,%d,%d attr %08x type %p %s\n",
80 h->base_classes->bases[i],
81 h->base_classes->bases[i]->num_base_classes,
82 h->base_classes->bases[i]->offsets.this_offset,
83 h->base_classes->bases[i]->offsets.vbase_descr,
84 h->base_classes->bases[i]->offsets.vbase_offset,
85 h->base_classes->bases[i]->attributes,
86 h->base_classes->bases[i]->type_descriptor,
87 dbgstr_type_info(h->base_classes->bases[i]->type_descriptor) );
88 }
89}
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
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 const char * dbgstr_type_info(const type_info *info)
Definition: cppexcept.h:155
static PVOID ptr
Definition: dispmode.c:27

Referenced by MSVCRT___RTDynamicCast().

◆ EXCEPTION_ctor()

static void EXCEPTION_ctor ( exception _this,
const char **  name 
)
static

Definition at line 124 of file cpp.c.

125{
127 if (*name)
128 {
129 unsigned int name_len = strlen(*name) + 1;
130 _this->name = MSVCRT_malloc(name_len);
131 memcpy(_this->name, *name, name_len);
132 _this->do_free = TRUE;
133 }
134 else
135 {
136 _this->name = NULL;
137 _this->do_free = FALSE;
138 }
139}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define MSVCRT_malloc
Definition: msvcrt.h:151
const vtable_ptr MSVCRT_exception_vtable
char * name
Definition: cpp.c:28
vtable_ptr * vtable
Definition: cpp.c:27
int do_free
Definition: cpp.c:29
Definition: name.c:39

Referenced by MSVCRT___non_rtti_object_ctor(), MSVCRT_bad_cast_ctor(), MSVCRT_bad_cast_ctor_charptr(), MSVCRT_bad_typeid_ctor(), MSVCRT_exception_copy_ctor(), MSVCRT_exception_ctor(), and MSVCRT_exception_default_ctor().

◆ get_obj_locator()

static const rtti_object_locator * get_obj_locator ( void cppobj)
inlinestatic

Definition at line 60 of file cpp.c.

61{
62 const vtable_ptr *vtable = get_vtable( cppobj );
63 return (const rtti_object_locator *)vtable[-1];
64}
void(* vtable_ptr)(void)
Definition: cpp.c:23
static vtable_ptr * get_vtable(void *obj)
Definition: cpp.c:880
static void * vtable[]
Definition: typelib.c:1231

◆ get_vtable()

static const vtable_ptr * get_vtable ( void obj)
inlinestatic

Definition at line 55 of file cpp.c.

56{
57 return *(const vtable_ptr **)obj;
58}

◆ MSVCRT___non_rtti_object_copy_ctor()

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

Definition at line 367 of file cpp.c.

369{
370 TRACE("(%p %p)\n", _this, rhs);
371 MSVCRT_bad_typeid_copy_ctor(_this, rhs);
372 _this->vtable = &MSVCRT___non_rtti_object_vtable;
373 return _this;
374}
bad_typeid *__thiscall MSVCRT_bad_typeid_copy_ctor(bad_typeid *_this, const bad_typeid *rhs)
Definition: cpp.c:278
const vtable_ptr MSVCRT___non_rtti_object_vtable

◆ MSVCRT___non_rtti_object_ctor()

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

Definition at line 380 of file cpp.c.

382{
383 TRACE("(%p %s)\n", _this, name);
384 EXCEPTION_ctor(_this, &name);
385 _this->vtable = &MSVCRT___non_rtti_object_vtable;
386 return _this;
387}
static void EXCEPTION_ctor(exception *_this, const char **name)
Definition: cpp.c:124

Referenced by MSVCRT___RTCastToVoid(), MSVCRT___RTDynamicCast(), and MSVCRT___RTtypeid().

◆ MSVCRT___non_rtti_object_dtor()

void __thiscall MSVCRT___non_rtti_object_dtor ( __non_rtti_object *  _this)

Definition at line 393 of file cpp.c.

394{
395 TRACE("(%p)\n", _this);
397}
void __thiscall MSVCRT_bad_typeid_dtor(bad_typeid *_this)
Definition: cpp.c:311

Referenced by MSVCRT___non_rtti_object_scalar_dtor(), and MSVCRT___non_rtti_object_vector_dtor().

◆ MSVCRT___non_rtti_object_opequals()

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

Definition at line 403 of file cpp.c.

405{
406 TRACE("(%p %p)\n", _this, rhs);
407 MSVCRT_bad_typeid_opequals(_this, rhs);
408 return _this;
409}
bad_typeid *__thiscall MSVCRT_bad_typeid_opequals(bad_typeid *_this, const bad_typeid *rhs)
Definition: cpp.c:321

◆ MSVCRT___non_rtti_object_scalar_dtor()

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

Definition at line 438 of file cpp.c.

439{
440 TRACE("(%p %x)\n", _this, flags);
442 if (flags & 1) MSVCRT_operator_delete(_this);
443 return _this;
444}
GLbitfield flags
Definition: glext.h:7161
void __cdecl MSVCRT_operator_delete(void *)
Definition: heap.c:196
void __thiscall MSVCRT___non_rtti_object_dtor(__non_rtti_object *_this)
Definition: cpp.c:393

◆ MSVCRT___non_rtti_object_vector_dtor()

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

Definition at line 415 of file cpp.c.

416{
417 TRACE("(%p %x)\n", _this, flags);
418 if (flags & 2)
419 {
420 /* we have an array, with the number of elements stored before the first object */
421 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
422
423 for (i = *ptr - 1; i >= 0; i--) MSVCRT___non_rtti_object_dtor(_this + i);
425 }
426 else
427 {
429 if (flags & 1) MSVCRT_operator_delete(_this);
430 }
431 return _this;
432}
int32_t INT_PTR
Definition: typedefs.h:64

Referenced by __asm_dummy_vtables().

◆ MSVCRT___RTCastToVoid()

void *CDECL MSVCRT___RTCastToVoid ( void cppobj)

Definition at line 1547 of file cpp.c.

1548{
1549 void *ret;
1550
1551 if (!cppobj) return NULL;
1552
1553 __TRY
1554 {
1555 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
1556 ret = (char *)cppobj - obj_locator->base_class_offset;
1557 }
1559 {
1560 __non_rtti_object e;
1561 MSVCRT___non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
1562 _CxxThrowException( &e, &__non_rtti_object_exception_type );
1563 return NULL;
1564 }
1565 __ENDTRY
1566 return ret;
1567}
#define __TRY
Definition: compat.h:80
#define __ENDTRY
Definition: compat.h:82
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
static void * get_obj_locator(void *cppobj)
Definition: cpp.c:885
__non_rtti_object *__thiscall MSVCRT___non_rtti_object_ctor(__non_rtti_object *_this, const char *name)
Definition: cpp.c:380
int base_class_offset
Definition: cxx.h:202
int ret

◆ MSVCRT___RTDynamicCast()

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

Definition at line 1403 of file cpp.c.

1406{
1407 void *ret;
1408
1409 if (!cppobj) return NULL;
1410
1411 TRACE("obj: %p unknown: %d src: %p %s dst: %p %s do_throw: %d)\n",
1412 cppobj, unknown, src, dbgstr_type_info(src), dst, dbgstr_type_info(dst), do_throw);
1413
1414 /* To cast an object at runtime:
1415 * 1.Find out the true type of the object from the typeinfo at vtable[-1]
1416 * 2.Search for the destination type in the class hierarchy
1417 * 3.If destination type is found, return base object address + dest offset
1418 * Otherwise, fail the cast
1419 *
1420 * FIXME: the unknown parameter doesn't seem to be used for anything
1421 */
1422 __TRY
1423 {
1424 int i;
1425 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
1426 const rtti_object_hierarchy *obj_bases = obj_locator->type_hierarchy;
1427 const rtti_base_descriptor * const* base_desc = obj_bases->base_classes->bases;
1428
1429 if (TRACE_ON(msvcrt)) dump_obj_locator(obj_locator);
1430
1431 ret = NULL;
1432 for (i = 0; i < obj_bases->array_len; i++)
1433 {
1434 const type_info *typ = base_desc[i]->type_descriptor;
1435
1436 if (!strcmp(typ->mangled, dst->mangled))
1437 {
1438 /* compute the correct this pointer for that base class */
1439 void *this_ptr = (char *)cppobj - obj_locator->base_class_offset;
1440 ret = get_this_pointer( &base_desc[i]->offsets, this_ptr );
1441 break;
1442 }
1443 }
1444 /* VC++ sets do_throw to 1 when the result of a dynamic_cast is assigned
1445 * to a reference, since references cannot be NULL.
1446 */
1447 if (!ret && do_throw)
1448 {
1449 const char *msg = "Bad dynamic_cast!";
1450 bad_cast e;
1452 _CxxThrowException( &e, &bad_cast_exception_type );
1453 }
1454 }
1456 {
1457 __non_rtti_object e;
1458 MSVCRT___non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
1459 _CxxThrowException( &e, &__non_rtti_object_exception_type );
1460 return NULL;
1461 }
1462 __ENDTRY
1463 return ret;
1464}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#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
static const FxOffsetAndName offsets[]
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static void * get_this_pointer(const this_ptr_offsets *off, void *object)
Definition: cppexcept.h:163
bad_cast *__thiscall MSVCRT_bad_cast_ctor(bad_cast *_this, const char **name)
Definition: cpp.c:451
static void dump_obj_locator(const rtti_object_locator *ptr)
Definition: cpp.c:67
char mangled[16]
Definition: cpp.c:36
const rtti_base_descriptor * bases[10]
Definition: cxx.h:188
const type_info * type_descriptor
Definition: cxx.h:180
const rtti_base_array * base_classes
Definition: cxx.h:196
const rtti_object_hierarchy * type_hierarchy
Definition: cxx.h:205

◆ MSVCRT___RTtypeid()

const type_info *CDECL MSVCRT___RTtypeid ( void cppobj)

Definition at line 1314 of file cpp.c.

1315{
1316 const type_info *ret;
1317
1318 if (!cppobj)
1319 {
1320 bad_typeid e;
1321 MSVCRT_bad_typeid_ctor( &e, "Attempted a typeid of NULL pointer!" );
1322 _CxxThrowException( &e, &bad_typeid_exception_type );
1323 return NULL;
1324 }
1325
1326 __TRY
1327 {
1328 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
1329 ret = obj_locator->type_descriptor;
1330 }
1332 {
1333 __non_rtti_object e;
1334 MSVCRT___non_rtti_object_ctor( &e, "Bad read pointer - no RTTI data!" );
1335 _CxxThrowException( &e, &__non_rtti_object_exception_type );
1336 return NULL;
1337 }
1338 __ENDTRY
1339 return ret;
1340}
bad_typeid *__thiscall MSVCRT_bad_typeid_ctor(bad_typeid *_this, const char *name)
Definition: cpp.c:290
const type_info * type_descriptor
Definition: cxx.h:204

◆ MSVCRT__get_terminate()

MSVCRT_terminate_function CDECL MSVCRT__get_terminate ( void  )

Definition at line 1215 of file cpp.c.

1216{
1218 TRACE("returning %p\n", data->terminate_handler);
1219 return data->terminate_handler;
1220}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
thread_data_t * msvcrt_get_thread_data(void)
Definition: tls.c:31

◆ MSVCRT__get_unexpected()

MSVCRT_unexpected_function CDECL MSVCRT__get_unexpected ( void  )

Definition at line 1245 of file cpp.c.

1246{
1248 TRACE("returning %p\n", data->unexpected_handler);
1249 return data->unexpected_handler;
1250}

◆ MSVCRT__set_se_translator()

Definition at line 1255 of file cpp.c.

1256{
1258 MSVCRT__se_translator_function previous = data->se_translator;
1259 TRACE("(%p) returning %p\n",func,previous);
1260 data->se_translator = func;
1261 return previous;
1262}
GLenum func
Definition: glext.h:6028
void(__cdecl * MSVCRT__se_translator_function)(unsigned int code, struct _EXCEPTION_POINTERS *info)
Definition: msvcrt.h:83

◆ MSVCRT_bad_cast_copy_ctor()

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

Definition at line 463 of file cpp.c.

464{
465 TRACE("(%p %p)\n", _this, rhs);
466 MSVCRT_exception_copy_ctor(_this, rhs);
467 _this->vtable = &MSVCRT_bad_cast_vtable;
468 return _this;
469}
const vtable_ptr MSVCRT_bad_cast_vtable
exception __thiscall MSVCRT_exception_copy_ctor(exception *_this, const exception *rhs)
Definition: cpp.c:173

◆ MSVCRT_bad_cast_ctor()

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

Definition at line 451 of file cpp.c.

452{
453 TRACE("(%p %s)\n", _this, *name);
454 EXCEPTION_ctor(_this, name);
455 _this->vtable = &MSVCRT_bad_cast_vtable;
456 return _this;
457}

Referenced by MSVCRT___RTDynamicCast().

◆ MSVCRT_bad_cast_ctor_charptr()

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

Definition at line 475 of file cpp.c.

476{
477 TRACE("(%p %s)\n", _this, name);
478 EXCEPTION_ctor(_this, &name);
479 _this->vtable = &MSVCRT_bad_cast_vtable;
480 return _this;
481}

Referenced by MSVCRT_bad_cast_default_ctor().

◆ MSVCRT_bad_cast_default_ctor()

bad_cast *__thiscall MSVCRT_bad_cast_default_ctor ( bad_cast *  _this)

Definition at line 487 of file cpp.c.

488{
489 return MSVCRT_bad_cast_ctor_charptr( _this, "bad cast" );
490}
bad_cast *__thiscall MSVCRT_bad_cast_ctor_charptr(bad_cast *_this, const char *name)
Definition: cpp.c:475

◆ MSVCRT_bad_cast_dtor()

void __thiscall MSVCRT_bad_cast_dtor ( bad_cast *  _this)

Definition at line 496 of file cpp.c.

497{
498 TRACE("(%p)\n", _this);
500}
void __thiscall MSVCRT_exception_dtor(exception *_this)
Definition: cpp.c:206

Referenced by MSVCRT_bad_cast_scalar_dtor(), and MSVCRT_bad_cast_vector_dtor().

◆ MSVCRT_bad_cast_opequals()

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

Definition at line 506 of file cpp.c.

507{
508 TRACE("(%p %p)\n", _this, rhs);
509 MSVCRT_exception_opequals(_this, rhs);
510 return _this;
511}
exception __thiscall MSVCRT_exception_opequals(exception *_this, const exception *rhs)
Definition: cpp.c:217

◆ MSVCRT_bad_cast_scalar_dtor()

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

Definition at line 540 of file cpp.c.

541{
542 TRACE("(%p %x)\n", _this, flags);
544 if (flags & 1) MSVCRT_operator_delete(_this);
545 return _this;
546}
void __thiscall MSVCRT_bad_cast_dtor(bad_cast *_this)
Definition: cpp.c:496

◆ MSVCRT_bad_cast_vector_dtor()

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

Definition at line 517 of file cpp.c.

518{
519 TRACE("(%p %x)\n", _this, flags);
520 if (flags & 2)
521 {
522 /* we have an array, with the number of elements stored before the first object */
523 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
524
525 for (i = *ptr - 1; i >= 0; i--) MSVCRT_bad_cast_dtor(_this + i);
527 }
528 else
529 {
531 if (flags & 1) MSVCRT_operator_delete(_this);
532 }
533 return _this;
534}

Referenced by __asm_dummy_vtables().

◆ MSVCRT_bad_typeid_copy_ctor()

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

Definition at line 278 of file cpp.c.

279{
280 TRACE("(%p %p)\n", _this, rhs);
281 MSVCRT_exception_copy_ctor(_this, rhs);
282 _this->vtable = &MSVCRT_bad_typeid_vtable;
283 return _this;
284}
const vtable_ptr MSVCRT_bad_typeid_vtable

Referenced by MSVCRT___non_rtti_object_copy_ctor().

◆ MSVCRT_bad_typeid_ctor()

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

Definition at line 290 of file cpp.c.

291{
292 TRACE("(%p %s)\n", _this, name);
293 EXCEPTION_ctor(_this, &name);
294 _this->vtable = &MSVCRT_bad_typeid_vtable;
295 return _this;
296}

Referenced by MSVCRT___RTtypeid(), and MSVCRT_bad_typeid_default_ctor().

◆ MSVCRT_bad_typeid_default_ctor()

bad_typeid *__thiscall MSVCRT_bad_typeid_default_ctor ( bad_typeid *  _this)

Definition at line 302 of file cpp.c.

303{
304 return MSVCRT_bad_typeid_ctor( _this, "bad typeid" );
305}

◆ MSVCRT_bad_typeid_dtor()

void __thiscall MSVCRT_bad_typeid_dtor ( bad_typeid *  _this)

Definition at line 311 of file cpp.c.

312{
313 TRACE("(%p)\n", _this);
315}

Referenced by MSVCRT___non_rtti_object_dtor(), MSVCRT_bad_typeid_scalar_dtor(), and MSVCRT_bad_typeid_vector_dtor().

◆ MSVCRT_bad_typeid_opequals()

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

Definition at line 321 of file cpp.c.

322{
323 TRACE("(%p %p)\n", _this, rhs);
324 MSVCRT_exception_opequals(_this, rhs);
325 return _this;
326}

Referenced by MSVCRT___non_rtti_object_opequals().

◆ MSVCRT_bad_typeid_scalar_dtor()

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

Definition at line 355 of file cpp.c.

356{
357 TRACE("(%p %x)\n", _this, flags);
359 if (flags & 1) MSVCRT_operator_delete(_this);
360 return _this;
361}

◆ MSVCRT_bad_typeid_vector_dtor()

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

Definition at line 332 of file cpp.c.

333{
334 TRACE("(%p %x)\n", _this, flags);
335 if (flags & 2)
336 {
337 /* we have an array, with the number of elements stored before the first object */
338 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
339
340 for (i = *ptr - 1; i >= 0; i--) MSVCRT_bad_typeid_dtor(_this + i);
342 }
343 else
344 {
346 if (flags & 1) MSVCRT_operator_delete(_this);
347 }
348 return _this;
349}

Referenced by __asm_dummy_vtables().

◆ MSVCRT_exception_copy_ctor()

exception __thiscall MSVCRT_exception_copy_ctor ( exception _this,
const exception rhs 
)

Definition at line 173 of file cpp.c.

174{
175 TRACE("(%p,%p)\n", _this, rhs);
176
177 if (!rhs->do_free)
178 {
180 _this->name = rhs->name;
181 _this->do_free = FALSE;
182 }
183 else
184 EXCEPTION_ctor(_this, (const char**)&rhs->name);
185 TRACE("name = %s\n", _this->name);
186 return _this;
187}

Referenced by MSVCRT_bad_cast_copy_ctor(), MSVCRT_bad_typeid_copy_ctor(), and MSVCRT_exception_opequals().

◆ MSVCRT_exception_ctor()

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

Definition at line 149 of file cpp.c.

150{
151 TRACE("(%p,%s)\n", _this, *name);
152 EXCEPTION_ctor(_this, name);
153 return _this;
154}

Referenced by __ExceptionPtrRethrow().

◆ MSVCRT_exception_ctor_noalloc()

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

Definition at line 160 of file cpp.c.

161{
162 TRACE("(%p,%s)\n", _this, *name);
164 _this->name = *name;
165 _this->do_free = FALSE;
166 return _this;
167}

◆ MSVCRT_exception_default_ctor()

exception __thiscall MSVCRT_exception_default_ctor ( exception _this)

Definition at line 193 of file cpp.c.

194{
195 static const char* empty = NULL;
196
197 TRACE("(%p)\n", _this);
198 EXCEPTION_ctor(_this, &empty);
199 return _this;
200}
static const WCHAR empty[]
Definition: main.c:47

◆ MSVCRT_exception_dtor()

void __thiscall MSVCRT_exception_dtor ( exception _this)

Definition at line 206 of file cpp.c.

207{
208 TRACE("(%p)\n", _this);
210 if (_this->do_free) MSVCRT_free(_this->name);
211}
#define MSVCRT_free
Definition: msvcrt.h:152

Referenced by MSVCRT_bad_cast_dtor(), MSVCRT_bad_typeid_dtor(), MSVCRT_exception_opequals(), MSVCRT_exception_scalar_dtor(), and MSVCRT_exception_vector_dtor().

◆ MSVCRT_exception_opequals()

exception __thiscall MSVCRT_exception_opequals ( exception _this,
const exception rhs 
)

Definition at line 217 of file cpp.c.

218{
219 TRACE("(%p %p)\n", _this, rhs);
220 if (_this != rhs)
221 {
223 MSVCRT_exception_copy_ctor(_this, rhs);
224 }
225 TRACE("name = %s\n", _this->name);
226 return _this;
227}

Referenced by MSVCRT_bad_cast_opequals(), and MSVCRT_bad_typeid_opequals().

◆ MSVCRT_exception_scalar_dtor()

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

Definition at line 256 of file cpp.c.

257{
258 TRACE("(%p %x)\n", _this, flags);
260 if (flags & 1) MSVCRT_operator_delete(_this);
261 return _this;
262}

◆ MSVCRT_exception_vector_dtor()

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

Definition at line 233 of file cpp.c.

234{
235 TRACE("(%p %x)\n", _this, flags);
236 if (flags & 2)
237 {
238 /* we have an array, with the number of elements stored before the first object */
239 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
240
241 for (i = *ptr - 1; i >= 0; i--) MSVCRT_exception_dtor(_this + i);
243 }
244 else
245 {
247 if (flags & 1) MSVCRT_operator_delete(_this);
248 }
249 return _this;
250}

Referenced by __asm_dummy_vtables().

◆ msvcrt_init_exception()

void msvcrt_init_exception ( void base)

Definition at line 1101 of file cpp.c.

1102{
1103#ifdef __x86_64__
1104 init_type_info_rtti(base);
1105 init_exception_rtti(base);
1106#if _MSVCR_VER >= 80
1107 init_exception_old_rtti(base);
1108 init_bad_alloc_rtti(base);
1109#endif
1110 init_bad_typeid_rtti(base);
1111 init_bad_cast_rtti(base);
1112 init___non_rtti_object_rtti(base);
1113#if _MSVCR_VER >= 100
1114 init_scheduler_resource_allocation_error_rtti(base);
1115 init_improper_lock_rtti(base);
1116 init_invalid_scheduler_policy_key_rtti(base);
1117 init_invalid_scheduler_policy_value_rtti(base);
1118 init_invalid_scheduler_policy_thread_specification_rtti(base);
1119 init_improper_scheduler_attach_rtti(base);
1120 init_improper_scheduler_detach_rtti(base);
1121#endif
1122
1123 init_exception_cxx(base);
1124 init_bad_typeid_cxx(base);
1125 init_bad_cast_cxx(base);
1126 init___non_rtti_object_cxx(base);
1127#if _MSVCR_VER >= 80
1128 init_bad_alloc_cxx(base);
1129#endif
1130#if _MSVCR_VER >= 100
1131 init_scheduler_resource_allocation_error_cxx(base);
1132 init_improper_lock_cxx(base);
1133 init_invalid_scheduler_policy_key_cxx(base);
1134 init_invalid_scheduler_policy_value_cxx(base);
1135 init_invalid_scheduler_policy_thread_specification_cxx(base);
1136 init_improper_scheduler_attach_cxx(base);
1137 init_improper_scheduler_detach_cxx(base);
1138#endif
1139#endif
1140}

◆ MSVCRT_set_terminate()

Definition at line 1203 of file cpp.c.

1204{
1206 MSVCRT_terminate_function previous = data->terminate_handler;
1207 TRACE("(%p) returning %p\n",func,previous);
1208 data->terminate_handler = func;
1209 return previous;
1210}
void(__cdecl * MSVCRT_terminate_function)(void)
Definition: msvcrt.h:80

◆ MSVCRT_set_unexpected()

Definition at line 1233 of file cpp.c.

1234{
1236 MSVCRT_unexpected_function previous = data->unexpected_handler;
1237 TRACE("(%p) returning %p\n",func,previous);
1238 data->unexpected_handler = func;
1239 return previous;
1240}
void(__cdecl * MSVCRT_unexpected_function)(void)
Definition: msvcrt.h:82

◆ MSVCRT_terminate()

void CDECL MSVCRT_terminate ( void  )

Definition at line 1277 of file cpp.c.

1278{
1280 if (data->terminate_handler) data->terminate_handler();
1281 MSVCRT_abort();
1282}
#define MSVCRT_abort
Definition: winternl.h:311

Referenced by MSVCRT_unexpected().

◆ MSVCRT_type_info_before()

int __thiscall MSVCRT_type_info_before ( type_info _this,
const type_info rhs 
)

Definition at line 574 of file cpp.c.

575{
576 int ret = strcmp(_this->mangled + 1, rhs->mangled + 1) < 0;
577 TRACE("(%p %p) returning %d\n", _this, rhs, ret);
578 return ret;
579}

◆ MSVCRT_type_info_dtor()

void __thiscall MSVCRT_type_info_dtor ( type_info _this)

Definition at line 585 of file cpp.c.

586{
587 TRACE("(%p)\n", _this);
588 MSVCRT_free(_this->name);
589}
char * name
Definition: cpp.c:35

Referenced by MSVCRT_type_info_vector_dtor().

◆ MSVCRT_type_info_name()

const char *__thiscall MSVCRT_type_info_name ( type_info _this)

Definition at line 595 of file cpp.c.

596{
597 if (!_this->name)
598 {
599 /* Create and set the demangled name */
600 /* Note: mangled name in type_info struct always starts with a '.', while
601 * it isn't valid for mangled name.
602 * Is this '.' really part of the mangled name, or has it some other meaning ?
603 */
604 char* name = __unDName(0, _this->mangled + 1, 0,
606 if (name)
607 {
608 unsigned int len = strlen(name);
609
610 /* It seems _unDName may leave blanks at the end of the demangled name */
611 while (len && name[--len] == ' ')
612 name[len] = '\0';
613
614 if (InterlockedCompareExchangePointer((void**)&_this->name, name, NULL))
615 {
616 /* Another thread set this member since we checked above - use it */
618 }
619 }
620 }
621 TRACE("(%p) returning %s\n", _this, _this->name);
622 return _this->name;
623}
#define UNDNAME_32_BIT_DECODE
Definition: dbghelp.h:1264
#define UNDNAME_NO_ARGUMENTS
Definition: dbghelp.h:1266
GLenum GLsizei len
Definition: glext.h:6722
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
char *__cdecl __unDName(char *, const char *, int, malloc_func_t, free_func_t, unsigned short int)
Definition: undname.c:1645

◆ MSVCRT_type_info_opequals_equals()

int __thiscall MSVCRT_type_info_opequals_equals ( type_info _this,
const type_info rhs 
)

Definition at line 552 of file cpp.c.

553{
554 int ret = !strcmp(_this->mangled + 1, rhs->mangled + 1);
555 TRACE("(%p %p) returning %d\n", _this, rhs, ret);
556 return ret;
557}

◆ MSVCRT_type_info_opnot_equals()

int __thiscall MSVCRT_type_info_opnot_equals ( type_info _this,
const type_info rhs 
)

Definition at line 563 of file cpp.c.

564{
565 int ret = !!strcmp(_this->mangled + 1, rhs->mangled + 1);
566 TRACE("(%p %p) returning %d\n", _this, rhs, ret);
567 return ret;
568}

◆ MSVCRT_type_info_raw_name()

const char *__thiscall MSVCRT_type_info_raw_name ( type_info _this)

Definition at line 629 of file cpp.c.

630{
631 TRACE("(%p) returning %s\n", _this, _this->mangled);
632 return _this->mangled;
633}

◆ MSVCRT_type_info_vector_dtor()

void *__thiscall MSVCRT_type_info_vector_dtor ( type_info _this,
unsigned int  flags 
)

Definition at line 637 of file cpp.c.

638{
639 TRACE("(%p %x)\n", _this, flags);
640 if (flags & 2)
641 {
642 /* we have an array, with the number of elements stored before the first object */
643 INT_PTR i, *ptr = (INT_PTR *)_this - 1;
644
645 for (i = *ptr - 1; i >= 0; i--) MSVCRT_type_info_dtor(_this + i);
647 }
648 else
649 {
651 if (flags & 1) MSVCRT_operator_delete(_this);
652 }
653 return _this;
654}
void __thiscall MSVCRT_type_info_dtor(type_info *_this)
Definition: cpp.c:585

Referenced by __asm_dummy_vtables().

◆ MSVCRT_unexpected()

void CDECL MSVCRT_unexpected ( void  )

Definition at line 1287 of file cpp.c.

1288{
1290 if (data->unexpected_handler) data->unexpected_handler();
1292}
void CDECL MSVCRT_terminate(void)
Definition: cpp.c:1277

◆ MSVCRT_what_exception()

const char *__thiscall MSVCRT_what_exception ( exception _this)

Definition at line 268 of file cpp.c.

269{
270 TRACE("(%p) returning %s\n", _this, _this->name);
271 return _this->name ? _this->name : "Unknown exception";
272}

Referenced by __asm_dummy_vtables().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msvcrt  )

Variable Documentation

◆ MSVCRT___non_rtti_object_vtable

const vtable_ptr MSVCRT___non_rtti_object_vtable
extern

◆ MSVCRT_bad_cast_vtable

◆ MSVCRT_bad_typeid_vtable

const vtable_ptr MSVCRT_bad_typeid_vtable
extern

◆ MSVCRT_exception_vtable

◆ MSVCRT_type_info_vtable

const vtable_ptr MSVCRT_type_info_vtable
extern