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
23 #define ALIGNED_SIZE(size, alignment) (((size)+((alignment)-1))/(alignment)*(alignment))
25 typedef unsigned char MSVCP_bool
;
26 typedef SIZE_T MSVCP_size_t
;
29 typedef __int64
DECLSPEC_ALIGN(8) streamoff
;
30 typedef __int64
DECLSPEC_ALIGN(8) streamsize
;
31 #define STREAMOFF_BITS 64
32 #define STREAMSIZE_BITS 64
34 typedef SSIZE_T streamoff
;
35 typedef SSIZE_T streamsize
;
36 #define STREAMOFF_BITS 32
37 #define STREAMSIZE_BITS 32
40 void __cdecl
_invalid_parameter(const wchar_t*, const wchar_t*,
41 const wchar_t*, unsigned int, uintptr_t);
42 BOOL __cdecl
__uncaught_exception(void);
44 extern void* (__cdecl
*MSVCRT_operator_new
)(MSVCP_size_t
);
45 extern void (__cdecl
*MSVCRT_operator_delete
)(void*);
46 extern void* (__cdecl
*MSVCRT_set_new_handler
)(void*);
48 /* basic_string<char, char_traits<char>, allocator<char>> */
49 #define BUF_SIZE_CHAR 16
54 char buf
[BUF_SIZE_CHAR
];
61 basic_string_char
* __thiscall
MSVCP_basic_string_char_ctor(basic_string_char
*);
62 basic_string_char
* __thiscall
MSVCP_basic_string_char_ctor_cstr(basic_string_char
*, const char*);
63 basic_string_char
* __thiscall
MSVCP_basic_string_char_ctor_cstr_len(basic_string_char
*, const char*, MSVCP_size_t
);
64 basic_string_char
* __thiscall
MSVCP_basic_string_char_copy_ctor(basic_string_char
*, const basic_string_char
*);
65 void __thiscall
MSVCP_basic_string_char_dtor(basic_string_char
*);
66 const char* __thiscall
MSVCP_basic_string_char_c_str(const basic_string_char
*);
67 void __thiscall
MSVCP_basic_string_char_clear(basic_string_char
*);
68 basic_string_char
* __thiscall
MSVCP_basic_string_char_append_ch(basic_string_char
*, char);
69 MSVCP_size_t __thiscall
MSVCP_basic_string_char_length(const basic_string_char
*);
70 basic_string_char
* __thiscall
MSVCP_basic_string_char_assign(basic_string_char
*, const basic_string_char
*);
72 #define BUF_SIZE_WCHAR 8
77 wchar_t buf
[BUF_SIZE_WCHAR
];
84 basic_string_wchar
* __thiscall
MSVCP_basic_string_wchar_ctor(basic_string_wchar
*);
85 basic_string_wchar
* __thiscall
MSVCP_basic_string_wchar_ctor_cstr(basic_string_wchar
*, const wchar_t*);
86 basic_string_wchar
* __thiscall
MSVCP_basic_string_wchar_ctor_cstr_len(basic_string_wchar
*, const wchar_t*, MSVCP_size_t
);
87 void __thiscall
MSVCP_basic_string_wchar_dtor(basic_string_wchar
*);
88 const wchar_t* __thiscall
MSVCP_basic_string_wchar_c_str(const basic_string_wchar
*);
89 void __thiscall
MSVCP_basic_string_wchar_clear(basic_string_wchar
*);
90 basic_string_wchar
* __thiscall
MSVCP_basic_string_wchar_append_ch(basic_string_wchar
*, wchar_t);
91 MSVCP_size_t __thiscall
MSVCP_basic_string_wchar_length(const basic_string_wchar
*);
93 char* __thiscall
MSVCP_allocator_char_allocate(void*, MSVCP_size_t
);
94 void __thiscall
MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t
);
95 MSVCP_size_t __thiscall
MSVCP_allocator_char_max_size(void*);
96 wchar_t* __thiscall
MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t
);
97 void __thiscall
MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t
);
98 MSVCP_size_t __thiscall
MSVCP_allocator_wchar_max_size(void*);
106 _Yarn_char
* __thiscall
_Yarn_char_ctor_cstr(_Yarn_char
*, const char*);
107 _Yarn_char
* __thiscall
_Yarn_char_copy_ctor(_Yarn_char
*, const _Yarn_char
*);
108 const char* __thiscall
_Yarn_char_c_str(const _Yarn_char
*);
109 void __thiscall
_Yarn_char_dtor(_Yarn_char
*);
110 _Yarn_char
* __thiscall
_Yarn_char_op_assign(_Yarn_char
*, const _Yarn_char
*);
112 /* class locale::facet */
114 const vtable_ptr
*vtable
;
123 } codecvt_base_result
;
132 #if _MSVCP_VER >= 110
137 /* class codecvt_base */
142 /* class codecvt<char> */
147 MSVCP_bool __thiscall
codecvt_base_always_noconv(const codecvt_base
*);
148 int __thiscall
codecvt_char_unshift(const codecvt_char
*, int*, char*, char*, char**);
149 int __thiscall
codecvt_char_out(const codecvt_char
*, int*, const char*,
150 const char*, const char**, char*, char*, char**);
151 int __thiscall
codecvt_char_in(const codecvt_char
*, int*, const char*,
152 const char*, const char**, char*, char*, char**);
153 int __thiscall
codecvt_base_max_length(const codecvt_base
*);
160 /* class codecvt<wchar> */
166 int __thiscall
codecvt_wchar_unshift(const codecvt_wchar
*, int*, char*, char*, char**);
167 int __thiscall
codecvt_wchar_out(const codecvt_wchar
*, int*, const wchar_t*,
168 const wchar_t*, const wchar_t**, char*, char*, char**);
169 int __thiscall
codecvt_wchar_in(const codecvt_wchar
*, int*, const char*,
170 const char*, const char**, wchar_t*, wchar_t*, wchar_t**);
172 /* class ctype_base */
177 /* class ctype<char> */
183 MSVCP_bool __thiscall
ctype_char_is_ch(const ctype_char
*, short, char);
184 char __thiscall
ctype_char_narrow_ch(const ctype_char
*, char, char);
185 char __thiscall
ctype_char_widen_ch(const ctype_char
*, char);
187 /* class ctype<wchar> */
194 MSVCP_bool __thiscall
ctype_wchar_is_ch(const ctype_wchar
*, short, wchar_t);
195 char __thiscall
ctype_wchar_narrow_ch(const ctype_wchar
*, wchar_t, char);
196 wchar_t __thiscall
ctype_wchar_widen_ch(const ctype_wchar
*, char);
201 struct _locale__Locimp
*ptr
;
204 locale
* __thiscall
locale_ctor(locale
*);
205 locale
* __thiscall
locale_copy_ctor(locale
*, const locale
*);
206 locale
* __thiscall
locale_operator_assign(locale
*, const locale
*);
207 void __thiscall
locale_dtor(locale
*);
208 void free_locale(void);
209 codecvt_char
* codecvt_char_use_facet(const locale
*);
210 codecvt_wchar
* codecvt_wchar_use_facet(const locale
*);
211 codecvt_wchar
* codecvt_short_use_facet(const locale
*);
212 ctype_char
* ctype_char_use_facet(const locale
*);
213 ctype_wchar
* ctype_wchar_use_facet(const locale
*);
214 ctype_wchar
* ctype_short_use_facet(const locale
*);
221 #define _LOCK_LOCALE 0
222 #define _LOCK_MALLOC 1
223 #define _LOCK_STREAM 2
224 #define _LOCK_DEBUG 3
227 void init_lockit(void);
228 void free_lockit(void);
229 _Lockit
* __thiscall
_Lockit_ctor_locktype(_Lockit
*, int);
230 void __thiscall
_Lockit_dtor(_Lockit
*);
237 mutex
* __thiscall
mutex_ctor(mutex
*);
238 void __thiscall
mutex_dtor(mutex
*);
239 void __thiscall
mutex_lock(mutex
*);
240 void __thiscall
mutex_unlock(mutex
*);
243 FMTFLAG_skipws
= 0x0001,
244 FMTFLAG_unitbuf
= 0x0002,
245 FMTFLAG_uppercase
= 0x0004,
246 FMTFLAG_showbase
= 0x0008,
247 FMTFLAG_showpoint
= 0x0010,
248 FMTFLAG_showpos
= 0x0020,
249 FMTFLAG_left
= 0x0040,
250 FMTFLAG_right
= 0x0080,
251 FMTFLAG_internal
= 0x0100,
252 FMTFLAG_dec
= 0x0200,
253 FMTFLAG_oct
= 0x0400,
254 FMTFLAG_hex
= 0x0800,
255 FMTFLAG_scientific
= 0x1000,
256 FMTFLAG_fixed
= 0x2000,
257 FMTFLAG_hexfloat
= 0x3000,
258 FMTFLAG_boolalpha
= 0x4000,
259 FMTFLAG_stdio
= 0x8000,
260 FMTFLAG_adjustfield
= FMTFLAG_left
|FMTFLAG_right
|FMTFLAG_internal
,
261 FMTFLAG_basefield
= FMTFLAG_dec
|FMTFLAG_oct
|FMTFLAG_hex
,
262 FMTFLAG_floatfield
= FMTFLAG_scientific
|FMTFLAG_fixed
,
263 FMTFLAG_mask
= 0xffff
271 OPENMODE_trunc
= 0x10,
272 OPENMODE__Nocreate
= 0x40,
273 OPENMODE__Noreplace
= 0x80,
274 OPENMODE_binary
= 0x20,
286 IOSTATE_goodbit
= 0x00,
287 IOSTATE_eofbit
= 0x01,
288 IOSTATE_failbit
= 0x02,
289 IOSTATE_badbit
= 0x04,
290 IOSTATE__Hardfail
= 0x10,
294 typedef struct _iosarray
{
295 struct _iosarray
*next
;
308 typedef void (CDECL
*IOS_BASE_event_callback
)(IOS_BASE_event
, struct _ios_base
*, int);
309 typedef struct _fnarray
{
310 struct _fnarray
*next
;
312 IOS_BASE_event_callback event_handler
;
316 typedef struct _ios_base
{
317 const vtable_ptr
*vtable
;
318 #if _MSVCP_VER >= 100
319 MSVCP_size_t
DECLSPEC_ALIGN(8) stdstr
;
328 IOS_BASE_iosarray
*arr
;
329 IOS_BASE_fnarray
*calls
;
333 /* class basic_streambuf<char> */
335 const vtable_ptr
*vtable
;
336 #if _MSVCP_VER <= 100
352 } basic_streambuf_char
;
355 basic_streambuf_char
*strbuf
;
358 } istreambuf_iterator_char
;
362 void *iter_container
;
365 basic_streambuf_char
*strbuf
;
366 } ostreambuf_iterator_char
;
368 int __thiscall
basic_streambuf_char_sgetc(basic_streambuf_char
*);
369 int __thiscall
basic_streambuf_char_sbumpc(basic_streambuf_char
*);
370 int __thiscall
basic_streambuf_char_sputc(basic_streambuf_char
*, char);
372 /* class basic_streambuf<wchar> */
374 const vtable_ptr
*vtable
;
375 #if _MSVCP_VER <= 100
391 } basic_streambuf_wchar
;
394 basic_streambuf_wchar
*strbuf
;
397 } istreambuf_iterator_wchar
;
401 void *iter_container
;
404 basic_streambuf_wchar
*strbuf
;
405 } ostreambuf_iterator_wchar
;
407 unsigned short __thiscall
basic_streambuf_wchar_sgetc(basic_streambuf_wchar
*);
408 unsigned short __thiscall
basic_streambuf_wchar_sbumpc(basic_streambuf_wchar
*);
409 unsigned short __thiscall
basic_streambuf_wchar_sputc(basic_streambuf_wchar
*, wchar_t);
411 /* class num_get<char> */
417 num_get
* num_get_char_use_facet(const locale
*);
418 istreambuf_iterator_char
* __thiscall
num_get_char_get_long(const num_get
*, istreambuf_iterator_char
*,
419 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, LONG
*);
420 istreambuf_iterator_char
* __thiscall
num_get_char_get_ushort(const num_get
*, istreambuf_iterator_char
*,
421 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, unsigned short*);
422 istreambuf_iterator_char
* __thiscall
num_get_char_get_uint(const num_get
*, istreambuf_iterator_char
*,
423 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, unsigned int*);
424 istreambuf_iterator_char
* __thiscall
num_get_char_get_ulong(const num_get
*, istreambuf_iterator_char
*,
425 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, ULONG
*);
426 istreambuf_iterator_char
* __thiscall
num_get_char_get_float(const num_get
*, istreambuf_iterator_char
*,
427 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, float*);
428 istreambuf_iterator_char
*__thiscall
num_get_char_get_double(const num_get
*, istreambuf_iterator_char
*,
429 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, double*);
430 istreambuf_iterator_char
*__thiscall
num_get_char_get_ldouble(const num_get
*, istreambuf_iterator_char
*,
431 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, double*);
432 istreambuf_iterator_char
*__thiscall
num_get_char_get_void(const num_get
*, istreambuf_iterator_char
*,
433 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, void**);
434 istreambuf_iterator_char
*__thiscall
num_get_char_get_int64(const num_get
*, istreambuf_iterator_char
*,
435 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, LONGLONG
*);
436 istreambuf_iterator_char
*__thiscall
num_get_char_get_uint64(const num_get
*, istreambuf_iterator_char
*,
437 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, ULONGLONG
*);
438 istreambuf_iterator_char
*__thiscall
num_get_char_get_bool(const num_get
*, istreambuf_iterator_char
*,
439 istreambuf_iterator_char
, istreambuf_iterator_char
, ios_base
*, int*, MSVCP_bool
*);
441 num_get
* num_get_wchar_use_facet(const locale
*);
442 num_get
* num_get_short_use_facet(const locale
*);
443 istreambuf_iterator_wchar
* __thiscall
num_get_wchar_get_long(const num_get
*, istreambuf_iterator_wchar
*,
444 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, LONG
*);
445 istreambuf_iterator_wchar
* __thiscall
num_get_wchar_get_ushort(const num_get
*, istreambuf_iterator_wchar
*,
446 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, unsigned short*);
447 istreambuf_iterator_wchar
* __thiscall
num_get_wchar_get_uint(const num_get
*, istreambuf_iterator_wchar
*,
448 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, unsigned int*);
449 istreambuf_iterator_wchar
* __thiscall
num_get_wchar_get_ulong(const num_get
*, istreambuf_iterator_wchar
*,
450 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, ULONG
*);
451 istreambuf_iterator_wchar
* __thiscall
num_get_wchar_get_float(const num_get
*, istreambuf_iterator_wchar
*,
452 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, float*);
453 istreambuf_iterator_wchar
*__thiscall
num_get_wchar_get_double(const num_get
*, istreambuf_iterator_wchar
*,
454 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, double*);
455 istreambuf_iterator_wchar
*__thiscall
num_get_wchar_get_ldouble(const num_get
*, istreambuf_iterator_wchar
*,
456 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, double*);
457 istreambuf_iterator_wchar
*__thiscall
num_get_wchar_get_void(const num_get
*, istreambuf_iterator_wchar
*,
458 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, void**);
459 istreambuf_iterator_wchar
*__thiscall
num_get_wchar_get_int64(const num_get
*, istreambuf_iterator_wchar
*,
460 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, LONGLONG
*);
461 istreambuf_iterator_wchar
*__thiscall
num_get_wchar_get_uint64(const num_get
*, istreambuf_iterator_wchar
*,
462 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, ULONGLONG
*);
463 istreambuf_iterator_wchar
*__thiscall
num_get_wchar_get_bool(const num_get
*, istreambuf_iterator_wchar
*,
464 istreambuf_iterator_wchar
, istreambuf_iterator_wchar
, ios_base
*, int*, MSVCP_bool
*);
466 /* class num_put<char> */
467 /* class num_put<wchar> */
473 num_put
* num_put_char_use_facet(const locale
*);
474 ostreambuf_iterator_char
* __thiscall
num_put_char_put_long(const num_put
*, ostreambuf_iterator_char
*,
475 ostreambuf_iterator_char
, ios_base
*, char, LONG
);
476 ostreambuf_iterator_char
* __thiscall
num_put_char_put_ulong(const num_put
*, ostreambuf_iterator_char
*,
477 ostreambuf_iterator_char
, ios_base
*, char, ULONG
);
478 ostreambuf_iterator_char
* __thiscall
num_put_char_put_double(const num_put
*, ostreambuf_iterator_char
*,
479 ostreambuf_iterator_char
, ios_base
*, char, double);
480 ostreambuf_iterator_char
* __thiscall
num_put_char_put_ldouble(const num_put
*, ostreambuf_iterator_char
*,
481 ostreambuf_iterator_char
, ios_base
*, char, double);
482 ostreambuf_iterator_char
* __thiscall
num_put_char_put_ptr(const num_put
*, ostreambuf_iterator_char
*,
483 ostreambuf_iterator_char
, ios_base
*, char, const void*);
484 ostreambuf_iterator_char
* __thiscall
num_put_char_put_int64(const num_put
*, ostreambuf_iterator_char
*,
485 ostreambuf_iterator_char
, ios_base
*, char, __int64
);
486 ostreambuf_iterator_char
* __thiscall
num_put_char_put_uint64(const num_put
*, ostreambuf_iterator_char
*,
487 ostreambuf_iterator_char
, ios_base
*, char, unsigned __int64
);
488 ostreambuf_iterator_char
* __thiscall
num_put_char_put_bool(const num_put
*, ostreambuf_iterator_char
*,
489 ostreambuf_iterator_char
, ios_base
*, char, MSVCP_bool
);
491 num_put
* num_put_wchar_use_facet(const locale
*);
492 num_put
* num_put_short_use_facet(const locale
*);
493 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_long(const num_put
*, ostreambuf_iterator_wchar
*,
494 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, LONG
);
495 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_ulong(const num_put
*, ostreambuf_iterator_wchar
*,
496 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, ULONG
);
497 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_double(const num_put
*, ostreambuf_iterator_wchar
*,
498 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, double);
499 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_ldouble(const num_put
*, ostreambuf_iterator_wchar
*,
500 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, double);
501 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_ptr(const num_put
*, ostreambuf_iterator_wchar
*,
502 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, const void*);
503 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_int64(const num_put
*, ostreambuf_iterator_wchar
*,
504 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, __int64
);
505 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_uint64(const num_put
*, ostreambuf_iterator_wchar
*,
506 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, unsigned __int64
);
507 ostreambuf_iterator_wchar
* __thiscall
num_put_wchar_put_bool(const num_put
*, ostreambuf_iterator_wchar
*,
508 ostreambuf_iterator_wchar
, ios_base
*, wchar_t, MSVCP_bool
);
510 void init_exception(void*);
511 void init_locale(void*);
515 /* class complex<float> */
521 /* class complex<double> */
522 /* class complex<long double> */
529 #define memcpy_s( dst, size, src, count ) (memcpy( (dst), (src), (count) ), 0)
530 #define memmove_s( dst, size, src, count ) (memmove( (dst), (src), (count) ), 0)
531 #define mbstowcs_s( ret, wcs, size, mbs, count ) (mbstowcs( (wcs), (mbs), (count) ))
532 #define hypotf( x, y ) ((float)hypot( (double)(x), (double)(y) ))