mirror of
https://github.com/encounter/winedll.git
synced 2026-07-11 06:18:49 -07:00
Add msvcirt.dll, msvcrt40.dll
This commit is contained in:
@@ -19,6 +19,8 @@ add_subdirectory(dlls/advapi32)
|
||||
add_subdirectory(dlls/kernel32)
|
||||
add_subdirectory(dlls/kernelbase)
|
||||
add_subdirectory(dlls/msvcrt)
|
||||
add_subdirectory(dlls/msvcirt)
|
||||
add_subdirectory(dlls/msvcrt40)
|
||||
add_subdirectory(dlls/msvcr70)
|
||||
add_subdirectory(dlls/msvcr71)
|
||||
add_subdirectory(dlls/msvcr80)
|
||||
|
||||
@@ -4,6 +4,8 @@ This repository builds standalone versions of Wine's msvcrt/ucrtbase DLLs using
|
||||
|
||||
The following Microsoft Visual C++ runtime libraries are built:
|
||||
- msvcrt.dll
|
||||
- msvcirt.dll
|
||||
- msvcrt40.dll
|
||||
- msvcr70.dll
|
||||
- msvcr71.dll
|
||||
- msvcr80.dll
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(MSVCIRT_GENERATED_STUBS ${CMAKE_CURRENT_BINARY_DIR}/generated_stubs.c)
|
||||
set(MSVCIRT_DEF ${CMAKE_CURRENT_BINARY_DIR}/msvcirt.def)
|
||||
set(MSVCRT_IMPORT_DEF ${CMAKE_CURRENT_BINARY_DIR}/msvcrt_import.def)
|
||||
set(MSVCRT_IMPORT_LIB ${CMAKE_CURRENT_BINARY_DIR}/msvcrt.lib)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCIRT_GENERATED_STUBS}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_STUBS_TOOL}
|
||||
--arch i386
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcirt.spec
|
||||
${MSVCIRT_GENERATED_STUBS}
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcirt.spec
|
||||
${GENERATE_STUBS_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating msvcirt stubs"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCIRT_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--no-stdcall-suffix
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcirt.spec
|
||||
${MSVCIRT_DEF}
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcirt.spec
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating msvcirt.def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT_IMPORT_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--imports-only
|
||||
${PROJECT_SOURCE_DIR}/dlls/msvcrt/msvcrt.spec
|
||||
${MSVCRT_IMPORT_DEF}
|
||||
DEPENDS
|
||||
${PROJECT_SOURCE_DIR}/dlls/msvcrt/msvcrt.spec
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating msvcrt import def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT_IMPORT_LIB}
|
||||
COMMAND llvm-dlltool -m i386 -k -d ${MSVCRT_IMPORT_DEF} -l ${MSVCRT_IMPORT_LIB}
|
||||
DEPENDS ${MSVCRT_IMPORT_DEF}
|
||||
COMMENT "Generating msvcrt import library"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(msvcrt_import_for_msvcirt ALL DEPENDS ${MSVCRT_IMPORT_LIB})
|
||||
|
||||
add_library(msvcrt_import_lib STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(msvcrt_import_lib PROPERTIES
|
||||
IMPORTED_LOCATION ${MSVCRT_IMPORT_LIB}
|
||||
)
|
||||
add_dependencies(msvcrt_import_lib msvcrt_import_for_msvcirt)
|
||||
|
||||
add_library(msvcirt SHARED
|
||||
../msvcp90/exception.c
|
||||
msvcirt.c
|
||||
${MSVCIRT_GENERATED_STUBS}
|
||||
../winecrt0/crt_dllmain.c
|
||||
../winecrt0/setjmp.c
|
||||
../winecrt0/exception.c
|
||||
${MSVCIRT_DEF}
|
||||
)
|
||||
|
||||
set_target_properties(msvcirt PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME msvcirt
|
||||
)
|
||||
|
||||
target_compile_definitions(msvcirt
|
||||
PRIVATE
|
||||
_CRTIMP=
|
||||
_MSVCIRT
|
||||
_NO_CRT_STDIO_INLINE
|
||||
_NTSYSTEM_
|
||||
__WINE_PE_BUILD
|
||||
)
|
||||
|
||||
target_compile_options(msvcirt
|
||||
PRIVATE
|
||||
-fno-builtin
|
||||
-fno-strict-aliasing
|
||||
-fno-omit-frame-pointer
|
||||
-Wno-deprecated-declarations
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-braces
|
||||
-Wno-ignored-qualifiers
|
||||
)
|
||||
|
||||
target_link_options(msvcirt
|
||||
PRIVATE
|
||||
-Wl,--enable-stdcall-fixup
|
||||
)
|
||||
|
||||
target_include_directories(msvcirt
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROJECT_SOURCE_DIR}/dlls/msvcp90
|
||||
${PROJECT_SOURCE_DIR}/dlls/msvcrt
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${PROJECT_SOURCE_DIR}/include/msvcrt
|
||||
${PROJECT_SOURCE_DIR}/include/wine
|
||||
)
|
||||
|
||||
target_link_libraries(msvcirt
|
||||
PRIVATE
|
||||
msvcrt_import_lib
|
||||
kernel32_import_lib
|
||||
ntdll_import_lib
|
||||
)
|
||||
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
target_link_libraries(msvcirt
|
||||
PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/vendor/libclang_rt.builtins-i386.a
|
||||
)
|
||||
endif()
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2015 Iván Matellanes
|
||||
*
|
||||
* 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"
|
||||
#include "windef.h"
|
||||
#include "cxx.h"
|
||||
|
||||
typedef LONG streamoff;
|
||||
typedef LONG streampos;
|
||||
typedef int filedesc;
|
||||
typedef void* (__cdecl *allocFunction)(LONG);
|
||||
typedef void (__cdecl *freeFunction)(void*);
|
||||
|
||||
typedef enum {
|
||||
IOSTATE_goodbit = 0x0,
|
||||
IOSTATE_eofbit = 0x1,
|
||||
IOSTATE_failbit = 0x2,
|
||||
IOSTATE_badbit = 0x4
|
||||
} ios_io_state;
|
||||
|
||||
typedef enum {
|
||||
OPENMODE_in = 0x1,
|
||||
OPENMODE_out = 0x2,
|
||||
OPENMODE_ate = 0x4,
|
||||
OPENMODE_app = 0x8,
|
||||
OPENMODE_trunc = 0x10,
|
||||
OPENMODE_nocreate = 0x20,
|
||||
OPENMODE_noreplace = 0x40,
|
||||
OPENMODE_binary = 0x80
|
||||
} ios_open_mode;
|
||||
|
||||
typedef enum {
|
||||
SEEKDIR_beg = 0,
|
||||
SEEKDIR_cur = 1,
|
||||
SEEKDIR_end = 2
|
||||
} ios_seek_dir;
|
||||
|
||||
typedef enum {
|
||||
FLAGS_skipws = 0x1,
|
||||
FLAGS_left = 0x2,
|
||||
FLAGS_right = 0x4,
|
||||
FLAGS_internal = 0x8,
|
||||
FLAGS_dec = 0x10,
|
||||
FLAGS_oct = 0x20,
|
||||
FLAGS_hex = 0x40,
|
||||
FLAGS_showbase = 0x80,
|
||||
FLAGS_showpoint = 0x100,
|
||||
FLAGS_uppercase = 0x200,
|
||||
FLAGS_showpos = 0x400,
|
||||
FLAGS_scientific = 0x800,
|
||||
FLAGS_fixed = 0x1000,
|
||||
FLAGS_unitbuf = 0x2000,
|
||||
FLAGS_stdio = 0x4000
|
||||
} ios_flags;
|
||||
|
||||
void __cdecl operator_delete(void*);
|
||||
void* __cdecl operator_new(SIZE_T) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(operator_delete) __WINE_MALLOC;
|
||||
|
||||
void init_exception(void*);
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,439 @@
|
||||
/*
|
||||
* Copyright 2012 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 "windef.h"
|
||||
#include "winternl.h"
|
||||
#include "rtlsupportapi.h"
|
||||
#include "wine/asm.h"
|
||||
|
||||
#define CLASS_IS_SIMPLE_TYPE 1
|
||||
#define CLASS_HAS_VIRTUAL_BASE_CLASS 4
|
||||
#define CLASS_IS_WINRT 8
|
||||
|
||||
#define TYPE_FLAG_CONST 1
|
||||
#define TYPE_FLAG_VOLATILE 2
|
||||
#define TYPE_FLAG_REFERENCE 8
|
||||
#define TYPE_FLAG_WINRT 16
|
||||
|
||||
#ifdef __i386__
|
||||
#undef CXX_USE_RVA
|
||||
#else
|
||||
#define CXX_USE_RVA 1
|
||||
#endif
|
||||
|
||||
#ifndef _WIN64
|
||||
#undef RTTI_USE_RVA
|
||||
#else
|
||||
#define RTTI_USE_RVA 1
|
||||
#endif
|
||||
|
||||
#ifdef _WIN64
|
||||
|
||||
#define VTABLE_ADD_FUNC(name) "\t.quad " THISCALL_NAME(name) "\n"
|
||||
|
||||
#define __ASM_VTABLE(name,funcs) \
|
||||
__asm__(".data\n" \
|
||||
"\t.balign 8\n" \
|
||||
"\t.quad " __ASM_NAME(#name "_rtti") "\n" \
|
||||
__ASM_GLOBL(__ASM_NAME(#name "_vtable")) "\n" \
|
||||
funcs "\n\t.text")
|
||||
|
||||
#else
|
||||
|
||||
#define VTABLE_ADD_FUNC(name) "\t.long " THISCALL_NAME(name) "\n"
|
||||
|
||||
#define __ASM_VTABLE(name,funcs) \
|
||||
__asm__(".data\n" \
|
||||
"\t.balign 4\n" \
|
||||
"\t.long " __ASM_NAME(#name "_rtti") "\n" \
|
||||
__ASM_GLOBL(__ASM_NAME(#name "_vtable")) "\n" \
|
||||
funcs "\n\t.text")
|
||||
|
||||
#endif /* _WIN64 */
|
||||
|
||||
#ifndef RTTI_USE_RVA
|
||||
|
||||
#define DEFINE_RTTI_DATA(name, off, mangled_name, ...) \
|
||||
static type_info name ## _type_info = { &type_info_vtable, NULL, mangled_name }; \
|
||||
\
|
||||
static const rtti_base_descriptor name ## _rtti_base_descriptor[1] = \
|
||||
{ { &name ##_type_info, ARRAY_SIZE(((const void *[]){ __VA_ARGS__ })), { 0, -1, 0}, 64 } }; \
|
||||
\
|
||||
static const rtti_base_array name ## _rtti_base_array = \
|
||||
{ { name ## _rtti_base_descriptor, __VA_ARGS__ } }; \
|
||||
\
|
||||
static const rtti_object_hierarchy name ## _hierarchy = \
|
||||
{ 0, 0, ARRAY_SIZE(((const void *[]){ NULL, __VA_ARGS__ })), &name ## _rtti_base_array }; \
|
||||
\
|
||||
const rtti_object_locator name ## _rtti = \
|
||||
{ 0, off, 0, &name ## _type_info, &name ## _hierarchy };
|
||||
|
||||
#define INIT_RTTI(name,base) /* nothing to do */
|
||||
|
||||
#elif defined __WINE_PE_BUILD
|
||||
|
||||
#define DEFINE_RTTI_DATA2(name, off, mangled_name, ...) \
|
||||
extern const rtti_object_locator name##_rtti; \
|
||||
type_info name ## _type_info = { &type_info_vtable, NULL, mangled_name }; \
|
||||
extern const rtti_base_descriptor name ## _rtti_base_descriptor[1]; \
|
||||
void __asm_dummy_ ## name ## _rtti(void) \
|
||||
{ \
|
||||
asm( ".balign 4\n\t" \
|
||||
__ASM_GLOBL(#name "_rtti_base_descriptor") "\n\t" \
|
||||
".rva " #name "_type_info\n\t" \
|
||||
".long %c0-1, 0, -1, 0, 64\n" \
|
||||
#name "_rtti_base_array:\n\t" \
|
||||
".rva " #__VA_ARGS__ "\n" \
|
||||
#name "_rtti_hierarchy:\n\t" \
|
||||
".long 0, 0, %c0\n\t" \
|
||||
".rva " #name "_rtti_base_array\n\t" \
|
||||
__ASM_GLOBL(#name "_rtti") "\n\t" \
|
||||
".long 1, %c1, 0\n\t" \
|
||||
".rva " #name "_type_info\n\t" \
|
||||
".rva " #name "_rtti_hierarchy\n\t" \
|
||||
".rva " #name "_rtti\n\t" \
|
||||
:: "i"(ARRAY_SIZE(((const void *[]){ __VA_ARGS__ }))), "i"(off) ); \
|
||||
}
|
||||
#define DEFINE_RTTI_DATA(name, off, mangled_name, ...) \
|
||||
DEFINE_RTTI_DATA2(name, off, mangled_name, name ## _rtti_base_descriptor, ##__VA_ARGS__)
|
||||
|
||||
#define INIT_RTTI(name,base) /* nothing to do */
|
||||
|
||||
#else /* RTTI_USE_RVA */
|
||||
|
||||
#define DEFINE_RTTI_DATA(name, off, mangled_name, ...) \
|
||||
static type_info name ## _type_info = { &type_info_vtable, NULL, mangled_name }; \
|
||||
\
|
||||
static rtti_base_descriptor name ## _rtti_base_descriptor[1] = \
|
||||
{ { 0xdeadbeef, ARRAY_SIZE(((const void *[]){ __VA_ARGS__ })), { 0, -1, 0}, 64 } }; \
|
||||
\
|
||||
static rtti_base_array name ## _rtti_base_array; \
|
||||
\
|
||||
static rtti_object_hierarchy name ## _hierarchy = \
|
||||
{ 0, 0, ARRAY_SIZE(((const void *[]){ NULL, __VA_ARGS__ })) }; \
|
||||
\
|
||||
rtti_object_locator name ## _rtti = \
|
||||
{ 1, off, 0, 0xdeadbeef, 0xdeadbeef, 0xdeadbeef }; \
|
||||
\
|
||||
static void init_ ## name ## _rtti(char *base) \
|
||||
{ \
|
||||
const void * const name ## _rtti_bases[] = { name ## _rtti_base_descriptor, __VA_ARGS__ }; \
|
||||
name ## _rtti_base_descriptor[0].type_descriptor = (char*)&name ## _type_info - base; \
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(name ## _rtti_bases); i++) \
|
||||
name ## _rtti_base_array.bases[i] = (char*)name ## _rtti_bases[i] - base; \
|
||||
name ## _hierarchy.base_classes = (char*)&name ## _rtti_base_array - base; \
|
||||
name ## _rtti.type_descriptor = (char*)&name ## _type_info - base; \
|
||||
name ## _rtti.type_hierarchy = (char*)&name ## _hierarchy - base; \
|
||||
name ## _rtti.object_locator = (char*)&name ## _rtti - base; \
|
||||
}
|
||||
|
||||
#define INIT_RTTI(name,base) init_ ## name ## _rtti((void *)(base))
|
||||
|
||||
#endif /* RTTI_USE_RVA */
|
||||
|
||||
#ifndef CXX_USE_RVA
|
||||
|
||||
#define DEFINE_CXX_TYPE(type, dtor, ...) \
|
||||
static const cxx_type_info type ## _cxx_type_info[1] = \
|
||||
{ { 0, &type ##_type_info, { 0, -1, 0 }, sizeof(type), THISCALL(type ##_copy_ctor) } }; \
|
||||
\
|
||||
static const cxx_type_info_table type ## _cxx_type_table = \
|
||||
{ ARRAY_SIZE(((const void *[]){ NULL, __VA_ARGS__ })), { type ## _cxx_type_info, __VA_ARGS__ } }; \
|
||||
\
|
||||
static const cxx_exception_type type ## _exception_type = \
|
||||
{ 0, THISCALL(dtor), NULL, & type ## _cxx_type_table };
|
||||
|
||||
#define INIT_CXX_TYPE(name,base) (void)name ## _exception_type
|
||||
|
||||
#elif defined __WINE_PE_BUILD
|
||||
|
||||
#define DEFINE_CXX_TYPE2(type, dtor, ...) \
|
||||
extern const cxx_type_info type ## _cxx_type_info[1]; \
|
||||
extern const cxx_exception_type type ## _exception_type; \
|
||||
void __asm_dummy_ ## type ## _exception_type(void) \
|
||||
{ \
|
||||
asm( ".balign 4\n\t" \
|
||||
__ASM_GLOBL(#type "_cxx_type_info") "\n\t" \
|
||||
".long 0\n\t" \
|
||||
".rva " #type "_type_info\n\t" \
|
||||
".long 0, -1, 0, %c0\n\t" \
|
||||
".rva " #type "_copy_ctor\n" \
|
||||
#type "_type_table:\n\t" \
|
||||
".long %c1\n\t" \
|
||||
".rva " #__VA_ARGS__ "\n\t" \
|
||||
__ASM_GLOBL(#type "_exception_type") "\n\t" \
|
||||
".long 0\n\t" \
|
||||
".rva " #dtor "\n\t" \
|
||||
".long 0\n\t" \
|
||||
".rva " #type "_type_table\n\t" \
|
||||
:: "i"(sizeof(type)), "i"(ARRAY_SIZE(((const void *[]){ &__VA_ARGS__ }))) ); \
|
||||
}
|
||||
#define DEFINE_CXX_TYPE(type, dtor, ...) \
|
||||
DEFINE_CXX_TYPE2(type, dtor, type ## _cxx_type_info, ##__VA_ARGS__)
|
||||
|
||||
#define INIT_CXX_TYPE(name,base) /* nothing to do */
|
||||
|
||||
#else /* CXX_USE_RVA */
|
||||
|
||||
#define DEFINE_CXX_TYPE(type, dtor, ...) \
|
||||
static cxx_type_info type ## _cxx_type_info[1] = \
|
||||
{ { 0, 0xdeadbeef, { 0, -1, 0 }, sizeof(type), 0xdeadbeef } }; \
|
||||
\
|
||||
static const void * const type ## _cxx_type_classes[] = { type ## _cxx_type_info, __VA_ARGS__ }; \
|
||||
static cxx_type_info_table type ## _cxx_type_table = { ARRAY_SIZE(type ## _cxx_type_classes) }; \
|
||||
static cxx_exception_type type ##_exception_type; \
|
||||
\
|
||||
static void init_ ## type ## _cxx(char *base) \
|
||||
{ \
|
||||
type ## _cxx_type_info[0].type_info = (char *)&type ## _type_info - base; \
|
||||
type ## _cxx_type_info[0].copy_ctor = (char *)type ## _copy_ctor - base; \
|
||||
for (unsigned int i = 0; i < ARRAY_SIZE(type ## _cxx_type_classes); i++) \
|
||||
type ## _cxx_type_table.info[i] = (char *)type ## _cxx_type_classes[i] - base; \
|
||||
type ## _exception_type.destructor = (char *)dtor - base; \
|
||||
type ## _exception_type.type_info_table = (char *)&type ## _cxx_type_table - base; \
|
||||
}
|
||||
|
||||
#define INIT_CXX_TYPE(name,base) init_ ## name ## _cxx((void *)(base))
|
||||
|
||||
#endif /* CXX_USE_RVA */
|
||||
|
||||
#ifdef __ASM_USE_THISCALL_WRAPPER
|
||||
|
||||
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (WINAPI*)type)&vtbl_wrapper_##off)args
|
||||
|
||||
extern void *vtbl_wrapper_0;
|
||||
extern void *vtbl_wrapper_4;
|
||||
extern void *vtbl_wrapper_8;
|
||||
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;
|
||||
extern void *vtbl_wrapper_44;
|
||||
extern void *vtbl_wrapper_48;
|
||||
extern void *vtbl_wrapper_52;
|
||||
extern void *vtbl_wrapper_56;
|
||||
|
||||
#else
|
||||
|
||||
#define CALL_VTBL_FUNC(this, off, ret, type, args) ((ret (__thiscall***)type)this)[0][off/4]args
|
||||
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
|
||||
/* rtti */
|
||||
typedef struct __type_info
|
||||
{
|
||||
const vtable_ptr *vtable;
|
||||
char *name; /* Unmangled name, allocated lazily */
|
||||
char mangled[128]; /* 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;
|
||||
|
||||
#ifndef RTTI_USE_RVA
|
||||
|
||||
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[10]; /* 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;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int type_descriptor;
|
||||
int num_base_classes;
|
||||
this_ptr_offsets offsets; /* offsets for computing the this pointer */
|
||||
unsigned int attributes;
|
||||
} rtti_base_descriptor;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int bases[10]; /* First element is the class itself */
|
||||
} rtti_base_array;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int signature;
|
||||
unsigned int attributes;
|
||||
int array_len; /* Size of the array pointed to by 'base_classes' */
|
||||
unsigned int base_classes;
|
||||
} rtti_object_hierarchy;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int signature;
|
||||
int base_class_offset;
|
||||
unsigned int flags;
|
||||
unsigned int type_descriptor;
|
||||
unsigned int type_hierarchy;
|
||||
unsigned int object_locator;
|
||||
} rtti_object_locator;
|
||||
|
||||
#endif /* RTTI_USE_RVA */
|
||||
|
||||
#ifndef CXX_USE_RVA
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT flags;
|
||||
const type_info *type_info;
|
||||
this_ptr_offsets offsets;
|
||||
unsigned int size;
|
||||
void *copy_ctor;
|
||||
} cxx_type_info;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT count;
|
||||
const cxx_type_info *info[5];
|
||||
} cxx_type_info_table;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT flags;
|
||||
void *destructor;
|
||||
void *custom_handler;
|
||||
const cxx_type_info_table *type_info_table;
|
||||
} cxx_exception_type;
|
||||
|
||||
#else
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT flags;
|
||||
unsigned int type_info;
|
||||
this_ptr_offsets offsets;
|
||||
unsigned int size;
|
||||
unsigned int copy_ctor;
|
||||
} cxx_type_info;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT count;
|
||||
unsigned int info[5];
|
||||
} cxx_type_info_table;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT flags;
|
||||
unsigned int destructor;
|
||||
unsigned int custom_handler;
|
||||
unsigned int type_info_table;
|
||||
} cxx_exception_type;
|
||||
|
||||
#endif /* CXX_USE_RVA */
|
||||
|
||||
extern const vtable_ptr type_info_vtable;
|
||||
|
||||
#ifdef CXX_USE_RVA
|
||||
|
||||
static inline uintptr_t cxx_rva_base( const void *ptr )
|
||||
{
|
||||
void *base;
|
||||
return (uintptr_t)RtlPcToFileHeader( (void *)ptr, &base );
|
||||
}
|
||||
|
||||
static inline void *cxx_rva( unsigned int rva, uintptr_t base )
|
||||
{
|
||||
return (void *)(base + rva);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static inline uintptr_t cxx_rva_base( const void *ptr )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void *cxx_rva( const void *ptr, uintptr_t base )
|
||||
{
|
||||
return (void *)ptr;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#define CREATE_TYPE_INFO_VTABLE \
|
||||
DEFINE_THISCALL_WRAPPER(type_info_vector_dtor,8) \
|
||||
void * __thiscall type_info_vector_dtor(type_info * _this, unsigned int flags) \
|
||||
{ \
|
||||
if (flags & 2) \
|
||||
{ \
|
||||
/* we have an array, with the number of elements stored before the first object */ \
|
||||
INT_PTR i, *ptr = (INT_PTR *)_this - 1; \
|
||||
\
|
||||
for (i = *ptr - 1; i >= 0; i--) free(_this[i].name); \
|
||||
free(ptr); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
free(_this->name); \
|
||||
if (flags & 1) free(_this); \
|
||||
} \
|
||||
return _this; \
|
||||
} \
|
||||
\
|
||||
DEFINE_RTTI_DATA( type_info, 0, ".?AVtype_info@@" ) \
|
||||
\
|
||||
__ASM_BLOCK_BEGIN(type_info_vtables) \
|
||||
__ASM_VTABLE(type_info, \
|
||||
VTABLE_ADD_FUNC(type_info_vector_dtor)); \
|
||||
__ASM_BLOCK_END
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,75 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(MSVCRT40_GENERATED_STUBS ${CMAKE_CURRENT_BINARY_DIR}/generated_stubs.c)
|
||||
set(MSVCRT40_DEF ${CMAKE_CURRENT_BINARY_DIR}/msvcrt40.def)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT40_GENERATED_STUBS}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_STUBS_TOOL}
|
||||
--arch i386
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcrt40.spec
|
||||
${MSVCRT40_GENERATED_STUBS}
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcrt40.spec
|
||||
${GENERATE_STUBS_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating msvcrt40 stubs"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${MSVCRT40_DEF}
|
||||
COMMAND ${Python3_EXECUTABLE} ${GENERATE_DEF_TOOL}
|
||||
--arch i386
|
||||
--no-stdcall-suffix
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcrt40.spec
|
||||
${MSVCRT40_DEF}
|
||||
DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/msvcrt40.spec
|
||||
${GENERATE_DEF_TOOL}
|
||||
${SPEC_PARSER_LIB}
|
||||
COMMENT "Generating msvcrt40.def"
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_library(msvcrt40 SHARED
|
||||
msvcrt40.c
|
||||
${MSVCRT40_GENERATED_STUBS}
|
||||
../winecrt0/crt_dllmain.c
|
||||
${MSVCRT40_DEF}
|
||||
)
|
||||
|
||||
set_target_properties(msvcrt40 PROPERTIES
|
||||
PREFIX ""
|
||||
OUTPUT_NAME msvcrt40
|
||||
)
|
||||
|
||||
target_compile_definitions(msvcrt40
|
||||
PRIVATE
|
||||
_CRTIMP=
|
||||
_NTSYSTEM_
|
||||
__WINE_PE_BUILD
|
||||
)
|
||||
|
||||
target_compile_options(msvcrt40
|
||||
PRIVATE
|
||||
-fno-builtin
|
||||
-fno-strict-aliasing
|
||||
-fno-omit-frame-pointer
|
||||
-Wno-deprecated-declarations
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-braces
|
||||
-Wno-ignored-qualifiers
|
||||
)
|
||||
|
||||
target_link_options(msvcrt40
|
||||
PRIVATE
|
||||
-Wl,--enable-stdcall-fixup
|
||||
)
|
||||
|
||||
target_include_directories(msvcrt40
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/include
|
||||
${PROJECT_SOURCE_DIR}/include/msvcrt
|
||||
${PROJECT_SOURCE_DIR}/include/wine
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user