winebuild-Fake_Dlls: Get rid of dependency on ntdll-User_Shared_Data.

By using the marginally documented 'SystemCall' field rather than adding our own.

Note that the SystemCall field is only 32 bits wide even on 64-bit systems, so we have to write over the SystemCallReturn field as well. Since we don't need return thunks this should be fine.
This commit is contained in:
Zebediah Figura 2018-06-20 00:07:16 -05:00
parent ae4862e0fb
commit c9eaabbba9
3 changed files with 38 additions and 77 deletions

View File

@ -1884,13 +1884,6 @@ if test "$enable_wined3d_CSMT_Main" -eq 1; then
enable_wined3d_UAV_Counters=1
fi
if test "$enable_winebuild_Fake_Dlls" -eq 1; then
if test "$enable_ntdll_User_Shared_Data" -gt 1; then
abort "Patchset ntdll-User_Shared_Data disabled, but winebuild-Fake_Dlls depends on that."
fi
enable_ntdll_User_Shared_Data=1
fi
if test "$enable_wineboot_ProxySettings" -eq 1; then
if test "$enable_wineboot_DriveSerial" -gt 1; then
abort "Patchset wineboot-DriveSerial disabled, but wineboot-ProxySettings depends on that."
@ -7543,9 +7536,6 @@ fi
# Patchset winebuild-Fake_Dlls
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-ThreadTime, ntdll-Hide_Wine_Exports, ntdll-User_Shared_Data
# |
# | This patchset fixes the following Wine bugs:
# | * [#21232] Chromium-based browser engines (Chrome, Opera, Comodo Dragon, SRWare Iron) crash on startup unless '--no-
# | sandbox' is used (native API sandboxing/hooking scheme incompatible with Wine)

View File

@ -1,4 +1,4 @@
From e6812e345ddbfdf41222de31025661cc7c66c747 Mon Sep 17 00:00:00 2001
From 57bc2f7968034641df20e843a9b26014153202f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Thu, 7 Sep 2017 00:38:09 +0200
Subject: tools/winebuild: Add syscall thunks for 64 bit.
@ -6,17 +6,17 @@ Subject: tools/winebuild: Add syscall thunks for 64 bit.
---
dlls/kernel32/tests/loader.c | 7 +-
dlls/ntdll/signal_x86_64.c | 3 +
dlls/ntdll/thread.c | 7 +-
dlls/ntdll/thread.c | 4 +
libs/wine/loader.c | 4 +
tools/winebuild/parser.c | 2 +-
tools/winebuild/spec32.c | 211 +++++++++++++++++++++++++++++++++++++++++--
6 files changed, 224 insertions(+), 10 deletions(-)
tools/winebuild/spec32.c | 192 +++++++++++++++++++++++++++++++++++++++++--
6 files changed, 203 insertions(+), 9 deletions(-)
diff --git a/dlls/kernel32/tests/loader.c b/dlls/kernel32/tests/loader.c
index 57b2b08aeca..1a47abe5a4f 100644
index 65b09d4..ec19d5f 100644
--- a/dlls/kernel32/tests/loader.c
+++ b/dlls/kernel32/tests/loader.c
@@ -858,7 +858,7 @@ static void test_Loader(void)
@@ -1360,7 +1360,7 @@ static void test_filenames(void)
static void test_FakeDLL(void)
{
@ -25,7 +25,7 @@ index 57b2b08aeca..1a47abe5a4f 100644
NTSTATUS (WINAPI *pNtSetEvent)(HANDLE, ULONG *) = NULL;
IMAGE_EXPORT_DIRECTORY *dir;
HMODULE module = GetModuleHandleA("ntdll.dll");
@@ -900,8 +900,13 @@ static void test_FakeDLL(void)
@@ -1402,8 +1402,13 @@ static void test_FakeDLL(void)
dll_func = (BYTE *)GetProcAddress(module, func_name);
ok(dll_func != NULL, "%s: GetProcAddress returned NULL\n", func_name);
@ -40,10 +40,10 @@ index 57b2b08aeca..1a47abe5a4f 100644
todo_wine ok(0, "%s: Export is a stub-function, skipping\n", func_name);
continue;
diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c
index a74825c3c36..83bcd4d46f7 100644
index 0d25360..bb344bb 100644
--- a/dlls/ntdll/signal_x86_64.c
+++ b/dlls/ntdll/signal_x86_64.c
@@ -326,6 +326,8 @@ static inline struct amd64_thread_data *amd64_thread_data(void)
@@ -328,6 +328,8 @@ static inline struct amd64_thread_data *amd64_thread_data(void)
return (struct amd64_thread_data *)NtCurrentTeb()->SystemReserved2;
}
@ -52,7 +52,7 @@ index a74825c3c36..83bcd4d46f7 100644
/***********************************************************************
* Dynamic unwind table
*/
@@ -2973,6 +2975,7 @@ NTSTATUS signal_alloc_thread( TEB **teb )
@@ -3276,6 +3278,7 @@ NTSTATUS signal_alloc_thread( TEB **teb )
{
(*teb)->Tib.Self = &(*teb)->Tib;
(*teb)->Tib.ExceptionList = (void *)~0UL;
@ -61,11 +61,11 @@ index a74825c3c36..83bcd4d46f7 100644
return status;
}
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 86e5047facb..8b9df0cc7c0 100644
index 59d64e1..84e9e45 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -60,6 +60,8 @@ struct _KUSER_SHARED_DATA *user_shared_data_external;
struct _KUSER_SHARED_DATA *user_shared_data = &user_shared_data_internal;
@@ -55,6 +55,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread);
struct _KUSER_SHARED_DATA *user_shared_data = NULL;
static const WCHAR default_windirW[] = {'C',':','\\','w','i','n','d','o','w','s',0};
+extern void DECLSPEC_NORETURN __wine_syscall_dispatcher( void );
@ -73,27 +73,17 @@ index 86e5047facb..8b9df0cc7c0 100644
PUNHANDLED_EXCEPTION_FILTER unhandled_exception_filter = NULL;
void (WINAPI *kernel32_start_process)(LPTHREAD_START_ROUTINE,void*) = NULL;
@@ -89,7 +91,6 @@ static RTL_CRITICAL_SECTION_DEBUG critse
};
static RTL_CRITICAL_SECTION peb_lock = { &critsect_debug, -1, 0, 0, 0, 0 };
@@ -401,6 +403,8 @@ HANDLE thread_init(void)
user_shared_data->TickCountLowDeprecated = user_shared_data->u.TickCount.LowPart;
user_shared_data->TickCountMultiplier = 1 << 24;
-
BOOL read_process_time(int unix_pid, int unix_tid, unsigned long clk_tck,
LARGE_INTEGER *kernel, LARGE_INTEGER *user)
{
@@ -497,6 +498,10 @@ HANDLE thread_init(void)
InitializeListHead( &ldr.InInitializationOrderModuleList );
*(ULONG_PTR *)peb->Reserved = get_image_addr();
+#if defined(__APPLE__) && defined(__x86_64__)
+ *((DWORD*)((char*)user_shared_data_external + 0x1000)) = __wine_syscall_dispatcher;
+#endif
+ *((void **)&user_shared_data->SystemCall) = __wine_syscall_dispatcher;
+
/*
* Starting with Vista, the first user to log on has session id 1.
* Session id 0 is for processes that don't interact with the user (like services).
fill_cpu_info();
NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 );
diff --git a/libs/wine/loader.c b/libs/wine/loader.c
index 0a64ea4a73b..e2ae56df427 100644
index 0a64ea4..e2ae56d 100644
--- a/libs/wine/loader.c
+++ b/libs/wine/loader.c
@@ -455,7 +455,11 @@ static void *map_dll( const IMAGE_NT_HEADERS *nt_descr )
@ -109,7 +99,7 @@ index 0a64ea4a73b..e2ae56df427 100644
sec++;
diff --git a/tools/winebuild/parser.c b/tools/winebuild/parser.c
index c4b9abfc9fc..064019c4404 100644
index c4b9abf..064019c 100644
--- a/tools/winebuild/parser.c
+++ b/tools/winebuild/parser.c
@@ -521,7 +521,7 @@ static const char *parse_spec_flags( DLLSPEC *spec, ORDDEF *odp )
@ -122,10 +112,10 @@ index c4b9abfc9fc..064019c4404 100644
if (odp->flags & (FLAG_FORWARD | FLAG_REGISTER))
return 0;
diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c
index 6b6f4afae77..e7ae6f6eaee 100644
index 430c7a5..d4dc8ea 100644
--- a/tools/winebuild/spec32.c
+++ b/tools/winebuild/spec32.c
@@ -299,11 +299,11 @@ static void output_relay_debug( DLLSPEC *spec )
@@ -342,11 +342,11 @@ static void output_relay_debug( DLLSPEC *spec )
}
/*******************************************************************
@ -139,7 +129,7 @@ index 6b6f4afae77..e7ae6f6eaee 100644
{
const unsigned int page_size = get_page_size();
int i;
@@ -369,7 +369,91 @@ static void output_syscall_thunks( DLLSPEC *spec )
@@ -412,7 +412,81 @@ static void output_syscall_thunks( DLLSPEC *spec )
output( "1:\tpopl %%ecx\n" );
output( "\tjmpl *(%s-1b)(%%ecx,%%eax,%d)\n", asm_name("__wine_syscall_table"), get_ptr_size() );
}
@ -184,19 +174,9 @@ index 6b6f4afae77..e7ae6f6eaee 100644
+ output( "\t%s\n", func_declaration(name) );
+ output( "%s\n", asm_globl(name) );
+ output_cfi( ".cfi_startproc" );
+ output( "\t.byte 0xb8\n" ); /* mov eax, SYSCALL */
+ output( "\t.long %d\n", i );
+ if (target_platform == PLATFORM_APPLE)
+ {
+ output( "\t.byte 0xff,0x14,0x25\n" ); /* call [0x7ffe1000] */
+ output( "\t.long 0x7ffe1000\n" );
+ }
+ else
+ {
+ output( "\t.byte 0x65,0xff,0x14,0x25\n" ); /* call qword ptr gs:[0x100] */
+ output( "\t.long 0x100\n");
+ }
+ output( "\t.byte 0xc3\n" ); /* ret */
+ output( "\tmov $%d, %%eax\n", i );
+ output( "\tcall *0x7ffe0300\n" ); /* KUSER_SHARED_DATA->SystemCall */
+ output( "\tret\n" );
+ output_cfi( ".cfi_endproc" );
+ output_function_size( name );
+ }
@ -232,7 +212,7 @@ index 6b6f4afae77..e7ae6f6eaee 100644
output( "\tret\n" );
output_cfi( ".cfi_endproc" );
output_function_size( "__wine_syscall_dispatcher" );
@@ -732,7 +816,10 @@ void BuildSpec32File( DLLSPEC *spec )
@@ -775,7 +849,10 @@ void BuildSpec32File( DLLSPEC *spec )
resolve_imports( spec );
output_standard_file_header();
output_module( spec );
@ -244,7 +224,7 @@ index 6b6f4afae77..e7ae6f6eaee 100644
output_stubs( spec );
output_exports( spec );
output_imports( spec );
@@ -744,7 +831,7 @@ void BuildSpec32File( DLLSPEC *spec )
@@ -787,7 +864,7 @@ void BuildSpec32File( DLLSPEC *spec )
static int needs_stub_exports( DLLSPEC *spec )
{
@ -253,7 +233,7 @@ index 6b6f4afae77..e7ae6f6eaee 100644
return 0;
if (!(spec->characteristics & IMAGE_FILE_DLL))
return 0;
@@ -754,7 +841,7 @@ static int needs_stub_exports( DLLSPEC *spec )
@@ -797,7 +874,7 @@ static int needs_stub_exports( DLLSPEC *spec )
}
@ -262,7 +242,7 @@ index 6b6f4afae77..e7ae6f6eaee 100644
{
int i, nr_exports = spec->base <= spec->limit ? spec->limit - spec->base + 1 : 0;
size_t rva, thunk;
@@ -916,6 +1003,113 @@ static void create_stub_exports_text( DLLSPEC *spec )
@@ -959,6 +1036,104 @@ static void create_stub_exports_text( DLLSPEC *spec )
}
@ -277,18 +257,9 @@ index 6b6f4afae77..e7ae6f6eaee 100644
+
+ align_output_rva( 16, 16 );
+ put_label( odp->link_name );
+ put_byte( 0xb8 ); put_dword( i ); /* mov eax, SYSCALL */
+ if (target_platform == PLATFORM_APPLE)
+ {
+ put_byte( 0xff ); put_byte( 0x14 ); /* call [0x7ffe1000] */
+ put_byte( 0x25 ); put_dword( 0x7ffe1000 );
+ }
+ else
+ {
+ put_byte( 0x65 ); put_byte( 0xff ); /* call ptr gs:[0x100] */
+ put_byte( 0x14 ); put_byte( 0x25 ); put_dword( 0x100 );
+
+ }
+ put_byte( 0xb8 ); put_dword( i ); /* mov SYSCALL, %eax */
+ put_byte( 0xff ); put_byte( 0x14 ); /* call *0x7ffe0300 */
+ put_byte( 0x25 ); put_dword( 0x7ffe0300 );
+ put_byte( 0xc3 ); /* ret */
+ }
+
@ -376,7 +347,7 @@ index 6b6f4afae77..e7ae6f6eaee 100644
static void create_stub_exports_data( DLLSPEC *spec )
{
int i;
@@ -1115,7 +1309,10 @@ static void output_fake_module_pass( DLLSPEC *spec )
@@ -1158,7 +1333,10 @@ static void output_fake_module_pass( DLLSPEC *spec )
if (needs_stub_exports( spec ))
{
put_label( "text_start" );
@ -389,4 +360,5 @@ index 6b6f4afae77..e7ae6f6eaee 100644
}
else
--
2.14.1
2.7.4

View File

@ -1,4 +1,3 @@
Fixes: [21232] Chromium-based browser engines (Chrome, Opera, Comodo Dragon, SRWare Iron) crash on startup unless '--no-sandbox' is used (native API sandboxing/hooking scheme incompatible with Wine)
Fixes: [42741] StarCraft I: 1.18 PTR fails to initialize ClientSdk.dll
Fixes: [45349] Multiple applications and games crash due to missing support for 64-bit syscall thunks (StreetFighter V)
Depends: ntdll-User_Shared_Data