Added patch to ensure process_attach callbacks are not executed too early.

This commit is contained in:
Sebastian Lackner 2016-07-20 05:00:15 +02:00
parent cbd440689d
commit 97fec39e47
7 changed files with 112 additions and 34 deletions

View File

@ -0,0 +1,41 @@
From de0a7b30ea846237b6ea60ec75cf30540ef25743 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.
---
dlls/ntdll/loader.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index d9176d7..f90b347 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -63,6 +63,7 @@ WINE_DECLARE_DEBUG_CHANNEL(pid);
typedef DWORD (CALLBACK *DLLENTRYPROC)(HMODULE,DWORD,LPVOID);
+static BOOL process_attaching = TRUE; /* set on process attach to avoid calling callbacks too early */
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 );
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)
{
if (process_attach( wm, NULL ) != STATUS_SUCCESS)
{
@@ -2961,6 +2962,7 @@ static NTSTATUS attach_process_dlls( void *wm )
{
NTSTATUS status;
+ process_attaching = FALSE;
pthread_sigmask( SIG_UNBLOCK, &server_block_set, NULL );
RtlEnterCriticalSection( &loader_section );
--
2.8.0

View File

@ -0,0 +1 @@
Fixes: [40714] Ensure process_attach callbacks are not executed too early

View File

@ -1,4 +1,4 @@
From cea071b746980986f7a1a5c502445588c95e6f37 Mon Sep 17 00:00:00 2001
From 030cc76851a388c7e4f2eb5b1623c78b9611e0e9 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,10 +8,10 @@ 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 1e2e28e..94ca2f0 100644
index 8db8087..c78f79a 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -92,6 +92,7 @@ struct builtin_load_info
@@ -93,6 +93,7 @@ struct builtin_load_info
{
const WCHAR *load_path;
const WCHAR *filename;
@ -19,7 +19,7 @@ index 1e2e28e..94ca2f0 100644
NTSTATUS status;
WINE_MODREF *wm;
};
@@ -117,7 +118,8 @@ static WINE_MODREF *cached_modref;
@@ -118,7 +119,8 @@ static WINE_MODREF *cached_modref;
static WINE_MODREF *current_modref;
static WINE_MODREF *last_failed_modref;
@ -35,7 +35,7 @@ index 1e2e28e..94ca2f0 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))
!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) && !process_attaching)
{
if (process_attach( wm, NULL ) != STATUS_SUCCESS)
@@ -599,7 +601,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
@ -65,7 +65,7 @@ index 1e2e28e..94ca2f0 100644
{
WINE_MODREF *wm;
const WCHAR *p;
@@ -950,7 +952,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
@@ -949,7 +951,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, LPCWSTR filename )
wm->ldr.TimeDateStamp = 0;
wm->ldr.ActivationContext = 0;
@ -74,7 +74,7 @@ index 1e2e28e..94ca2f0 100644
if ((p = strrchrW( wm->ldr.FullDllName.Buffer, '\\' ))) p++;
else p = wm->ldr.FullDllName.Buffer;
RtlInitUnicodeString( &wm->ldr.BaseDllName, p );
@@ -1589,7 +1591,7 @@ static void load_builtin_callback( void *module, const char *filename )
@@ -1577,7 +1579,7 @@ static void load_builtin_callback( void *module, const char *filename )
return;
}
@ -83,7 +83,7 @@ index 1e2e28e..94ca2f0 100644
RtlFreeHeap( GetProcessHeap(), 0, fullname );
if (!wm)
{
@@ -1771,8 +1773,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len )
@@ -1759,8 +1761,8 @@ static NTSTATUS perform_relocations( void *module, SIZE_T len )
/******************************************************************************
* load_native_dll (internal)
*/
@ -94,7 +94,7 @@ index 1e2e28e..94ca2f0 100644
{
void *module;
HANDLE mapping;
@@ -1806,7 +1808,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
@@ -1794,7 +1796,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
/* create the MODREF */
@ -103,7 +103,7 @@ index 1e2e28e..94ca2f0 100644
{
status = STATUS_NO_MEMORY;
goto done;
@@ -1870,8 +1872,8 @@ done:
@@ -1858,8 +1860,8 @@ done:
/***********************************************************************
* load_builtin_dll
*/
@ -114,7 +114,7 @@ index 1e2e28e..94ca2f0 100644
{
char error[256], dllname[MAX_PATH];
const WCHAR *name, *p;
@@ -1891,6 +1893,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, LPCWSTR path, HANDLE file,
@@ -1879,6 +1881,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 1e2e28e..94ca2f0 100644
info.status = STATUS_SUCCESS;
info.wm = NULL;
@@ -2331,14 +2334,14 @@ overflow:
@@ -2319,14 +2322,14 @@ overflow:
return STATUS_BUFFER_TOO_SMALL;
}
@ -139,7 +139,7 @@ index 1e2e28e..94ca2f0 100644
{
BOOL data = flags & (LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE);
enum loadorder loadorder;
@@ -2376,6 +2379,25 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2364,6 +2367,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 1e2e28e..94ca2f0 100644
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, filename );
if (handle && is_fake_dll( handle ))
@@ -2398,22 +2420,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2386,22 +2408,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 1e2e28e..94ca2f0 100644
if (nts == STATUS_SUCCESS && loadorder == LO_DEFAULT &&
(MODULE_InitDLL( *pwm, DLL_WINE_PREATTACH, NULL ) != STATUS_SUCCESS))
{
@@ -2423,7 +2445,7 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
@@ -2411,7 +2433,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 1e2e28e..94ca2f0 100644
break;
}
@@ -2456,7 +2478,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
@@ -2444,7 +2466,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 1e2e28e..94ca2f0 100644
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
@@ -3419,7 +3441,7 @@ void __wine_process_init(void)
@@ -3410,7 +3432,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 1e2e28e..94ca2f0 100644
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
exit(1);
--
2.7.1
2.8.0

View File

@ -1,4 +1,5 @@
Fixes: Support for loader dll redirections
Depends: ntdll-Loader_Machine_Type
Depends: ntdll-DllOverrides_WOW64
Depends: ntdll-Attach_Process_DLLs
Category: stable

View File

@ -1,4 +1,4 @@
From cbdf0dd0760cda9667c1b7a3ae458a7a6724dc58 Mon Sep 17 00:00:00 2001
From d804ddb4f49172915b88eb048cfe532a96eb41df Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sat, 30 May 2015 02:23:15 +0200
Subject: ntdll: Add support for hiding wine version information from
@ -10,22 +10,23 @@ Subject: ntdll: Add support for hiding wine version information from
2 files changed, 100 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 921bf57..6390df0 100644
index 130d154..d84e156 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -56,8 +56,11 @@ WINE_DECLARE_DEBUG_CHANNEL(imports);
@@ -63,9 +63,12 @@ WINE_DECLARE_DEBUG_CHANNEL(pid);
typedef DWORD (CALLBACK *DLLENTRYPROC)(HMODULE,DWORD,LPVOID);
+#define IS_OPTION_TRUE(ch) ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
+
static BOOL process_attaching = TRUE; /* set on process attach to avoid calling callbacks too early */
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 */
+static BOOL hide_wine_exports = FALSE; /* try to hide ntdll wine exports from applications */
static const char * const reason_names[] =
{
@@ -1395,6 +1398,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic )
@@ -1543,6 +1546,96 @@ NTSTATUS WINAPI LdrUnlockLoaderLock( ULONG flags, ULONG_PTR magic )
}
@ -122,7 +123,7 @@ index 921bf57..6390df0 100644
/******************************************************************
* LdrGetProcedureAddress (NTDLL.@)
*/
@@ -1415,7 +1508,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
@@ -1563,7 +1656,7 @@ NTSTATUS WINAPI LdrGetProcedureAddress(HMODULE module, const ANSI_STRING *name,
LPCWSTR load_path = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
void *proc = name ? find_named_export( module, exports, exp_size, name->Buffer, -1, load_path )
: find_ordinal_export( module, exports, exp_size, ord - exports->Base, load_path );
@ -131,7 +132,7 @@ index 921bf57..6390df0 100644
{
*address = proc;
ret = STATUS_SUCCESS;
@@ -2897,6 +2990,7 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
@@ -3198,6 +3291,7 @@ void WINAPI LdrInitializeThunk( void *kernel_start, ULONG_PTR unknown2,
if (!peb->ProcessParameters->WindowTitle.Buffer)
peb->ProcessParameters->WindowTitle = wm->ldr.FullDllName;
version_init( wm->ldr.FullDllName.Buffer );
@ -140,10 +141,10 @@ index 921bf57..6390df0 100644
LdrQueryImageFileExecutionOptions( &peb->ProcessParameters->ImagePathName, globalflagW,
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index cbd19db..3a55926 100644
index 5e4c39e..723c3d8 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -268,4 +268,9 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN;
@@ -266,4 +266,9 @@ extern HANDLE keyed_event DECLSPEC_HIDDEN;
NTSTATUS WINAPI RtlHashUnicodeString(PCUNICODE_STRING,BOOLEAN,ULONG,ULONG*);
@ -154,5 +155,5 @@ index cbd19db..3a55926 100644
+
#endif
--
2.4.2
2.8.0

View File

@ -1 +1,2 @@
Fixes: [38656] Add support for hiding wine version information from applications
Depends: ntdll-Attach_Process_DLLs

View File

@ -200,6 +200,7 @@ patch_enable_all ()
enable_ntdll_APC_Start_Process="$1"
enable_ntdll_Activation_Context="$1"
enable_ntdll_ApiSetQueryApiSetPresence="$1"
enable_ntdll_Attach_Process_DLLs="$1"
enable_ntdll_CLI_Images="$1"
enable_ntdll_DOS_Attributes="$1"
enable_ntdll_Dealloc_Thread_Stack="$1"
@ -773,6 +774,9 @@ patch_enable ()
ntdll-ApiSetQueryApiSetPresence)
enable_ntdll_ApiSetQueryApiSetPresence="$2"
;;
ntdll-Attach_Process_DLLs)
enable_ntdll_Attach_Process_DLLs="$2"
;;
ntdll-CLI_Images)
enable_ntdll_CLI_Images="$2"
;;
@ -2147,13 +2151,24 @@ if test "$enable_ntdll_Junction_Points" -eq 1; then
enable_ntdll_NtQueryEaFile=1
fi
if test "$enable_ntdll_Hide_Wine_Exports" -eq 1; then
if test "$enable_ntdll_Attach_Process_DLLs" -gt 1; then
abort "Patchset ntdll-Attach_Process_DLLs disabled, but ntdll-Hide_Wine_Exports depends on that."
fi
enable_ntdll_Attach_Process_DLLs=1
fi
if test "$enable_ntdll_DllRedirects" -eq 1; then
if test "$enable_ntdll_Attach_Process_DLLs" -gt 1; then
abort "Patchset ntdll-Attach_Process_DLLs disabled, but ntdll-DllRedirects depends on that."
fi
if test "$enable_ntdll_DllOverrides_WOW64" -gt 1; then
abort "Patchset ntdll-DllOverrides_WOW64 disabled, but ntdll-DllRedirects depends on that."
fi
if test "$enable_ntdll_Loader_Machine_Type" -gt 1; then
abort "Patchset ntdll-Loader_Machine_Type disabled, but ntdll-DllRedirects depends on that."
fi
enable_ntdll_Attach_Process_DLLs=1
enable_ntdll_DllOverrides_WOW64=1
enable_ntdll_Loader_Machine_Type=1
fi
@ -4658,6 +4673,21 @@ if test "$enable_ntdll_ApiSetQueryApiSetPresence" -eq 1; then
) >> "$patchlist"
fi
# Patchset ntdll-Attach_Process_DLLs
# |
# | This patchset fixes the following Wine bugs:
# | * [#40714] Ensure process_attach callbacks are not executed too early
# |
# | Modified files:
# | * dlls/ntdll/loader.c
# |
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 },';
) >> "$patchlist"
fi
# Patchset ntdll-CLI_Images
# |
# | This patchset has the following (direct or indirect) dependencies:
@ -4764,7 +4794,7 @@ fi
# Patchset ntdll-DllRedirects
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type
# | * ntdll-Attach_Process_DLLs, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type
# |
# | Modified files:
# | * dlls/ntdll/loader.c, dlls/ntdll/loadorder.c, dlls/ntdll/ntdll_misc.h
@ -4854,6 +4884,9 @@ fi
# Patchset ntdll-Hide_Wine_Exports
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * ntdll-Attach_Process_DLLs
# |
# | This patchset fixes the following Wine bugs:
# | * [#38656] Add support for hiding wine version information from applications
# |
@ -5000,7 +5033,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-Attach_Process_DLLs, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects
# |
# | Modified files:
# | * dlls/ntdll/loadorder.c
@ -6843,7 +6876,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-Attach_Process_DLLs, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects
# |
# | Modified files:
# | * aclocal.m4, configure.ac, dlls/uxtheme-gtk/Makefile.in, dlls/uxtheme-gtk/button.c, dlls/uxtheme-gtk/combobox.c, dlls
@ -7206,8 +7239,8 @@ fi
# Patchset wined3d-CSMT_Helper
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * makedep-PARENTSPEC, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects, wined3d-Accounting,
# | wined3d-DXTn, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs
# | * makedep-PARENTSPEC, ntdll-Attach_Process_DLLs, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects,
# | wined3d-Accounting, wined3d-DXTn, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs
# |
# | Modified files:
# | * configure.ac, dlls/wined3d-csmt/Makefile.in, dlls/wined3d-csmt/version.rc
@ -7234,8 +7267,8 @@ fi
# Patchset wined3d-CSMT_Main
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * makedep-PARENTSPEC, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects, wined3d-Accounting,
# | wined3d-DXTn, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs, wined3d-CSMT_Helper
# | * makedep-PARENTSPEC, ntdll-Attach_Process_DLLs, ntdll-DllOverrides_WOW64, ntdll-Loader_Machine_Type, ntdll-DllRedirects,
# | wined3d-Accounting, wined3d-DXTn, wined3d-QUERY_Stubs, wined3d-Silence_FIXMEs, wined3d-CSMT_Helper
# |
# | This patchset fixes the following Wine bugs:
# | * [#11674] Support for CSMT (command stream) to increase graphic performance