2010-07-20 21:22:59 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Piotr Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "stdlib.h"
|
2010-08-18 08:36:40 +00:00
|
|
|
#include "windef.h"
|
2010-07-20 21:22:59 +00:00
|
|
|
|
2011-05-27 12:34:27 +00:00
|
|
|
typedef unsigned char MSVCP_bool;
|
2011-05-27 12:56:18 +00:00
|
|
|
typedef SIZE_T MSVCP_size_t;
|
2012-06-06 12:49:05 +00:00
|
|
|
typedef SSIZE_T streamoff;
|
|
|
|
typedef SSIZE_T streamsize;
|
2010-07-20 21:22:59 +00:00
|
|
|
|
|
|
|
void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
|
|
|
|
const wchar_t*, unsigned int, uintptr_t);
|
2012-06-01 15:03:36 +00:00
|
|
|
BOOL __cdecl __uncaught_exception(void);
|
2010-07-22 07:40:19 +00:00
|
|
|
|
2011-05-27 12:56:18 +00:00
|
|
|
extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
|
2010-07-25 10:23:22 +00:00
|
|
|
extern void (__cdecl *MSVCRT_operator_delete)(void*);
|
2011-09-13 08:30:29 +00:00
|
|
|
extern void* (__cdecl *MSVCRT_set_new_handler)(void*);
|
2010-07-22 07:40:19 +00:00
|
|
|
|
|
|
|
/* Copied from dlls/msvcrt/cpp.c */
|
|
|
|
#ifdef __i386__ /* thiscall functions are i386-specific */
|
|
|
|
|
|
|
|
#define THISCALL(func) __thiscall_ ## func
|
2010-08-18 08:36:52 +00:00
|
|
|
#define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
|
2010-08-24 14:31:25 +00:00
|
|
|
#define __thiscall __stdcall
|
2010-07-22 07:40:19 +00:00
|
|
|
#define DEFINE_THISCALL_WRAPPER(func,args) \
|
|
|
|
extern void THISCALL(func)(void); \
|
|
|
|
__ASM_GLOBAL_FUNC(__thiscall_ ## func, \
|
|
|
|
"popl %eax\n\t" \
|
|
|
|
"pushl %ecx\n\t" \
|
|
|
|
"pushl %eax\n\t" \
|
|
|
|
"jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
|
|
|
|
#else /* __i386__ */
|
|
|
|
|
|
|
|
#define THISCALL(func) func
|
2010-08-18 08:36:52 +00:00
|
|
|
#define THISCALL_NAME(func) __ASM_NAME(#func)
|
2010-08-24 14:31:25 +00:00
|
|
|
#define __thiscall __cdecl
|
2010-07-22 07:40:19 +00:00
|
|
|
#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|
2010-08-18 08:36:40 +00:00
|
|
|
|
2011-05-27 12:34:27 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
|
2011-12-15 09:16:08 +00:00
|
|
|
#define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
|
|
|
|
|
2011-05-27 12:34:27 +00:00
|
|
|
#define __ASM_VTABLE(name,funcs) \
|
|
|
|
__asm__(".data\n" \
|
|
|
|
"\t.align 8\n" \
|
|
|
|
"\t.quad " __ASM_NAME(#name "_rtti") "\n" \
|
|
|
|
"\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
|
|
|
|
__ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
|
|
|
|
"\t.quad " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
|
2011-11-05 20:54:30 +00:00
|
|
|
funcs "\n\t.text")
|
2011-05-27 12:34:27 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
2011-12-15 09:16:08 +00:00
|
|
|
#define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
|
|
|
|
|
2011-05-27 12:34:27 +00:00
|
|
|
#define __ASM_VTABLE(name,funcs) \
|
|
|
|
__asm__(".data\n" \
|
|
|
|
"\t.align 4\n" \
|
|
|
|
"\t.long " __ASM_NAME(#name "_rtti") "\n" \
|
|
|
|
"\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
|
|
|
|
__ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
|
|
|
|
"\t.long " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
|
2011-11-05 20:54:30 +00:00
|
|
|
funcs "\n\t.text")
|
2011-05-27 12:34:27 +00:00
|
|
|
|
|
|
|
#endif /* _WIN64 */
|
|
|
|
|
2012-06-14 13:35:45 +00:00
|
|
|
#define DEFINE_RTTI_DATA(name, off, base_classes, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
|
2011-12-19 14:55:16 +00:00
|
|
|
static const type_info name ## _type_info = { \
|
2012-04-04 18:12:07 +00:00
|
|
|
&MSVCP_type_info_vtable, \
|
2011-12-19 14:55:16 +00:00
|
|
|
NULL, \
|
|
|
|
mangled_name \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
static const rtti_base_descriptor name ## _rtti_base_descriptor = { \
|
|
|
|
&name ##_type_info, \
|
|
|
|
base_classes, \
|
|
|
|
{ 0, -1, 0}, \
|
|
|
|
64 \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
static const rtti_base_array name ## _rtti_base_array = { \
|
|
|
|
{ \
|
|
|
|
&name ## _rtti_base_descriptor, \
|
|
|
|
cl1, \
|
|
|
|
cl2, \
|
2012-06-12 16:13:27 +00:00
|
|
|
cl3, \
|
2012-06-13 13:22:13 +00:00
|
|
|
cl4, \
|
|
|
|
cl5, \
|
|
|
|
cl6, \
|
|
|
|
cl7, \
|
|
|
|
cl8, \
|
2012-06-14 13:35:45 +00:00
|
|
|
cl9, \
|
2011-12-19 14:55:16 +00:00
|
|
|
} \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
static const rtti_object_hierarchy name ## _hierarchy = { \
|
|
|
|
0, \
|
|
|
|
0, \
|
|
|
|
base_classes+1, \
|
|
|
|
&name ## _rtti_base_array \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
const rtti_object_locator name ## _rtti = { \
|
|
|
|
0, \
|
|
|
|
off, \
|
|
|
|
0, \
|
|
|
|
&name ## _type_info, \
|
|
|
|
&name ## _hierarchy \
|
|
|
|
}
|
|
|
|
|
2012-06-12 16:13:27 +00:00
|
|
|
#define DEFINE_RTTI_DATA0(name, off, mangled_name) \
|
2012-06-14 13:35:45 +00:00
|
|
|
DEFINE_RTTI_DATA(name, off, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
|
2012-06-12 16:13:27 +00:00
|
|
|
#define DEFINE_RTTI_DATA1(name, off, cl1, mangled_name) \
|
2012-06-14 13:35:45 +00:00
|
|
|
DEFINE_RTTI_DATA(name, off, 1, cl1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
|
2012-06-12 16:13:27 +00:00
|
|
|
#define DEFINE_RTTI_DATA2(name, off, cl1, cl2, mangled_name) \
|
2012-06-14 13:35:45 +00:00
|
|
|
DEFINE_RTTI_DATA(name, off, 2, cl1, cl2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
|
2012-06-12 16:13:27 +00:00
|
|
|
#define DEFINE_RTTI_DATA3(name, off, cl1, cl2, cl3, mangled_name) \
|
2012-06-14 13:35:45 +00:00
|
|
|
DEFINE_RTTI_DATA(name, off, 3, cl1, cl2, cl3, NULL, NULL, NULL, NULL, NULL, NULL, mangled_name)
|
2012-06-12 16:13:27 +00:00
|
|
|
#define DEFINE_RTTI_DATA4(name, off, cl1, cl2, cl3, cl4, mangled_name) \
|
2012-06-14 13:35:45 +00:00
|
|
|
DEFINE_RTTI_DATA(name, off, 4, cl1, cl2, cl3, cl4, NULL, NULL, NULL, NULL, NULL, mangled_name)
|
2012-06-13 13:22:13 +00:00
|
|
|
#define DEFINE_RTTI_DATA8(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, mangled_name) \
|
2012-06-14 13:35:45 +00:00
|
|
|
DEFINE_RTTI_DATA(name, off, 8, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, NULL, mangled_name)
|
|
|
|
#define DEFINE_RTTI_DATA9(name, off, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name) \
|
|
|
|
DEFINE_RTTI_DATA(name, off, 9, cl1, cl2, cl3, cl4, cl5, cl6, cl7, cl8, cl9, mangled_name)
|
2012-06-12 16:13:27 +00:00
|
|
|
|
2011-12-20 14:56:42 +00:00
|
|
|
#ifdef __i386__
|
|
|
|
|
|
|
|
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
|
|
|
|
|
|
|
|
extern void *vtbl_wrapper_0;
|
2011-12-20 14:57:08 +00:00
|
|
|
extern void *vtbl_wrapper_4;
|
2011-12-21 14:59:09 +00:00
|
|
|
extern void *vtbl_wrapper_8;
|
2011-12-20 14:57:19 +00:00
|
|
|
extern void *vtbl_wrapper_12;
|
|
|
|
extern void *vtbl_wrapper_16;
|
|
|
|
extern void *vtbl_wrapper_20;
|
|
|
|
extern void *vtbl_wrapper_24;
|
|
|
|
extern void *vtbl_wrapper_28;
|
|
|
|
extern void *vtbl_wrapper_32;
|
|
|
|
extern void *vtbl_wrapper_36;
|
|
|
|
extern void *vtbl_wrapper_40;
|
2011-12-22 17:24:21 +00:00
|
|
|
extern void *vtbl_wrapper_44;
|
|
|
|
extern void *vtbl_wrapper_48;
|
|
|
|
extern void *vtbl_wrapper_52;
|
|
|
|
extern void *vtbl_wrapper_56;
|
|
|
|
extern void *vtbl_wrapper_60;
|
2011-12-20 14:56:42 +00:00
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__cdecl***)type)this)[0][off/4]args
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2010-08-18 08:36:40 +00:00
|
|
|
/* exception object */
|
|
|
|
typedef void (*vtable_ptr)(void);
|
|
|
|
typedef struct __exception
|
|
|
|
{
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
char *name; /* Name of this exception, always a new copy for each object */
|
|
|
|
int do_free; /* Whether to free 'name' in our dtor */
|
|
|
|
} exception;
|
|
|
|
|
|
|
|
/* Internal: throws selected exception */
|
|
|
|
typedef enum __exception_type {
|
2012-03-29 14:13:13 +00:00
|
|
|
EXCEPTION_RERAISE,
|
2010-08-18 08:36:52 +00:00
|
|
|
EXCEPTION,
|
2010-08-19 21:48:56 +00:00
|
|
|
EXCEPTION_BAD_ALLOC,
|
2010-08-19 21:49:08 +00:00
|
|
|
EXCEPTION_LOGIC_ERROR,
|
2010-08-19 21:49:18 +00:00
|
|
|
EXCEPTION_LENGTH_ERROR,
|
2010-08-23 14:34:15 +00:00
|
|
|
EXCEPTION_OUT_OF_RANGE,
|
2011-11-25 09:46:48 +00:00
|
|
|
EXCEPTION_INVALID_ARGUMENT,
|
2012-03-29 14:11:31 +00:00
|
|
|
EXCEPTION_RUNTIME_ERROR,
|
|
|
|
EXCEPTION_FAILURE,
|
2010-08-18 08:36:40 +00:00
|
|
|
} exception_type;
|
|
|
|
void throw_exception(exception_type, const char *);
|
2010-08-18 08:36:52 +00:00
|
|
|
|
|
|
|
/* rtti */
|
|
|
|
typedef struct __type_info
|
|
|
|
{
|
|
|
|
const vtable_ptr *vtable;
|
2012-01-04 01:10:17 +00:00
|
|
|
char *name; /* Unmangled name, allocated lazily */
|
|
|
|
char mangled[128]; /* Variable length, but we declare it large enough for static RTTI */
|
2010-08-18 08:36:52 +00:00
|
|
|
} type_info;
|
|
|
|
|
2012-04-04 18:12:07 +00:00
|
|
|
extern const vtable_ptr MSVCP_type_info_vtable;
|
|
|
|
|
2010-08-18 08:36:52 +00:00
|
|
|
/* offsets for computing the this pointer */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int this_offset; /* offset of base class this pointer from start of object */
|
|
|
|
int vbase_descr; /* offset of virtual base class descriptor */
|
|
|
|
int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
|
|
|
|
} this_ptr_offsets;
|
|
|
|
|
|
|
|
typedef struct _rtti_base_descriptor
|
|
|
|
{
|
|
|
|
const type_info *type_descriptor;
|
|
|
|
int num_base_classes;
|
|
|
|
this_ptr_offsets offsets; /* offsets for computing the this pointer */
|
|
|
|
unsigned int attributes;
|
|
|
|
} rtti_base_descriptor;
|
|
|
|
|
|
|
|
typedef struct _rtti_base_array
|
|
|
|
{
|
2012-06-14 13:35:45 +00:00
|
|
|
const rtti_base_descriptor *bases[10]; /* First element is the class itself */
|
2010-08-18 08:36:52 +00:00
|
|
|
} rtti_base_array;
|
|
|
|
|
|
|
|
typedef struct _rtti_object_hierarchy
|
|
|
|
{
|
|
|
|
unsigned int signature;
|
|
|
|
unsigned int attributes;
|
|
|
|
int array_len; /* Size of the array pointed to by 'base_classes' */
|
|
|
|
const rtti_base_array *base_classes;
|
|
|
|
} rtti_object_hierarchy;
|
|
|
|
|
|
|
|
typedef struct _rtti_object_locator
|
|
|
|
{
|
|
|
|
unsigned int signature;
|
|
|
|
int base_class_offset;
|
|
|
|
unsigned int flags;
|
|
|
|
const type_info *type_descriptor;
|
|
|
|
const rtti_object_hierarchy *type_hierarchy;
|
|
|
|
} rtti_object_locator;
|
2010-08-19 10:17:11 +00:00
|
|
|
|
|
|
|
/* basic_string<char, char_traits<char>, allocator<char>> */
|
|
|
|
#define BUF_SIZE_CHAR 16
|
|
|
|
typedef struct _basic_string_char
|
|
|
|
{
|
|
|
|
void *allocator;
|
2010-08-30 14:35:30 +00:00
|
|
|
union {
|
2010-08-19 10:17:11 +00:00
|
|
|
char buf[BUF_SIZE_CHAR];
|
|
|
|
char *ptr;
|
|
|
|
} data;
|
2011-05-27 12:56:18 +00:00
|
|
|
MSVCP_size_t size;
|
|
|
|
MSVCP_size_t res;
|
2010-08-19 10:17:11 +00:00
|
|
|
} basic_string_char;
|
|
|
|
|
2012-06-28 10:32:47 +00:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_ctor(basic_string_char*);
|
2010-08-19 21:48:56 +00:00
|
|
|
basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*);
|
2012-06-28 10:32:47 +00:00
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_ctor_cstr_len(basic_string_char*, const char*, MSVCP_size_t);
|
2010-08-19 21:48:56 +00:00
|
|
|
basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
|
|
|
|
void __stdcall MSVCP_basic_string_char_dtor(basic_string_char*);
|
2011-12-06 11:48:46 +00:00
|
|
|
const char* __stdcall MSVCP_basic_string_char_c_str(const basic_string_char*);
|
2012-06-12 16:14:09 +00:00
|
|
|
void __thiscall MSVCP_basic_string_char_clear(basic_string_char*);
|
|
|
|
basic_string_char* __thiscall MSVCP_basic_string_char_append_ch(basic_string_char*, char);
|
2012-06-15 09:07:23 +00:00
|
|
|
MSVCP_size_t __thiscall MSVCP_basic_string_char_length(const basic_string_char*);
|
2010-08-19 21:48:56 +00:00
|
|
|
|
2010-08-30 14:35:30 +00:00
|
|
|
#define BUF_SIZE_WCHAR 8
|
|
|
|
typedef struct _basic_string_wchar
|
|
|
|
{
|
|
|
|
void *allocator;
|
|
|
|
union {
|
|
|
|
wchar_t buf[BUF_SIZE_WCHAR];
|
|
|
|
wchar_t *ptr;
|
|
|
|
} data;
|
2011-05-27 12:56:18 +00:00
|
|
|
MSVCP_size_t size;
|
|
|
|
MSVCP_size_t res;
|
2010-08-30 14:35:30 +00:00
|
|
|
} basic_string_wchar;
|
|
|
|
|
2012-06-25 13:48:18 +00:00
|
|
|
basic_string_wchar* __thiscall MSVCP_basic_string_wchar_ctor_cstr(basic_string_wchar*, const wchar_t*);
|
|
|
|
void __thiscall MSVCP_basic_string_wchar_dtor(basic_string_wchar*);
|
|
|
|
const wchar_t* __thiscall MSVCP_basic_string_wchar_c_str(const basic_string_wchar*);
|
2012-06-26 12:34:26 +00:00
|
|
|
void __thiscall MSVCP_basic_string_wchar_clear(basic_string_wchar*);
|
|
|
|
basic_string_wchar* __thiscall MSVCP_basic_string_wchar_append_ch(basic_string_wchar*, wchar_t);
|
2012-06-25 13:48:18 +00:00
|
|
|
MSVCP_size_t __thiscall MSVCP_basic_string_wchar_length(const basic_string_wchar*);
|
2012-03-28 09:20:22 +00:00
|
|
|
|
2011-05-27 12:56:18 +00:00
|
|
|
char* __stdcall MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
|
|
|
|
void __stdcall MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
|
2011-10-14 13:01:22 +00:00
|
|
|
MSVCP_size_t __stdcall MSVCP_allocator_char_max_size(void*);
|
2011-05-27 12:56:18 +00:00
|
|
|
wchar_t* __stdcall MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
|
|
|
|
void __stdcall MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
|
2011-10-14 13:01:22 +00:00
|
|
|
MSVCP_size_t __stdcall MSVCP_allocator_wchar_max_size(void*);
|
2011-05-27 12:34:27 +00:00
|
|
|
|
2012-06-12 16:12:32 +00:00
|
|
|
/* class locale::facet */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
MSVCP_size_t refs;
|
|
|
|
} locale_facet;
|
|
|
|
|
2012-06-12 16:13:06 +00:00
|
|
|
typedef enum {
|
|
|
|
CODECVT_ok = 0,
|
|
|
|
CODECVT_partial = 1,
|
|
|
|
CODECVT_error = 2,
|
|
|
|
CODECVT_noconv = 3
|
|
|
|
} codecvt_base_result;
|
|
|
|
|
2012-06-18 14:59:56 +00:00
|
|
|
typedef struct {
|
|
|
|
LCID handle;
|
|
|
|
unsigned page;
|
|
|
|
const short *table;
|
|
|
|
int delfl;
|
|
|
|
} _Ctypevec;
|
|
|
|
|
2012-06-12 16:13:06 +00:00
|
|
|
/* class codecvt_base */
|
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
} codecvt_base;
|
|
|
|
|
|
|
|
/* class codecvt<char> */
|
|
|
|
typedef struct {
|
|
|
|
codecvt_base base;
|
|
|
|
} codecvt_char;
|
|
|
|
|
|
|
|
MSVCP_bool __thiscall codecvt_base_always_noconv(const codecvt_base*);
|
|
|
|
int __thiscall codecvt_char_unshift(const codecvt_char*, int*, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_char_out(const codecvt_char*, int*, const char*,
|
|
|
|
const char*, const char**, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_char_in(const codecvt_char*, int*, const char*,
|
|
|
|
const char*, const char**, char*, char*, char**);
|
|
|
|
int __thiscall codecvt_base_max_length(const codecvt_base*);
|
|
|
|
|
2012-06-14 13:37:13 +00:00
|
|
|
typedef struct {
|
|
|
|
LCID handle;
|
|
|
|
unsigned page;
|
2012-06-18 14:59:56 +00:00
|
|
|
} _Cvtvec;
|
|
|
|
|
|
|
|
/* class codecvt<wchar> */
|
|
|
|
typedef struct {
|
|
|
|
codecvt_base base;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} codecvt_wchar;
|
2012-06-14 13:37:13 +00:00
|
|
|
|
|
|
|
/* class ctype_base */
|
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
} ctype_base;
|
|
|
|
|
|
|
|
/* class ctype<char> */
|
|
|
|
typedef struct {
|
|
|
|
ctype_base base;
|
|
|
|
_Ctypevec ctype;
|
|
|
|
} ctype_char;
|
|
|
|
|
|
|
|
MSVCP_bool __thiscall ctype_char_is_ch(const ctype_char*, short, char);
|
2012-06-15 09:09:04 +00:00
|
|
|
char __thiscall ctype_char_narrow_ch(const ctype_char*, char, char);
|
2012-06-15 09:09:15 +00:00
|
|
|
char __thiscall ctype_char_widen_ch(const ctype_char*, char);
|
2012-06-15 09:09:04 +00:00
|
|
|
|
|
|
|
/* class ctype<wchar> */
|
|
|
|
typedef struct {
|
|
|
|
ctype_base base;
|
|
|
|
_Ctypevec ctype;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} ctype_wchar;
|
|
|
|
|
2012-06-26 12:34:26 +00:00
|
|
|
MSVCP_bool __thiscall ctype_wchar_is_ch(const ctype_wchar*, short, wchar_t);
|
2012-06-15 09:09:04 +00:00
|
|
|
char __thiscall ctype_wchar_narrow_ch(const ctype_wchar*, wchar_t, char);
|
2012-06-15 09:09:15 +00:00
|
|
|
wchar_t __thiscall ctype_wchar_widen_ch(const ctype_wchar*, char);
|
2012-06-14 13:37:13 +00:00
|
|
|
|
2011-05-27 12:34:27 +00:00
|
|
|
/* class locale */
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-11-23 15:14:11 +00:00
|
|
|
struct _locale__Locimp *ptr;
|
2011-05-27 12:34:27 +00:00
|
|
|
} locale;
|
2011-06-22 12:03:54 +00:00
|
|
|
|
2011-08-24 12:38:53 +00:00
|
|
|
locale* __thiscall locale_ctor(locale*);
|
2012-03-28 09:20:56 +00:00
|
|
|
locale* __thiscall locale_copy_ctor(locale*, const locale*);
|
2012-03-29 14:11:31 +00:00
|
|
|
locale* __thiscall locale_operator_assign(locale*, const locale*);
|
2011-08-24 12:38:53 +00:00
|
|
|
void __thiscall locale_dtor(locale*);
|
2012-06-12 16:12:12 +00:00
|
|
|
void free_locale(void);
|
2012-06-12 16:13:06 +00:00
|
|
|
codecvt_char* codecvt_char_use_facet(const locale*);
|
2012-06-18 14:59:56 +00:00
|
|
|
codecvt_char* codecvt_char_use_facet(const locale*);
|
2012-06-14 13:37:13 +00:00
|
|
|
ctype_char* ctype_char_use_facet(const locale*);
|
2012-06-15 09:09:04 +00:00
|
|
|
ctype_wchar* ctype_wchar_use_facet(const locale*);
|
2011-08-24 12:38:53 +00:00
|
|
|
|
2011-06-22 12:03:54 +00:00
|
|
|
/* class _Lockit */
|
|
|
|
typedef struct {
|
|
|
|
int locktype;
|
|
|
|
} _Lockit;
|
|
|
|
|
2011-08-24 12:38:35 +00:00
|
|
|
#define _LOCK_LOCALE 0
|
|
|
|
#define _LOCK_MALLOC 1
|
|
|
|
#define _LOCK_STREAM 2
|
|
|
|
#define _LOCK_DEBUG 3
|
|
|
|
#define _MAX_LOCK 4
|
|
|
|
|
2011-06-22 12:03:54 +00:00
|
|
|
void init_lockit(void);
|
|
|
|
void free_lockit(void);
|
2011-08-24 12:38:35 +00:00
|
|
|
_Lockit* __thiscall _Lockit_ctor_locktype(_Lockit*, int);
|
|
|
|
void __thiscall _Lockit_dtor(_Lockit*);
|
2011-08-23 09:50:56 +00:00
|
|
|
|
|
|
|
/* class mutex */
|
|
|
|
typedef struct {
|
|
|
|
void *mutex;
|
|
|
|
} mutex;
|
2011-08-24 12:39:12 +00:00
|
|
|
|
|
|
|
mutex* __thiscall mutex_ctor(mutex*);
|
|
|
|
void __thiscall mutex_dtor(mutex*);
|
|
|
|
void __thiscall mutex_lock(mutex*);
|
|
|
|
void __thiscall mutex_unlock(mutex*);
|
2012-06-15 09:07:49 +00:00
|
|
|
|
2012-06-21 10:25:23 +00:00
|
|
|
typedef enum {
|
|
|
|
FMTFLAG_skipws = 0x0001,
|
|
|
|
FMTFLAG_unitbuf = 0x0002,
|
|
|
|
FMTFLAG_uppercase = 0x0004,
|
|
|
|
FMTFLAG_showbase = 0x0008,
|
|
|
|
FMTFLAG_showpoint = 0x0010,
|
|
|
|
FMTFLAG_showpos = 0x0020,
|
|
|
|
FMTFLAG_left = 0x0040,
|
|
|
|
FMTFLAG_right = 0x0080,
|
|
|
|
FMTFLAG_internal = 0x0100,
|
|
|
|
FMTFLAG_dec = 0x0200,
|
|
|
|
FMTFLAG_oct = 0x0400,
|
|
|
|
FMTFLAG_hex = 0x0800,
|
|
|
|
FMTFLAG_scientific = 0x1000,
|
|
|
|
FMTFLAG_fixed = 0x2000,
|
|
|
|
FMTFLAG_hexfloat = 0x3000,
|
|
|
|
FMTFLAG_boolalpha = 0x4000,
|
|
|
|
FMTFLAG_stdio = 0x8000,
|
|
|
|
FMTFLAG_adjustfield = FMTFLAG_left|FMTFLAG_right|FMTFLAG_internal,
|
|
|
|
FMTFLAG_basefield = FMTFLAG_dec|FMTFLAG_oct|FMTFLAG_hex,
|
2012-06-22 08:27:50 +00:00
|
|
|
FMTFLAG_floatfield = FMTFLAG_scientific|FMTFLAG_fixed,
|
2012-06-21 10:25:23 +00:00
|
|
|
FMTFLAG_mask = 0xffff
|
|
|
|
} IOSB_fmtflags;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
OPENMODE_in = 0x01,
|
|
|
|
OPENMODE_out = 0x02,
|
|
|
|
OPENMODE_ate = 0x04,
|
|
|
|
OPENMODE_app = 0x08,
|
|
|
|
OPENMODE_trunc = 0x10,
|
|
|
|
OPENMODE__Nocreate = 0x40,
|
|
|
|
OPENMODE__Noreplace = 0x80,
|
|
|
|
OPENMODE_binary = 0x20,
|
|
|
|
OPENMODE_mask = 0xff
|
|
|
|
} IOSB_openmode;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SEEKDIR_beg = 0x1,
|
|
|
|
SEEKDIR_cur = 0x2,
|
|
|
|
SEEKDIR_end = 0x3,
|
|
|
|
SEEKDIR_mask = 0x3
|
|
|
|
} IOSB_seekdir;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
IOSTATE_goodbit = 0x00,
|
|
|
|
IOSTATE_eofbit = 0x01,
|
|
|
|
IOSTATE_failbit = 0x02,
|
|
|
|
IOSTATE_badbit = 0x04,
|
|
|
|
IOSTATE__Hardfail = 0x10,
|
|
|
|
IOSTATE_mask = 0x17
|
|
|
|
} IOSB_iostate;
|
|
|
|
|
|
|
|
typedef struct _iosarray {
|
|
|
|
struct _iosarray *next;
|
|
|
|
int index;
|
|
|
|
int long_val;
|
|
|
|
void *ptr_val;
|
|
|
|
} IOS_BASE_iosarray;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
EVENT_erase_event,
|
|
|
|
EVENT_imbue_event,
|
|
|
|
EVENT_copyfmt_event
|
|
|
|
} IOS_BASE_event;
|
|
|
|
|
|
|
|
struct _ios_base;
|
|
|
|
typedef void (CDECL *IOS_BASE_event_callback)(IOS_BASE_event, struct _ios_base*, int);
|
|
|
|
typedef struct _fnarray {
|
|
|
|
struct _fnarray *next;
|
|
|
|
int index;
|
|
|
|
IOS_BASE_event_callback event_handler;
|
|
|
|
} IOS_BASE_fnarray;
|
|
|
|
|
|
|
|
/* class ios_base */
|
|
|
|
typedef struct _ios_base {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
MSVCP_size_t stdstr;
|
|
|
|
IOSB_iostate state;
|
|
|
|
IOSB_iostate except;
|
|
|
|
IOSB_fmtflags fmtfl;
|
|
|
|
streamsize prec;
|
|
|
|
streamsize wide;
|
|
|
|
IOS_BASE_iosarray *arr;
|
|
|
|
IOS_BASE_fnarray *calls;
|
|
|
|
locale *loc;
|
|
|
|
} ios_base;
|
|
|
|
|
2012-06-21 10:25:44 +00:00
|
|
|
/* class basic_streambuf<char> */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
mutex lock;
|
|
|
|
char *rbuf;
|
|
|
|
char *wbuf;
|
|
|
|
char **prbuf;
|
|
|
|
char **pwbuf;
|
|
|
|
char *rpos;
|
|
|
|
char *wpos;
|
|
|
|
char **prpos;
|
|
|
|
char **pwpos;
|
|
|
|
int rsize;
|
|
|
|
int wsize;
|
|
|
|
int *prsize;
|
|
|
|
int *pwsize;
|
|
|
|
locale *loc;
|
|
|
|
} basic_streambuf_char;
|
|
|
|
|
2012-06-21 10:27:21 +00:00
|
|
|
typedef struct {
|
|
|
|
basic_streambuf_char *strbuf;
|
|
|
|
MSVCP_bool got;
|
|
|
|
char val;
|
|
|
|
} istreambuf_iterator_char;
|
|
|
|
|
2012-06-22 08:26:32 +00:00
|
|
|
typedef struct {
|
|
|
|
MSVCP_bool failed;
|
|
|
|
basic_streambuf_char *strbuf;
|
|
|
|
} ostreambuf_iterator_char;
|
|
|
|
|
2012-06-21 10:26:20 +00:00
|
|
|
int __thiscall basic_streambuf_char_sgetc(basic_streambuf_char*);
|
|
|
|
int __thiscall basic_streambuf_char_sbumpc(basic_streambuf_char*);
|
2012-06-22 08:26:48 +00:00
|
|
|
int __thiscall basic_streambuf_char_sputc(basic_streambuf_char*, char);
|
2012-06-21 10:26:20 +00:00
|
|
|
|
2012-06-21 10:25:44 +00:00
|
|
|
/* class basic_streambuf<wchar> */
|
|
|
|
typedef struct {
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
mutex lock;
|
|
|
|
wchar_t *rbuf;
|
|
|
|
wchar_t *wbuf;
|
|
|
|
wchar_t **prbuf;
|
|
|
|
wchar_t **pwbuf;
|
|
|
|
wchar_t *rpos;
|
|
|
|
wchar_t *wpos;
|
|
|
|
wchar_t **prpos;
|
|
|
|
wchar_t **pwpos;
|
|
|
|
int rsize;
|
|
|
|
int wsize;
|
|
|
|
int *prsize;
|
|
|
|
int *pwsize;
|
|
|
|
locale *loc;
|
|
|
|
} basic_streambuf_wchar;
|
|
|
|
|
2012-06-25 13:48:59 +00:00
|
|
|
typedef struct {
|
|
|
|
basic_streambuf_wchar *strbuf;
|
|
|
|
MSVCP_bool got;
|
|
|
|
wchar_t val;
|
|
|
|
} istreambuf_iterator_wchar;
|
|
|
|
|
2012-06-25 13:48:18 +00:00
|
|
|
typedef struct {
|
|
|
|
MSVCP_bool failed;
|
|
|
|
basic_streambuf_wchar *strbuf;
|
|
|
|
} ostreambuf_iterator_wchar;
|
|
|
|
|
2012-06-25 13:48:59 +00:00
|
|
|
unsigned short __thiscall basic_streambuf_wchar_sgetc(basic_streambuf_wchar*);
|
|
|
|
unsigned short __thiscall basic_streambuf_wchar_sbumpc(basic_streambuf_wchar*);
|
2012-06-25 13:48:18 +00:00
|
|
|
unsigned short __thiscall basic_streambuf_wchar_sputc(basic_streambuf_wchar*, wchar_t);
|
|
|
|
|
2012-06-21 10:27:21 +00:00
|
|
|
/* class num_get<char> */
|
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} num_get;
|
|
|
|
|
|
|
|
num_get* num_get_char_use_facet(const locale*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_long(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, LONG*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_ushort(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, unsigned short*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_uint(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, unsigned int*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_ulong(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, ULONG*);
|
|
|
|
istreambuf_iterator_char* __thiscall num_get_char_get_float(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, float*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_double(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_ldouble(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_void(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, void**);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_int64(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, LONGLONG*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_uint64(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, ULONGLONG*);
|
|
|
|
istreambuf_iterator_char *__thiscall num_get_char_get_bool(const num_get*, istreambuf_iterator_char*,
|
|
|
|
istreambuf_iterator_char, istreambuf_iterator_char, ios_base*, int*, MSVCP_bool*);
|
|
|
|
|
2012-06-26 12:34:26 +00:00
|
|
|
num_get* num_get_wchar_use_facet(const locale*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_long(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, LONG*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_ushort(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, unsigned short*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_uint(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, unsigned int*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_ulong(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, ULONG*);
|
|
|
|
istreambuf_iterator_wchar* __thiscall num_get_wchar_get_float(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, float*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_double(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_ldouble(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, double*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_void(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, void**);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_int64(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, LONGLONG*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_uint64(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, ULONGLONG*);
|
|
|
|
istreambuf_iterator_wchar *__thiscall num_get_wchar_get_bool(const num_get*, istreambuf_iterator_wchar*,
|
|
|
|
istreambuf_iterator_wchar, istreambuf_iterator_wchar, ios_base*, int*, MSVCP_bool*);
|
|
|
|
|
2012-06-22 08:26:32 +00:00
|
|
|
/* class num_put<char> */
|
2012-06-25 13:48:18 +00:00
|
|
|
/* class num_put<wchar> */
|
2012-06-22 08:26:32 +00:00
|
|
|
typedef struct {
|
|
|
|
locale_facet facet;
|
|
|
|
_Cvtvec cvt;
|
|
|
|
} num_put;
|
|
|
|
|
2012-06-22 08:28:05 +00:00
|
|
|
num_put* num_put_char_use_facet(const locale*);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_long(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, LONG);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_ulong(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, ULONG);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_double(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, double);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_ldouble(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, double);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_ptr(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, const void*);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_int64(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, __int64);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_uint64(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, unsigned __int64);
|
|
|
|
ostreambuf_iterator_char* __thiscall num_put_char_put_bool(const num_put*, ostreambuf_iterator_char*,
|
|
|
|
ostreambuf_iterator_char, ios_base*, char, MSVCP_bool);
|
|
|
|
|
2012-06-25 13:49:53 +00:00
|
|
|
num_put* num_put_wchar_use_facet(const locale*);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_long(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, LONG);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ulong(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, ULONG);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_double(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, double);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ldouble(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, double);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_ptr(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, const void*);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_int64(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, __int64);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_uint64(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, unsigned __int64);
|
|
|
|
ostreambuf_iterator_wchar* __thiscall num_put_wchar_put_bool(const num_put*, ostreambuf_iterator_wchar*,
|
|
|
|
ostreambuf_iterator_wchar, ios_base*, wchar_t, MSVCP_bool);
|
|
|
|
|
2012-06-15 09:07:49 +00:00
|
|
|
void init_io(void);
|
|
|
|
void free_io(void);
|