msvcp100: Copy source files from msvcp90.
[wine/multimedia.git] / dlls / msvcp100 / msvcp100.c
blob17253c57ecfc92d4022da65e4d9ca0705188531e
1 /*
2 * msvcp100 specific functions
4 * Copyright 2011 Austin English
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "config.h"
23 #include <stdarg.h>
25 #include "msvcp.h"
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
33 #ifdef __i386__
35 #define DEFINE_VTBL_WRAPPER(off) \
36 __ASM_GLOBAL_FUNC(vtbl_wrapper_ ## off, \
37 "popl %eax\n\t" \
38 "popl %ecx\n\t" \
39 "pushl %eax\n\t" \
40 "movl 0(%ecx), %eax\n\t" \
41 "jmp *" #off "(%eax)\n\t")
43 DEFINE_VTBL_WRAPPER(0);
44 DEFINE_VTBL_WRAPPER(4);
45 DEFINE_VTBL_WRAPPER(8);
46 DEFINE_VTBL_WRAPPER(12);
47 DEFINE_VTBL_WRAPPER(16);
48 DEFINE_VTBL_WRAPPER(20);
49 DEFINE_VTBL_WRAPPER(24);
50 DEFINE_VTBL_WRAPPER(28);
51 DEFINE_VTBL_WRAPPER(32);
52 DEFINE_VTBL_WRAPPER(36);
53 DEFINE_VTBL_WRAPPER(40);
54 DEFINE_VTBL_WRAPPER(44);
55 DEFINE_VTBL_WRAPPER(48);
56 DEFINE_VTBL_WRAPPER(52);
57 DEFINE_VTBL_WRAPPER(56);
58 DEFINE_VTBL_WRAPPER(60);
60 #endif
62 void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
63 void (__cdecl *MSVCRT_operator_delete)(void*);
64 void* (__cdecl *MSVCRT_set_new_handler)(void*);
66 static void init_cxx_funcs(void)
68 HMODULE hmod = GetModuleHandleA("msvcrt.dll");
70 if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
72 MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z");
73 MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z");
74 MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z");
76 else
78 MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z");
79 MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z");
80 MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z");
84 /* _Container_base0 is used by apps compiled without iterator checking
85 * (i.e. with _ITERATOR_DEBUG_LEVEL=0 ).
86 * It provides empty versions of methods used by visual c++'s stl's
87 * iterator checking.
88 * msvcr100 has to provide them in case apps are compiled with /Od
89 * or the optimizer fails to inline those (empty) calls.
92 /* ?_Orphan_all@_Container_base0@std@@QAEXXZ */
93 /* ?_Orphan_all@_Container_base0@std@@QEAAXXZ */
94 DEFINE_THISCALL_WRAPPER(Container_base0_Orphan_all, 4)
95 void __thiscall Container_base0_Orphan_all(void *this)
99 /* ?_Swap_all@_Container_base0@std@@QAEXAAU12@@Z */
100 /* ?_Swap_all@_Container_base0@std@@QEAAXAEAU12@@Z */
101 DEFINE_THISCALL_WRAPPER(Container_base0_Swap_all, 8)
102 void __thiscall Container_base0_Swap_all(void *this, void *that)
106 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
108 TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
110 switch (fdwReason)
112 case DLL_WINE_PREATTACH:
113 return FALSE; /* prefer native version */
114 case DLL_PROCESS_ATTACH:
115 init_cxx_funcs();
116 init_lockit();
117 init_io();
118 break;
119 case DLL_PROCESS_DETACH:
120 free_io();
121 free_locale();
122 free_lockit();
123 break;
126 return TRUE;
129 /* ?_BADOFF@std@@3JB -> long const std::_BADOFF */
130 /* ?_BADOFF@std@@3_JB -> __int64 const std::_BADOFF */
131 const streamoff std_BADOFF = -1;