From 0ebd8990dfc9988f933adc5c6ccc43c02f5e8725 Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Fri, 7 Sep 2012 11:00:37 +0200 Subject: [PATCH] msvcp60: Fixed RTTI structure on 64-bit systems. --- dlls/msvcp60/cxx.h | 113 +++++++++++++++++++++++++++++++++++++-- dlls/msvcp60/exception.c | 14 +++++ dlls/msvcp60/main.c | 1 + dlls/msvcp60/msvcp.h | 2 + 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/dlls/msvcp60/cxx.h b/dlls/msvcp60/cxx.h index f709d12f318..956675c17fa 100644 --- a/dlls/msvcp60/cxx.h +++ b/dlls/msvcp60/cxx.h @@ -64,7 +64,9 @@ #endif /* _WIN64 */ -#define DEFINE_RTTI_DATA(name, off, base_classes, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \ +#ifndef __x86_64__ + +#define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \ static const type_info name ## _type_info = { \ &MSVCP_type_info_vtable, \ NULL, \ @@ -73,7 +75,7 @@ \ static const rtti_base_descriptor name ## _rtti_base_descriptor = { \ &name ##_type_info, \ - base_classes, \ + base_classes_no, \ { 0, -1, 0}, \ 64 \ }; \ @@ -96,7 +98,7 @@ static const rtti_base_array name ## _rtti_base_array = { \ static const rtti_object_hierarchy name ## _hierarchy = { \ 0, \ 0, \ - base_classes+1, \ + base_classes_no+1, \ &name ## _rtti_base_array \ }; \ \ @@ -108,6 +110,74 @@ const rtti_object_locator name ## _rtti = { \ &name ## _hierarchy \ } +#else + +#define DEFINE_RTTI_DATA(name, off, base_classes_no, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \ + static const type_info name ## _type_info = { \ + &MSVCP_type_info_vtable, \ + NULL, \ + mangled_name \ + }; \ +\ +static rtti_base_descriptor name ## _rtti_base_descriptor = { \ + 0xdeadbeef, \ + base_classes_no, \ + { 0, -1, 0}, \ + 64 \ +}; \ +\ +static rtti_base_array name ## _rtti_base_array = { \ + { \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + } \ +}; \ +\ +static rtti_object_hierarchy name ## _hierarchy = { \ + 0, \ + 0, \ + base_classes_no+1, \ + 0xdeadbeef \ +}; \ +\ +rtti_object_locator name ## _rtti = { \ + 1, \ + off, \ + 0, \ + 0xdeadbeef, \ + 0xdeadbeef, \ + 0xdeadbeef \ +};\ +\ +static void init_ ## name ## _rtti(char *base) \ +{ \ + name ## _rtti_base_descriptor.type_descriptor = (char*)&name ## _type_info - base; \ + name ## _rtti_base_array.bases[0] = (char*)&name ## _rtti_base_descriptor - base; \ + name ## _rtti_base_array.bases[1] = (char*)cl1 - base; \ + name ## _rtti_base_array.bases[2] = (char*)cl2 - base; \ + name ## _rtti_base_array.bases[3] = (char*)cl3 - base; \ + name ## _rtti_base_array.bases[4] = (char*)cl4 - base; \ + name ## _rtti_base_array.bases[5] = (char*)cl5 - base; \ + name ## _rtti_base_array.bases[6] = (char*)cl6 - base; \ + name ## _rtti_base_array.bases[7] = (char*)cl7 - base; \ + name ## _rtti_base_array.bases[8] = (char*)cl8 - base; \ + name ## _rtti_base_array.bases[9] = (char*)cl9 - base; \ + name ## _hierarchy.base_classes = (char*)&name ## _rtti_base_array - base; \ + name ## _rtti.type_descriptor = (char*)&name ## _type_info - base; \ + name ## _rtti.type_hierarchy = (char*)&name ## _hierarchy - base; \ + name ## _rtti.object_locator = (char*)&name ## _rtti - base; \ +} + +#endif + #define DEFINE_RTTI_DATA0(name, off, mangled_name) \ DEFINE_RTTI_DATA(name, off, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name) #define DEFINE_RTTI_DATA1(name, off, cl1, mangled_name) \ @@ -191,6 +261,8 @@ typedef struct int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */ } this_ptr_offsets; +#ifndef __x86_64__ + typedef struct _rtti_base_descriptor { const type_info *type_descriptor; @@ -220,3 +292,38 @@ typedef struct _rtti_object_locator const type_info *type_descriptor; const rtti_object_hierarchy *type_hierarchy; } rtti_object_locator; + +#else + +typedef struct +{ + unsigned int type_descriptor; + int num_base_classes; + this_ptr_offsets offsets; /* offsets for computing the this pointer */ + unsigned int attributes; +} rtti_base_descriptor; + +typedef struct +{ + unsigned int bases[10]; /* First element is the class itself */ +} rtti_base_array; + +typedef struct +{ + unsigned int signature; + unsigned int attributes; + int array_len; /* Size of the array pointed to by 'base_classes' */ + unsigned int base_classes; +} rtti_object_hierarchy; + +typedef struct +{ + unsigned int signature; + int base_class_offset; + unsigned int flags; + unsigned int type_descriptor; + unsigned int type_hierarchy; + unsigned int object_locator; +} rtti_object_locator; + +#endif diff --git a/dlls/msvcp60/exception.c b/dlls/msvcp60/exception.c index 6d72e474e41..dde066cbd54 100644 --- a/dlls/msvcp60/exception.c +++ b/dlls/msvcp60/exception.c @@ -784,3 +784,17 @@ void throw_exception(exception_type et, const char *str) ERR("exception type not handled: %d\n", et); } } + +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); + init_length_error_rtti(base); + init_out_of_range_rtti(base); + init_invalid_argument_rtti(base); + init_runtime_error_rtti(base); +#endif +} diff --git a/dlls/msvcp60/main.c b/dlls/msvcp60/main.c index a979528f17b..dbaf5ee2735 100644 --- a/dlls/msvcp60/main.c +++ b/dlls/msvcp60/main.c @@ -90,6 +90,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) case DLL_PROCESS_ATTACH: init_cxx_funcs(); init_lockit(); + init_exception(hinstDLL); break; case DLL_PROCESS_DETACH: free_lockit(); diff --git a/dlls/msvcp60/msvcp.h b/dlls/msvcp60/msvcp.h index 7e1c47a02aa..b1035b2650a 100644 --- a/dlls/msvcp60/msvcp.h +++ b/dlls/msvcp60/msvcp.h @@ -94,3 +94,5 @@ mutex* __thiscall mutex_ctor(mutex*); void __thiscall mutex_dtor(mutex*); void __thiscall mutex_lock(mutex*); void __thiscall mutex_unlock(mutex*); + +void init_exception(void*);