From d2d0366ce5df254957a96bb6b7eb02c1616dba1d Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 14 Jul 2020 16:06:00 +0300 Subject: [PATCH] Added winebuild-pe_syscall_thunks patchset. Restores the major bits of functionality of the former 'winebuild-Fake_Dlls' patchset which are yet missing upstream. --- patches/patchinstall.sh | 32 +++ ...gn-stack-pointer-in-__wine_syscall_d.patch | 59 +++++ ..._wine_syscall_dispatcher-through-the.patch | 77 +++++++ ...ate-syscall-thunks-for-Nt-functions-.patch | 205 ++++++++++++++++++ ...ontextThread-on-i386-with-PE-syscall.patch | 55 +++++ .../winebuild-pe_syscall_thunks/definition | 5 + 6 files changed, 433 insertions(+) create mode 100644 patches/winebuild-pe_syscall_thunks/0001-ntdll-Always-align-stack-pointer-in-__wine_syscall_d.patch create mode 100644 patches/winebuild-pe_syscall_thunks/0002-winebuild-Call-__wine_syscall_dispatcher-through-the.patch create mode 100644 patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch create mode 100644 patches/winebuild-pe_syscall_thunks/0004-ntdll-Fix-NtGetContextThread-on-i386-with-PE-syscall.patch create mode 100644 patches/winebuild-pe_syscall_thunks/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 7587bc21..06856d10 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -281,6 +281,7 @@ patch_enable_all () enable_wineboot_HKEY_DYN_DATA="$1" enable_wineboot_ProxySettings="$1" enable_wineboot_drivers_etc_Stubs="$1" + enable_winebuild_pe_syscall_thunks="$1" enable_winecfg_Libraries="$1" enable_winecfg_Staging="$1" enable_wined3d_Accounting="$1" @@ -930,6 +931,9 @@ patch_enable () wineboot-drivers_etc_Stubs) enable_wineboot_drivers_etc_Stubs="$2" ;; + winebuild-pe_syscall_thunks) + enable_winebuild_pe_syscall_thunks="$2" + ;; winecfg-Libraries) enable_winecfg_Libraries="$2" ;; @@ -5437,6 +5441,34 @@ if test "$enable_wineboot_ProxySettings" -eq 1; then ) >> "$patchlist" fi +# Patchset winebuild-pe_syscall_thunks +# | +# | 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) +# | * [#42741] StarCraft I: 1.18 PTR fails to initialize ClientSdk.dll +# | * [#45349] Multiple applications and games crash due to missing support for 64-bit syscall thunks (StreetFighter V, World +# | of Warcraft) +# | * [#45573] League of Legends 8.12+ fails to start a game (anticheat engine, hooking of syscall return instructions) +# | * [#45650] chromium 32-bit sandbox expects different syscall thunks depending on Windows version +# | +# | Modified files: +# | * dlls/ntdll/ntdll.spec, dlls/ntdll/signal_i386.c, dlls/ntdll/unix/loader.c, dlls/ntdll/unix/virtual.c, +# | tools/winebuild/import.c, tools/winebuild/spec32.c +# | +if test "$enable_winebuild_pe_syscall_thunks" -eq 1; then + patch_apply winebuild-pe_syscall_thunks/0001-ntdll-Always-align-stack-pointer-in-__wine_syscall_d.patch + patch_apply winebuild-pe_syscall_thunks/0002-winebuild-Call-__wine_syscall_dispatcher-through-the.patch + patch_apply winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch + patch_apply winebuild-pe_syscall_thunks/0004-ntdll-Fix-NtGetContextThread-on-i386-with-PE-syscall.patch + ( + printf '%s\n' '+ { "Paul Gofman", "ntdll: Always align stack pointer in __wine_syscall_dispatcher on x64.", 1 },'; + printf '%s\n' '+ { "Paul Gofman", "winebuild: Call __wine_syscall_dispatcher through the fixed address.", 1 },'; + printf '%s\n' '+ { "Paul Gofman", "ntdll: Also generate syscall thunks for Nt functions not yet in the Unix part.", 1 },'; + printf '%s\n' '+ { "Paul Gofman", "ntdll: Fix NtGetContextThread on i386 with PE syscall thunks.", 1 },'; + ) >> "$patchlist" +fi + # Patchset winecfg-Libraries # | # | Modified files: diff --git a/patches/winebuild-pe_syscall_thunks/0001-ntdll-Always-align-stack-pointer-in-__wine_syscall_d.patch b/patches/winebuild-pe_syscall_thunks/0001-ntdll-Always-align-stack-pointer-in-__wine_syscall_d.patch new file mode 100644 index 00000000..855e14fc --- /dev/null +++ b/patches/winebuild-pe_syscall_thunks/0001-ntdll-Always-align-stack-pointer-in-__wine_syscall_d.patch @@ -0,0 +1,59 @@ +From 4b84ee691550970aa6f599ca649316f20272f84a Mon Sep 17 00:00:00 2001 +From: Paul Gofman +Date: Tue, 14 Jul 2020 02:41:53 +0300 +Subject: [PATCH] ntdll: Always align stack pointer in + __wine_syscall_dispatcher on x64. + +Syscall thunks break stack alignment for dispatcher. Regardless of that, +it is probably better not to assume aligned stack in syscall thunk entry. +--- + tools/winebuild/import.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c +index 97191ca89ec2..4f641825e367 100644 +--- a/tools/winebuild/import.c ++++ b/tools/winebuild/import.c +@@ -1497,23 +1497,25 @@ void output_syscalls( DLLSPEC *spec ) + * depends on us returning to it. Adjust the return address accordingly. */ + output( "\tsubq $0xb,0x8(%%rbp)\n" ); + output( "\tcmpq $%u,%%rax\n", count ); +- output( "\tjae 3f\n" ); ++ output( "\tjae 4f\n" ); + output( "\tleaq .Lsyscall_args(%%rip),%%rcx\n" ); + output( "\tmovzbl (%%rcx,%%rax),%%ecx\n" ); + output( "\tsubq $0x20,%%rcx\n" ); +- output( "\tjbe 1f\n" ); +- output( "\tsubq %%rcx,%%rsp\n" ); ++ output( "\tja 1f\n" ); ++ output( "\tandq $~15,%%rsp\n\t" ); ++ output( "\tjmp 2f\n" ); ++ output( "1:\tsubq %%rcx,%%rsp\n" ); + output( "\tshrq $3,%%rcx\n" ); + output( "\tleaq 0x38(%%rbp),%%rsi\n" ); + output( "\tandq $~15,%%rsp\n\t" ); + output( "\tmovq %%rsp,%%rdi\n" ); + output( "\tcld\n" ); + output( "\trep; movsq\n" ); +- output( "1:\tmovq %%r10,%%rcx\n" ); ++ output( "2:\tmovq %%r10,%%rcx\n" ); + output( "\tsubq $0x20,%%rsp\n" ); + output( "\tleaq .Lsyscall_table(%%rip),%%r10\n" ); + output( "\tcallq *(%%r10,%%rax,8)\n" ); +- output( "2:\tleaq -0x10(%%rbp),%%rsp\n" ); ++ output( "3:\tleaq -0x10(%%rbp),%%rsp\n" ); + output( "\tpopq %%rdi\n" ); + output_cfi( ".cfi_same_value %%rdi" ); + output( "\tpopq %%rsi\n" ); +@@ -1523,7 +1525,7 @@ void output_syscalls( DLLSPEC *spec ) + output_cfi( ".cfi_adjust_cfa_offset -8" ); + output_cfi( ".cfi_same_value %%rbp" ); + output( "\tret\n" ); +- output( "3:\tmovl $0x%x,%%eax\n", invalid_param ); ++ output( "4:\tmovl $0x%x,%%eax\n", invalid_param ); + output( "\tjmp 2b\n" ); + break; + case CPU_ARM: +-- +2.26.2 + diff --git a/patches/winebuild-pe_syscall_thunks/0002-winebuild-Call-__wine_syscall_dispatcher-through-the.patch b/patches/winebuild-pe_syscall_thunks/0002-winebuild-Call-__wine_syscall_dispatcher-through-the.patch new file mode 100644 index 00000000..ecf1da0b --- /dev/null +++ b/patches/winebuild-pe_syscall_thunks/0002-winebuild-Call-__wine_syscall_dispatcher-through-the.patch @@ -0,0 +1,77 @@ +From 7ef3c9eaa792085641feefd5ee7f7bc157093064 Mon Sep 17 00:00:00 2001 +From: Paul Gofman +Date: Tue, 14 Jul 2020 14:43:01 +0300 +Subject: [PATCH] winebuild: Call __wine_syscall_dispatcher through the fixed + address. +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Based on a patch by Erich E. Hoover and Michael Müller. + +Helps applications which directly load ntdll.dll from disk and +call syscall thunks from the loaded image. +--- + dlls/ntdll/unix/virtual.c | 6 ++++-- + tools/winebuild/import.c | 8 ++++---- + 2 files changed, 8 insertions(+), 6 deletions(-) + +diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c +index d7d7bd9084f6..60d27d31c4a9 100644 +--- a/dlls/ntdll/unix/virtual.c ++++ b/dlls/ntdll/unix/virtual.c +@@ -2796,20 +2796,22 @@ TEB *virtual_alloc_first_teb(void) + TEB *teb; + PEB *peb; + NTSTATUS status; +- SIZE_T data_size = page_size; ++ SIZE_T data_size = page_size * 2; + SIZE_T peb_size = page_size; + SIZE_T teb_size = signal_stack_mask + 1; + SIZE_T total = 32 * teb_size; + + /* reserve space for shared user data */ + status = NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&user_shared_data, 0, &data_size, +- MEM_RESERVE | MEM_COMMIT, PAGE_READONLY ); ++ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE ); + if (status) + { + ERR( "wine: failed to map the shared user data: %08x\n", status ); + exit(1); + } + ++ *((void **)((char *)user_shared_data + 0x1000)) = __wine_syscall_dispatcher; ++ + NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&teb_block, 0, &total, + MEM_RESERVE | MEM_TOP_DOWN, PAGE_READWRITE ); + teb_block_pos = 30; +diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c +index 4f641825e367..cf251c9b77d4 100644 +--- a/tools/winebuild/import.c ++++ b/tools/winebuild/import.c +@@ -1613,10 +1613,10 @@ void output_syscalls( DLLSPEC *spec ) + output( "\t.byte 0xc3\n" ); /* ret */ + output( "\tjmp 1f\n" ); + output( "\t.byte 0xc3\n" ); /* ret */ +- if (target_platform == PLATFORM_WINDOWS) ++ if (target_platform == PLATFORM_WINDOWS || target_platform == PLATFORM_APPLE) + { +- output( "1:\t.byte 0xff,0x14,0x25\n" ); /* 2: callq *(__wine_syscall_dispatcher) */ +- output( "\t.long __wine_syscall_dispatcher\n" ); ++ output( "1:\t.byte 0xff,0x14,0x25\n" ); /* call *(user_shared_data + 0x1000) */ ++ output( "\t.long 0x7ffe1000\n" ); + } + else + { +@@ -1653,7 +1653,7 @@ void output_syscalls( DLLSPEC *spec ) + output( "\t.align %d\n", get_alignment(16) ); + output( "\t%s\n", func_declaration("__wine_syscall") ); + output( "%s:\n", asm_name("__wine_syscall") ); +- output( "\tjmp *(%s)\n", asm_name("__wine_syscall_dispatcher") ); ++ output( "\tjmp *(0x7ffe1000)\n" ); + output_function_size( "__wine_syscall" ); + } + output( "\t.data\n" ); +-- +2.26.2 + diff --git a/patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch b/patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch new file mode 100644 index 00000000..36370efc --- /dev/null +++ b/patches/winebuild-pe_syscall_thunks/0003-ntdll-Also-generate-syscall-thunks-for-Nt-functions-.patch @@ -0,0 +1,205 @@ +From bcab391401b586a877ee0ff69525a3429a1b2b48 Mon Sep 17 00:00:00 2001 +From: Paul Gofman +Date: Tue, 14 Jul 2020 02:05:59 +0300 +Subject: [PATCH] ntdll: Also generate syscall thunks for Nt functions not yet + in the Unix part. + +--- + dlls/ntdll/ntdll.spec | 1 + + dlls/ntdll/unix/loader.c | 37 +++++++++++++++++++++++++++++++++ + tools/winebuild/import.c | 44 +++++++++++++++++++++++++++++++++++----- + tools/winebuild/spec32.c | 16 ++++++++++++++- + 4 files changed, 92 insertions(+), 6 deletions(-) + +diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec +index b873b54b09d6..09b060b094ae 100644 +--- a/dlls/ntdll/ntdll.spec ++++ b/dlls/ntdll/ntdll.spec +@@ -1588,6 +1588,7 @@ + @ cdecl __wine_set_unix_funcs(long ptr) + @ extern __wine_syscall_dispatcher + @ extern -arch=i386 __wine_ldt_copy ++@ extern pe_syscall_table + + # Debugging + @ cdecl -norelay __wine_dbg_get_channel_flags(ptr) +diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c +index b211708aca02..c6760831d48c 100644 +--- a/dlls/ntdll/unix/loader.c ++++ b/dlls/ntdll/unix/loader.c +@@ -788,6 +788,41 @@ static ULONG_PTR find_pe_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *e + return find_named_export( module, exports, (char *)name->Name ); + } + ++static void fixup_syscall_table(const IMAGE_EXPORT_DIRECTORY *ntdll_exports) ++{ ++ extern unsigned int syscall_count; ++ extern void *syscall_table[]; ++ unsigned int fixup_count; ++ void **pe_syscall_table; ++ unsigned int i; ++ ++ pe_syscall_table = (void **)find_named_export( ntdll_module, ntdll_exports, "pe_syscall_table" ); ++ ++ if (!pe_syscall_table) ++ { ++ ERR( "pe_syscall_table not found\n" ); ++ return; ++ } ++ ++ fixup_count = 0; ++ for (i = 0; i < syscall_count; ++i) ++ { ++ assert ( (syscall_table[i] == (void *)0xdeadbeef ++ && pe_syscall_table[i] && pe_syscall_table[i] != (void *)0xdeadcafe) ++ || (pe_syscall_table[i] == (void *)0xdeadcafe && syscall_table[i] ++ && syscall_table[i] != (void *)0xdeadbeef) ); ++ ++ if (syscall_table[i] == (void *)0xdeadbeef) ++ { ++ syscall_table[i] = pe_syscall_table[i]; ++ ++fixup_count; ++ } ++ } ++ ++ if (!fixup_count) ++ FIXME("No functions to fixup.\n"); ++} ++ + static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt ) + { + const IMAGE_EXPORT_DIRECTORY *ntdll_exports = get_export_dir( ntdll_module ); +@@ -828,6 +863,8 @@ static void fixup_ntdll_imports( const IMAGE_NT_HEADERS *nt ) + thunk_list++; + } + ++ fixup_syscall_table(ntdll_exports); ++ + #define GET_FUNC(name) \ + if (!(p##name = (void *)find_named_export( ntdll_module, ntdll_exports, #name ))) \ + ERR( "%s not found\n", #name ) +diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c +index cf251c9b77d4..71d397122f60 100644 +--- a/tools/winebuild/import.c ++++ b/tools/winebuild/import.c +@@ -1418,11 +1418,13 @@ void output_syscalls( DLLSPEC *spec ) + const unsigned int invalid_param = 0xc000000d; /* STATUS_INVALID_PARAMETER */ + int i, count; + ORDDEF **syscalls = NULL; ++ int is_ntdll = spec->dll_name && !strcmp(spec->dll_name, "ntdll"); + + for (i = count = 0; i < spec->nb_entry_points; i++) + { + ORDDEF *odp = &spec->entry_points[i]; +- if (!(odp->flags & FLAG_SYSCALL)) continue; ++ if (!(odp->flags & FLAG_SYSCALL) && (!is_ntdll ++ || (strncmp(odp->link_name, "Nt", 2) && strncmp(odp->link_name, "Zw", 2)))) continue; + if (!syscalls) syscalls = xmalloc( (spec->nb_entry_points - i) * sizeof(*syscalls) ); + syscalls[count++] = odp; + } +@@ -1560,25 +1562,57 @@ void output_syscalls( DLLSPEC *spec ) + } + output_cfi( ".cfi_endproc" ); + output_function_size( "__wine_syscall_dispatcher" ); +- + output( "\t.data\n" ); ++ ++ output( "\t.align %d\n", get_alignment( get_ptr_size() ) ); ++ output( "%s\n", asm_globl("syscall_count") ); ++ output( "\t.long %u\n", count ); ++ + output( "\t.align %d\n", get_alignment( get_ptr_size() ) ); ++ output( "%s\n", asm_globl("syscall_table") ); + output( ".Lsyscall_table:\n" ); + for (i = 0; i < count; i++) +- output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_link_name( syscalls[i] ))); ++ { ++ if (syscalls[i]->flags & FLAG_SYSCALL) ++ output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_link_name( syscalls[i] ))); ++ else ++ output( "\t%s 0xdeadbeef\n", get_asm_ptr_keyword()); ++ } + output( ".Lsyscall_args:\n" ); + for (i = 0; i < count; i++) + output( "\t.byte %u\n", get_args_size( syscalls[i] )); + return; + } + ++ output( "\t.data\n" ); ++ output( "\t.align %d\n", get_alignment( get_ptr_size() ) ); ++ output( "%s\n", asm_globl("pe_syscall_table") ); ++ output( ".Lpe_syscall_table:\n" ); ++ ++ for (i = 0; i < count; i++) ++ { ++ if (!(syscalls[i]->flags & FLAG_SYSCALL)) ++ output( "\t%s %s\n", get_asm_ptr_keyword(), asm_name( get_link_name( syscalls[i] ))); ++ else ++ output( "\t%s 0xdeadcafe\n", get_asm_ptr_keyword()); ++ } ++ ++ output( "\t.text\n" ); ++ + for (i = 0; i < count; i++) + { + ORDDEF *odp = syscalls[i]; + const char *name = get_link_name(odp); ++ char exp_name[256]; ++ ++ if (odp->flags & FLAG_SYSCALL) ++ strcpy(exp_name, name); ++ else ++ sprintf(exp_name, "_syscall_%s", name); ++ + output( "\t.align %d\n", get_alignment(16) ); +- output( "\t%s\n", func_declaration(name) ); +- output( "%s\n", asm_globl(name) ); ++ output( "\t%s\n", func_declaration(exp_name) ); ++ output( "%s\n", asm_globl(exp_name) ); + output_cfi( ".cfi_startproc" ); + switch (target_cpu) + { +diff --git a/tools/winebuild/spec32.c b/tools/winebuild/spec32.c +index c85249b2a961..7cfbe5389bdf 100644 +--- a/tools/winebuild/spec32.c ++++ b/tools/winebuild/spec32.c +@@ -394,6 +394,7 @@ void output_exports( DLLSPEC *spec ) + int nr_exports = get_exports_count( spec ); + const char *func_ptr = (target_platform == PLATFORM_WINDOWS) ? ".rva" : get_asm_ptr_keyword(); + const char *name; ++ int is_ntdll = spec->dll_name && !strcmp(spec->dll_name, "ntdll"); + + if (!nr_exports) return; + +@@ -445,6 +446,7 @@ void output_exports( DLLSPEC *spec ) + else if ((odp->flags & FLAG_IMPORT) && (target_cpu == CPU_x86 || target_cpu == CPU_x86_64)) + { + name = odp->name ? odp->name : odp->export_name; ++ + if (name) output( "\t%s %s_%s\n", func_ptr, asm_name("__wine_spec_imp"), name ); + else output( "\t%s %s_%u\n", func_ptr, asm_name("__wine_spec_imp"), i ); + needs_imports = 1; +@@ -455,7 +457,19 @@ void output_exports( DLLSPEC *spec ) + } + else + { +- output( "\t%s %s\n", func_ptr, asm_name( get_link_name( odp ))); ++ const char *name = get_link_name( odp ); ++ ++ if (!(odp->flags & FLAG_SYSCALL) && is_ntdll ++ && (!strncmp(name, "Nt", 2) || !strncmp(name, "Zw", 2))) ++ { ++ char sc_name[256]; ++ sprintf(sc_name, "_syscall_%s", name); ++ output( "\t%s %s\n", func_ptr, asm_name( sc_name )); ++ } ++ else ++ { ++ output( "\t%s %s\n", func_ptr, asm_name( name )); ++ } + } + break; + case TYPE_STUB: +-- +2.26.2 + diff --git a/patches/winebuild-pe_syscall_thunks/0004-ntdll-Fix-NtGetContextThread-on-i386-with-PE-syscall.patch b/patches/winebuild-pe_syscall_thunks/0004-ntdll-Fix-NtGetContextThread-on-i386-with-PE-syscall.patch new file mode 100644 index 00000000..bdfdb95b --- /dev/null +++ b/patches/winebuild-pe_syscall_thunks/0004-ntdll-Fix-NtGetContextThread-on-i386-with-PE-syscall.patch @@ -0,0 +1,55 @@ +From 52177a4f877115f0fa358c37da6dcdcfb17e83f8 Mon Sep 17 00:00:00 2001 +From: Paul Gofman +Date: Tue, 14 Jul 2020 13:31:48 +0300 +Subject: [PATCH] ntdll: Fix NtGetContextThread on i386 with PE syscall thunks. + +Note: to be dropped once i386 NtGetContextThread moves to the +Unix part. +--- + dlls/ntdll/signal_i386.c | 8 +++++--- + tools/winebuild/import.c | 3 +++ + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c +index a130638cb310..e098b3e409b2 100644 +--- a/dlls/ntdll/signal_i386.c ++++ b/dlls/ntdll/signal_i386.c +@@ -331,6 +331,8 @@ __ASM_STDCALL_FUNC( RtlCaptureContext, 4, + "ret $4" ) + + ++extern NTSTATUS WINAPI _syscall_NtGetContextThread( HANDLE handle, CONTEXT *context ); ++ + /*********************************************************************** + * NtGetContextThread (NTDLL.@) + * ZwGetContextThread (NTDLL.@) +@@ -353,9 +355,9 @@ NTSTATUS CDECL DECLSPEC_HIDDEN __regs_NtGetContextThread( DWORD edi, DWORD esi, + } + if (needed_flags & CONTEXT_CONTROL) + { +- context->Ebp = ebp; +- context->Esp = (DWORD)&retaddr; +- context->Eip = (DWORD)NtGetContextThread + 12; ++ context->Ebp = *(DWORD *)ebp; ++ context->Esp = ebp + 4; ++ context->Eip = (DWORD)_syscall_NtGetContextThread + 18; + context->EFlags = eflags; + } + return unix_funcs->NtGetContextThread( handle, context ); +diff --git a/tools/winebuild/import.c b/tools/winebuild/import.c +index 71d397122f60..e8bd141e962b 100644 +--- a/tools/winebuild/import.c ++++ b/tools/winebuild/import.c +@@ -1469,6 +1469,9 @@ void output_syscalls( DLLSPEC *spec ) + output( "\tmovl %%esp,%%edi\n" ); + output( "\tcld\n" ); + output( "\trep; movsl\n" ); ++ output( "\tmovl -0x4(%%ebp),%%esi\n" ); ++ output( "\tmovl -0x8(%%ebp),%%edi\n" ); ++ + if (UsePIC) + output( "\tcall *.Lsyscall_table-1b(%%eax,%%edx,4)\n" ); + else +-- +2.26.2 + diff --git a/patches/winebuild-pe_syscall_thunks/definition b/patches/winebuild-pe_syscall_thunks/definition new file mode 100644 index 00000000..7b86a429 --- /dev/null +++ b/patches/winebuild-pe_syscall_thunks/definition @@ -0,0 +1,5 @@ +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, World of Warcraft) +Fixes: [45573] League of Legends 8.12+ fails to start a game (anticheat engine, hooking of syscall return instructions) +Fixes: [45650] chromium 32-bit sandbox expects different syscall thunks depending on Windows version