wow64cpu-Wow64Transition: Add patchset.

This commit is contained in:
Zebediah Figura 2018-08-08 22:57:52 -05:00
parent ec218012c3
commit 2c7a662655
6 changed files with 207 additions and 26 deletions

View File

@ -1,17 +1,17 @@
From a76d12531d1183232b0c95632da2a3626bf929f3 Mon Sep 17 00:00:00 2001
From 842a1b3187b333e1af023dd7c1bb685dfa6b9967 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 13 Dec 2014 05:34:48 +0100
Subject: [PATCH] ntdll: Implement loader redirection scheme.
---
dlls/ntdll/loader.c | 72 +++++++++++++++++++++++++++++++++++++----------------
1 file changed, 50 insertions(+), 22 deletions(-)
dlls/ntdll/loader.c | 74 ++++++++++++++++++++++++++++++++++++-----------------
1 file changed, 51 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index d2f0617..b417512 100644
index d9b1712..868d400 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -100,6 +100,7 @@ struct builtin_load_info
@@ -110,6 +110,7 @@ struct builtin_load_info
{
const WCHAR *load_path;
const WCHAR *filename;
@ -19,7 +19,7 @@ index d2f0617..b417512 100644
NTSTATUS status;
WINE_MODREF *wm;
};
@@ -125,7 +126,8 @@ static WINE_MODREF *cached_modref;
@@ -135,7 +136,8 @@ static WINE_MODREF *cached_modref;
static WINE_MODREF *current_modref;
static WINE_MODREF *last_failed_modref;
@ -29,7 +29,7 @@ index d2f0617..b417512 100644
static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved );
static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, DWORD ordinal, LPCWSTR load_path );
@@ -478,7 +480,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
@@ -511,7 +513,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
if (!(wm = find_basename_module( mod_name )))
{
TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward );
@ -38,7 +38,7 @@ index d2f0617..b417512 100644
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
if (!imports_fixup_done && current_modref)
@@ -649,7 +651,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
@@ -682,7 +684,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
{
ascii_to_unicode( buffer, name, len );
buffer[len] = 0;
@ -47,7 +47,7 @@ index d2f0617..b417512 100644
}
else /* need to allocate a larger buffer */
{
@@ -657,7 +659,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
@@ -690,7 +692,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
if (!ptr) return FALSE;
ascii_to_unicode( ptr, name, len );
ptr[len] = 0;
@ -56,7 +56,7 @@ index d2f0617..b417512 100644
RtlFreeHeap( GetProcessHeap(), 0, ptr );
}
@@ -943,7 +945,7 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
@@ -976,7 +978,7 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
prev = current_modref;
current_modref = wm;
@ -65,7 +65,7 @@ index d2f0617..b417512 100644
current_modref = prev;
if (status)
{
@@ -1031,7 +1033,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
@@ -1064,7 +1066,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
* Allocate a WINE_MODREF structure and add it to the process list
* The loader_section must be locked while calling this function.
*/
@ -74,7 +74,7 @@ index d2f0617..b417512 100644
{
WINE_MODREF *wm;
const WCHAR *p;
@@ -1045,7 +1047,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
@@ -1078,7 +1080,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
wm->ldr.TlsIndex = -1;
wm->ldr.LoadCount = 1;
@ -83,7 +83,7 @@ index d2f0617..b417512 100644
if ((p = strrchrW( wm->ldr.FullDllName.Buffer, '\\' ))) p++;
else p = wm->ldr.FullDllName.Buffer;
RtlInitUnicodeString( &wm->ldr.BaseDllName, p );
@@ -1657,7 +1659,7 @@ static void load_builtin_callback( void *module, const char *filename )
@@ -1745,7 +1747,7 @@ static void load_builtin_callback( void *module, const char *filename )
return;
}
@ -92,7 +92,7 @@ index d2f0617..b417512 100644
RtlFreeHeap( GetProcessHeap(), 0, fullname );
if (!wm)
{
@@ -1867,8 +1869,8 @@ static BOOL is_valid_binary( HMODULE module, const pe_image_info_t *info )
@@ -1955,8 +1957,8 @@ static BOOL is_valid_binary( HMODULE module, const pe_image_info_t *info )
/******************************************************************************
* load_native_dll (internal)
*/
@ -103,7 +103,7 @@ index d2f0617..b417512 100644
{
void *module;
HANDLE mapping;
@@ -1911,7 +1913,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
@@ -1999,7 +2001,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
/* create the MODREF */
@ -112,7 +112,7 @@ index d2f0617..b417512 100644
{
if (module) NtUnmapViewOfSection( NtCurrentProcess(), module );
return STATUS_NO_MEMORY;
@@ -1979,8 +1981,8 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
@@ -2067,8 +2069,8 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
/***********************************************************************
* load_builtin_dll
*/
@ -123,7 +123,7 @@ index d2f0617..b417512 100644
{
char error[256], dllname[MAX_PATH];
const WCHAR *name, *p;
@@ -2000,6 +2002,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
@@ -2088,6 +2090,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
*/
info.load_path = load_path;
info.filename = NULL;
@ -131,7 +131,7 @@ index d2f0617..b417512 100644
info.status = STATUS_SUCCESS;
info.wm = NULL;
@@ -2473,7 +2476,8 @@ overflow:
@@ -2584,7 +2587,8 @@ overflow:
* Load a PE style module according to the load order.
* The loader_section must be locked while calling this function.
*/
@ -141,7 +141,7 @@ index d2f0617..b417512 100644
{
BOOL data = flags & (LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
enum loadorder loadorder;
@@ -2512,6 +2516,30 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2623,6 +2627,30 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
}
main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
@ -172,7 +172,7 @@ index d2f0617..b417512 100644
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, filename );
if (handle && is_fake_dll( handle ))
@@ -2534,22 +2562,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2645,22 +2673,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
if (!handle) nts = STATUS_DLL_NOT_FOUND;
else
{
@ -200,7 +200,7 @@ index d2f0617..b417512 100644
if (nts == STATUS_SUCCESS && loadorder == LO_DEFAULT &&
(MODULE_InitDLL( *pwm, DLL_WINE_PREATTACH, NULL ) != STATUS_SUCCESS))
{
@@ -2559,7 +2587,7 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2670,7 +2698,7 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
nts = STATUS_DLL_NOT_FOUND;
}
if (nts == STATUS_DLL_NOT_FOUND && loadorder != LO_BUILTIN)
@ -209,7 +209,7 @@ index d2f0617..b417512 100644
break;
}
@@ -2592,7 +2620,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
@@ -2703,7 +2731,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
RtlEnterCriticalSection( &loader_section );
if (!path_name) path_name = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
@ -218,10 +218,16 @@ index d2f0617..b417512 100644
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
@@ -3553,7 +3581,7 @@ void __wine_process_init(void)
@@ -3666,12 +3694,12 @@ void __wine_process_init(void)
/* setup the load callback and create ntdll modref */
wine_dll_set_callback( load_builtin_callback );
- if ((status = load_builtin_dll( NULL, wow64cpuW, 0, 0, &wow64cpu_wm )) == STATUS_SUCCESS)
+ if ((status = load_builtin_dll( NULL, wow64cpuW, NULL, 0, 0, &wow64cpu_wm )) == STATUS_SUCCESS)
Wow64Transition = wow64cpu_wm->ldr.BaseAddress;
else
WARN( "could not load wow64cpu.dll, status %#x\n", status );
- if ((status = load_builtin_dll( NULL, kernel32W, 0, 0, &wm )) != STATUS_SUCCESS)
+ if ((status = load_builtin_dll( NULL, kernel32W, NULL, 0, 0, &wm )) != STATUS_SUCCESS)
{

View File

@ -1,3 +1,4 @@
Fixes: Support for loader dll redirections
Depends: ntdll-Loader_Machine_Type
Depends: ntdll-DllOverrides_WOW64
Depends: wow64cpu-Wow64Transition

View File

@ -410,6 +410,7 @@ patch_enable_all ()
enable_wintab32_improvements="$1"
enable_wintrust_WTHelperGetProvCertFromChain="$1"
enable_wintrust_WinVerifyTrust="$1"
enable_wow64cpu_Wow64Transition="$1"
enable_wpcap_Dynamic_Linking="$1"
enable_ws2_32_APC_Performance="$1"
enable_ws2_32_Connect_Time="$1"
@ -1412,6 +1413,9 @@ patch_enable ()
wintrust-WinVerifyTrust)
enable_wintrust_WinVerifyTrust="$2"
;;
wow64cpu-Wow64Transition)
enable_wow64cpu_Wow64Transition="$2"
;;
wpcap-Dynamic_Linking)
enable_wpcap_Dynamic_Linking="$2"
;;
@ -2167,8 +2171,12 @@ if test "$enable_ntdll_DllRedirects" -eq 1; then
if test "$enable_ntdll_Loader_Machine_Type" -gt 1; then
abort "Patchset ntdll-Loader_Machine_Type disabled, but ntdll-DllRedirects depends on that."
fi
if test "$enable_wow64cpu_Wow64Transition" -gt 1; then
abort "Patchset wow64cpu-Wow64Transition disabled, but ntdll-DllRedirects depends on that."
fi
enable_ntdll_DllOverrides_WOW64=1
enable_ntdll_Loader_Machine_Type=1
enable_wow64cpu_Wow64Transition=1
fi
if test "$enable_ntdll_Builtin_Prot" -eq 1; then
@ -5151,10 +5159,28 @@ if test "$enable_ntdll_Loader_Machine_Type" -eq 1; then
) >> "$patchlist"
fi
# Patchset wow64cpu-Wow64Transition
# |
# | 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
# |
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-DllRedirects
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, wow64cpu-Wow64Transition
# |
# | Modified files:
# | * dlls/ntdll/loader.c, dlls/ntdll/loadorder.c, dlls/ntdll/ntdll_misc.h
@ -5518,7 +5544,7 @@ fi
# Patchset ntdll-Purist_Mode
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, wow64cpu-Wow64Transition, ntdll-DllRedirects
# |
# | Modified files:
# | * dlls/ntdll/loadorder.c
@ -7277,7 +7303,7 @@ fi
# Patchset uxtheme-GTK_Theming
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, wow64cpu-Wow64Transition, ntdll-DllRedirects
# |
# | Modified files:
# | * aclocal.m4, configure.ac, dlls/uxtheme-gtk/Makefile.in, dlls/uxtheme-gtk/button.c, dlls/uxtheme-gtk/combobox.c, dlls

View File

@ -0,0 +1,87 @@
From 9598e08f8b900be94d23df995105b210c4f7567f Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Tue, 7 Aug 2018 21:05:56 -0500
Subject: [PATCH 1/2] wow64cpu: Add stub dll.
---
configure | 2 ++
configure.ac | 1 +
dlls/wow64cpu/Makefile.in | 1 +
dlls/wow64cpu/wow64cpu.spec | 25 +++++++++++++++++++++++++
4 files changed, 29 insertions(+)
create mode 100644 dlls/wow64cpu/Makefile.in
create mode 100644 dlls/wow64cpu/wow64cpu.spec
diff --git a/configure b/configure
index 337ce91..477fe02 100755
--- a/configure
+++ b/configure
@@ -1612,6 +1612,7 @@ enable_wmp
enable_wmphoto
enable_wmvcore
enable_wnaspi32
+enable_wow64cpu
enable_wpc
enable_wpcap
enable_ws2_32
@@ -19952,6 +19953,7 @@ wine_fn_config_makefile dlls/wmvcore enable_wmvcore
wine_fn_config_makefile dlls/wmvcore/tests enable_tests
wine_fn_config_makefile dlls/wnaspi32 enable_wnaspi32
wine_fn_config_makefile dlls/wow32 enable_win16
+wine_fn_config_makefile dlls/wow64cpu enable_wow64cpu
wine_fn_config_makefile dlls/wpc enable_wpc
wine_fn_config_makefile dlls/wpc/tests enable_tests
wine_fn_config_makefile dlls/wpcap enable_wpcap
diff --git a/configure.ac b/configure.ac
index be247ea..376b818 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3813,6 +3813,7 @@ WINE_CONFIG_MAKEFILE(dlls/wmvcore)
WINE_CONFIG_MAKEFILE(dlls/wmvcore/tests)
WINE_CONFIG_MAKEFILE(dlls/wnaspi32)
WINE_CONFIG_MAKEFILE(dlls/wow32,enable_win16)
+WINE_CONFIG_MAKEFILE(dlls/wow64cpu)
WINE_CONFIG_MAKEFILE(dlls/wpc)
WINE_CONFIG_MAKEFILE(dlls/wpc/tests)
WINE_CONFIG_MAKEFILE(dlls/wpcap)
diff --git a/dlls/wow64cpu/Makefile.in b/dlls/wow64cpu/Makefile.in
new file mode 100644
index 0000000..261363f
--- /dev/null
+++ b/dlls/wow64cpu/Makefile.in
@@ -0,0 +1 @@
+MODULE = wow64cpu.dll
diff --git a/dlls/wow64cpu/wow64cpu.spec b/dlls/wow64cpu/wow64cpu.spec
new file mode 100644
index 0000000..2d074ee
--- /dev/null
+++ b/dlls/wow64cpu/wow64cpu.spec
@@ -0,0 +1,25 @@
+@ stub CpuFlushInstructionCache
+@ stub CpuGetContext
+@ stub CpuGetStackPointer
+@ stub CpuInitializeStartupContext
+@ stub CpuNotifyAffinityChange
+@ stub CpuNotifyAfterFork
+@ stub CpuNotifyBeforeFork
+@ stub CpuNotifyDllLoad
+@ stub CpuNotifyDllUnload
+@ stub CpuPrepareForDebuggerAttach
+@ stub CpuProcessDebugEvent
+@ stub CpuProcessInit
+@ stub CpuProcessTerm
+@ stub CpuResetFloatingPoint
+@ stub CpuResetToConsistentState
+@ stub CpuSetContext
+@ stub CpuSetInstructionPointer
+@ stub CpuSetStackPointer
+@ stub CpuSimulate
+@ stub CpuSuspendLocalThread
+@ stub CpuSuspendThread
+@ stub CpuThreadInit
+@ stub CpuThreadTerm
+@ stub TurboDispatchJumpAddressEnd
+@ stub TurboDispatchJumpAddressStart
--
2.7.4

View File

@ -0,0 +1,60 @@
From 97251c147d843617cf2e3fcf3f273ea779d39742 Mon Sep 17 00:00:00 2001
From: Zebediah Figura <z.figura12@gmail.com>
Date: Wed, 8 Aug 2018 20:00:15 -0500
Subject: [PATCH 2/2] ntdll: Add a stub implementation of Wow64Transition.
---
dlls/ntdll/loader.c | 9 ++++++++-
dlls/ntdll/ntdll.spec | 1 +
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index df206e8..e37aec2 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3493,15 +3493,17 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
return TRUE;
}
+void *Wow64Transition;
/***********************************************************************
* __wine_process_init
*/
void __wine_process_init(void)
{
+ static const WCHAR wow64cpuW[] = {'w','o','w','6','4','c','p','u','.','d','l','l',0};
static const WCHAR kernel32W[] = {'k','e','r','n','e','l','3','2','.','d','l','l',0};
- WINE_MODREF *wm;
+ WINE_MODREF *wm, *wow64cpu_wm;
NTSTATUS status;
ANSI_STRING func_name;
void (* DECLSPEC_NORETURN CDECL init_func)(void);
@@ -3517,6 +3519,11 @@ void __wine_process_init(void)
/* setup the load callback and create ntdll modref */
wine_dll_set_callback( load_builtin_callback );
+ if ((status = load_builtin_dll( NULL, wow64cpuW, 0, 0, &wow64cpu_wm )) == STATUS_SUCCESS)
+ Wow64Transition = wow64cpu_wm->ldr.BaseAddress;
+ else
+ WARN( "could not load wow64cpu.dll, status %#x\n", status );
+
if ((status = load_builtin_dll( NULL, kernel32W, 0, 0, &wm )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index d321c44..3a7a144 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1034,6 +1034,7 @@
@ stdcall WinSqmIsOptedIn()
@ stdcall WinSqmSetDWORD(ptr long long)
@ stdcall WinSqmStartSession(ptr long long)
+@ extern Wow64Transition
@ stdcall -private ZwAcceptConnectPort(ptr long ptr long ptr ptr) NtAcceptConnectPort
@ stdcall -private ZwAccessCheck(ptr long long ptr ptr ptr ptr ptr) NtAccessCheck
@ stdcall -private ZwAccessCheckAndAuditAlarm(ptr long ptr ptr ptr long ptr long ptr ptr ptr) NtAccessCheckAndAuditAlarm
--
2.7.4

View File

@ -0,0 +1 @@
Fixes: [45567] League of Legends 8.12+ fails to start a game (anticheat engine, validation of WoW64 syscall dispatcher)