2 * msvcp80 specific functions
4 * Copyright 2010 Piotr Caban for CodeWeavers
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
28 #ifdef __i386__ /* thiscall functions are i386-specific */
30 #define THISCALL(func) __thiscall_ ## func
31 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
32 #define __thiscall __stdcall
33 #define DEFINE_THISCALL_WRAPPER(func,args) \
34 extern void THISCALL(func)(void); \
35 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
39 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
42 #define THISCALL(func) func
43 #define THISCALL_NAME(func) __ASM_NAME(#func)
44 #define __thiscall __cdecl
45 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
49 typedef SIZE_T MSVCP_size_t;
53 /* basic_string<char, char_traits<char>, allocator<char>> */
54 #define BUF_SIZE_CHAR 16
59 char buf[BUF_SIZE_CHAR];
66 #define BUF_SIZE_WCHAR 8
71 wchar_t buf[BUF_SIZE_WCHAR];
78 /* _String_iterator<char> and _String_const_iterator<char> class */
81 const basic_string_char *bstr;
83 } basic_string_char_reverse_iter;
87 const basic_string_wchar *bstr;
89 } basic_string_wchar_reverse_iter;
91 static const struct locale* (CDECL *plocale_classic)(void);
92 static MSVCP_size_t (CDECL *pcollate_char__Getcat)(const struct locale_facet**,const struct locale*);
93 static MSVCP_size_t (CDECL *pcollate_wchar__Getcat)(const struct locale_facet**,const struct locale*);
94 static MSVCP_size_t (CDECL *pcollate_short__Getcat)(const struct locale_facet**,const struct locale*);
95 static MSVCP_size_t (CDECL *pctype_char__Getcat)(const struct locale_facet**,const struct locale*);
96 static MSVCP_size_t (CDECL *pctype_wchar__Getcat)(const struct locale_facet**,const struct locale*);
97 static MSVCP_size_t (CDECL *pctype_short__Getcat)(const struct locale_facet**,const struct locale*);
98 static MSVCP_size_t (CDECL *pcodecvt_char__Getcat)(const struct locale_facet**,const struct locale*);
99 static MSVCP_size_t (CDECL *pcodecvt_wchar__Getcat)(const struct locale_facet**,const struct locale*);
100 static MSVCP_size_t (CDECL *pcodecvt_short__Getcat)(const struct locale_facet**,const struct locale*);
101 static MSVCP_size_t (CDECL *pnumpunct_char__Getcat)(const struct locale_facet**,const struct locale*);
102 static MSVCP_size_t (CDECL *pnumpunct_wchar__Getcat)(const struct locale_facet**,const struct locale*);
103 static MSVCP_size_t (CDECL *pnumpunct_short__Getcat)(const struct locale_facet**,const struct locale*);
105 static BOOL init_funcs(void)
107 HMODULE hmod = LoadLibraryA("msvcp90.dll");
111 if(sizeof(void*) > sizeof(int)) { /* 64-bit has different names */
112 plocale_classic = (void*)GetProcAddress(hmod, "?classic@locale@std@@SAAEBV12@XZ");
113 pcollate_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$collate@D@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
114 pcollate_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$collate@_W@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
115 pcollate_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$collate@G@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
116 pctype_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$ctype@D@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
117 pctype_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$ctype@_W@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
118 pctype_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$ctype@G@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
119 pcodecvt_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$codecvt@DDH@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
120 pcodecvt_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$codecvt@_WDH@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
121 pcodecvt_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$codecvt@GDH@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
122 pnumpunct_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$numpunct@D@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
123 pnumpunct_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$numpunct@_W@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
124 pnumpunct_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$numpunct@G@std@@SA_KPEAPEBVfacet@locale@2@PEBV42@@Z");
126 plocale_classic = (void*)GetProcAddress(hmod, "?classic@locale@std@@SAABV12@XZ");
127 pcollate_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$collate@D@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
128 pcollate_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$collate@_W@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
129 pcollate_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$collate@G@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
130 pctype_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
131 pctype_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$ctype@_W@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
132 pctype_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
133 pcodecvt_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$codecvt@DDH@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
134 pcodecvt_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$codecvt@_WDH@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
135 pcodecvt_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$codecvt@GDH@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
136 pnumpunct_char__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$numpunct@D@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
137 pnumpunct_wchar__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$numpunct@_W@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
138 pnumpunct_short__Getcat = (void*)GetProcAddress(hmod, "?_Getcat@?$numpunct@G@std@@SAIPAPBVfacet@locale@2@PBV42@@Z");
144 BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved)
148 case DLL_WINE_PREATTACH:
149 return FALSE; /* prefer native version */
151 case DLL_PROCESS_ATTACH:
152 DisableThreadLibraryCalls(hdll);
159 /* ?_Getcat@?$collate@D@std@@SAIPAPBVfacet@locale@2@@Z */
160 /* ?_Getcat@?$collate@D@std@@SA_KPEAPEBVfacet@locale@2@@Z */
161 MSVCP_size_t __cdecl collate_char__Getcat(const struct locale_facet **facet)
163 return pcollate_char__Getcat(facet, plocale_classic());
166 /* ?_Getcat@?$collate@_W@std@@SAIPAPBVfacet@locale@2@@Z */
167 /* ?_Getcat@?$collate@_W@std@@SA_KPEAPEBVfacet@locale@2@@Z */
168 MSVCP_size_t __cdecl collate_wchar__Getcat(const struct locale_facet **facet)
170 return pcollate_wchar__Getcat(facet, plocale_classic());
173 /* ?_Getcat@?$collate@G@std@@SAIPAPBVfacet@locale@2@@Z */
174 /* ?_Getcat@?$collate@G@std@@SA_KPEAPEBVfacet@locale@2@@Z */
175 MSVCP_size_t __cdecl collate_short__Getcat(const struct locale_facet **facet)
177 return pcollate_short__Getcat(facet, plocale_classic());
180 /* ?_Getcat@?$ctype@D@std@@SAIPAPBVfacet@locale@2@@Z */
181 /* ?_Getcat@?$ctype@D@std@@SA_KPEAPEBVfacet@locale@2@@Z */
182 MSVCP_size_t __cdecl ctype_char__Getcat(const struct locale_facet **facet)
184 return pctype_char__Getcat(facet, plocale_classic());
187 /* ?_Getcat@?$ctype@_W@std@@SAIPAPBVfacet@locale@2@@Z */
188 /* ?_Getcat@?$ctype@_W@std@@SA_KPEAPEBVfacet@locale@2@@Z */
189 MSVCP_size_t __cdecl ctype_wchar__Getcat(const struct locale_facet **facet)
191 return pctype_wchar__Getcat(facet, plocale_classic());
194 /* ?_Getcat@?$ctype@G@std@@SAIPAPBVfacet@locale@2@@Z */
195 /* ?_Getcat@?$ctype@G@std@@SA_KPEAPEBVfacet@locale@2@@Z */
196 MSVCP_size_t __cdecl ctype_short__Getcat(const struct locale_facet **facet)
198 return pctype_short__Getcat(facet, plocale_classic());
201 /* ?_Getcat@?$codecvt@DDH@std@@SAIPAPBVfacet@locale@2@@Z */
202 /* ?_Getcat@?$codecvt@DDH@std@@SA_KPEAPEBVfacet@locale@2@@Z */
203 MSVCP_size_t __cdecl codecvt_char__Getcat(const struct locale_facet **facet)
205 return pcodecvt_char__Getcat(facet, plocale_classic());
208 /* ?_Getcat@?$codecvt@_WDH@std@@SAIPAPBVfacet@locale@2@@Z */
209 /* ?_Getcat@?$codecvt@_WDH@std@@SA_KPEAPEBVfacet@locale@2@@Z */
210 MSVCP_size_t __cdecl codecvt_wchar__Getcat(const struct locale_facet **facet)
212 return pcodecvt_wchar__Getcat(facet, plocale_classic());
215 /* ?_Getcat@?$codecvt@GDH@std@@SAIPAPBVfacet@locale@2@@Z */
216 /* ?_Getcat@?$codecvt@GDH@std@@SA_KPEAPEBVfacet@locale@2@@Z */
217 MSVCP_size_t __cdecl codecvt_short__Getcat(const struct locale_facet **facet)
219 return pcodecvt_short__Getcat(facet, plocale_classic());
222 /* ?_Getcat@?$numpunct@D@std@@SAIPAPBVfacet@locale@2@@Z */
223 /* ?_Getcat@?$numpunct@D@std@@SA_KPEAPEBVfacet@locale@2@@Z */
224 MSVCP_size_t __cdecl numpunct_char__Getcat(const struct locale_facet **facet)
226 return pnumpunct_char__Getcat(facet, plocale_classic());
229 /* ?_Getcat@?$numpunct@_W@std@@SAIPAPBVfacet@locale@2@@Z */
230 /* ?_Getcat@?$numpunct@_W@std@@SA_KPEAPEBVfacet@locale@2@@Z */
231 MSVCP_size_t __cdecl numpunct_wchar__Getcat(const struct locale_facet **facet)
233 return pnumpunct_wchar__Getcat(facet, plocale_classic());
236 /* ?_Getcat@?$numpunct@G@std@@SAIPAPBVfacet@locale@2@@Z */
237 /* ?_Getcat@?$numpunct@G@std@@SA_KPEAPEBVfacet@locale@2@@Z */
238 MSVCP_size_t __cdecl numpunct_short__Getcat(const struct locale_facet **facet)
240 return pnumpunct_short__Getcat(facet, plocale_classic());
243 static const char* basic_string_char_const_ptr(const basic_string_char *this)
245 if(this->res == BUF_SIZE_CHAR-1)
246 return this->data.buf;
247 return this->data.ptr;
250 static const wchar_t* basic_string_wchar_const_ptr(const basic_string_wchar *this)
252 if(this->res == BUF_SIZE_WCHAR-1)
253 return this->data.buf;
254 return this->data.ptr;
257 /* ?rbegin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$reverse_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
258 /* ?rbegin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA?AV?$reverse_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
259 /* ?rbegin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$reverse_iterator@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
260 /* ?rbegin@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$reverse_iterator@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
261 DEFINE_THISCALL_WRAPPER(basic_string_char_rbegin, 8)
262 basic_string_char_reverse_iter* __thiscall basic_string_char_rbegin(const basic_string_char *this, basic_string_char_reverse_iter *ret)
266 ret->pos = basic_string_char_const_ptr(this)+this->size;
270 /* ?rbegin@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE?AV?$reverse_iterator@V?$_String_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
271 /* ?rbegin@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA?AV?$reverse_iterator@V?$_String_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
272 /* ?rbegin@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE?AV?$reverse_iterator@V?$_String_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
273 /* ?rbegin@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA?AV?$reverse_iterator@V?$_String_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
274 /* ?rbegin@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$reverse_iterator@V?$_String_const_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
275 /* ?rbegin@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$reverse_iterator@V?$_String_const_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
276 /* ?rbegin@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$reverse_iterator@V?$_String_const_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
277 /* ?rbegin@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$reverse_iterator@V?$_String_const_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
278 DEFINE_THISCALL_WRAPPER(basic_string_wchar_rbegin, 8)
279 basic_string_wchar_reverse_iter* __thiscall basic_string_wchar_rbegin(const basic_string_wchar *this, basic_string_wchar_reverse_iter *ret)
283 ret->pos = basic_string_wchar_const_ptr(this)+this->size;
287 /* ?rend@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE?AV?$reverse_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
288 /* ?rend@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEAA?AV?$reverse_iterator@V?$_String_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
289 /* ?rend@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QBE?AV?$reverse_iterator@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
290 /* ?rend@?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QEBA?AV?$reverse_iterator@V?$_String_const_iterator@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@2@XZ */
291 DEFINE_THISCALL_WRAPPER(basic_string_char_rend, 8)
292 basic_string_char_reverse_iter* __thiscall basic_string_char_rend(const basic_string_char *this, basic_string_char_reverse_iter *ret)
296 ret->pos = basic_string_char_const_ptr(this);
300 /* ?rend@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QAE?AV?$reverse_iterator@V?$_String_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
301 /* ?rend@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEAA?AV?$reverse_iterator@V?$_String_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
302 /* ?rend@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QAE?AV?$reverse_iterator@V?$_String_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
303 /* ?rend@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEAA?AV?$reverse_iterator@V?$_String_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
304 /* ?rend@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QBE?AV?$reverse_iterator@V?$_String_const_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
305 /* ?rend@?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@QEBA?AV?$reverse_iterator@V?$_String_const_iterator@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@@2@XZ */
306 /* ?rend@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QBE?AV?$reverse_iterator@V?$_String_const_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
307 /* ?rend@?$basic_string@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@QEBA?AV?$reverse_iterator@V?$_String_const_iterator@GU?$char_traits@G@std@@V?$allocator@G@2@@std@@@2@XZ */
308 DEFINE_THISCALL_WRAPPER(basic_string_wchar_rend, 8)
309 basic_string_wchar_reverse_iter* __thiscall basic_string_wchar_rend(const basic_string_wchar *this, basic_string_wchar_reverse_iter *ret)
313 ret->pos = basic_string_wchar_const_ptr(this);