2012-01-04 15:44:07 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Piotr Caban 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 "msvcp.h"
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2012-08-14 10:51:34 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
|
2012-01-04 15:44:07 +01:00
|
|
|
|
2020-04-27 02:30:44 +02:00
|
|
|
#ifdef __ASM_USE_THISCALL_WRAPPER
|
2012-01-04 15:44:07 +01:00
|
|
|
|
|
|
|
#define DEFINE_VTBL_WRAPPER(off) \
|
|
|
|
__ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
|
|
|
|
"popl %eax\n\t" \
|
|
|
|
"popl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
|
|
|
"movl 0(%ecx), %eax\n\t" \
|
|
|
|
"jmp *" #off "(%eax)\n\t")
|
|
|
|
|
|
|
|
DEFINE_VTBL_WRAPPER(0);
|
|
|
|
DEFINE_VTBL_WRAPPER(4);
|
|
|
|
DEFINE_VTBL_WRAPPER(8);
|
|
|
|
DEFINE_VTBL_WRAPPER(12);
|
|
|
|
DEFINE_VTBL_WRAPPER(16);
|
|
|
|
DEFINE_VTBL_WRAPPER(20);
|
|
|
|
DEFINE_VTBL_WRAPPER(24);
|
|
|
|
DEFINE_VTBL_WRAPPER(28);
|
|
|
|
DEFINE_VTBL_WRAPPER(32);
|
|
|
|
DEFINE_VTBL_WRAPPER(36);
|
|
|
|
DEFINE_VTBL_WRAPPER(40);
|
|
|
|
DEFINE_VTBL_WRAPPER(44);
|
|
|
|
DEFINE_VTBL_WRAPPER(48);
|
2015-03-17 06:23:38 +01:00
|
|
|
DEFINE_VTBL_WRAPPER(52);
|
|
|
|
DEFINE_VTBL_WRAPPER(56);
|
2012-01-04 15:44:07 +01:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-01-20 18:18:50 +01:00
|
|
|
/* ?_Fpz@std@@3_JB */
|
|
|
|
const __int64 std_Fpz = 0;
|
|
|
|
|
2020-11-27 17:28:14 +01:00
|
|
|
void* (__cdecl *MSVCRT_operator_new)(size_t);
|
2012-01-04 15:44:07 +01:00
|
|
|
void (__cdecl *MSVCRT_operator_delete)(void*);
|
2015-03-12 09:25:45 +01:00
|
|
|
void* (__cdecl *MSVCRT_set_new_handler)(void*);
|
2012-01-04 15:44:07 +01:00
|
|
|
|
|
|
|
static void init_cxx_funcs(void)
|
|
|
|
{
|
|
|
|
HMODULE hmod = GetModuleHandleA("msvcrt.dll");
|
|
|
|
|
|
|
|
if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
|
|
|
|
{
|
|
|
|
MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z");
|
|
|
|
MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z");
|
2015-03-12 09:25:45 +01:00
|
|
|
MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z");
|
2012-01-04 15:44:07 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z");
|
|
|
|
MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z");
|
2015-03-12 09:25:45 +01:00
|
|
|
MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z");
|
2012-01-04 15:44:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
|
|
|
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
|
|
|
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
init_cxx_funcs();
|
2019-06-05 18:56:09 +02:00
|
|
|
_Init_locks__Init_locks_ctor(NULL);
|
2012-09-07 11:00:37 +02:00
|
|
|
init_exception(hinstDLL);
|
2012-10-04 13:15:41 +02:00
|
|
|
init_locale(hinstDLL);
|
|
|
|
init_io(hinstDLL);
|
2012-01-04 15:44:07 +01:00
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2013-05-20 12:28:48 +02:00
|
|
|
if (lpvReserved) break;
|
2012-10-04 13:15:41 +02:00
|
|
|
free_io();
|
|
|
|
free_locale();
|
2019-06-05 18:56:09 +02:00
|
|
|
_Init_locks__Init_locks_dtor(NULL);
|
2012-01-04 15:44:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|