wow64cpu-Wow64Transition: Load wow64cpu.dll after kernel32.dll.

Fixes bug 46251.
This commit is contained in:
Zebediah Figura 2018-12-10 19:48:41 -06:00
parent 6be0dfd008
commit e45211698d
2 changed files with 46 additions and 44 deletions

View File

@ -1,14 +1,14 @@
From 842a1b3187b333e1af023dd7c1bb685dfa6b9967 Mon Sep 17 00:00:00 2001
From 8fe83e82d903a0b80a442d83e9a03b527fd3e53d 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 | 74 ++++++++++++++++++++++++++++++++++++-----------------
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 d9b1712..868d400 100644
index cd31a444..15e4af8c 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -110,6 +110,7 @@ struct builtin_load_info
@ -19,7 +19,7 @@ index d9b1712..868d400 100644
NTSTATUS status;
WINE_MODREF *wm;
};
@@ -135,7 +136,8 @@ static WINE_MODREF *cached_modref;
@@ -134,7 +135,8 @@ static WINE_MODREF *cached_modref;
static WINE_MODREF *current_modref;
static WINE_MODREF *last_failed_modref;
@ -29,7 +29,7 @@ index d9b1712..868d400 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 );
@@ -511,7 +513,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
@@ -510,7 +512,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 d9b1712..868d400 100644
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
if (!imports_fixup_done && current_modref)
@@ -682,7 +684,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
@@ -681,7 +683,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 d9b1712..868d400 100644
}
else /* need to allocate a larger buffer */
{
@@ -690,7 +692,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
@@ -689,7 +691,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 d9b1712..868d400 100644
RtlFreeHeap( GetProcessHeap(), 0, ptr );
}
@@ -976,7 +978,7 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
@@ -975,7 +977,7 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
prev = current_modref;
current_modref = wm;
@ -65,7 +65,7 @@ index d9b1712..868d400 100644
current_modref = prev;
if (status)
{
@@ -1064,7 +1066,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
@@ -1063,7 +1065,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 d9b1712..868d400 100644
{
WINE_MODREF *wm;
const WCHAR *p;
@@ -1078,7 +1080,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
@@ -1077,7 +1079,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
wm->ldr.TlsIndex = -1;
wm->ldr.LoadCount = 1;
@ -83,7 +83,7 @@ index d9b1712..868d400 100644
if ((p = strrchrW( wm->ldr.FullDllName.Buffer, '\\' ))) p++;
else p = wm->ldr.FullDllName.Buffer;
RtlInitUnicodeString( &wm->ldr.BaseDllName, p );
@@ -1745,7 +1747,7 @@ static void load_builtin_callback( void *module, const char *filename )
@@ -1744,7 +1746,7 @@ static void load_builtin_callback( void *module, const char *filename )
return;
}
@ -92,7 +92,7 @@ index d9b1712..868d400 100644
RtlFreeHeap( GetProcessHeap(), 0, fullname );
if (!wm)
{
@@ -1955,8 +1957,8 @@ static BOOL is_valid_binary( HMODULE module, const pe_image_info_t *info )
@@ -1995,8 +1997,8 @@ static BOOL is_valid_binary( HMODULE module, const pe_image_info_t *info )
/******************************************************************************
* load_native_dll (internal)
*/
@ -103,7 +103,7 @@ index d9b1712..868d400 100644
{
void *module;
HANDLE mapping;
@@ -1999,7 +2001,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
@@ -2039,7 +2041,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
/* create the MODREF */
@ -112,7 +112,7 @@ index d9b1712..868d400 100644
{
if (module) NtUnmapViewOfSection( NtCurrentProcess(), module );
return STATUS_NO_MEMORY;
@@ -2067,8 +2069,8 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
@@ -2107,8 +2109,8 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
/***********************************************************************
* load_builtin_dll
*/
@ -123,7 +123,7 @@ index d9b1712..868d400 100644
{
char error[256], dllname[MAX_PATH];
const WCHAR *name, *p;
@@ -2088,6 +2090,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
@@ -2128,6 +2130,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 d9b1712..868d400 100644
info.status = STATUS_SUCCESS;
info.wm = NULL;
@@ -2584,7 +2587,8 @@ overflow:
@@ -2624,7 +2627,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 d9b1712..868d400 100644
{
BOOL data = flags & (LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
enum loadorder loadorder;
@@ -2623,6 +2627,30 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2663,6 +2667,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 d9b1712..868d400 100644
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, filename );
if (handle && is_fake_dll( handle ))
@@ -2645,22 +2673,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2685,22 +2713,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 d9b1712..868d400 100644
if (nts == STATUS_SUCCESS && loadorder == LO_DEFAULT &&
(MODULE_InitDLL( *pwm, DLL_WINE_PREATTACH, NULL ) != STATUS_SUCCESS))
{
@@ -2670,7 +2698,7 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2710,7 +2738,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 d9b1712..868d400 100644
break;
}
@@ -2703,7 +2731,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
@@ -2743,7 +2771,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,21 +218,22 @@ index d9b1712..868d400 100644
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
@@ -3666,12 +3694,12 @@ void __wine_process_init(void)
@@ -3719,13 +3747,13 @@ 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)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
exit(1);
}
- 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 );
--
2.7.4
2.19.2

View File

@ -1,18 +1,18 @@
From 97251c147d843617cf2e3fcf3f273ea779d39742 Mon Sep 17 00:00:00 2001
From af247c7d7c66b23aaa62054d2f7eeb20f8428e26 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(-)
dlls/ntdll/loader.c | 10 +++++++++-
dlls/ntdll/ntdll.spec | 1 +
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index df206e8..e37aec2 100644
index 631e8bd9..f7a64a80 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -3493,15 +3493,17 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
@@ -3546,15 +3546,17 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
return TRUE;
}
@ -31,23 +31,24 @@ index df206e8..e37aec2 100644
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 );
@@ -3575,6 +3577,12 @@ void __wine_process_init(void)
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
exit(1);
}
+
+ 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 );
RtlInitAnsiString( &func_name, "__wine_kernel_init" );
if ((status = LdrGetProcedureAddress( wm->ldr.BaseAddress, &func_name,
0, (void **)&init_func )) != STATUS_SUCCESS)
diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec
index d321c44..3a7a144 100644
index c2e2fb1c..cb55df3a 100644
--- a/dlls/ntdll/ntdll.spec
+++ b/dlls/ntdll/ntdll.spec
@@ -1034,6 +1034,7 @@
@@ -1046,6 +1046,7 @@
@ stdcall WinSqmIsOptedIn()
@ stdcall WinSqmSetDWORD(ptr long long)
@ stdcall WinSqmStartSession(ptr long long)
@ -56,5 +57,5 @@ index d321c44..3a7a144 100644
@ 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
2.19.2