mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2024-11-21 16:46:54 -08:00
ntdll-Attach_Process_DLLs: Update patchset and fix a bug related to load ordering.
This commit is contained in:
parent
2260ec5633
commit
69b39e2f8a
@ -1,14 +1,14 @@
|
||||
From de0a7b30ea846237b6ea60ec75cf30540ef25743 Mon Sep 17 00:00:00 2001
|
||||
From 3c9bfe68c7bc4accbe80eeba910a227dc5ffa588 Mon Sep 17 00:00:00 2001
|
||||
From: Sebastian Lackner <sebastian@fds-team.de>
|
||||
Date: Wed, 20 Jul 2016 02:21:41 +0200
|
||||
Subject: ntdll: Ensure process dlls are not attached too early.
|
||||
Subject: ntdll: Ensure process dlls are not attached too early. (v2)
|
||||
|
||||
---
|
||||
dlls/ntdll/loader.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
dlls/ntdll/loader.c | 17 ++++++++++++++++-
|
||||
1 file changed, 16 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
|
||||
index d9176d7..f90b347 100644
|
||||
index f1ef7ab..adb6b95 100644
|
||||
--- a/dlls/ntdll/loader.c
|
||||
+++ b/dlls/ntdll/loader.c
|
||||
@@ -63,6 +63,7 @@ WINE_DECLARE_DEBUG_CHANNEL(pid);
|
||||
@ -19,16 +19,29 @@ index d9176d7..f90b347 100644
|
||||
static BOOL process_detaching = FALSE; /* set on process detach to avoid deadlocks with thread detach */
|
||||
static int free_lib_count; /* recursion depth of LdrUnloadDll calls */
|
||||
|
||||
@@ -443,7 +444,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
|
||||
{
|
||||
TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward );
|
||||
@@ -445,7 +446,20 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
|
||||
if (load_dll( load_path, mod_name, 0, &wm ) == STATUS_SUCCESS &&
|
||||
- !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
|
||||
+ !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) && !process_attaching)
|
||||
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
|
||||
{
|
||||
if (process_attach( wm, NULL ) != STATUS_SUCCESS)
|
||||
- if (process_attach( wm, NULL ) != STATUS_SUCCESS)
|
||||
+ if (process_attaching)
|
||||
+ {
|
||||
+ WINE_MODREF **deps, *prev = get_modref( module );
|
||||
+ if (!prev->deps)
|
||||
+ deps = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*deps) );
|
||||
+ else
|
||||
+ deps = RtlReAllocateHeap( GetProcessHeap(), 0, prev->deps, (prev->nDeps + 1) * sizeof(*deps) );
|
||||
+ if (deps)
|
||||
+ {
|
||||
+ prev->deps = deps;
|
||||
+ prev->deps[prev->nDeps++] = wm;
|
||||
+ }
|
||||
+ }
|
||||
+ else if (process_attach( wm, NULL ) != STATUS_SUCCESS)
|
||||
{
|
||||
@@ -2961,6 +2962,7 @@ static NTSTATUS attach_process_dlls( void *wm )
|
||||
LdrUnloadDll( wm->ldr.BaseAddress );
|
||||
wm = NULL;
|
||||
@@ -2970,6 +2984,7 @@ static NTSTATUS attach_process_dlls( void *wm )
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
||||
@ -37,5 +50,5 @@ index d9176d7..f90b347 100644
|
||||
|
||||
RtlEnterCriticalSection( &loader_section );
|
||||
--
|
||||
2.8.0
|
||||
2.9.0
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
From 030cc76851a388c7e4f2eb5b1623c78b9611e0e9 Mon Sep 17 00:00:00 2001
|
||||
From 0015fe086c802ef0e65a10f5e8a98a434967c617 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: ntdll: Implement loader redirection scheme.
|
||||
@ -8,7 +8,7 @@ Subject: ntdll: Implement loader redirection scheme.
|
||||
1 file changed, 44 insertions(+), 22 deletions(-)
|
||||
|
||||
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
|
||||
index 8db8087..c78f79a 100644
|
||||
index 0e862f9..a7e92b8 100644
|
||||
--- a/dlls/ntdll/loader.c
|
||||
+++ b/dlls/ntdll/loader.c
|
||||
@@ -93,6 +93,7 @@ struct builtin_load_info
|
||||
@ -35,10 +35,10 @@ index 8db8087..c78f79a 100644
|
||||
TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward );
|
||||
- if (load_dll( load_path, mod_name, 0, &wm ) == STATUS_SUCCESS &&
|
||||
+ if (load_dll( load_path, mod_name, NULL, 0, &wm ) == STATUS_SUCCESS &&
|
||||
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) && !process_attaching)
|
||||
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
|
||||
{
|
||||
if (process_attach( wm, NULL ) != STATUS_SUCCESS)
|
||||
@@ -599,7 +601,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
|
||||
if (process_attaching)
|
||||
@@ -612,7 +614,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 8db8087..c78f79a 100644
|
||||
}
|
||||
else /* need to allocate a larger buffer */
|
||||
{
|
||||
@@ -607,7 +609,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
|
||||
@@ -620,7 +622,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 8db8087..c78f79a 100644
|
||||
RtlFreeHeap( GetProcessHeap(), 0, ptr );
|
||||
}
|
||||
|
||||
@@ -927,7 +929,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
|
||||
@@ -944,7 +946,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.
|
||||
*/
|
||||
@ -65,7 +65,7 @@ index 8db8087..c78f79a 100644
|
||||
{
|
||||
WINE_MODREF *wm;
|
||||
const WCHAR *p;
|
||||
@@ -949,7 +951,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
|
||||
@@ -966,7 +968,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
|
||||
wm->ldr.TimeDateStamp = 0;
|
||||
wm->ldr.ActivationContext = 0;
|
||||
|
||||
@ -74,7 +74,7 @@ index 8db8087..c78f79a 100644
|
||||
if ((p = strrchrW( wm->ldr.FullDllName.Buffer, '\\' ))) p++;
|
||||
else p = wm->ldr.FullDllName.Buffer;
|
||||
RtlInitUnicodeString( &wm->ldr.BaseDllName, p );
|
||||
@@ -1577,7 +1579,7 @@ static void load_builtin_callback( void *module, const char *filename )
|
||||
@@ -1599,7 +1601,7 @@ static void load_builtin_callback( void *module, const char *filename )
|
||||
return;
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ index 8db8087..c78f79a 100644
|
||||
RtlFreeHeap( GetProcessHeap(), 0, fullname );
|
||||
if (!wm)
|
||||
{
|
||||
@@ -1759,8 +1761,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len )
|
||||
@@ -1781,8 +1783,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len )
|
||||
/******************************************************************************
|
||||
* load_native_dll (internal)
|
||||
*/
|
||||
@ -94,7 +94,7 @@ index 8db8087..c78f79a 100644
|
||||
{
|
||||
void *module;
|
||||
HANDLE mapping;
|
||||
@@ -1794,7 +1796,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
||||
@@ -1816,7 +1818,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
|
||||
|
||||
/* create the MODREF */
|
||||
|
||||
@ -103,7 +103,7 @@ index 8db8087..c78f79a 100644
|
||||
{
|
||||
status = STATUS_NO_MEMORY;
|
||||
goto done;
|
||||
@@ -1858,8 +1860,8 @@ done:
|
||||
@@ -1880,8 +1882,8 @@ done:
|
||||
/***********************************************************************
|
||||
* load_builtin_dll
|
||||
*/
|
||||
@ -114,7 +114,7 @@ index 8db8087..c78f79a 100644
|
||||
{
|
||||
char error[256], dllname[MAX_PATH];
|
||||
const WCHAR *name, *p;
|
||||
@@ -1879,6 +1881,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
|
||||
@@ -1901,6 +1903,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
|
||||
*/
|
||||
info.load_path = load_path;
|
||||
info.filename = NULL;
|
||||
@ -122,7 +122,7 @@ index 8db8087..c78f79a 100644
|
||||
info.status = STATUS_SUCCESS;
|
||||
info.wm = NULL;
|
||||
|
||||
@@ -2319,14 +2322,14 @@ overflow:
|
||||
@@ -2341,14 +2344,14 @@ overflow:
|
||||
return STATUS_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ index 8db8087..c78f79a 100644
|
||||
{
|
||||
BOOL data = flags & (LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
|
||||
enum loadorder loadorder;
|
||||
@@ -2364,6 +2367,25 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
|
||||
@@ -2386,6 +2389,25 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
|
||||
}
|
||||
|
||||
main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
|
||||
@ -165,7 +165,7 @@ index 8db8087..c78f79a 100644
|
||||
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, filename );
|
||||
|
||||
if (handle && is_fake_dll( handle ))
|
||||
@@ -2386,22 +2408,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
|
||||
@@ -2408,22 +2430,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
|
||||
if (!handle) nts = STATUS_DLL_NOT_FOUND;
|
||||
else
|
||||
{
|
||||
@ -193,7 +193,7 @@ index 8db8087..c78f79a 100644
|
||||
if (nts == STATUS_SUCCESS && loadorder == LO_DEFAULT &&
|
||||
(MODULE_InitDLL( *pwm, DLL_WINE_PREATTACH, NULL ) != STATUS_SUCCESS))
|
||||
{
|
||||
@@ -2411,7 +2433,7 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
|
||||
@@ -2433,7 +2455,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)
|
||||
@ -202,7 +202,7 @@ index 8db8087..c78f79a 100644
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2444,7 +2466,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
|
||||
@@ -2466,7 +2488,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
|
||||
RtlEnterCriticalSection( &loader_section );
|
||||
|
||||
if (!path_name) path_name = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
|
||||
@ -211,7 +211,7 @@ index 8db8087..c78f79a 100644
|
||||
|
||||
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
|
||||
{
|
||||
@@ -3410,7 +3432,7 @@ void __wine_process_init(void)
|
||||
@@ -3437,7 +3459,7 @@ void __wine_process_init(void)
|
||||
/* setup the load callback and create ntdll modref */
|
||||
wine_dll_set_callback( load_builtin_callback );
|
||||
|
||||
@ -221,5 +221,5 @@ index 8db8087..c78f79a 100644
|
||||
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
|
||||
exit(1);
|
||||
--
|
||||
2.8.0
|
||||
2.9.0
|
||||
|
||||
|
@ -4740,7 +4740,7 @@ fi
|
||||
if test "$enable_ntdll_Attach_Process_DLLs" -eq 1; then
|
||||
patch_apply ntdll-Attach_Process_DLLs/0001-ntdll-Ensure-process-dlls-are-not-attached-too-early.patch
|
||||
(
|
||||
echo '+ { "Sebastian Lackner", "ntdll: Ensure process dlls are not attached too early.", 1 },';
|
||||
echo '+ { "Sebastian Lackner", "ntdll: Ensure process dlls are not attached too early.", 2 },';
|
||||
) >> "$patchlist"
|
||||
fi
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user