From 38efd9d1bca8e85fff0e591a829955580303e0b0 Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 21 Nov 2019 10:58:02 -0600 Subject: [PATCH] ntdll-x86_64_SegDs: Add patch. --- ...Ds-to-be-identical-to-SegSs-on-x86_6.patch | 45 +++++++++++++++++++ patches/ntdll-x86_64_SegDs/definition | 1 + patches/patchinstall.sh | 19 ++++++++ 3 files changed, 65 insertions(+) create mode 100644 patches/ntdll-x86_64_SegDs/0001-ntdll-Report-SegDs-to-be-identical-to-SegSs-on-x86_6.patch create mode 100644 patches/ntdll-x86_64_SegDs/definition diff --git a/patches/ntdll-x86_64_SegDs/0001-ntdll-Report-SegDs-to-be-identical-to-SegSs-on-x86_6.patch b/patches/ntdll-x86_64_SegDs/0001-ntdll-Report-SegDs-to-be-identical-to-SegSs-on-x86_6.patch new file mode 100644 index 00000000..455a3be4 --- /dev/null +++ b/patches/ntdll-x86_64_SegDs/0001-ntdll-Report-SegDs-to-be-identical-to-SegSs-on-x86_6.patch @@ -0,0 +1,45 @@ +From 1178a02719088e81b2e5b35074b4559f60d8a5b1 Mon Sep 17 00:00:00 2001 +From: Zebediah Figura +Date: Thu, 21 Nov 2019 10:44:42 -0600 +Subject: [PATCH] ntdll: Report SegDs to be identical to SegSs on x86_64. + +Based on a patch by David Torok. + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47970 +Signed-off-by: Zebediah Figura +--- + dlls/ntdll/signal_x86_64.c | 11 ++++++----- + 1 file changed, 6 insertions(+), 5 deletions(-) + +diff --git a/dlls/ntdll/signal_x86_64.c b/dlls/ntdll/signal_x86_64.c +index c372f65b34b..a1797811da3 100644 +--- a/dlls/ntdll/signal_x86_64.c ++++ b/dlls/ntdll/signal_x86_64.c +@@ -1699,11 +1699,6 @@ static void save_context( CONTEXT *context, const ucontext_t *sigcontext ) + context->SegFs = FS_sig(sigcontext); + context->SegGs = GS_sig(sigcontext); + context->EFlags = EFL_sig(sigcontext); +-#ifdef DS_sig +- context->SegDs = DS_sig(sigcontext); +-#else +- __asm__("movw %%ds,%0" : "=m" (context->SegDs)); +-#endif + #ifdef ES_sig + context->SegEs = ES_sig(sigcontext); + #else +@@ -1714,6 +1709,12 @@ static void save_context( CONTEXT *context, const ucontext_t *sigcontext ) + #else + __asm__("movw %%ss,%0" : "=m" (context->SegSs)); + #endif ++ /* Legends of Runeterra depends on having SegDs == SegSs in an exception ++ * handler. Testing shows that Windows returns fixed values from ++ * RtlCaptureContext() and NtGetContextThread() for at least %ds and %es, ++ * regardless of their actual values, and never sets them in ++ * NtSetContextThread(). */ ++ context->SegDs = context->SegSs; + context->Dr0 = amd64_thread_data()->dr0; + context->Dr1 = amd64_thread_data()->dr1; + context->Dr2 = amd64_thread_data()->dr2; +-- +2.23.0 + diff --git a/patches/ntdll-x86_64_SegDs/definition b/patches/ntdll-x86_64_SegDs/definition new file mode 100644 index 00000000..aa6491a7 --- /dev/null +++ b/patches/ntdll-x86_64_SegDs/definition @@ -0,0 +1 @@ +Fixes: [47970] Legends of Runeterra crashes at launch diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 8e295a8a..cd8ce0c2 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -228,6 +228,7 @@ patch_enable_all () enable_ntdll_aarch_TEB="$1" enable_ntdll_ext4_case_folder="$1" enable_ntdll_set_full_cpu_context="$1" + enable_ntdll_x86_64_SegDs="$1" enable_ntoskrnl_Stubs="$1" enable_nvapi_Stub_DLL="$1" enable_nvcuda_CUDA_Support="$1" @@ -807,6 +808,9 @@ patch_enable () ntdll-set_full_cpu_context) enable_ntdll_set_full_cpu_context="$2" ;; + ntdll-x86_64_SegDs) + enable_ntdll_x86_64_SegDs="$2" + ;; ntoskrnl-Stubs) enable_ntoskrnl_Stubs="$2" ;; @@ -5173,6 +5177,21 @@ if test "$enable_ntdll_set_full_cpu_context" -eq 1; then ) >> "$patchlist" fi +# Patchset ntdll-x86_64_SegDs +# | +# | This patchset fixes the following Wine bugs: +# | * [#47970] Legends of Runeterra crashes at launch +# | +# | Modified files: +# | * dlls/ntdll/signal_x86_64.c +# | +if test "$enable_ntdll_x86_64_SegDs" -eq 1; then + patch_apply ntdll-x86_64_SegDs/0001-ntdll-Report-SegDs-to-be-identical-to-SegSs-on-x86_6.patch + ( + printf '%s\n' '+ { "Zebediah Figura", "ntdll: Report SegDs to be identical to SegSs on x86_64.", 1 },'; + ) >> "$patchlist" +fi + # Patchset ntoskrnl-Stubs # | # | Modified files: