diff --git a/dlls/msvcp70/msvcp70.spec b/dlls/msvcp70/msvcp70.spec index fbff36ad33c..88c6328de1f 100644 --- a/dlls/msvcp70/msvcp70.spec +++ b/dlls/msvcp70/msvcp70.spec @@ -446,10 +446,10 @@ @ stub -arch=win64 ??0__non_rtti_object@std@@QEAA@AEBV01@@Z @ stub -arch=win32 ??0__non_rtti_object@std@@QAE@PBD@Z @ stub -arch=win64 ??0__non_rtti_object@std@@QEAA@PEBD@Z -@ thiscall -arch=i386 ??0bad_cast@std@@QAE@ABV01@@Z(ptr ptr) msvcrt.??0bad_cast@@QAE@ABV0@@Z -@ cdecl -arch=win64 ??0bad_cast@std@@QEAA@AEBV01@@Z(ptr ptr) msvcrt.??0bad_cast@@QEAA@AEBV0@@Z -@ thiscall -arch=i386 ??0bad_cast@std@@QAE@PBD@Z(ptr str) msvcrt.??0bad_cast@@QAE@PBD@Z -@ cdecl -arch=win64 ??0bad_cast@std@@QEAA@PEBD@Z(ptr str) msvcrt.??0bad_cast@@QEAA@PEBD@Z +@ thiscall -arch=i386 ??0bad_cast@std@@QAE@ABV01@@Z(ptr ptr) MSVCP_bad_cast_copy_ctor +@ cdecl -arch=win64 ??0bad_cast@std@@QEAA@AEBV01@@Z(ptr ptr) MSVCP_bad_cast_copy_ctor +@ thiscall -arch=i386 ??0bad_cast@std@@QAE@PBD@Z(ptr str) MSVCP_bad_cast_ctor +@ cdecl -arch=win64 ??0bad_cast@std@@QEAA@PEBD@Z(ptr str) MSVCP_bad_cast_ctor @ stub -arch=win32 ??0bad_typeid@std@@QAE@ABV01@@Z @ stub -arch=win64 ??0bad_typeid@std@@QEAA@AEBV01@@Z @ stub -arch=win32 ??0bad_typeid@std@@QAE@PBD@Z @@ -672,8 +672,8 @@ @ cdecl -arch=win64 ??1_Winit@std@@QEAA@XZ(ptr) _Winit_dtor @ stub -arch=win32 ??1__non_rtti_object@std@@UAE@XZ @ stub -arch=win64 ??1__non_rtti_object@std@@UEAA@XZ -@ thiscall -arch=i386 ??1bad_cast@std@@UAE@XZ(ptr) msvcrt.??1bad_cast@@UAE@XZ -@ cdecl -arch=win64 ??1bad_cast@std@@UEAA@XZ(ptr) msvcrt.??1bad_cast@@UEAA@XZ +@ thiscall -arch=i386 ??1bad_cast@std@@UAE@XZ(ptr) MSVCP_bad_cast_dtor +@ cdecl -arch=win64 ??1bad_cast@std@@UEAA@XZ(ptr) MSVCP_bad_cast_dtor @ stub -arch=win32 ??1bad_typeid@std@@UAE@XZ @ stub -arch=win64 ??1bad_typeid@std@@UEAA@XZ @ thiscall -arch=i386 ??1codecvt_base@std@@UAE@XZ(ptr) codecvt_base_dtor @@ -812,8 +812,8 @@ @ cdecl -arch=win64 ??4_Winit@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) _Winit_op_assign @ stub -arch=win32 ??4__non_rtti_object@std@@QAEAAV01@ABV01@@Z @ stub -arch=win64 ??4__non_rtti_object@std@@QEAAAEAV01@AEBV01@@Z -@ thiscall -arch=i386 ??4bad_cast@std@@QAEAAV01@ABV01@@Z(ptr ptr) msvcrt.??4bad_cast@@QAEAAV0@ABV0@@Z -@ cdecl -arch=win64 ??4bad_cast@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) msvcrt.??4bad_cast@@QEAAAEAV0@AEBV0@@Z +@ thiscall -arch=i386 ??4bad_cast@std@@QAEAAV01@ABV01@@Z(ptr ptr) MSVCP_bad_cast_opequals +@ cdecl -arch=win64 ??4bad_cast@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) MSVCP_bad_cast_opequals @ stub -arch=win32 ??4bad_typeid@std@@QAEAAV01@ABV01@@Z @ stub -arch=win64 ??4bad_typeid@std@@QEAAAEAV01@AEBV01@@Z @ thiscall -arch=win32 ??4ios_base@std@@QAEAAV01@ABV01@@Z(ptr ptr) ios_base_assign @@ -1726,8 +1726,8 @@ @ cdecl -arch=win64 ??_F_Locinfo@std@@QEAAXXZ(ptr) _Locinfo_ctor @ thiscall -arch=i386 ??_F_Timevec@std@@QAEXXZ(ptr) _Timevec_ctor @ cdecl -arch=win64 ??_F_Timevec@std@@QEAAXXZ(ptr) _Timevec_ctor -@ thiscall -arch=i386 ??_Fbad_cast@std@@QAEXXZ(ptr) msvcrt.??_Fbad_cast@@QAEXXZ -@ cdecl -arch=win64 ??_Fbad_cast@std@@QEAAXXZ(ptr) msvcrt.??_Fbad_cast@@QEAAXXZ +@ thiscall -arch=i386 ??_Fbad_cast@std@@QAEXXZ(ptr) MSVCP_bad_cast_default_ctor +@ cdecl -arch=win64 ??_Fbad_cast@std@@QEAAXXZ(ptr) MSVCP_bad_cast_default_ctor @ stub -arch=win32 ??_Fbad_typeid@std@@QAEXXZ @ stub -arch=win64 ??_Fbad_typeid@std@@QEAAXXZ @ thiscall -arch=i386 ??_Fcodecvt_base@std@@QAEXXZ(ptr) codecvt_base_ctor diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index dfd35d98c4d..da3a4bf6605 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -41,6 +41,7 @@ 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; extern const vtable_ptr MSVCP_failure_vtable; +extern const vtable_ptr MSVCP_bad_cast_vtable; static void MSVCP_type_info_dtor(type_info * _this) { @@ -447,6 +448,75 @@ const char* __thiscall MSVCP_failure_what(failure *this) DEFINE_RTTI_DATA2(failure, 0, &runtime_error_rtti_base_descriptor, &exception_rtti_base_descriptor, ".?AVfailure@std@@") DEFINE_CXX_DATA2(failure, &runtime_error_cxx_type_info, &exception_cxx_type_info, MSVCP_runtime_error_dtor) +/* bad_cast class data */ +typedef exception bad_cast; + +DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_ctor, 8) +bad_cast* __thiscall MSVCP_bad_cast_ctor(bad_cast *this, const char *name) +{ + TRACE("%p %s\n", this, name); + MSVCP_exception_ctor(this, &name); + this->vtable = &MSVCP_bad_cast_vtable; + return this; +} + +DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_default_ctor,4) +bad_cast* __thiscall MSVCP_bad_cast_default_ctor(bad_cast *this) +{ + return MSVCP_bad_cast_ctor(this, "bad cast"); +} + +DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_copy_ctor, 8) +bad_cast* __thiscall MSVCP_bad_cast_copy_ctor(bad_cast *this, const bad_cast *rhs) +{ + TRACE("%p %p\n", this, rhs); + MSVCP_exception_copy_ctor(this, rhs); + this->vtable = &MSVCP_bad_cast_vtable; + return this; +} + +DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_dtor, 4) +void __thiscall MSVCP_bad_cast_dtor(bad_cast *this) +{ + TRACE("%p\n", this); + MSVCP_exception_dtor(this); +} + +DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_vector_dtor, 8) +void * __thiscall MSVCP_bad_cast_vector_dtor(bad_cast *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_PTR i, *ptr = (INT_PTR *)this-1; + + for(i=*ptr-1; i>=0; i--) + MSVCP_bad_cast_dtor(this+i); + MSVCRT_operator_delete(ptr); + } else { + MSVCP_bad_cast_dtor(this); + if(flags & 1) + MSVCRT_operator_delete(this); + } + + return this; +} + +DEFINE_THISCALL_WRAPPER(MSVCP_bad_cast_opequals, 8) +bad_cast* __thiscall MSVCP_bad_cast_opequals(bad_cast *this, const bad_cast *rhs) +{ + TRACE("(%p %p)\n", this, rhs); + + if(this != rhs) { + MSVCP_exception_dtor(this); + MSVCP_exception_copy_ctor(this, rhs); + } + return this; +} + +DEFINE_RTTI_DATA1(bad_cast, 0, &exception_rtti_base_descriptor, ".?AVbad_cast@std@@") +DEFINE_CXX_DATA1(bad_cast, &exception_cxx_type_info, MSVCP_bad_cast_dtor) + /* ?_Nomemory@std@@YAXXZ */ void __cdecl _Nomemory(void) { @@ -528,6 +598,9 @@ void __asm_dummy_vtables(void) { __ASM_VTABLE(failure, VTABLE_ADD_FUNC(MSVCP_failure_vector_dtor) VTABLE_ADD_FUNC(MSVCP_failure_what)); + __ASM_VTABLE(bad_cast, + VTABLE_ADD_FUNC(MSVCP_bad_cast_vector_dtor) + VTABLE_ADD_FUNC(MSVCP_what_exception)); #ifndef __GNUC__ } #endif @@ -595,6 +668,7 @@ void init_exception(void *base) init_invalid_argument_rtti(base); init_runtime_error_rtti(base); init_failure_rtti(base); + init_bad_cast_rtti(base); init_exception_cxx(base); init_bad_alloc_cxx(base); @@ -604,5 +678,6 @@ void init_exception(void *base) init_invalid_argument_cxx(base); init_runtime_error_cxx(base); init_failure_cxx(base); + init_bad_cast_cxx(base); #endif }