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
22 typedef unsigned char MSVCP_bool;
23 typedef int MSVCP_long;
24 typedef SIZE_T MSVCP_size_t;
26 void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
27 const wchar_t*, unsigned int, uintptr_t);
29 extern void* (__cdecl *MSVCRT_operator_new)(MSVCP_size_t);
30 extern void (__cdecl *MSVCRT_operator_delete)(void*);
32 /* Copied from dlls/msvcrt/cpp.c */
33 #ifdef __i386__ /* thiscall functions are i386-specific */
35 #define THISCALL(func) __thiscall_ ## func
36 #define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
37 #define __thiscall __stdcall
38 #define DEFINE_THISCALL_WRAPPER(func,args) \
39 extern void THISCALL(func)(void); \
40 __ASM_GLOBAL_FUNC(__thiscall_ ## func, \
44 "jmp " __ASM_NAME(#func) __ASM_STDCALL(args) )
47 #define THISCALL(func) func
48 #define THISCALL_NAME(func) __ASM_NAME(#func)
49 #define __thiscall __cdecl
50 #define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
56 #define __ASM_VTABLE(name,funcs) \
59 "\t.quad " __ASM_NAME(#name "_rtti") "\n" \
60 "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
61 __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
62 "\t.quad " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
67 #define __ASM_VTABLE(name,funcs) \
70 "\t.long " __ASM_NAME(#name "_rtti") "\n" \
71 "\t.globl " __ASM_NAME("MSVCP_" #name "_vtable") "\n" \
72 __ASM_NAME("MSVCP_" #name "_vtable") ":\n" \
73 "\t.long " THISCALL_NAME(MSVCP_ ## name ## _vector_dtor) "\n" \
78 /* exception object */
79 typedef void (*vtable_ptr)(void);
80 typedef struct __exception
82 const vtable_ptr *vtable;
83 char *name; /* Name of this exception, always a new copy for each object */
84 int do_free; /* Whether to free 'name' in our dtor */
87 /* Internal: throws selected exception */
88 typedef enum __exception_type {
91 EXCEPTION_LOGIC_ERROR,
92 EXCEPTION_LENGTH_ERROR,
93 EXCEPTION_OUT_OF_RANGE,
94 EXCEPTION_INVALID_ARGUMENT
96 void throw_exception(exception_type, const char *);
97 void set_exception_vtable(void);
100 typedef struct __type_info
102 const vtable_ptr *vtable;
103 char *name; /* Unmangled name, allocated lazily */
104 char mangled[64]; /* Variable length, but we declare it large enough for static RTTI */
107 /* offsets for computing the this pointer */
110 int this_offset; /* offset of base class this pointer from start of object */
111 int vbase_descr; /* offset of virtual base class descriptor */
112 int vbase_offset; /* offset of this pointer offset in virtual base class descriptor */
115 typedef struct _rtti_base_descriptor
117 const type_info *type_descriptor;
118 int num_base_classes;
119 this_ptr_offsets offsets; /* offsets for computing the this pointer */
120 unsigned int attributes;
121 } rtti_base_descriptor;
123 typedef struct _rtti_base_array
125 const rtti_base_descriptor *bases[3]; /* First element is the class itself */
128 typedef struct _rtti_object_hierarchy
130 unsigned int signature;
131 unsigned int attributes;
132 int array_len; /* Size of the array pointed to by 'base_classes' */
133 const rtti_base_array *base_classes;
134 } rtti_object_hierarchy;
136 typedef struct _rtti_object_locator
138 unsigned int signature;
139 int base_class_offset;
141 const type_info *type_descriptor;
142 const rtti_object_hierarchy *type_hierarchy;
143 } rtti_object_locator;
145 /* basic_string<char, char_traits<char>, allocator<char>> */
146 #define BUF_SIZE_CHAR 16
147 typedef struct _basic_string_char
151 char buf[BUF_SIZE_CHAR];
158 basic_string_char* __stdcall MSVCP_basic_string_char_ctor_cstr(basic_string_char*, const char*);
159 basic_string_char* __stdcall MSVCP_basic_string_char_copy_ctor(basic_string_char*, const basic_string_char*);
160 void __stdcall MSVCP_basic_string_char_dtor(basic_string_char*);
161 const char* __stdcall MSVCP_basic_string_char_c_str(basic_string_char*);
163 #define BUF_SIZE_WCHAR 8
164 typedef struct _basic_string_wchar
168 wchar_t buf[BUF_SIZE_WCHAR];
173 } basic_string_wchar;
175 char* __stdcall MSVCP_allocator_char_allocate(void*, MSVCP_size_t);
176 void __stdcall MSVCP_allocator_char_deallocate(void*, char*, MSVCP_size_t);
177 wchar_t* __stdcall MSVCP_allocator_wchar_allocate(void*, MSVCP_size_t);
178 void __stdcall MSVCP_allocator_wchar_deallocate(void*, wchar_t*, MSVCP_size_t);
183 /*_Lockimp*/void *ptr;