From d3ad4e1115be903a4373beaf2241c1f637a3ad6b Mon Sep 17 00:00:00 2001 From: Paul Gofman Date: Tue, 11 Feb 2020 16:33:47 +0300 Subject: [PATCH] Updated ntdll-User_shared_data_fields patchset. --- ...rOfPhysicalPages-field-in-user-share.patch | 82 ++++++++++++++----- .../ntdll-User_shared_data_fields/definition | 1 - patches/patchinstall.sh | 68 +++++++-------- 3 files changed, 90 insertions(+), 61 deletions(-) diff --git a/patches/ntdll-User_shared_data_fields/0001-ntdll-Fill-NumberOfPhysicalPages-field-in-user-share.patch b/patches/ntdll-User_shared_data_fields/0001-ntdll-Fill-NumberOfPhysicalPages-field-in-user-share.patch index dd4f573c..ac7aab48 100644 --- a/patches/ntdll-User_shared_data_fields/0001-ntdll-Fill-NumberOfPhysicalPages-field-in-user-share.patch +++ b/patches/ntdll-User_shared_data_fields/0001-ntdll-Fill-NumberOfPhysicalPages-field-in-user-share.patch @@ -1,35 +1,75 @@ -From 43fa5b9a922859b4bf4698c2336de125ae9b5c94 Mon Sep 17 00:00:00 2001 +From e4b6be33cb122d796f1009761b8f53b4c3e46774 Mon Sep 17 00:00:00 2001 From: Paul Gofman -Date: Mon, 30 Dec 2019 13:33:46 +0300 +Date: Tue, 11 Feb 2020 15:17:55 +0300 Subject: [PATCH] ntdll: Fill NumberOfPhysicalPages field in user shared data area. --- - dlls/ntdll/loader.c | 4 ++++ - 1 file changed, 4 insertions(+) + dlls/ntdll/tests/virtual.c | 16 ++++++++++++++++ + dlls/ntdll/thread.c | 4 ++++ + 2 files changed, 20 insertions(+) -diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c -index f2f86ea5a8..5db716089c 100644 ---- a/dlls/ntdll/loader.c -+++ b/dlls/ntdll/loader.c -@@ -4453,6 +4453,7 @@ void __wine_process_init(void) - RTL_USER_PROCESS_PARAMETERS *params; - ACTIVATION_CONTEXT_RUN_LEVEL_INFORMATION runlevel; - WINE_MODREF *wm, *wow64cpu_wm; +diff --git a/dlls/ntdll/tests/virtual.c b/dlls/ntdll/tests/virtual.c +index 31eb66c143..20dfeb9830 100644 +--- a/dlls/ntdll/tests/virtual.c ++++ b/dlls/ntdll/tests/virtual.c +@@ -25,6 +25,7 @@ + #include "windef.h" + #include "winternl.h" + #include "wine/test.h" ++#include "ddk/wdm.h" + + static unsigned int page_size; + +@@ -513,6 +514,20 @@ static void test_NtMapViewOfSection(void) + CloseHandle(process); + } + ++static void test_user_shared_data(void) ++{ ++ const KSHARED_USER_DATA *user_shared_data = (void *)0x7ffe0000; + SYSTEM_BASIC_INFORMATION sbi; - NTSTATUS status; - ANSI_STRING func_name; - UNICODE_STRING nt_name; -@@ -4571,6 +4572,9 @@ void __wine_process_init(void) - elevate_process(); /* FIXME: the process exists with a wrong token for a short time */ - } ++ NTSTATUS status; ++ ++ memset(&sbi, 0, sizeof(sbi)); ++ status = NtQuerySystemInformation(SystemBasicInformation, &sbi, sizeof(sbi), NULL); ++ ok(status == STATUS_SUCCESS, "Unexpected status %#x.\n", status); ++ ok(sbi.MmNumberOfPhysicalPages && sbi.MmNumberOfPhysicalPages == user_shared_data->NumberOfPhysicalPages, ++ "Unexpected number of physical pages %#x, NtQuerySystemInformation() reported %#x.\n", ++ user_shared_data->NumberOfPhysicalPages, sbi.MmNumberOfPhysicalPages); ++} ++ + START_TEST(virtual) + { + SYSTEM_BASIC_INFORMATION sbi; +@@ -546,4 +561,5 @@ START_TEST(virtual) + test_NtAllocateVirtualMemory(); + test_RtlCreateUserStack(); + test_NtMapViewOfSection(); ++ test_user_shared_data(); + } +diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c +index 35187ba470..cd1fdb4fe8 100644 +--- a/dlls/ntdll/thread.c ++++ b/dlls/ntdll/thread.c +@@ -277,6 +277,7 @@ static void set_process_name( int argc, char *argv[] ) + */ + TEB *thread_init(void) + { ++ SYSTEM_BASIC_INFORMATION sbi; + TEB *teb; + void *addr; + SIZE_T size; +@@ -370,6 +371,9 @@ TEB *thread_init(void) + __wine_user_shared_data(); + fill_cpu_info(); + virtual_get_system_info(&sbi); + user_shared_data->NumberOfPhysicalPages = sbi.MmNumberOfPhysicalPages; + - /* the main exe needs to be the first in the load order list */ - RemoveEntryList( &wm->ldr.InLoadOrderModuleList ); - InsertHeadList( &peb->LdrData->InLoadOrderModuleList, &wm->ldr.InLoadOrderModuleList ); + return teb; + } + -- 2.24.1 diff --git a/patches/ntdll-User_shared_data_fields/definition b/patches/ntdll-User_shared_data_fields/definition index 3176ba70..d706b931 100644 --- a/patches/ntdll-User_shared_data_fields/definition +++ b/patches/ntdll-User_shared_data_fields/definition @@ -1,4 +1,3 @@ Fixes: [48386] Some CPU features are not reported for Intel CPU (Detroit: Become Human is affected) Fixes: [48387] User shared data area should have NumberOfPhysicalPages field filled in (used by Detroit: Become Human) -Depends: wow64cpu-Wow64Transition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index f513dd25..a4d3f38e 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -1559,6 +1559,13 @@ if test "$enable_ws2_32_TransmitFile" -eq 1; then enable_server_Desktop_Refcount=1 fi +if test "$enable_wow64cpu_Wow64Transition" -eq 1; then + if test "$enable_advapi32_Token_Integrity_Level" -gt 1; then + abort "Patchset advapi32-Token_Integrity_Level disabled, but wow64cpu-Wow64Transition depends on that." + fi + enable_advapi32_Token_Integrity_Level=1 +fi + if test "$enable_winex11_WM_WINDOWPOSCHANGING" -eq 1; then if test "$enable_winex11__NET_ACTIVE_WINDOW" -gt 1; then abort "Patchset winex11-_NET_ACTIVE_WINDOW disabled, but winex11-WM_WINDOWPOSCHANGING depends on that." @@ -1733,20 +1740,6 @@ if test "$enable_ntdll_WRITECOPY" -eq 1; then enable_ntdll_User_Shared_Data=1 fi -if test "$enable_ntdll_User_shared_data_fields" -eq 1; then - if test "$enable_wow64cpu_Wow64Transition" -gt 1; then - abort "Patchset wow64cpu-Wow64Transition disabled, but ntdll-User_shared_data_fields depends on that." - fi - enable_wow64cpu_Wow64Transition=1 -fi - -if test "$enable_wow64cpu_Wow64Transition" -eq 1; then - if test "$enable_advapi32_Token_Integrity_Level" -gt 1; then - abort "Patchset advapi32-Token_Integrity_Level disabled, but wow64cpu-Wow64Transition depends on that." - fi - enable_advapi32_Token_Integrity_Level=1 -fi - if test "$enable_ntdll_Syscall_Emulation" -eq 1; then if test "$enable_winebuild_Fake_Dlls" -gt 1; then abort "Patchset winebuild-Fake_Dlls disabled, but ntdll-Syscall_Emulation depends on that." @@ -5026,38 +5019,14 @@ if test "$enable_ntdll_ThreadHideFromDebugger" -eq 1; then ) >> "$patchlist" fi -# Patchset wow64cpu-Wow64Transition -# | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level -# | -# | This patchset fixes the following Wine bugs: -# | * [#45567] League of Legends 8.12+ fails to start a game (anticheat engine, validation of WoW64 syscall dispatcher) -# | -# | Modified files: -# | * configure, configure.ac, dlls/ntdll/loader.c, dlls/ntdll/ntdll.spec, dlls/wow64cpu/Makefile.in, -# | dlls/wow64cpu/wow64cpu.spec, dlls/wow64cpu/wow64cpu_main.c -# | -if test "$enable_wow64cpu_Wow64Transition" -eq 1; then - patch_apply wow64cpu-Wow64Transition/0001-wow64cpu-Add-stub-dll.patch - patch_apply wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch - ( - printf '%s\n' '+ { "Zebediah Figura", "wow64cpu: Add stub dll.", 1 },'; - printf '%s\n' '+ { "Zebediah Figura", "ntdll: Add a stub implementation of Wow64Transition.", 1 },'; - ) >> "$patchlist" -fi - # Patchset ntdll-User_shared_data_fields # | -# | This patchset has the following (direct or indirect) dependencies: -# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level, wow64cpu-Wow64Transition -# | # | This patchset fixes the following Wine bugs: # | * [#48386] Some CPU features are not reported for Intel CPU (Detroit: Become Human is affected) # | * [#48387] User shared data area should have NumberOfPhysicalPages field filled in (used by Detroit: Become Human) # | # | Modified files: -# | * dlls/ntdll/loader.c, dlls/ntdll/nt.c +# | * dlls/ntdll/nt.c, dlls/ntdll/tests/virtual.c, dlls/ntdll/thread.c # | if test "$enable_ntdll_User_shared_data_fields" -eq 1; then patch_apply ntdll-User_shared_data_fields/0001-ntdll-Fill-NumberOfPhysicalPages-field-in-user-share.patch @@ -7309,6 +7278,27 @@ if test "$enable_wintrust_WTHelperGetProvCertFromChain" -eq 1; then ) >> "$patchlist" fi +# Patchset wow64cpu-Wow64Transition +# | +# | This patchset has the following (direct or indirect) dependencies: +# | * Staging, advapi32-CreateRestrictedToken, advapi32-Token_Integrity_Level +# | +# | This patchset fixes the following Wine bugs: +# | * [#45567] League of Legends 8.12+ fails to start a game (anticheat engine, validation of WoW64 syscall dispatcher) +# | +# | Modified files: +# | * configure, configure.ac, dlls/ntdll/loader.c, dlls/ntdll/ntdll.spec, dlls/wow64cpu/Makefile.in, +# | dlls/wow64cpu/wow64cpu.spec, dlls/wow64cpu/wow64cpu_main.c +# | +if test "$enable_wow64cpu_Wow64Transition" -eq 1; then + patch_apply wow64cpu-Wow64Transition/0001-wow64cpu-Add-stub-dll.patch + patch_apply wow64cpu-Wow64Transition/0002-ntdll-Add-a-stub-implementation-of-Wow64Transition.patch + ( + printf '%s\n' '+ { "Zebediah Figura", "wow64cpu: Add stub dll.", 1 },'; + printf '%s\n' '+ { "Zebediah Figura", "ntdll: Add a stub implementation of Wow64Transition.", 1 },'; + ) >> "$patchlist" +fi + # Patchset wpcap-Dynamic_Linking # | # | Modified files: