From e35e107e5eda2c64c2da8265a4b7ca5eceecaeed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Iv=C3=A1n=20Matellanes?= Date: Tue, 26 May 2015 13:08:39 +0200 Subject: [PATCH] msvcirt: Share exceptions implementation with msvcp. --- dlls/msvcirt/Makefile.in | 3 ++ dlls/msvcirt/msvcirt.c | 40 ++++++++--------- dlls/msvcirt/msvcirt.h | 25 +++++++++++ dlls/msvcirt/msvcirt.spec | 52 +++++++++++----------- dlls/msvcp90/exception.c | 106 ++++++++++++++++++++++++++++++++++++++++---- dlls/msvcrt40/msvcrt40.spec | 22 ++++----- 6 files changed, 181 insertions(+), 67 deletions(-) create mode 100644 dlls/msvcirt/msvcirt.h diff --git a/dlls/msvcirt/Makefile.in b/dlls/msvcirt/Makefile.in index 21a9801189a..acaf495d17b 100644 --- a/dlls/msvcirt/Makefile.in +++ b/dlls/msvcirt/Makefile.in @@ -1,5 +1,8 @@ MODULE = msvcirt.dll IMPORTS = msvcrt +EXTRADEFS = -D_MSVCIRT +PARENTSRC = ../msvcp90 C_SRCS = \ + exception.c \ msvcirt.c diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index a5614129b52..e73f93e8184 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -20,6 +20,7 @@ #include +#include "msvcirt.h" #include "windef.h" #include "winbase.h" #include "wine/debug.h" @@ -38,27 +39,6 @@ typedef struct { LPVOID VTable; } class_strstreambuf; -#ifdef __i386__ /* thiscall functions are i386-specific */ - -#define THISCALL(func) __thiscall_ ## func -#define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func) -#define __thiscall __stdcall -#define DEFINE_THISCALL_WRAPPER(func,args) \ - extern void THISCALL(func)(void); \ - __ASM_GLOBAL_FUNC(__thiscall_ ## func, \ - "popl %eax\n\t" \ - "pushl %ecx\n\t" \ - "pushl %eax\n\t" \ - "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) ) -#else /* __i386__ */ - -#define THISCALL(func) func -#define THISCALL_NAME(func) __ASM_NAME(#func) -#define __thiscall __cdecl -#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */ - -#endif /* __i386__ */ - /****************************************************************** * ??1ios@@UAE@XZ (MSVCRTI.@) * class ios & __thiscall ios::-ios<<(void) @@ -156,6 +136,22 @@ char * __thiscall MSVCIRT_str_sl_void(class_strstreambuf * _this) return 0; } +void (__cdecl *MSVCRT_operator_delete)(void*); + +static void init_cxx_funcs(void) +{ + HMODULE hmod = GetModuleHandleA("msvcrt.dll"); + + if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ + { + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z"); + } + else + { + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z"); + } +} + BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) { switch (reason) @@ -163,6 +159,8 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) case DLL_WINE_PREATTACH: return FALSE; /* prefer native version */ case DLL_PROCESS_ATTACH: + init_cxx_funcs(); + init_exception(inst); DisableThreadLibraryCalls( inst ); break; } diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h new file mode 100644 index 00000000000..43015288cdd --- /dev/null +++ b/dlls/msvcirt/msvcirt.h @@ -0,0 +1,25 @@ +/* + * Copyright 2015 Iván Matellanes + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include "stdlib.h" +#include "windef.h" +#include "cxx.h" + +extern void (__cdecl *MSVCRT_operator_delete)(void*); + +void init_exception(void*); diff --git a/dlls/msvcirt/msvcirt.spec b/dlls/msvcirt/msvcirt.spec index baafadb2767..3399b5d63eb 100644 --- a/dlls/msvcirt/msvcirt.spec +++ b/dlls/msvcirt/msvcirt.spec @@ -2,12 +2,12 @@ @ stub -arch=win64 ??0Iostream_init@@QEAA@AEAVios@@H@Z @ stub -arch=win32 ??0Iostream_init@@QAE@XZ # __thiscall Iostream_init::Iostream_init(void) @ stub -arch=win64 ??0Iostream_init@@QEAA@XZ -@ thiscall -arch=i386 ??0exception@@QAE@ABQBD@Z(ptr ptr) msvcrt.??0exception@@QAE@ABQBD@Z -@ cdecl -arch=win64 ??0exception@@QEAA@AEBQEBD@Z(ptr ptr) msvcrt.??0exception@@QEAA@AEBQEBD@Z -@ thiscall -arch=i386 ??0exception@@QAE@ABV0@@Z(ptr ptr) msvcrt.??0exception@@QAE@ABV0@@Z -@ cdecl -arch=win64 ??0exception@@QEAA@AEBV0@@Z(ptr ptr) msvcrt.??0exception@@QEAA@AEBV0@@Z -@ thiscall -arch=i386 ??0exception@@QAE@XZ(ptr) msvcrt.??0exception@@QAE@XZ -@ cdecl -arch=win64 ??0exception@@QEAA@XZ(ptr) msvcrt.??0exception@@QEAA@XZ +@ thiscall -arch=i386 ??0exception@@QAE@ABQBD@Z(ptr ptr) MSVCP_exception_ctor +@ cdecl -arch=win64 ??0exception@@QEAA@AEBQEBD@Z(ptr ptr) MSVCP_exception_ctor +@ thiscall -arch=i386 ??0exception@@QAE@ABV0@@Z(ptr ptr) MSVCP_exception_copy_ctor +@ cdecl -arch=win64 ??0exception@@QEAA@AEBV0@@Z(ptr ptr) MSVCP_exception_copy_ctor +@ thiscall -arch=i386 ??0exception@@QAE@XZ(ptr) MSVCP_exception_default_ctor +@ cdecl -arch=win64 ??0exception@@QEAA@XZ(ptr) MSVCP_exception_default_ctor @ stub -arch=win32 ??0filebuf@@QAE@ABV0@@Z # __thiscall filebuf::filebuf(class filebuf const &) @ stub -arch=win64 ??0filebuf@@QEAA@AEBV0@@Z @ stub -arch=win32 ??0filebuf@@QAE@H@Z # __thiscall filebuf::filebuf(int) @@ -66,10 +66,10 @@ @ stub -arch=win64 ??0istrstream@@QEAA@PEAD@Z @ stub -arch=win32 ??0istrstream@@QAE@PADH@Z # __thiscall istrstream::istrstream(char *,int) @ stub -arch=win64 ??0istrstream@@QEAA@PEADH@Z -@ stub -arch=win32 ??0logic_error@@QAE@ABQBD@Z # __thiscall logic_error::logic_error(char const * const &) -@ stub -arch=win64 ??0logic_error@@QEAA@AEBQEBD@Z -@ stub -arch=win32 ??0logic_error@@QAE@ABV0@@Z # __thiscall logic_error::logic_error(class logic_error const &) -@ stub -arch=win64 ??0logic_error@@QEAA@AEBV0@@Z +@ thiscall -arch=win32 ??0logic_error@@QAE@ABQBD@Z(ptr ptr) MSVCP_logic_error_ctor +@ cdecl -arch=win64 ??0logic_error@@QEAA@AEBQEBD@Z(ptr ptr) MSVCP_logic_error_ctor +@ thiscall -arch=win32 ??0logic_error@@QAE@ABV0@@Z(ptr ptr) MSVCP_logic_error_copy_ctor +@ cdecl -arch=win64 ??0logic_error@@QEAA@AEBV0@@Z(ptr ptr) MSVCP_logic_error_copy_ctor @ stub -arch=win32 ??0ofstream@@QAE@ABV0@@Z # __thiscall ofstream::ofstream(class ofstream const &) @ stub -arch=win64 ??0ofstream@@QEAA@AEBV0@@Z @ stub -arch=win32 ??0ofstream@@QAE@H@Z # __thiscall ofstream::ofstream(int) @@ -132,8 +132,8 @@ @ stub -arch=win64 ??0strstreambuf@@QEAA@XZ @ stub -arch=win32 ??1Iostream_init@@QAE@XZ # __thiscall Iostream_init::~Iostream_init(void) @ stub -arch=win64 ??1Iostream_init@@QEAA@XZ -@ thiscall -arch=i386 ??1exception@@UAE@XZ(ptr) msvcrt.??1exception@@UAE@XZ -@ cdecl -arch=win64 ??1exception@@UEAA@XZ(ptr) msvcrt.??1exception@@UEAA@XZ +@ thiscall -arch=i386 ??1exception@@UAE@XZ(ptr) MSVCP_exception_dtor +@ cdecl -arch=win64 ??1exception@@UEAA@XZ(ptr) MSVCP_exception_dtor @ stub -arch=win32 ??1filebuf@@UAE@XZ # virtual __thiscall filebuf::~filebuf(void) @ stub -arch=win64 ??1filebuf@@UEAA@XZ @ stub -arch=win32 ??1fstream@@UAE@XZ # virtual __thiscall fstream::~fstream(void) @@ -150,8 +150,8 @@ @ stub -arch=win64 ??1istream_withassign@@UEAA@XZ @ stub -arch=win32 ??1istrstream@@UAE@XZ # virtual __thiscall istrstream::~istrstream(void) @ stub -arch=win64 ??1istrstream@@UEAA@XZ -@ stub -arch=win32 ??1logic_error@@UAE@XZ # virtual __thiscall logic_error::~logic_error(void) -@ stub -arch=win64 ??1logic_error@@UEAA@XZ +@ thiscall -arch=win32 ??1logic_error@@UAE@XZ(ptr) MSVCP_logic_error_dtor +@ cdecl -arch=win64 ??1logic_error@@UEAA@XZ(ptr) MSVCP_logic_error_dtor @ stub -arch=win32 ??1ofstream@@UAE@XZ # virtual __thiscall ofstream::~ofstream(void) @ stub -arch=win64 ??1ofstream@@UEAA@XZ @ stub -arch=win32 ??1ostream@@UAE@XZ # virtual __thiscall ostream::~ostream(void) @@ -172,8 +172,8 @@ @ stub -arch=win64 ??1strstreambuf@@UEAA@XZ @ stub -arch=win32 ??4Iostream_init@@QAEAAV0@ABV0@@Z # class Iostream_init & __thiscall Iostream_init::operator=(class Iostream_init const &) @ stub -arch=win64 ??4Iostream_init@@QEAAAEAV0@AEBV0@@Z -@ thiscall -arch=i386 ??4exception@@QAEAAV0@ABV0@@Z(ptr ptr) msvcrt.??4exception@@QAEAAV0@ABV0@@Z -@ cdecl -arch=win64 ??4exception@@QEAAAEAV0@AEBV0@@Z(ptr ptr) msvcrt.??4exception@@QEAAAEAV0@AEBV0@@Z +@ thiscall -arch=i386 ??4exception@@QAEAAV0@ABV0@@Z(ptr ptr) MSVCP_exception_assign +@ cdecl -arch=win64 ??4exception@@QEAAAEAV0@AEBV0@@Z(ptr ptr) MSVCP_exception_assign @ stub -arch=win32 ??4filebuf@@QAEAAV0@ABV0@@Z # class filebuf & __thiscall filebuf::operator=(class filebuf const &) @ stub -arch=win64 ??4filebuf@@QEAAAEAV0@AEBV0@@Z @ stub -arch=win32 ??4fstream@@QAEAAV0@AAV0@@Z # class fstream & __thiscall fstream::operator=(class fstream &) @@ -198,8 +198,8 @@ @ stub -arch=win64 ??4istream_withassign@@QEAAAEAVistream@@PEAVstreambuf@@@Z @ stub -arch=win32 ??4istrstream@@QAEAAV0@ABV0@@Z # class istrstream & __thiscall istrstream::operator=(class istrstream const &) @ stub -arch=win64 ??4istrstream@@QEAAAEAV0@AEBV0@@Z -@ stub -arch=win32 ??4logic_error@@QAEAAV0@ABV0@@Z # class logic_error & __thiscall logic_error::operator=(class logic_error const &) -@ stub -arch=win64 ??4logic_error@@QEAAAEAV0@AEBV0@@Z +@ thiscall -arch=win32 ??4logic_error@@QAEAAV0@ABV0@@Z(ptr ptr) MSVCP_logic_error_assign +@ cdecl -arch=win64 ??4logic_error@@QEAAAEAV0@AEBV0@@Z(ptr ptr) MSVCP_logic_error_assign @ stub -arch=win32 ??4ofstream@@QAEAAV0@ABV0@@Z # class ofstream & __thiscall ofstream::operator=(class ofstream const &) @ stub -arch=win64 ??4ofstream@@QEAAAEAV0@AEBV0@@Z @ stub -arch=win32 ??4ostream@@IAEAAV0@ABV0@@Z # class ostream & __thiscall ostream::operator=(class ostream const &) @@ -302,7 +302,7 @@ @ stub -arch=win64 ??7ios@@QEBAHXZ @ stub -arch=win32 ??Bios@@QBEPAXXZ # __thiscall ios::operator void *(void)const @ stub -arch=win64 ??Bios@@QEBAPEAXXZ -@ extern ??_7exception@@6B@ msvcrt.??_7exception@@6B@ +@ extern ??_7exception@@6B@ MSVCP_exception_vtable # @ extern ??_7filebuf@@6B@ # const filebuf::`vftable' # @ extern ??_7fstream@@6B@ # const fstream::`vftable' # @ extern ??_7ifstream@@6B@ # const ifstream::`vftable' @@ -311,7 +311,7 @@ # @ extern ??_7istream@@6B@ # const istream::`vftable' # @ extern ??_7istream_withassign@@6B@ # const istream_withassign::`vftable' # @ extern ??_7istrstream@@6B@ # const istrstream::`vftable' -# @ extern ??_7logic_error@@6B@ # const logic_error::`vftable' +@ extern ??_7logic_error@@6B@ MSVCP_logic_error_vtable # @ extern ??_7ofstream@@6B@ # const ofstream::`vftable' # @ extern ??_7ostream@@6B@ # const ostream::`vftable' # @ extern ??_7ostream_withassign@@6B@ # const ostream_withassign::`vftable' @@ -361,7 +361,7 @@ @ stub -arch=win64 ??_Dstdiostream@@QEAAXXZ @ stub -arch=win32 ??_Dstrstream@@QAEXXZ # void __thiscall strstream::`vbase destructor'(void) @ stub -arch=win64 ??_Dstrstream@@QEAAXXZ -@ thiscall -arch=win32 ??_Eexception@@UAEPAXI@Z(ptr long) msvcrt.??_Eexception@@UAEPAXI@Z # virtual void * __thiscall exception::`vector deleting destructor'(unsigned int) +@ thiscall -arch=win32 ??_Eexception@@UAEPAXI@Z(ptr long) MSVCP_exception_vector_dtor @ stub -arch=win32 ??_Efilebuf@@UAEPAXI@Z # virtual void * __thiscall filebuf::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Efstream@@UAEPAXI@Z # virtual void * __thiscall fstream::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Eifstream@@UAEPAXI@Z # virtual void * __thiscall ifstream::`vector deleting destructor'(unsigned int) @@ -370,7 +370,7 @@ @ stub -arch=win32 ??_Eistream@@UAEPAXI@Z # virtual void * __thiscall istream::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Eistream_withassign@@UAEPAXI@Z # virtual void * __thiscall istream_withassign::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Eistrstream@@UAEPAXI@Z # virtual void * __thiscall istrstream::`vector deleting destructor'(unsigned int) -@ stub -arch=win32 ??_Elogic_error@@UAEPAXI@Z # virtual void * __thiscall logic_error::`vector deleting destructor'(unsigned int) +@ thiscall -arch=win32 ??_Elogic_error@@UAEPAXI@Z(ptr long) MSVCP_logic_error_vector_dtor @ stub -arch=win32 ??_Eofstream@@UAEPAXI@Z # virtual void * __thiscall ofstream::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Eostream@@UAEPAXI@Z # virtual void * __thiscall ostream::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Eostream_withassign@@UAEPAXI@Z # virtual void * __thiscall ostream_withassign::`vector deleting destructor'(unsigned int) @@ -380,7 +380,7 @@ @ stub -arch=win32 ??_Estreambuf@@UAEPAXI@Z # virtual void * __thiscall streambuf::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Estrstream@@UAEPAXI@Z # virtual void * __thiscall strstream::`vector deleting destructor'(unsigned int) @ stub -arch=win32 ??_Estrstreambuf@@UAEPAXI@Z # virtual void * __thiscall strstreambuf::`vector deleting destructor'(unsigned int) -@ thiscall -arch=win32 ??_Gexception@@UAEPAXI@Z(ptr long) msvcrt.??_Gexception@@UAEPAXI@Z # virtual void * __thiscall exception::`scalar deleting destructor'(unsigned int) +@ thiscall -arch=win32 ??_Gexception@@UAEPAXI@Z(ptr long) MSVCP_exception_scalar_dtor @ stub -arch=win32 ??_Gfilebuf@@UAEPAXI@Z # virtual void * __thiscall filebuf::`scalar deleting destructor'(unsigned int) @ stub -arch=win32 ??_Gfstream@@UAEPAXI@Z # virtual void * __thiscall fstream::`scalar deleting destructor'(unsigned int) @ stub -arch=win32 ??_Gifstream@@UAEPAXI@Z # virtual void * __thiscall ifstream::`scalar deleting destructor'(unsigned int) @@ -389,7 +389,7 @@ @ stub -arch=win32 ??_Gistream@@UAEPAXI@Z # virtual void * __thiscall istream::`scalar deleting destructor'(unsigned int) @ stub -arch=win32 ??_Gistream_withassign@@UAEPAXI@Z # virtual void * __thiscall istream_withassign::`scalar deleting destructor'(unsigned int) @ stub -arch=win32 ??_Gistrstream@@UAEPAXI@Z # virtual void * __thiscall istrstream::`scalar deleting destructor'(unsigned int) -@ stub -arch=win32 ??_Glogic_error@@UAEPAXI@Z # virtual void * __thiscall logic_error::`scalar deleting destructor'(unsigned int) +@ thiscall -arch=win32 ??_Glogic_error@@UAEPAXI@Z(ptr long) MSVCP_logic_error_scalar_dtor @ stub -arch=win32 ??_Gofstream@@UAEPAXI@Z # virtual void * __thiscall ofstream::`scalar deleting destructor'(unsigned int) @ stub -arch=win32 ??_Gostream@@UAEPAXI@Z # virtual void * __thiscall ostream::`scalar deleting destructor'(unsigned int) @ stub -arch=win32 ??_Gostream_withassign@@UAEPAXI@Z # virtual void * __thiscall ostream_withassign::`scalar deleting destructor'(unsigned int) @@ -760,8 +760,8 @@ @ stub ?unlockc@ios@@KAXXZ # static void __cdecl ios::unlockc(void) @ stub -arch=win32 ?unsetf@ios@@QAEJJ@Z # long __thiscall ios::unsetf(long) @ stub -arch=win64 ?unsetf@ios@@QEAAJJ@Z -@ thiscall -arch=i386 ?what@exception@@UBEPBDXZ(ptr) msvcrt.?what@exception@@UBEPBDXZ -@ cdecl -arch=win64 ?what@exception@@UEBAPEBDXZ(ptr) msvcrt.?what@exception@@UEBAPEBDXZ +@ thiscall -arch=i386 ?what@exception@@UBEPBDXZ(ptr) MSVCP_exception_what +@ cdecl -arch=win64 ?what@exception@@UEBAPEBDXZ(ptr) MSVCP_exception_what @ stub -arch=win32 ?width@ios@@QAEHH@Z # int __thiscall ios::width(int) @ stub -arch=win64 ?width@ios@@QEAAHH@Z @ stub -arch=win32 ?width@ios@@QBEHXZ # int __thiscall ios::width(void)const diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index faeadda8f6e..d323ded1d08 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -21,7 +21,6 @@ #include #include "msvcp90.h" - #include "windef.h" #include "winbase.h" #include "wine/debug.h" @@ -32,7 +31,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcp); void WINAPI _CxxThrowException(exception*,const cxx_exception_type*); -#if _MSVCP_VER >= 70 +#if _MSVCP_VER >= 70 || defined(_MSVCIRT) typedef const char **exception_name; #define EXCEPTION_STR(name) (*name) #define EXCEPTION_NAME(str) ((exception_name)&str) @@ -87,7 +86,10 @@ void * __thiscall MSVCP_type_info_vector_dtor(type_info * _this, unsigned int fl DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" ) -static exception* MSVCP_exception_ctor(exception *this, exception_name name) +/* ??0exception@@QAE@ABQBD@Z */ +/* ??0exception@@QEAA@AEBQEBD@Z */ +DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor,8) +exception* __thiscall MSVCP_exception_ctor(exception *this, exception_name name) { TRACE("(%p %s)\n", this, EXCEPTION_STR(name)); @@ -119,6 +121,18 @@ exception* __thiscall MSVCP_exception_copy_ctor(exception *this, const exception return this; } +/* ??0exception@@QAE@XZ */ +/* ??0exception@@QEAA@XZ */ +DEFINE_THISCALL_WRAPPER(MSVCP_exception_default_ctor,4) +exception* __thiscall MSVCP_exception_default_ctor(exception *this) +{ + TRACE("(%p)\n", this); + this->vtable = &MSVCP_exception_vtable; + this->name = NULL; + this->do_free = FALSE; + return this; +} + DEFINE_THISCALL_WRAPPER(MSVCP_exception_dtor,4) void __thiscall MSVCP_exception_dtor(exception *this) { @@ -148,8 +162,24 @@ void * __thiscall MSVCP_exception_vector_dtor(exception *this, unsigned int flag return this; } -DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@") -DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor) +/* ??_Gexception@@UAEPAXI@Z */ +DEFINE_THISCALL_WRAPPER(MSVCP_exception_scalar_dtor, 8) +void * __thiscall MSVCP_exception_scalar_dtor(exception *this, unsigned int flags) +{ + TRACE("(%p %x)\n", this, flags); + MSVCP_exception_dtor(this); + if (flags & 1) MSVCRT_operator_delete(this); + return this; +} + +/* ??4exception@@QAEAAV0@ABV0@@Z */ +/* ??4exception@@QEAAAEAV0@AEBV0@@Z */ +DEFINE_THISCALL_WRAPPER(MSVCP_exception_assign, 8) +exception* __thiscall MSVCP_exception_assign(exception *this, const exception *assign) +{ + MSVCP_exception_dtor(this); + return MSVCP_exception_copy_ctor(this, assign); +} /* ?_Doraise@bad_alloc@std@@MBEXXZ */ /* ?_Doraise@bad_alloc@std@@MEBAXXZ */ @@ -176,6 +206,13 @@ const char* __thiscall MSVCP_exception_what(exception * this) return this->name ? this->name : "Unknown exception"; } +#ifdef _MSVCIRT +DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@std@@") +#else +DEFINE_RTTI_DATA0(exception, 0, ".?AVexception@@") +#endif +DEFINE_CXX_DATA0(exception, MSVCP_exception_dtor) + /* bad_alloc class data */ typedef exception bad_alloc; @@ -254,16 +291,25 @@ DEFINE_CXX_DATA1(bad_alloc, &exception_cxx_type_info, MSVCP_bad_alloc_dtor) /* logic_error class data */ typedef struct { exception e; +#ifndef _MSVCIRT basic_string_char str; +#endif } logic_error; -static logic_error* MSVCP_logic_error_ctor( logic_error *this, exception_name name ) +/* ??0logic_error@@QAE@ABQBD@Z */ +/* ??0logic_error@@QEAA@AEBQEBD@Z */ +DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor, 8) +logic_error* __thiscall MSVCP_logic_error_ctor( logic_error *this, exception_name name ) { TRACE("%p %s\n", this, EXCEPTION_STR(name)); - this->e.vtable = &MSVCP_logic_error_vtable; +#ifdef _MSVCIRT + MSVCP_exception_ctor(&this->e, name); +#else this->e.name = NULL; this->e.do_free = FALSE; MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name)); +#endif + this->e.vtable = &MSVCP_logic_error_vtable; return this; } @@ -275,13 +321,16 @@ logic_error* __thiscall MSVCP_logic_error_copy_ctor( { TRACE("%p %p\n", this, rhs); MSVCP_exception_copy_ctor(&this->e, &rhs->e); +#ifndef _MSVCIRT MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str); +#endif this->e.vtable = &MSVCP_logic_error_vtable; return this; } /* ??0logic_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ /* ??0logic_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ +#ifndef _MSVCIRT DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_ctor_bstr, 8) logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const basic_string_char *str) { @@ -289,6 +338,7 @@ logic_error* __thiscall MSVCP_logic_error_ctor_bstr(logic_error *this, const bas TRACE("(%p %p %s)\n", this, str, name); return MSVCP_logic_error_ctor(this, EXCEPTION_NAME(name)); } +#endif /* ??1logic_error@std@@UAE@XZ */ /* ??1logic_error@std@@UEAA@XZ */ @@ -301,7 +351,9 @@ void __thiscall MSVCP_logic_error_dtor(logic_error *this) { TRACE("%p\n", this); MSVCP_exception_dtor(&this->e); +#ifndef _MSVCIRT MSVCP_basic_string_char_dtor(&this->str); +#endif } DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_vector_dtor, 8) @@ -325,6 +377,16 @@ void* __thiscall MSVCP_logic_error_vector_dtor( return this; } +/* ??_Glogic_error@@UAEPAXI@Z */ +DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_scalar_dtor, 8) +void * __thiscall MSVCP_logic_error_scalar_dtor(logic_error *this, unsigned int flags) +{ + TRACE("(%p %x)\n", this, flags); + MSVCP_logic_error_dtor(this); + if (flags & 1) MSVCRT_operator_delete(this); + return this; +} + /* ??4logic_error@std@@QAEAAV01@ABV01@@Z */ /* ??4logic_error@std@@QEAAAEAV01@AEBV01@@Z */ DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_assign, 8) @@ -340,10 +402,18 @@ DEFINE_THISCALL_WRAPPER(MSVCP_logic_error_what, 4) const char* __thiscall MSVCP_logic_error_what(logic_error *this) { TRACE("%p\n", this); +#ifdef _MSVCIRT + return MSVCP_exception_what( &this->e ); +#else return MSVCP_basic_string_char_c_str(&this->str); +#endif } +#ifdef _MSVCIRT DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@std@@") +#else +DEFINE_RTTI_DATA1(logic_error, 0, &exception_rtti_base_descriptor, ".?AVlogic_error@@") +#endif DEFINE_CXX_DATA1(logic_error, &exception_cxx_type_info, MSVCP_logic_error_dtor) /* length_error class data */ @@ -371,6 +441,7 @@ length_error* __thiscall MSVCP_length_error_copy_ctor( /* ??0length_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ /* ??0length_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ +#ifndef _MSVCIRT DEFINE_THISCALL_WRAPPER(MSVCP_length_error_ctor_bstr, 8) length_error* __thiscall MSVCP_length_error_ctor_bstr(length_error *this, const basic_string_char *str) { @@ -378,6 +449,7 @@ length_error* __thiscall MSVCP_length_error_ctor_bstr(length_error *this, const TRACE("(%p %p %s)\n", this, str, name); return MSVCP_length_error_ctor(this, EXCEPTION_NAME(name)); } +#endif /* ??4length_error@std@@QAEAAV01@ABV01@@Z */ /* ??4length_error@std@@QEAAAEAV01@AEBV01@@Z */ @@ -416,6 +488,7 @@ out_of_range* __thiscall MSVCP_out_of_range_copy_ctor( /* ??0out_of_range@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ /* ??0out_of_range@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ +#ifndef _MSVCIRT DEFINE_THISCALL_WRAPPER(MSVCP_out_of_range_ctor_bstr, 8) out_of_range* __thiscall MSVCP_out_of_range_ctor_bstr(out_of_range *this, const basic_string_char *str) { @@ -423,6 +496,7 @@ out_of_range* __thiscall MSVCP_out_of_range_ctor_bstr(out_of_range *this, const TRACE("(%p %p %s)\n", this, str, name); return MSVCP_out_of_range_ctor(this, EXCEPTION_NAME(name)); } +#endif /* ??4out_of_range@std@@QAEAAV01@ABV01@@Z */ /* ??4out_of_range@std@@QEAAAEAV01@AEBV01@@Z */ @@ -469,10 +543,14 @@ typedef struct { static runtime_error* MSVCP_runtime_error_ctor( runtime_error *this, exception_name name ) { TRACE("%p %s\n", this, EXCEPTION_STR(name)); - this->e.vtable = &MSVCP_runtime_error_vtable; +#ifdef _MSVCIRT + MSVCP_exception_ctor(&this->e, name); +#else this->e.name = NULL; this->e.do_free = FALSE; MSVCP_basic_string_char_ctor_cstr(&this->str, EXCEPTION_STR(name)); +#endif + this->e.vtable = &MSVCP_runtime_error_vtable; return this; } @@ -484,13 +562,16 @@ runtime_error* __thiscall MSVCP_runtime_error_copy_ctor( { TRACE("%p %p\n", this, rhs); MSVCP_exception_copy_ctor(&this->e, &rhs->e); +#ifndef _MSVCIRT MSVCP_basic_string_char_copy_ctor(&this->str, &rhs->str); +#endif this->e.vtable = &MSVCP_runtime_error_vtable; return this; } /* ??0runtime_error@std@@QAE@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ /* ??0runtime_error@std@@QEAA@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@1@@Z */ +#ifndef _MSVCIRT DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_ctor_bstr, 8) runtime_error* __thiscall MSVCP_runtime_error_ctor_bstr(runtime_error *this, const basic_string_char *str) { @@ -498,6 +579,7 @@ runtime_error* __thiscall MSVCP_runtime_error_ctor_bstr(runtime_error *this, con TRACE("(%p %p %s)\n", this, str, name); return MSVCP_runtime_error_ctor(this, EXCEPTION_NAME(name)); } +#endif /* ??1runtime_error@std@@UAE@XZ */ /* ??1runtime_error@std@@UEAA@XZ */ @@ -506,7 +588,9 @@ void __thiscall MSVCP_runtime_error_dtor(runtime_error *this) { TRACE("%p\n", this); MSVCP_exception_dtor(&this->e); +#ifndef _MSVCIRT MSVCP_basic_string_char_dtor(&this->str); +#endif } DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_vector_dtor, 8) @@ -545,7 +629,11 @@ DEFINE_THISCALL_WRAPPER(MSVCP_runtime_error_what, 4) const char* __thiscall MSVCP_runtime_error_what(runtime_error *this) { TRACE("%p\n", this); +#ifdef _MSVCIRT + return MSVCP_exception_what( &this->e ); +#else return MSVCP_basic_string_char_c_str(&this->str); +#endif } DEFINE_RTTI_DATA1(runtime_error, 0, &exception_rtti_base_descriptor, ".?AVruntime_error@std@@") @@ -728,7 +816,7 @@ MSVCP_bool __cdecl MSVCP__uncaught_exception(void) return __uncaught_exception(); } -#if _MSVCP_VER >= 70 +#if _MSVCP_VER >= 70 || defined(_MSVCIRT) #define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs) #else #define EXCEPTION_VTABLE(name,funcs) __ASM_VTABLE(name,funcs VTABLE_ADD_FUNC(MSVCP_exception__Doraise)) diff --git a/dlls/msvcrt40/msvcrt40.spec b/dlls/msvcrt40/msvcrt40.spec index 5053253abdd..3b6b0d72f34 100644 --- a/dlls/msvcrt40/msvcrt40.spec +++ b/dlls/msvcrt40/msvcrt40.spec @@ -78,10 +78,10 @@ @ stub -arch=win64 ??0istrstream@@QEAA@PEAD@Z @ stub -arch=win32 ??0istrstream@@QAE@PADH@Z @ stub -arch=win64 ??0istrstream@@QEAA@PEADH@Z -@ stub -arch=win32 ??0logic_error@@QAE@ABQBD@Z -@ stub -arch=win64 ??0logic_error@@QEAA@AEBQEBD@Z -@ stub -arch=win32 ??0logic_error@@QAE@ABV0@@Z -@ stub -arch=win64 ??0logic_error@@QEAA@AEBV0@@Z +@ thiscall -arch=win32 ??0logic_error@@QAE@ABQBD@Z(ptr ptr) msvcirt.??0logic_error@@QAE@ABQBD@Z +@ cdecl -arch=win64 ??0logic_error@@QEAA@AEBQEBD@Z(ptr ptr) msvcirt.??0logic_error@@QEAA@AEBQEBD@Z +@ thiscall -arch=win32 ??0logic_error@@QAE@ABV0@@Z(ptr ptr) msvcirt.??0logic_error@@QAE@ABV0@@Z +@ cdecl -arch=win64 ??0logic_error@@QEAA@AEBV0@@Z(ptr ptr) msvcirt.??0logic_error@@QEAA@AEBV0@@Z @ stub -arch=win32 ??0ofstream@@QAE@ABV0@@Z @ stub -arch=win64 ??0ofstream@@QEAA@AEBV0@@Z @ stub -arch=win32 ??0ofstream@@QAE@H@Z @@ -166,8 +166,8 @@ @ stub -arch=win64 ??1istream_withassign@@UEAA@XZ @ stub -arch=win32 ??1istrstream@@UAE@XZ @ stub -arch=win64 ??1istrstream@@UEAA@XZ -@ stub -arch=win32 ??1logic_error@@UAE@XZ -@ stub -arch=win64 ??1logic_error@@UEAA@XZ +@ thiscall -arch=win32 ??1logic_error@@UAE@XZ(ptr) msvcirt.??1logic_error@@UAE@XZ +@ cdecl -arch=win64 ??1logic_error@@UEAA@XZ(ptr) msvcirt.??1logic_error@@UEAA@XZ @ stub -arch=win32 ??1ofstream@@UAE@XZ @ stub -arch=win64 ??1ofstream@@UEAA@XZ @ stub -arch=win32 ??1ostream@@UAE@XZ @@ -226,8 +226,8 @@ @ stub -arch=win64 ??4istream_withassign@@QEAAAEAVistream@@PEAVstreambuf@@@Z @ stub -arch=win32 ??4istrstream@@QAEAAV0@ABV0@@Z @ stub -arch=win64 ??4istrstream@@QEAAAEAV0@AEBV0@@Z -@ stub -arch=win32 ??4logic_error@@QAEAAV0@ABV0@@Z -@ stub -arch=win64 ??4logic_error@@QEAAAEAV0@AEBV0@@Z +@ thiscall -arch=win32 ??4logic_error@@QAEAAV0@ABV0@@Z(ptr ptr) msvcirt.??4logic_error@@QAEAAV0@ABV0@@Z +@ cdecl -arch=win64 ??4logic_error@@QEAAAEAV0@AEBV0@@Z(ptr ptr) msvcirt.??4logic_error@@QEAAAEAV0@AEBV0@@Z @ stub -arch=win32 ??4ofstream@@QAEAAV0@ABV0@@Z @ stub -arch=win64 ??4ofstream@@QEAAAEAV0@AEBV0@@Z @ stub -arch=win32 ??4ostream@@IAEAAV0@ABV0@@Z @@ -346,7 +346,7 @@ # @ extern ??_7istream@@6B@ # @ extern ??_7istream_withassign@@6B@ # @ extern ??_7istrstream@@6B@ -# @ extern ??_7logic_error@@6B@ +@ extern ??_7logic_error@@6B@ msvcirt.??_7logic_error@@6B@ # @ extern ??_7ofstream@@6B@ # @ extern ??_7ostream@@6B@ # @ extern ??_7ostream_withassign@@6B@ @@ -409,7 +409,7 @@ @ stub -arch=win32 ??_Eistream@@UAEPAXI@Z @ stub -arch=win32 ??_Eistream_withassign@@UAEPAXI@Z @ stub -arch=win32 ??_Eistrstream@@UAEPAXI@Z -@ stub -arch=win32 ??_Elogic_error@@UAEPAXI@Z +@ thiscall -arch=win32 ??_Elogic_error@@UAEPAXI@Z(ptr long) msvcirt.??_Elogic_error@@UAEPAXI@Z @ stub -arch=win32 ??_Eofstream@@UAEPAXI@Z @ stub -arch=win32 ??_Eostream@@UAEPAXI@Z @ stub -arch=win32 ??_Eostream_withassign@@UAEPAXI@Z @@ -432,7 +432,7 @@ @ stub -arch=win32 ??_Gistream@@UAEPAXI@Z @ stub -arch=win32 ??_Gistream_withassign@@UAEPAXI@Z @ stub -arch=win32 ??_Gistrstream@@UAEPAXI@Z -@ stub -arch=win32 ??_Glogic_error@@UAEPAXI@Z +@ thiscall -arch=win32 ??_Glogic_error@@UAEPAXI@Z(ptr long) msvcirt.??_Glogic_error@@UAEPAXI@Z @ stub -arch=win32 ??_Gofstream@@UAEPAXI@Z @ stub -arch=win32 ??_Gostream@@UAEPAXI@Z @ stub -arch=win32 ??_Gostream_withassign@@UAEPAXI@Z -- 2.11.4.GIT