include: Assorted spelling fixes.
[wine] / dlls / msvcp100 / msvcp100.c
1 /*
2  * msvcp100 specific functions
3  *
4  * Copyright 2011 Austin English
5  *
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.
10  *
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.
15  *
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
19  */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24
25 #include "msvcp.h"
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(msvcp);
32
33 #ifdef __i386__
34
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")
42
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
59 #endif
60
61 void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
62 void (__cdecl *MSVCRT_operator_delete)(void*);
63 void* (__cdecl *MSVCRT_set_new_handler)(void*);
64
65 static void init_cxx_funcs(void)
66 {
67     HMODULE hmod = GetModuleHandleA("msvcrt.dll");
68
69     if (sizeof(void *) > sizeof(int))  /* 64-bit has different names */
70     {
71         MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPEAX_K@Z");
72         MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPEAX@Z");
73         MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AH_K@ZP6AH0@Z@Z");
74     }
75     else
76     {
77         MSVCRT_operator_new = (void*)GetProcAddress(hmod, "??2@YAPAXI@Z");
78         MSVCRT_operator_delete = (void*)GetProcAddress(hmod, "??3@YAXPAX@Z");
79         MSVCRT_set_new_handler = (void*)GetProcAddress(hmod, "?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z");
80     }
81 }
82
83 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
84 {
85     TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
86
87     switch (fdwReason)
88     {
89         case DLL_WINE_PREATTACH:
90             return FALSE;  /* prefer native version */
91         case DLL_PROCESS_ATTACH:
92             init_cxx_funcs();
93             init_lockit();
94             init_exception(hinstDLL);
95             init_locale(hinstDLL);
96             init_io(hinstDLL);
97             break;
98         case DLL_PROCESS_DETACH:
99             free_io();
100             free_locale();
101             free_lockit();
102             break;
103     }
104
105     return TRUE;
106 }
107
108 /* ?_BADOFF@std@@3JB -> long const std::_BADOFF */
109 /* ?_BADOFF@std@@3_JB -> __int64 const std::_BADOFF */
110 const streamoff std_BADOFF = -1;