ReactOS 0.4.15-dev-8236-g99f0937
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 999 of file cpp.c.

999 {
1000#endif
1001
1007#if _MSVCR_VER >= 80
1008__ASM_VTABLE(exception_old,
1011__ASM_VTABLE(bad_alloc,
1014#endif
1015__ASM_VTABLE(bad_typeid,
1018__ASM_VTABLE(bad_cast,
1021__ASM_VTABLE(__non_rtti_object,
1024#if _MSVCR_VER >= 100
1025__ASM_VTABLE(scheduler_resource_allocation_error,
1028__ASM_VTABLE(improper_lock,
1031__ASM_VTABLE(invalid_scheduler_policy_key,
1034__ASM_VTABLE(invalid_scheduler_policy_value,
1037__ASM_VTABLE(invalid_scheduler_policy_thread_specification,
1040__ASM_VTABLE(improper_scheduler_attach,
1043__ASM_VTABLE(improper_scheduler_detach,
1046#endif
1047
1048#ifndef __GNUC__
1049}
#define __ASM_VTABLE(name, funcs)
Definition: cxx.h:40
#define VTABLE_ADD_FUNC(name)
Definition: cxx.h:38
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 1806 of file cpp.c.

1807{
1808 TRACE("(%p)\n", ep);
1809
1810 if (!ep->rec)
1811 {
1812 static const char *exception_msg = "bad exception";
1813 exception e;
1814
1815 MSVCRT_exception_ctor(&e, &exception_msg);
1816 _CxxThrowException(&e, &exception_exception_type);
1817 return;
1818 }
1819
1822}
VOID WINAPI RaiseException(_In_ DWORD dwExceptionCode, _In_ DWORD dwExceptionFlags, _In_ DWORD nNumberOfArguments, _In_opt_ const ULONG_PTR *lpArguments)
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:1572
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:1706

◆ _CxxThrowException()

void WINAPI _CxxThrowException ( exception object,
const cxx_exception_type type 
)

Definition at line 1572 of file cpp.c.

1573{
1574 ULONG_PTR args[3];
1575
1577 args[1] = (ULONG_PTR)object;
1578 args[2] = (ULONG_PTR)type;
1580}
#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:32
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 1545 of file cpp.c.

1546{
1547 void *ret;
1548
1549 if (!cppobj) return NULL;
1550
1551 __TRY
1552 {
1553 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
1554 ret = (char *)cppobj - obj_locator->base_class_offset;
1555 }
1557 {
1558 __non_rtti_object e;
1559 MSVCRT___non_rtti_object_ctor( &e, "Access violation - no RTTI data!" );
1560 _CxxThrowException( &e, &__non_rtti_object_exception_type );
1561 return NULL;
1562 }
1563 __ENDTRY
1564 return ret;
1565}
#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:206
int ret

◆ MSVCRT___RTDynamicCast()

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

Definition at line 1401 of file cpp.c.

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

◆ MSVCRT___RTtypeid()

const type_info *CDECL MSVCRT___RTtypeid ( void cppobj)

Definition at line 1312 of file cpp.c.

1313{
1314 const type_info *ret;
1315
1316 if (!cppobj)
1317 {
1318 bad_typeid e;
1319 MSVCRT_bad_typeid_ctor( &e, "Attempted a typeid of NULL pointer!" );
1320 _CxxThrowException( &e, &bad_typeid_exception_type );
1321 return NULL;
1322 }
1323
1324 __TRY
1325 {
1326 const rtti_object_locator *obj_locator = get_obj_locator( cppobj );
1327 ret = obj_locator->type_descriptor;
1328 }
1330 {
1331 __non_rtti_object e;
1332 MSVCRT___non_rtti_object_ctor( &e, "Bad read pointer - no RTTI data!" );
1333 _CxxThrowException( &e, &__non_rtti_object_exception_type );
1334 return NULL;
1335 }
1336 __ENDTRY
1337 return ret;
1338}
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:208

◆ MSVCRT__get_terminate()

MSVCRT_terminate_function CDECL MSVCRT__get_terminate ( void  )

Definition at line 1213 of file cpp.c.

1214{
1216 TRACE("returning %p\n", data->terminate_handler);
1217 return data->terminate_handler;
1218}
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 1243 of file cpp.c.

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

◆ MSVCRT__set_se_translator()

Definition at line 1253 of file cpp.c.

1254{
1256 MSVCRT__se_translator_function previous = data->se_translator;
1257 TRACE("(%p) returning %p\n",func,previous);
1258 data->se_translator = func;
1259 return previous;
1260}
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 1099 of file cpp.c.

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

◆ MSVCRT_set_terminate()

Definition at line 1201 of file cpp.c.

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

◆ MSVCRT_set_unexpected()

Definition at line 1231 of file cpp.c.

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

◆ MSVCRT_terminate()

void CDECL MSVCRT_terminate ( void  )

Definition at line 1275 of file cpp.c.

1276{
1278 if (data->terminate_handler) data->terminate_handler();
1279 MSVCRT_abort();
1280}
#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:1647

◆ 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 1285 of file cpp.c.

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

◆ 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