type_info is needed for RTTI, and in some cases pulling in whole exception.c is not an option due to its dependency on multiple MSVCRT_ functions.
Signed-off-by: Arkadiusz Hiler ahiler@codeweavers.com --- dlls/msvcirt/Makefile.in | 1 + dlls/msvcirt/msvcirt.c | 1 + dlls/msvcirt/msvcirt.h | 1 + dlls/msvcp100/Makefile.in | 1 + dlls/msvcp110/Makefile.in | 1 + dlls/msvcp120/Makefile.in | 1 + dlls/msvcp140/Makefile.in | 1 + dlls/msvcp60/Makefile.in | 1 + dlls/msvcp60/main.c | 1 + dlls/msvcp60/msvcp.h | 1 + dlls/msvcp70/Makefile.in | 1 + dlls/msvcp71/Makefile.in | 1 + dlls/msvcp80/Makefile.in | 1 + dlls/msvcp90/Makefile.in | 1 + dlls/msvcp90/exception.c | 31 ------------------ dlls/msvcp90/msvcp90.h | 1 + dlls/msvcp90/msvcp_main.c | 1 + dlls/msvcp90/type_info.c | 67 +++++++++++++++++++++++++++++++++++++++ 18 files changed, 83 insertions(+), 31 deletions(-) create mode 100644 dlls/msvcp90/type_info.c
diff --git a/dlls/msvcirt/Makefile.in b/dlls/msvcirt/Makefile.in index 1dee2b24c02..b792edabf09 100644 --- a/dlls/msvcirt/Makefile.in +++ b/dlls/msvcirt/Makefile.in @@ -6,5 +6,6 @@ IMPORTS = msvcrt EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native
C_SRCS = \ + type_info.c \ exception.c \ msvcirt.c diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index db4b736d272..87e1908c4a8 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -5213,6 +5213,7 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) { case DLL_PROCESS_ATTACH: init_cxx_funcs(); + init_type_info(inst); init_exception(inst); init_io(inst); DisableThreadLibraryCalls( inst ); diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h index 5b59b7862a3..e775eabb2fe 100644 --- a/dlls/msvcirt/msvcirt.h +++ b/dlls/msvcirt/msvcirt.h @@ -71,4 +71,5 @@ typedef enum { extern void* (__cdecl *MSVCRT_operator_new)(SIZE_T); extern void (__cdecl *MSVCRT_operator_delete)(void*);
+void init_type_info(void*); void init_exception(void*); diff --git a/dlls/msvcp100/Makefile.in b/dlls/msvcp100/Makefile.in index 258aff4b770..0ee8fee26c8 100644 --- a/dlls/msvcp100/Makefile.in +++ b/dlls/msvcp100/Makefile.in @@ -6,6 +6,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp110/Makefile.in b/dlls/msvcp110/Makefile.in index 6b1998a68ea..01a22340b6d 100644 --- a/dlls/msvcp110/Makefile.in +++ b/dlls/msvcp110/Makefile.in @@ -6,6 +6,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp120/Makefile.in b/dlls/msvcp120/Makefile.in index 2a77859bf99..22923b61937 100644 --- a/dlls/msvcp120/Makefile.in +++ b/dlls/msvcp120/Makefile.in @@ -6,6 +6,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp140/Makefile.in b/dlls/msvcp140/Makefile.in index ea05d6b3456..00bc6e219ce 100644 --- a/dlls/msvcp140/Makefile.in +++ b/dlls/msvcp140/Makefile.in @@ -5,6 +5,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp60/Makefile.in b/dlls/msvcp60/Makefile.in index b43395b44d1..92188139b02 100644 --- a/dlls/msvcp60/Makefile.in +++ b/dlls/msvcp60/Makefile.in @@ -6,6 +6,7 @@ IMPORTS = msvcrt EXTRADLLFLAGS = -mno-cygwin -Wb,--prefer-native
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp60/main.c b/dlls/msvcp60/main.c index ab9a6a3179d..a553e1438c2 100644 --- a/dlls/msvcp60/main.c +++ b/dlls/msvcp60/main.c @@ -89,6 +89,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) case DLL_PROCESS_ATTACH: init_cxx_funcs(); _Init_locks__Init_locks_ctor(NULL); + init_type_info(hinstDLL); init_exception(hinstDLL); init_locale(hinstDLL); init_io(hinstDLL); diff --git a/dlls/msvcp60/msvcp.h b/dlls/msvcp60/msvcp.h index 2507d9123d9..f078b33542a 100644 --- a/dlls/msvcp60/msvcp.h +++ b/dlls/msvcp60/msvcp.h @@ -465,6 +465,7 @@ ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_uint64(const num_put*, o ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_bool(const num_put*, ostreambuf_iterator_wchar*, ostreambuf_iterator_wchar, ios_base*, wchar_t, bool);
+void init_type_info(void*); void init_exception(void*); void init_locale(void*); void init_io(void*); diff --git a/dlls/msvcp70/Makefile.in b/dlls/msvcp70/Makefile.in index a023d1b8e2a..57987596f50 100644 --- a/dlls/msvcp70/Makefile.in +++ b/dlls/msvcp70/Makefile.in @@ -6,6 +6,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp71/Makefile.in b/dlls/msvcp71/Makefile.in index 6713ab469d3..743b6d4751c 100644 --- a/dlls/msvcp71/Makefile.in +++ b/dlls/msvcp71/Makefile.in @@ -6,6 +6,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp80/Makefile.in b/dlls/msvcp80/Makefile.in index 22a18fcc66a..7c1947f2721 100644 --- a/dlls/msvcp80/Makefile.in +++ b/dlls/msvcp80/Makefile.in @@ -6,6 +6,7 @@ PARENTSRC = ../msvcp90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp90/Makefile.in b/dlls/msvcp90/Makefile.in index b7e7b73423f..fe4bec04a9c 100644 --- a/dlls/msvcp90/Makefile.in +++ b/dlls/msvcp90/Makefile.in @@ -5,6 +5,7 @@ EXTRADEFS = -D_MSVCP_VER=90 EXTRADLLFLAGS = -mno-cygwin
C_SRCS = \ + type_info.c \ exception.c \ ios.c \ locale.c \ diff --git a/dlls/msvcp90/exception.c b/dlls/msvcp90/exception.c index 8ea4e132a0f..e6c9227cc27 100644 --- a/dlls/msvcp90/exception.c +++ b/dlls/msvcp90/exception.c @@ -65,34 +65,6 @@ extern const vtable_ptr MSVCP_bad_cast_vtable; /* ??_7range_error@std@@6B@ */ extern const vtable_ptr MSVCP_range_error_vtable;
-static void MSVCP_type_info_dtor(type_info * _this) -{ - free(_this->name); -} - -/* Unexported */ -DEFINE_THISCALL_WRAPPER(MSVCP_type_info_vector_dtor,8) -void * __thiscall MSVCP_type_info_vector_dtor(type_info * _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_type_info_dtor(_this + i); - MSVCRT_operator_delete(ptr); - } - else - { - MSVCP_type_info_dtor(_this); - if (flags & 1) MSVCRT_operator_delete(_this); - } - return _this; -} - -DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" ) - /* ??0exception@@QAE@ABQBD@Z */ /* ??0exception@@QEAA@AEBQEBD@Z */ DEFINE_THISCALL_WRAPPER(MSVCP_exception_ctor,8) @@ -1022,8 +994,6 @@ void __cdecl __ExceptionPtrDestroy(exception_ptr *ep) #endif
__ASM_BLOCK_BEGIN(exception_vtables) - __ASM_VTABLE(type_info, - VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor)); EXCEPTION_VTABLE(exception, VTABLE_ADD_FUNC(MSVCP_exception_vector_dtor) VTABLE_ADD_FUNC(MSVCP_exception_what)); @@ -1130,7 +1100,6 @@ void throw_exception(exception_type et, const char *str) void init_exception(void *base) { #ifdef __x86_64__ - init_type_info_rtti(base); init_exception_rtti(base); init_bad_alloc_rtti(base); init_logic_error_rtti(base); diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index b2e0ae8b15c..c4908f24245 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -618,6 +618,7 @@ ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_uint64(const num_put*, o ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_bool(const num_put*, ostreambuf_iterator_wchar*, ostreambuf_iterator_wchar, ios_base*, wchar_t, bool);
+void init_type_info(void*); void init_exception(void*); void init_locale(void*); void init_io(void*); diff --git a/dlls/msvcp90/msvcp_main.c b/dlls/msvcp90/msvcp_main.c index 6bfd8b14367..b023a3573de 100644 --- a/dlls/msvcp90/msvcp_main.c +++ b/dlls/msvcp90/msvcp_main.c @@ -184,6 +184,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) case DLL_PROCESS_ATTACH: init_cxx_funcs(); _Init_locks__Init_locks_ctor(NULL); + init_type_info(hinstDLL); init_exception(hinstDLL); init_locale(hinstDLL); init_io(hinstDLL); diff --git a/dlls/msvcp90/type_info.c b/dlls/msvcp90/type_info.c new file mode 100644 index 00000000000..38134ac5e86 --- /dev/null +++ b/dlls/msvcp90/type_info.c @@ -0,0 +1,67 @@ +/* + * Copyright 2021 Arkadiusz Hiler for CodeWeavers + * + * 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 <stdarg.h> + +#include "msvcp90.h" +#include "windef.h" +#include "winbase.h" +#include "winternl.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(msvcp); + +static void MSVCP_type_info_dtor(type_info * _this) +{ + free(_this->name); +} + +/* Unexported */ +DEFINE_THISCALL_WRAPPER(MSVCP_type_info_vector_dtor,8) +void * __thiscall MSVCP_type_info_vector_dtor(type_info * _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_type_info_dtor(_this + i); + MSVCRT_operator_delete(ptr); + } + else + { + MSVCP_type_info_dtor(_this); + if (flags & 1) MSVCRT_operator_delete(_this); + } + return _this; +} + +DEFINE_RTTI_DATA0( type_info, 0, ".?AVtype_info@@" ) + +__ASM_BLOCK_BEGIN(type_info_vtables) + __ASM_VTABLE(type_info, + VTABLE_ADD_FUNC(MSVCP_type_info_vector_dtor)); +__ASM_BLOCK_END + +void init_type_info(void *base) +{ +#ifdef __x86_64__ + init_type_info_rtti(base); +#endif +}