comctl32/tests: Use CRT allocation functions.
[wine.git] / dlls / msvcp60 / main.c
blob5d1894cb073fe9d386e73ade4a87f24aa790c5eb
1 /*
2 * Copyright 2010 Piotr Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #include <stdarg.h>
22 #include "msvcp.h"
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
30 #ifdef __ASM_USE_THISCALL_WRAPPER
32 #define DEFINE_VTBL_WRAPPER(off) \
33 __ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
34 "popl %eax\n\t" \
35 "popl %ecx\n\t" \
36 "pushl %eax\n\t" \
37 "movl 0(%ecx), %eax\n\t" \
38 "jmp *" #off "(%eax)\n\t")
40 DEFINE_VTBL_WRAPPER(0);
41 DEFINE_VTBL_WRAPPER(4);
42 DEFINE_VTBL_WRAPPER(8);
43 DEFINE_VTBL_WRAPPER(12);
44 DEFINE_VTBL_WRAPPER(16);
45 DEFINE_VTBL_WRAPPER(20);
46 DEFINE_VTBL_WRAPPER(24);
47 DEFINE_VTBL_WRAPPER(28);
48 DEFINE_VTBL_WRAPPER(32);
49 DEFINE_VTBL_WRAPPER(36);
50 DEFINE_VTBL_WRAPPER(40);
51 DEFINE_VTBL_WRAPPER(44);
52 DEFINE_VTBL_WRAPPER(48);
53 DEFINE_VTBL_WRAPPER(52);
54 DEFINE_VTBL_WRAPPER(56);
56 #endif
58 /* ?_Fpz@std@@3_JB */
59 const __int64 std_Fpz = 0;
61 static void* (__cdecl *MSVCRT_operator_new)(size_t);
62 static void (__cdecl *MSVCRT_operator_delete)(void*);
63 void* (__cdecl *MSVCRT_set_new_handler)(void*);
65 void* __cdecl operator_new(size_t size)
67 void *ret = MSVCRT_operator_new(size);
68 if (!ret) _Xmem();
69 return ret;
72 void __cdecl operator_delete(void *mem)
74 MSVCRT_operator_delete(mem);
77 static void init_cxx_funcs(void)
79 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
81 if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
83 MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z");
84 MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z");
85 MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z");
87 else
89 MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z");
90 MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z");
91 MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z");
95 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
97 TRACE("(0x%p, %ld, %p)\n", hinstDLL, fdwReason, lpvReserved);
99 switch (fdwReason)
101 case DLL_PROCESS_ATTACH:
102 init_cxx_funcs();
103 _Init_locks__Init_locks_ctor(NULL);
104 init_exception(hinstDLL);
105 init_locale(hinstDLL);
106 init_io(hinstDLL);
107 break;
108 case DLL_PROCESS_DETACH:
109 if (lpvReserved) break;
110 free_io();
111 free_locale();
112 _Init_locks__Init_locks_dtor(NULL);
113 break;
116 return TRUE;