msvcr80: Don't forward some function to msvcrt.
This commit is contained in:
parent
05a807af49
commit
1a3546e54b
|
@ -18,12 +18,96 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "stdio.h"
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
#if defined(__i386__) && !defined(__arm__)
|
||||
|
||||
#define THISCALL(func) __thiscall_ ## func
|
||||
#define __thiscall __stdcall
|
||||
#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) )
|
||||
|
||||
extern void *call_thiscall_func;
|
||||
__ASM_GLOBAL_FUNC(call_thiscall_func,
|
||||
"popl %eax\n\t"
|
||||
"popl %edx\n\t"
|
||||
"popl %ecx\n\t"
|
||||
"pushl %eax\n\t"
|
||||
"jmp *%edx\n\t")
|
||||
|
||||
#define call_func1(func,this) ((void* (WINAPI*)(void*,void*))&call_thiscall_func)(func,this)
|
||||
#define call_func2(func,this,a) ((void* (WINAPI*)(void*,void*,const void*))&call_thiscall_func)(func,this,(const void*)(a))
|
||||
#define call_func3(func,this,a,b) ((void* (WINAPI*)(void*,void*,const void*,const void*))&call_thiscall_func)(func,this,(const void*)(a),(const void*)(b))
|
||||
|
||||
#else /* __i386__ */
|
||||
|
||||
#define __thiscall __cdecl
|
||||
#define DEFINE_THISCALL_WRAPPER(func,args) /* nothing */
|
||||
|
||||
#define call_func1(func,this) func(this)
|
||||
#define call_func2(func,this,a) func(this,a)
|
||||
#define call_func3(func,this,a,b) func(this,a,b)
|
||||
|
||||
#endif /* __i386__ */
|
||||
|
||||
static void* (__thiscall *MSVCRT_exception_ctor)(void*, const char**);
|
||||
static void* (__thiscall *MSVCRT_exception_ctor_noalloc)(void*, char**, int);
|
||||
static void* (__thiscall *MSVCRT_exception_copy_ctor)(void*, const void*);
|
||||
static void* (__thiscall *MSVCRT_exception_default_ctor)(void*);
|
||||
static void (__thiscall *MSVCRT_exception_dtor)(void*);
|
||||
static int (__thiscall *MSVCRT_type_info_opequals_equals)(void*, const void*);
|
||||
static int (__thiscall *MSVCRT_type_info_opnot_equals)(void*, const void*);
|
||||
static const char* (__thiscall *MSVCR100_type_info_name_internal_method)(void*, void*);
|
||||
|
||||
static void init_cxx_funcs(void)
|
||||
{
|
||||
HMODULE hmsvcrt = GetModuleHandleA("msvcrt.dll");
|
||||
HMODULE hmsvcr100 = GetModuleHandleA("msvcr100.dll");
|
||||
|
||||
if (sizeof(void *) > sizeof(int)) /* 64-bit has different names */
|
||||
{
|
||||
MSVCRT_exception_ctor = (void*)GetProcAddress(hmsvcrt, "??0exception@@QEAA@AEBQEBD@Z");
|
||||
MSVCRT_exception_ctor_noalloc = (void*)GetProcAddress(hmsvcrt, "??0exception@@QEAA@AEBQEBDH@Z");
|
||||
MSVCRT_exception_copy_ctor = (void*)GetProcAddress(hmsvcrt, "??0exception@@QEAA@AEBV0@@Z");
|
||||
MSVCRT_exception_default_ctor = (void*)GetProcAddress(hmsvcrt, "??0exception@@QEAA@XZ");
|
||||
MSVCRT_exception_dtor = (void*)GetProcAddress(hmsvcrt, "??1exception@@UEAA@XZ");
|
||||
MSVCRT_type_info_opequals_equals = (void*)GetProcAddress(hmsvcrt, "??8type_info@@QEBAHAEBV0@@Z");
|
||||
MSVCRT_type_info_opnot_equals = (void*)GetProcAddress(hmsvcrt, "??9type_info@@QEBAHAEBV0@@Z");
|
||||
MSVCR100_type_info_name_internal_method = (void*)GetProcAddress(hmsvcr100,
|
||||
"?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z");
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __arm__
|
||||
MSVCRT_type_info_opequals_equals = (void*)GetProcAddress(hmsvcrt, "??8type_info@@QBA_NABV0@@Z");
|
||||
MSVCRT_type_info_opnot_equals = (void*)GetProcAddress(hmsvcrt, "??9type_info@@QBA_NABV0@@Z");
|
||||
MSVCR100_type_info_name_internal_method = (void*)GetProcAddress(hmsvcr100,
|
||||
"?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z");
|
||||
#else
|
||||
MSVCRT_exception_ctor = (void*)GetProcAddress(hmsvcrt, "??0exception@@QEAA@AEBQEBD@Z");
|
||||
MSVCRT_exception_ctor_noalloc = (void*)GetProcAddress(hmsvcrt, "??0exception@@QAE@ABQBDH@Z");
|
||||
MSVCRT_exception_copy_ctor = (void*)GetProcAddress(hmsvcrt, "??0exception@@QAE@ABV0@@Z");
|
||||
MSVCRT_exception_default_ctor = (void*)GetProcAddress(hmsvcrt, "??0exception@@QAE@XZ");
|
||||
MSVCRT_exception_dtor = (void*)GetProcAddress(hmsvcrt, "??1exception@@UAE@XZ");
|
||||
MSVCRT_type_info_opequals_equals = (void*)GetProcAddress(hmsvcrt, "??8type_info@@QBEHABV0@@Z");
|
||||
MSVCRT_type_info_opnot_equals = (void*)GetProcAddress(hmsvcrt, "??9type_info@@QBEHABV0@@Z");
|
||||
MSVCR100_type_info_name_internal_method = (void*)GetProcAddress(hmsvcr100,
|
||||
"?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
switch (reason)
|
||||
|
@ -33,6 +117,7 @@ BOOL WINAPI DllMain(HINSTANCE hdll, DWORD reason, LPVOID reserved)
|
|||
|
||||
case DLL_PROCESS_ATTACH:
|
||||
DisableThreadLibraryCalls(hdll);
|
||||
init_cxx_funcs();
|
||||
_set_printf_count_output(0);
|
||||
}
|
||||
return TRUE;
|
||||
|
@ -47,3 +132,70 @@ void * CDECL MSVCR80__encode_pointer(void * ptr)
|
|||
{
|
||||
return EncodePointer(ptr);
|
||||
}
|
||||
|
||||
/* ??0exception@std@@QAE@ABQBD@Z */
|
||||
/* ??0exception@std@@QEAA@AEBQEBD@Z */
|
||||
DEFINE_THISCALL_WRAPPER(exception_ctor, 8)
|
||||
void* __thiscall exception_ctor(void *this, const char **name)
|
||||
{
|
||||
return call_func2(MSVCRT_exception_ctor, this, name);
|
||||
}
|
||||
|
||||
/* ??0exception@std@@QAE@ABQBDH@Z */
|
||||
/* ??0exception@std@@QEAA@AEBQEBDH@Z */
|
||||
DEFINE_THISCALL_WRAPPER(exception_ctor_noalloc, 12)
|
||||
void* __thiscall exception_ctor_noalloc(void *this, char **name, int noalloc)
|
||||
{
|
||||
return call_func3(MSVCRT_exception_ctor_noalloc, this, name, noalloc);
|
||||
}
|
||||
|
||||
/* ??0exception@std@@QAE@ABV01@@Z */
|
||||
/* ??0exception@std@@QEAA@AEBV01@@Z */
|
||||
DEFINE_THISCALL_WRAPPER(exception_copy_ctor, 8)
|
||||
void* __thiscall exception_copy_ctor(void *this, const void *rhs)
|
||||
{
|
||||
return call_func2(MSVCRT_exception_copy_ctor, this, rhs);
|
||||
}
|
||||
|
||||
/* ??0exception@std@@QAE@XZ */
|
||||
/* ??0exception@std@@QEAA@XZ */
|
||||
DEFINE_THISCALL_WRAPPER(exception_default_ctor, 4)
|
||||
void* __thiscall exception_default_ctor(void *this)
|
||||
{
|
||||
return call_func1(MSVCRT_exception_default_ctor, this);
|
||||
}
|
||||
|
||||
/* ??1exception@std@@UAE@XZ */
|
||||
/* ??1exception@std@@UEAA@XZ */
|
||||
DEFINE_THISCALL_WRAPPER(exception_dtor, 4)
|
||||
void __thiscall exception_dtor(void *this)
|
||||
{
|
||||
call_func1(MSVCRT_exception_dtor, this);
|
||||
}
|
||||
|
||||
/* ??8type_info@@QBA_NABV0@@Z */
|
||||
/* ??8type_info@@QBE_NABV0@@Z */
|
||||
/* ??8type_info@@QEBA_NAEBV0@@Z */
|
||||
DEFINE_THISCALL_WRAPPER(type_info_op_equals, 8)
|
||||
int __thiscall type_info_op_equals(void *this, const void *rhs)
|
||||
{
|
||||
return (int)call_func2(MSVCRT_type_info_opequals_equals, this, rhs);
|
||||
}
|
||||
|
||||
/* ??9type_info@@QBA_NABV0@@Z */
|
||||
/* ??9type_info@@QBE_NABV0@@Z */
|
||||
/* ??9type_info@@QEBA_NAEBV0@@Z */
|
||||
DEFINE_THISCALL_WRAPPER(type_info_opnot_equals, 8)
|
||||
int __thiscall type_info_opnot_equals(void *this, const void *rhs)
|
||||
{
|
||||
return (int)call_func2(MSVCRT_type_info_opnot_equals, this, rhs);
|
||||
}
|
||||
|
||||
/* ?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z */
|
||||
/* ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z */
|
||||
/* ?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z */
|
||||
DEFINE_THISCALL_WRAPPER(type_info_name_internal_method,8)
|
||||
const char* __thiscall type_info_name_internal_method(void *this, void *node)
|
||||
{
|
||||
return call_func2(MSVCR100_type_info_name_internal_method, this, node);
|
||||
}
|
||||
|
|
|
@ -12,22 +12,22 @@
|
|||
@ cdecl -arch=win64 ??0bad_typeid@std@@QEAA@AEBV01@@Z(ptr ptr) msvcrt.??0bad_typeid@@QEAA@AEBV0@@Z
|
||||
@ thiscall -arch=i386 ??0bad_typeid@std@@QAE@PBD@Z(ptr str) msvcrt.??0bad_typeid@@QAE@PBD@Z
|
||||
@ cdecl -arch=win64 ??0bad_typeid@std@@QEAA@PEBD@Z(ptr str) msvcrt.??0bad_typeid@@QEAA@PEBD@Z
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@ABQBD@Z(ptr ptr) msvcrt.??0exception@@QAE@ABQBD@Z
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@AEBQEBD@Z(ptr ptr) msvcrt.??0exception@@QEAA@AEBQEBD@Z
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@ABQBDH@Z(ptr ptr long) msvcrt.??0exception@@QAE@ABQBDH@Z
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@AEBQEBDH@Z(ptr ptr long) msvcrt.??0exception@@QEAA@AEBQEBDH@Z
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@ABV01@@Z(ptr ptr) msvcrt.??0exception@@QAE@ABV0@@Z
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@AEBV01@@Z(ptr ptr) msvcrt.??0exception@@QEAA@AEBV0@@Z
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@XZ(ptr) msvcrt.??0exception@@QAE@XZ
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@XZ(ptr) msvcrt.??0exception@@QEAA@XZ
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@ABQBD@Z(ptr ptr) exception_ctor
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@AEBQEBD@Z(ptr ptr) exception_ctor
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@ABQBDH@Z(ptr ptr long) exception_ctor_noalloc
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@AEBQEBDH@Z(ptr ptr long) exception_ctor_noalloc
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@ABV01@@Z(ptr ptr) exception_copy_ctor
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@AEBV01@@Z(ptr ptr) exception_copy_ctor
|
||||
@ thiscall -arch=i386 ??0exception@std@@QAE@XZ(ptr) exception_default_ctor
|
||||
@ cdecl -arch=win64 ??0exception@std@@QEAA@XZ(ptr) exception_default_ctor
|
||||
@ thiscall -arch=i386 ??1__non_rtti_object@std@@UAE@XZ(ptr) msvcrt.??1__non_rtti_object@@UAE@XZ
|
||||
@ cdecl -arch=win64 ??1__non_rtti_object@std@@UEAA@XZ(ptr) msvcrt.??1__non_rtti_object@@UEAA@XZ
|
||||
@ thiscall -arch=i386 ??1bad_cast@std@@UAE@XZ(ptr) msvcrt.??1bad_cast@@UAE@XZ
|
||||
@ cdecl -arch=win64 ??1bad_cast@std@@UEAA@XZ(ptr) msvcrt.??1bad_cast@@UEAA@XZ
|
||||
@ thiscall -arch=i386 ??1bad_typeid@std@@UAE@XZ(ptr) msvcrt.??1bad_typeid@@UAE@XZ
|
||||
@ cdecl -arch=win64 ??1bad_typeid@std@@UEAA@XZ(ptr) msvcrt.??1bad_typeid@@UEAA@XZ
|
||||
@ thiscall -arch=i386 ??1exception@std@@UAE@XZ(ptr) msvcrt.??1exception@@UAE@XZ
|
||||
@ cdecl -arch=win64 ??1exception@std@@UEAA@XZ(ptr) msvcrt.??1exception@@UEAA@XZ
|
||||
@ thiscall -arch=i386 ??1exception@std@@UAE@XZ(ptr) exception_dtor
|
||||
@ cdecl -arch=win64 ??1exception@std@@UEAA@XZ(ptr) exception_dtor
|
||||
@ cdecl -arch=arm ??1type_info@@UAA@XZ(ptr) msvcrt.??1type_info@@UAA@XZ
|
||||
@ thiscall -arch=i386 ??1type_info@@UAE@XZ(ptr) msvcrt.??1type_info@@UAE@XZ
|
||||
@ cdecl -arch=win64 ??1type_info@@UEAA@XZ(ptr) msvcrt.??1type_info@@UEAA@XZ
|
||||
|
@ -45,12 +45,12 @@
|
|||
@ cdecl -arch=win64 ??4bad_typeid@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) msvcrt.??4bad_typeid@@QEAAAEAV0@AEBV0@@Z
|
||||
@ thiscall -arch=i386 ??4exception@std@@QAEAAV01@ABV01@@Z(ptr ptr) msvcrt.??4exception@@QAEAAV0@ABV0@@Z
|
||||
@ cdecl -arch=win64 ??4exception@std@@QEAAAEAV01@AEBV01@@Z(ptr ptr) msvcrt.??4exception@@QEAAAEAV0@AEBV0@@Z
|
||||
@ cdecl -arch=arm ??8type_info@@QBA_NABV0@@Z(ptr ptr) msvcrt.??8type_info@@QBA_NABV0@@Z
|
||||
@ thiscall -arch=i386 ??8type_info@@QBE_NABV0@@Z(ptr ptr) msvcrt.??8type_info@@QBEHABV0@@Z
|
||||
@ cdecl -arch=win64 ??8type_info@@QEBA_NAEBV0@@Z(ptr ptr) msvcrt.??8type_info@@QEBAHAEBV0@@Z
|
||||
@ cdecl -arch=arm ??9type_info@@QBA_NABV0@@Z(ptr ptr) msvcrt.??9type_info@@QBA_NABV0@@Z
|
||||
@ thiscall -arch=i386 ??9type_info@@QBE_NABV0@@Z(ptr ptr) msvcrt.??9type_info@@QBEHABV0@@Z
|
||||
@ cdecl -arch=win64 ??9type_info@@QEBA_NAEBV0@@Z(ptr ptr) msvcrt.??9type_info@@QEBAHAEBV0@@Z
|
||||
@ cdecl -arch=arm ??8type_info@@QBA_NABV0@@Z(ptr ptr) type_info_op_equals
|
||||
@ thiscall -arch=i386 ??8type_info@@QBE_NABV0@@Z(ptr ptr) type_info_op_equals
|
||||
@ cdecl -arch=win64 ??8type_info@@QEBA_NAEBV0@@Z(ptr ptr) type_info_op_equals
|
||||
@ cdecl -arch=arm ??9type_info@@QBA_NABV0@@Z(ptr ptr) type_info_opnot_equals
|
||||
@ thiscall -arch=i386 ??9type_info@@QBE_NABV0@@Z(ptr ptr) type_info_opnot_equals
|
||||
@ cdecl -arch=win64 ??9type_info@@QEBA_NAEBV0@@Z(ptr ptr) type_info_opnot_equals
|
||||
@ extern ??_7__non_rtti_object@std@@6B@ msvcrt.??_7__non_rtti_object@@6B@
|
||||
@ extern ??_7bad_cast@std@@6B@ msvcrt.??_7bad_cast@@6B@
|
||||
@ extern ??_7bad_typeid@std@@6B@ msvcrt.??_7bad_typeid@@6B@
|
||||
|
@ -86,9 +86,9 @@
|
|||
@ cdecl -arch=win64 ?_invalid_parameter@@YAXPEBG00I_K@Z(wstr wstr wstr long long) msvcrt._invalid_parameter
|
||||
@ stub -arch=win32 ?_is_exception_typeof@@YAHABVtype_info@@PAU_EXCEPTION_POINTERS@@@Z # int __cdecl _is_exception_typeof(class type_info const &,struct _EXCEPTION_POINTERS *)
|
||||
@ stub -arch=win64 ?_is_exception_typeof@@YAHAEBVtype_info@@PEAU_EXCEPTION_POINTERS@@@Z # int __cdecl _is_exception_typeof(class type_info const & __ptr64,struct _EXCEPTION_POINTERS * __ptr64)
|
||||
@ cdecl -arch=arm ?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z(ptr ptr) msvcr100.?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z
|
||||
@ thiscall -arch=i386 ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z(ptr ptr) msvcr100.?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z
|
||||
@ cdecl -arch=win64 ?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z(ptr ptr) msvcr100.?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z
|
||||
@ cdecl -arch=arm ?_name_internal_method@type_info@@QBAPBDPAU__type_info_node@@@Z(ptr ptr) type_info_name_internal_method
|
||||
@ thiscall -arch=i386 ?_name_internal_method@type_info@@QBEPBDPAU__type_info_node@@@Z(ptr ptr) type_info_name_internal_method
|
||||
@ cdecl -arch=win64 ?_name_internal_method@type_info@@QEBAPEBDPEAU__type_info_node@@@Z(ptr ptr) type_info_name_internal_method
|
||||
@ varargs -arch=win32 ?_open@@YAHPBDHH@Z(str long) msvcrt._open
|
||||
@ varargs -arch=win64 ?_open@@YAHPEBDHH@Z(str long) msvcrt._open
|
||||
@ cdecl -arch=win32 ?_query_new_handler@@YAP6AHI@ZXZ() msvcrt.?_query_new_handler@@YAP6AHI@ZXZ
|
||||
|
|
Loading…
Reference in New Issue