msvcp90: Use DEFINE_RTTI_DATA to initialize exception RTTI data.
This commit is contained in:
parent
1328da1815
commit
d18b406b56
|
@ -61,6 +61,7 @@ typedef struct __cxx_exception_type
|
|||
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
|
||||
|
||||
/* vtables */
|
||||
extern const vtable_ptr MSVCP_exception_vtable;
|
||||
extern const vtable_ptr MSVCP_bad_alloc_vtable;
|
||||
extern const vtable_ptr MSVCP_logic_error_vtable;
|
||||
extern const vtable_ptr MSVCP_length_error_vtable;
|
||||
|
@ -68,19 +69,12 @@ extern const vtable_ptr MSVCP_out_of_range_vtable;
|
|||
extern const vtable_ptr MSVCP_invalid_argument_vtable;
|
||||
extern const vtable_ptr MSVCP_runtime_error_vtable;
|
||||
|
||||
/* exception class data */
|
||||
static type_info exception_type_info = {
|
||||
NULL, /* set by set_exception_vtable */
|
||||
NULL,
|
||||
".?AVexception@std@@"
|
||||
};
|
||||
|
||||
DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor, 8)
|
||||
exception* __thiscall MSVCP_exception_ctor(exception *this, const char **name)
|
||||
{
|
||||
TRACE("(%p %s)\n", this, *name);
|
||||
|
||||
this->vtable = exception_type_info.vtable;
|
||||
this->vtable = &MSVCP_exception_vtable;
|
||||
if(*name) {
|
||||
unsigned int name_len = strlen(*name) + 1;
|
||||
this->name = malloc(name_len);
|
||||
|
@ -99,7 +93,7 @@ exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception
|
|||
TRACE("(%p,%p)\n", this, rhs);
|
||||
|
||||
if(!rhs->do_free) {
|
||||
this->vtable = exception_type_info.vtable;
|
||||
this->vtable = &MSVCP_exception_vtable;
|
||||
this->name = rhs->name;
|
||||
this->do_free = FALSE;
|
||||
} else
|
||||
|
@ -112,17 +106,32 @@ DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4)
|
|||
void __thiscall MSVCP_exception_dtor(exception *this)
|
||||
{
|
||||
TRACE("(%p)\n", this);
|
||||
this->vtable = exception_type_info.vtable;
|
||||
this->vtable = &MSVCP_exception_vtable;
|
||||
if(this->do_free)
|
||||
free(this->name);
|
||||
}
|
||||
|
||||
static const rtti_base_descriptor exception_rtti_base_descriptor = {
|
||||
&exception_type_info,
|
||||
0,
|
||||
{ 0, -1, 0 },
|
||||
0
|
||||
};
|
||||
DEFINE_THISCALL_WRAPPER(MSVCP_exception_vector_dtor, 8)
|
||||
void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flags)
|
||||
{
|
||||
TRACE("%p %x\n", this, flags);
|
||||
if(flags & 2) {
|
||||
/* we have an array, with the number of elements stored before the first object */
|
||||
int i, *ptr = (int *)this-1;
|
||||
|
||||
for(i=*ptr-1; i>=0; i--)
|
||||
MSVCP_exception_dtor(this+i);
|
||||
MSVCRT_operator_delete(ptr);
|
||||
} else {
|
||||
MSVCP_exception_dtor(this);
|
||||
if(flags & 1)
|
||||
MSVCRT_operator_delete(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
DEFINE_RTTI_DATA(exception, 0, 0, NULL, NULL, NULL, ".?AVexception@std@@");
|
||||
|
||||
static const cxx_type_info exception_cxx_type_info = {
|
||||
0,
|
||||
|
@ -148,12 +157,6 @@ static const cxx_exception_type exception_cxx_type = {
|
|||
&exception_cxx_type_table
|
||||
};
|
||||
|
||||
void set_exception_vtable(void)
|
||||
{
|
||||
HMODULE hmod = GetModuleHandleA("msvcrt.dll");
|
||||
exception_type_info.vtable = (void*)GetProcAddress(hmod, "??_7exception@@6B@");
|
||||
}
|
||||
|
||||
/* bad_alloc class data */
|
||||
typedef exception bad_alloc;
|
||||
|
||||
|
@ -591,6 +594,7 @@ const char* __thiscall MSVCP_runtime_error_what(runtime_error *this)
|
|||
#ifndef __GNUC__
|
||||
void __asm_dummy_vtables(void) {
|
||||
#endif
|
||||
__ASM_VTABLE(exception, VTABLE_ADD_FUNC(MSVCP_what_exception));
|
||||
__ASM_VTABLE(bad_alloc, VTABLE_ADD_FUNC(MSVCP_what_exception));
|
||||
__ASM_VTABLE(logic_error, VTABLE_ADD_FUNC(MSVCP_logic_error_what));
|
||||
__ASM_VTABLE(length_error, VTABLE_ADD_FUNC(MSVCP_logic_error_what));
|
||||
|
|
|
@ -166,7 +166,6 @@ typedef enum __exception_type {
|
|||
EXCEPTION_RUNTIME_ERROR
|
||||
} exception_type;
|
||||
void throw_exception(exception_type, const char *);
|
||||
void set_exception_vtable(void);
|
||||
|
||||
/* rtti */
|
||||
typedef struct __type_info
|
||||
|
|
|
@ -89,7 +89,6 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|||
return FALSE; /* prefer native version */
|
||||
case DLL_PROCESS_ATTACH:
|
||||
init_cxx_funcs();
|
||||
set_exception_vtable();
|
||||
init_lockit();
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
|
|
Loading…
Reference in New Issue