From a41f9b82880a99f76848d12d2f6d00637e7617dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Thu, 16 Jan 2025 21:55:27 +0100 Subject: [PATCH] lsteamclient: Update cxx.h to latest msvcrt version. --- lsteamclient/cxx.h | 65 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/lsteamclient/cxx.h b/lsteamclient/cxx.h index 701ab02f..8037d7de 100644 --- a/lsteamclient/cxx.h +++ b/lsteamclient/cxx.h @@ -16,8 +16,17 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include "windef.h" +#include "winternl.h" +#include "rtlsupportapi.h" #include "wine/asm.h" +#ifdef __i386__ +#undef RTTI_USE_RVA +#else +#define RTTI_USE_RVA 1 +#endif + #ifdef _WIN64 #define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n" @@ -44,7 +53,7 @@ #endif /* _WIN64 */ -#ifndef __x86_64__ +#ifndef RTTI_USE_RVA #define DEFINE_RTTI_BASE(name, base_classes_no, mangled_name) \ static type_info name ## _type_info = { \ @@ -99,7 +108,7 @@ static const cxx_type_info type ## _cxx_type_info = { \ & type ##_type_info, \ { 0, -1, 0 }, \ sizeof(type), \ - (cxx_copy_ctor)THISCALL(type ##_copy_ctor) \ + THISCALL(type ##_copy_ctor) \ }; #define DEFINE_CXX_DATA(type, base_no, cl1, cl2, cl3, cl4, dtor) \ @@ -116,9 +125,9 @@ static const cxx_type_info_table type ## _cxx_type_table = { \ } \ }; \ \ -static const cxx_exception_type type ## _cxx_type = { \ +static const cxx_exception_type type ## _exception_type = { \ 0, \ - (cxx_copy_ctor)THISCALL(dtor), \ + THISCALL(dtor), \ NULL, \ & type ## _cxx_type_table \ }; @@ -230,7 +239,7 @@ static cxx_type_info_table type ## _cxx_type_table = { \ } \ }; \ \ -static cxx_exception_type type ##_cxx_type = { \ +static cxx_exception_type type ##_exception_type = { \ 0, \ 0xdeadbeef, \ 0, \ @@ -245,8 +254,8 @@ static void init_ ## type ## _cxx(char *base) \ type ## _cxx_type_table.info[2] = (char *)cl2 - base; \ type ## _cxx_type_table.info[3] = (char *)cl3 - base; \ type ## _cxx_type_table.info[4] = (char *)cl4 - base; \ - type ## _cxx_type.destructor = (char *)dtor - base; \ - type ## _cxx_type.type_info_table = (char *)&type ## _cxx_type_table - base; \ + type ## _exception_type.destructor = (char *)dtor - base; \ + type ## _exception_type.type_info_table = (char *)&type ## _cxx_type_table - base; \ } #endif @@ -322,8 +331,6 @@ typedef struct __type_info char mangled[128]; /* Variable length, but we declare it large enough for static RTTI */ } type_info; -extern const vtable_ptr type_info_vtable; - /* offsets for computing the this pointer */ typedef struct { @@ -332,10 +339,7 @@ typedef struct int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */ } this_ptr_offsets; -/* dlls/msvcrt/cppexcept.h */ -typedef void (*cxx_copy_ctor)(void); - -#ifndef __x86_64__ +#ifndef RTTI_USE_RVA typedef struct _rtti_base_descriptor { @@ -373,7 +377,7 @@ typedef struct const type_info *type_info; this_ptr_offsets offsets; unsigned int size; - cxx_copy_ctor copy_ctor; + void *copy_ctor; } cxx_type_info; typedef struct @@ -385,8 +389,8 @@ typedef struct typedef struct { UINT flags; - void (*destructor)(void); - void* /*cxx_exc_custom_handler*/ custom_handler; + void *destructor; + void *custom_handler; const cxx_type_info_table *type_info_table; } cxx_exception_type; @@ -448,6 +452,35 @@ typedef struct #endif +extern const vtable_ptr type_info_vtable; + +#ifdef RTTI_USE_RVA + +static inline uintptr_t rtti_rva_base( const void *ptr ) +{ + void *base; + return (uintptr_t)RtlPcToFileHeader( (void *)ptr, &base ); +} + +static inline void *rtti_rva( unsigned int rva, uintptr_t base ) +{ + return (void *)(base + rva); +} + +#else + +static inline uintptr_t rtti_rva_base( const void *ptr ) +{ + return 0; +} + +static inline void *rtti_rva( const void *ptr, uintptr_t base ) +{ + return (void *)ptr; +} + +#endif + #define CREATE_TYPE_INFO_VTABLE \ DEFINE_THISCALL_WRAPPER(type_info_vector_dtor,8) \ void * __thiscall type_info_vector_dtor(type_info * _this, unsigned int flags) \