Added ntdll-User_shared_data_fields patchset

This commit is contained in:
Paul Gofman 2019-12-30 14:15:33 +03:00
parent 595f2f9860
commit ce3fc5723d
4 changed files with 185 additions and 28 deletions

View File

@ -0,0 +1,35 @@
From 43fa5b9a922859b4bf4698c2336de125ae9b5c94 Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 30 Dec 2019 13:33:46 +0300
Subject: [PATCH] ntdll: Fill NumberOfPhysicalPages field in user shared data
area.
---
dlls/ntdll/loader.c | 4 ++++
1 file changed, 4 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;
+ 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 */
}
+ 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 );
--
2.24.1

View File

@ -0,0 +1,86 @@
From 741e66e7ed773dffc5c5b7f44439f7786adc6c3a Mon Sep 17 00:00:00 2001
From: Paul Gofman <gofmanp@gmail.com>
Date: Mon, 30 Dec 2019 13:36:12 +0300
Subject: [PATCH] ntdll: Detect more processor features on Intel CPU.
---
dlls/ntdll/nt.c | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c
index 524e39144b..d39e487842 100644
--- a/dlls/ntdll/nt.c
+++ b/dlls/ntdll/nt.c
@@ -1172,6 +1172,7 @@ static inline BOOL have_sse_daz_mode(void)
static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
{
unsigned int regs[4], regs2[4];
+ BOOL amd_or_intel = FALSE;
#if defined(__i386__)
info->Architecture = PROCESSOR_ARCHITECTURE_INTEL;
@@ -1183,6 +1184,8 @@ static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
info->FeatureSet = CPU_FEATURE_VME | CPU_FEATURE_X86 | CPU_FEATURE_PGE;
info->Level = 3;
+ user_shared_data->ProcessorFeatures[PF_RDWRFSGSBASE_AVAILABLE] = TRUE;
+
if (!have_cpuid()) return;
do_cpuid(0x00000000, regs); /* get standard cpuid level and vendor name */
@@ -1227,15 +1230,7 @@ static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
info->Revision |= ((regs2[0] >> 4 ) & 0xf) << 8; /* model */
info->Revision |= regs2[0] & 0xf; /* stepping */
- do_cpuid(0x80000000, regs); /* get vendor cpuid level */
- if (regs[0] >= 0x80000001)
- {
- do_cpuid(0x80000001, regs2); /* get vendor features */
- user_shared_data->ProcessorFeatures[PF_VIRT_FIRMWARE_ENABLED] = (regs2[2] >> 2) & 1;
- user_shared_data->ProcessorFeatures[PF_NX_ENABLED] = (regs2[3] >> 20) & 1;
- user_shared_data->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] >> 31) & 1;
- if (regs2[3] >> 31) info->FeatureSet |= CPU_FEATURE_3DNOW;
- }
+ amd_or_intel = TRUE;
}
else if (regs[1] == GENU && regs[3] == INEI && regs[2] == NTEL)
{
@@ -1250,12 +1245,7 @@ static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
if(regs2[3] & (1 << 21)) info->FeatureSet |= CPU_FEATURE_DS;
user_shared_data->ProcessorFeatures[PF_VIRT_FIRMWARE_ENABLED] = (regs2[2] >> 5) & 1;
- do_cpuid(0x80000000, regs); /* get vendor cpuid level */
- if (regs[0] >= 0x80000001)
- {
- do_cpuid(0x80000001, regs2); /* get vendor features */
- user_shared_data->ProcessorFeatures[PF_NX_ENABLED] = (regs2[3] >> 20) & 1;
- }
+ amd_or_intel = TRUE;
}
else
{
@@ -1265,6 +1255,21 @@ static inline void get_cpuinfo(SYSTEM_CPU_INFORMATION* info)
info->Revision = ((regs2[0] >> 4 ) & 0xf) << 8; /* model */
info->Revision |= regs2[0] & 0xf; /* stepping */
}
+
+ if (amd_or_intel)
+ {
+ do_cpuid(0x80000000, regs); /* get vendor cpuid level */
+ if (regs[0] >= 0x80000001)
+ {
+ do_cpuid(0x80000001, regs2); /* get vendor features */
+ user_shared_data->ProcessorFeatures[PF_VIRT_FIRMWARE_ENABLED] = (regs2[2] >> 2) & 1;
+ user_shared_data->ProcessorFeatures[PF_NX_ENABLED] = (regs2[3] >> 20) & 1;
+ user_shared_data->ProcessorFeatures[PF_3DNOW_INSTRUCTIONS_AVAILABLE] = (regs2[3] >> 31) & 1;
+ user_shared_data->ProcessorFeatures[PF_RDTSC_INSTRUCTION_AVAILABLE] = (regs2[3] >> 27) & 1;
+ if (regs2[3] >> 31) info->FeatureSet |= CPU_FEATURE_3DNOW;
+ if ((regs2[3] >> 27) & 1) info->FeatureSet |= CPU_FEATURE_TSC;
+ }
+ }
}
}
--
2.24.1

View File

@ -0,0 +1,4 @@
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

View File

@ -226,6 +226,7 @@ patch_enable_all ()
enable_ntdll_ThreadTime="$1"
enable_ntdll_Threading="$1"
enable_ntdll_User_Shared_Data="$1"
enable_ntdll_User_shared_data_fields="$1"
enable_ntdll_WRITECOPY="$1"
enable_ntdll_Wait_User_APC="$1"
enable_ntdll_Zero_mod_name="$1"
@ -812,6 +813,9 @@ patch_enable ()
ntdll-User_Shared_Data)
enable_ntdll_User_Shared_Data="$2"
;;
ntdll-User_shared_data_fields)
enable_ntdll_User_shared_data_fields="$2"
;;
ntdll-WRITECOPY)
enable_ntdll_WRITECOPY="$2"
;;
@ -1627,13 +1631,6 @@ 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."
@ -1808,6 +1805,20 @@ if test "$enable_nvcuvid_CUDA_Video_Support" -eq 1; then
enable_nvapi_Stub_DLL=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."
@ -5293,6 +5304,48 @@ 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
# |
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
patch_apply ntdll-User_shared_data_fields/0002-ntdll-Detect-more-processor-features-on-Intel-CPU.patch
(
printf '%s\n' '+ { "Paul Gofman", "ntdll: Fill NumberOfPhysicalPages field in user shared data area.", 1 },';
printf '%s\n' '+ { "Paul Gofman", "ntdll: Detect more processor features on Intel CPU.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Zero_mod_name
# |
# | Modified files:
@ -7598,27 +7651,6 @@ 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: