diff --git a/dlls/msvcp90/misc.c b/dlls/msvcp90/misc.c index 3a3cb9f45f..bb3b52bba5 100644 --- a/dlls/msvcp90/misc.c +++ b/dlls/msvcp90/misc.c @@ -25,6 +25,8 @@ #include "windef.h" #include "winbase.h" +#include "wine/debug.h" +WINE_DEFAULT_DEBUG_CHANNEL(msvcp90); /* ??0_Mutex@std@@QAE@XZ */ /* ??0_Mutex@std@@QEAA@XZ */ @@ -191,3 +193,29 @@ unsigned short __cdecl wctype(const char *property) return 0; } + +typedef void (__cdecl *MSVCP_new_handler_func)(void); +static MSVCP_new_handler_func MSVCP_new_handler; +static int __cdecl new_handler_wrapper(MSVCP_size_t unused) +{ + MSVCP_new_handler(); + return 1; +} + +/* ?set_new_handler@std@@YAP6AXXZP6AXXZ@Z */ +MSVCP_new_handler_func __cdecl set_new_handler(MSVCP_new_handler_func new_handler) +{ + MSVCP_new_handler_func old_handler = MSVCP_new_handler; + + TRACE("%p\n", new_handler); + + MSVCP_new_handler = new_handler; + MSVCRT_set_new_handler(new_handler ? new_handler_wrapper : NULL); + return old_handler; +} + +/* ?set_new_handler@std@@YAP6AXXZH@Z */ +MSVCP_new_handler_func __cdecl set_new_handler_reset(int unused) +{ + return set_new_handler(NULL); +} diff --git a/dlls/msvcp90/msvcp90.h b/dlls/msvcp90/msvcp90.h index 7c331b5e65..0639a67855 100644 --- a/dlls/msvcp90/msvcp90.h +++ b/dlls/msvcp90/msvcp90.h @@ -29,6 +29,7 @@ void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*, extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t); extern void (__cdecl *MSVCRT_operator_delete)(void*); +extern void* (__cdecl *MSVCRT_set_new_handler)(void*); /* Copied from dlls/msvcrt/cpp.c */ #ifdef __i386__ /* thiscall functions are i386-specific */ diff --git a/dlls/msvcp90/msvcp90.spec b/dlls/msvcp90/msvcp90.spec index d5baaf4a2e..1522e80444 100644 --- a/dlls/msvcp90/msvcp90.spec +++ b/dlls/msvcp90/msvcp90.spec @@ -5310,8 +5310,8 @@ @ stub -arch=win64 ?seekpos@?$basic_stringbuf@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@MEAA?AV?$fpos@H@2@V32@H@Z @ stub -arch=win32 ?seekpos@strstreambuf@std@@MAE?AV?$fpos@H@2@V32@H@Z @ stub -arch=win64 ?seekpos@strstreambuf@std@@MEAA?AV?$fpos@H@2@V32@H@Z -@ stub ?set_new_handler@std@@YAP6AXXZH@Z -@ stub ?set_new_handler@std@@YAP6AXXZP6AXXZ@Z +@ cdecl ?set_new_handler@std@@YAP6AXXZH@Z(long) set_new_handler_reset +@ cdecl ?set_new_handler@std@@YAP6AXXZP6AXXZ@Z(ptr) set_new_handler @ stub ?setbase@std@@YA?AU?$_Smanip@H@1@H@Z @ stub -arch=win32 ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MAEPAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PADH@Z @ stub -arch=win64 ?setbuf@?$basic_filebuf@DU?$char_traits@D@std@@@std@@MEAAPEAV?$basic_streambuf@DU?$char_traits@D@std@@@2@PEAD_J@Z diff --git a/dlls/msvcp90/msvcp90_main.c b/dlls/msvcp90/msvcp90_main.c index f9c508a1ab..35fabfc0fd 100644 --- a/dlls/msvcp90/msvcp90_main.c +++ b/dlls/msvcp90/msvcp90_main.c @@ -30,6 +30,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(msvcp90); void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t); void (__cdecl *MSVCRT_operator_delete)(void*); +void* (__cdecl *MSVCRT_set_new_handler)(void*); + static void init_cxx_funcs(void) { HMODULE hmod = GetModuleHandleA("msvcrt.dll"); @@ -38,11 +40,13 @@ static void init_cxx_funcs(void) { MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z"); MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z"); + MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z"); } else { MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z"); MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z"); + MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z"); } }