From: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> msvcirt's PARENTSRC imports exception.c from msvcp90, but it uses a function pointer for these functions, resulting in a type mismatch. Signed-off-by: Gabriel Ivăncescu <gabrielopcode(a)gmail.com> --- diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 8d83fca..54d7b54 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -38,9 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcirt); #define RESERVE_SIZE 512 #define STATEBUF_SIZE 8 -void* (__cdecl *operator_new)(SIZE_T); -void (__cdecl *operator_delete)(void*); - /* ?sh_none(a)filebuf@@2HB */ const int filebuf_sh_none = 0x800; /* ?sh_read(a)filebuf@@2HB */ @@ -5132,19 +5129,32 @@ void __cdecl _mtunlock(CRITICAL_SECTION *crit) LeaveCriticalSection(crit); } +static void* (__cdecl *MSVCRT_operator_new)(SIZE_T); +static void (__cdecl *MSVCRT_operator_delete)(void*); + +void* __cdecl operator_new(SIZE_T size) +{ + return MSVCRT_operator_new(size); +} + +void __cdecl operator_delete(void *mem) +{ + MSVCRT_operator_delete(mem); +} + static void init_cxx_funcs(void) { HMODULE hmod = GetModuleHandleA("msvcrt.dll"); if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); } else { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); } } diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h index 5b59b78..875a4fd 100644 --- a/dlls/msvcirt/msvcirt.h +++ b/dlls/msvcirt/msvcirt.h @@ -68,7 +68,7 @@ typedef enum { FLAGS_stdio = 0x4000 } ios_flags; -extern void* (__cdecl *MSVCRT_operator_new)(SIZE_T); -extern void (__cdecl *MSVCRT_operator_delete)(void*); +void* __cdecl operator_new(SIZE_T); +void __cdecl operator_delete(void*); void init_exception(void*); -- 2.43.0 --- dlls/msvcirt/msvcirt.c | 24 +++++++++++++++++------- dlls/msvcirt/msvcirt.h | 4 ++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/dlls/msvcirt/msvcirt.c b/dlls/msvcirt/msvcirt.c index 8d83fca7c94..0fcdc52c203 100644 --- a/dlls/msvcirt/msvcirt.c +++ b/dlls/msvcirt/msvcirt.c @@ -38,9 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcirt); #define RESERVE_SIZE 512 #define STATEBUF_SIZE 8 -void* (__cdecl *operator_new)(SIZE_T); -void (__cdecl *operator_delete)(void*); - /* ?sh_none(a)filebuf@@2HB */ const int filebuf_sh_none = 0x800; /* ?sh_read(a)filebuf@@2HB */ @@ -5132,19 +5129,32 @@ void __cdecl _mtunlock(CRITICAL_SECTION *crit) LeaveCriticalSection(crit); } +static void* (__cdecl *MSVCRT_operator_new)(SIZE_T); +static void (__cdecl *MSVCRT_operator_delete)(void*); + +void* __cdecl operator_new(SIZE_T size) +{ + return MSVCRT_operator_new(size); +} + +void __cdecl operator_delete(void *mem) +{ + MSVCRT_operator_delete(mem); +} + static void init_cxx_funcs(void) { HMODULE hmod = GetModuleHandleA("msvcrt.dll"); if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */ { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPEAX_K@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPEAX@Z"); } else { - operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); - operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); + MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2(a)YAPAXI@Z"); + MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3(a)YAXPAX@Z"); } } diff --git a/dlls/msvcirt/msvcirt.h b/dlls/msvcirt/msvcirt.h index 5b59b7862a3..ccbc7027146 100644 --- a/dlls/msvcirt/msvcirt.h +++ b/dlls/msvcirt/msvcirt.h @@ -68,7 +68,7 @@ typedef enum { FLAGS_stdio = 0x4000 } ios_flags; -extern void* (__cdecl *MSVCRT_operator_new)(SIZE_T); -extern void (__cdecl *MSVCRT_operator_delete)(void*); +void* __cdecl operator_new(SIZE_T); +void __cdecl operator_delete(void*); void init_exception(void*); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/4864