2010-07-20 23:22:59 +02: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 10:36:40 +02:00
|
|
|
#include "windef.h"
|
2010-07-20 23:22:59 +02:00
|
|
|
|
|
|
|
typedef unsigned char MSVCP_BOOL;
|
|
|
|
|
|
|
|
void __cdecl _invalid_parameter(const wchar_t*, const wchar_t*,
|
|
|
|
const wchar_t*, unsigned int, uintptr_t);
|
2010-07-22 09:40:19 +02:00
|
|
|
|
2010-07-25 12:23:22 +02:00
|
|
|
extern void* (__cdecl *MSVCRT_operator_new)(size_t);
|
|
|
|
extern void (__cdecl *MSVCRT_operator_delete)(void*);
|
2010-07-22 09:40:19 +02:00
|
|
|
|
|
|
|
/* Copied from dlls/msvcrt/cpp.c */
|
|
|
|
#ifdef __i386__ /* thiscall functions are i386-specific */
|
|
|
|
|
|
|
|
#define THISCALL(func) __thiscall_ ## func
|
2010-08-18 10:36:52 +02:00
|
|
|
#define THISCALL_NAME(func) __ASM_NAME("__thiscall_" #func)
|
2010-07-22 09:40:19 +02: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 10:36:52 +02:00
|
|
|
#define THISCALL_NAME(func) __ASM_NAME(#func)
|
2010-07-22 09:40:19 +02:00
|
|
|
#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
|
|
|
|
|
|
|
|
#endif /* __i386__ */
|
2010-08-18 10:36:40 +02: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 {
|
2010-08-18 10:36:52 +02:00
|
|
|
EXCEPTION,
|
|
|
|
EXCEPTION_BAD_ALLOC
|
2010-08-18 10:36:40 +02:00
|
|
|
} exception_type;
|
|
|
|
void throw_exception(exception_type, const char *);
|
|
|
|
void set_exception_vtable(void);
|
2010-08-18 10:36:52 +02:00
|
|
|
|
|
|
|
/* rtti */
|
|
|
|
typedef struct __type_info
|
|
|
|
{
|
|
|
|
const vtable_ptr *vtable;
|
|
|
|
char *name; /* Unmangled name, allocated lazily */
|
|
|
|
char mangled[32]; /* Variable length, but we declare it large enough for static RTTI */
|
|
|
|
} type_info;
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
{
|
|
|
|
const rtti_base_descriptor *bases[3]; /* First element is the class itself */
|
|
|
|
} 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;
|