ntdll-DllRedirects: Remove patch set.

This patch has caused a disproportionate amount of annoyance during
rebases, and this is only likely to increase. On top of this it is not
an especially good way to structure things; switching between
interfaces is something best done within one DLL.
This commit is contained in:
Zebediah Figura 2019-02-09 16:20:19 -06:00
parent 3d74da6622
commit c6aeba1397
7 changed files with 18 additions and 804 deletions

View File

@ -1,146 +0,0 @@
From af18765a883e4eb6acb37ef63dd38f1782d24717 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 13 Dec 2014 02:14:30 +0100
Subject: ntdll: Move logic to determine loadorder HKCU/app key into separate
functions.
---
dlls/ntdll/loadorder.c | 104 +++++++++++++++++++++++------------------
1 file changed, 58 insertions(+), 46 deletions(-)
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index c6c02459..0102c560 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -289,6 +289,60 @@ static inline enum loadorder get_env_load_order( const WCHAR *module )
}
+/***************************************************************************
+ * open_user_reg_key
+ *
+ * Return a handle to a registry key under HKCU.
+ */
+static HANDLE open_user_reg_key(const WCHAR *key_name)
+{
+ HANDLE hkey, root;
+ OBJECT_ATTRIBUTES attr;
+ UNICODE_STRING nameW;
+
+ RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
+ attr.Length = sizeof(attr);
+ attr.RootDirectory = root;
+ attr.ObjectName = &nameW;
+ attr.Attributes = 0;
+ attr.SecurityDescriptor = NULL;
+ attr.SecurityQualityOfService = NULL;
+ RtlInitUnicodeString( &nameW, key_name );
+
+ if (NtOpenKey( &hkey, KEY_ALL_ACCESS, &attr )) hkey = 0;
+ NtClose( root );
+
+ return hkey;
+}
+
+
+/***************************************************************************
+ * open_app_reg_key
+ *
+ * Return a handle to an app-specific registry key.
+ */
+static HANDLE open_app_reg_key( const WCHAR *sub_key, const WCHAR *app_name )
+{
+ static const WCHAR AppDefaultsW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
+ 'A','p','p','D','e','f','a','u','l','t','s','\\',0};
+ WCHAR *str;
+ HANDLE hkey;
+
+ str = RtlAllocateHeap( GetProcessHeap(), 0,
+ sizeof(AppDefaultsW) +
+ strlenW(sub_key) * sizeof(WCHAR) +
+ strlenW(app_name) * sizeof(WCHAR) );
+ if (!str) return 0;
+ strcpyW( str, AppDefaultsW );
+ strcatW( str, app_name );
+ strcatW( str, sub_key );
+
+ hkey = open_user_reg_key( str );
+ RtlFreeHeap( GetProcessHeap(), 0, str );
+ return hkey;
+}
+
+
/***************************************************************************
* get_standard_key
*
@@ -301,24 +355,8 @@ static HANDLE get_standard_key(void)
static HANDLE std_key = (HANDLE)-1;
if (std_key == (HANDLE)-1)
- {
- OBJECT_ATTRIBUTES attr;
- UNICODE_STRING nameW;
- HANDLE root;
-
- RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
- attr.Length = sizeof(attr);
- attr.RootDirectory = root;
- attr.ObjectName = &nameW;
- attr.Attributes = 0;
- attr.SecurityDescriptor = NULL;
- attr.SecurityQualityOfService = NULL;
- RtlInitUnicodeString( &nameW, DllOverridesW );
-
- /* @@ Wine registry key: HKCU\Software\Wine\DllOverrides */
- if (NtOpenKey( &std_key, KEY_ALL_ACCESS, &attr )) std_key = 0;
- NtClose( root );
- }
+ std_key = open_user_reg_key( DllOverridesW );
+
return std_key;
}
@@ -330,38 +368,12 @@ static HANDLE get_standard_key(void)
*/
static HANDLE get_app_key( const WCHAR *app_name )
{
- OBJECT_ATTRIBUTES attr;
- UNICODE_STRING nameW;
- HANDLE root;
- WCHAR *str;
- static const WCHAR AppDefaultsW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
- 'A','p','p','D','e','f','a','u','l','t','s','\\',0};
static const WCHAR DllOverridesW[] = {'\\','D','l','l','O','v','e','r','r','i','d','e','s',0};
static HANDLE app_key = (HANDLE)-1;
- if (app_key != (HANDLE)-1) return app_key;
+ if (app_key == (HANDLE)-1)
+ app_key = open_app_reg_key( DllOverridesW, app_name );
- str = RtlAllocateHeap( GetProcessHeap(), 0,
- sizeof(AppDefaultsW) + sizeof(DllOverridesW) +
- strlenW(app_name) * sizeof(WCHAR) );
- if (!str) return 0;
- strcpyW( str, AppDefaultsW );
- strcatW( str, app_name );
- strcatW( str, DllOverridesW );
-
- RtlOpenCurrentUser( KEY_ALL_ACCESS, &root );
- attr.Length = sizeof(attr);
- attr.RootDirectory = root;
- attr.ObjectName = &nameW;
- attr.Attributes = 0;
- attr.SecurityDescriptor = NULL;
- attr.SecurityQualityOfService = NULL;
- RtlInitUnicodeString( &nameW, str );
-
- /* @@ Wine registry key: HKCU\Software\Wine\AppDefaults\app.exe\DllOverrides */
- if (NtOpenKey( &app_key, KEY_ALL_ACCESS, &attr )) app_key = 0;
- NtClose( root );
- RtlFreeHeap( GetProcessHeap(), 0, str );
return app_key;
}
--
2.20.1

View File

@ -1,85 +0,0 @@
From 659b7d1dce76b50a488472fd8fc53b1f4e9b48ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 13 Dec 2014 02:32:51 +0100
Subject: ntdll: Move logic to read loadorder registry values into separate
function.
---
dlls/ntdll/loadorder.c | 40 ++++++++++++++++++++++++++++------------
1 file changed, 28 insertions(+), 12 deletions(-)
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index d45a85f..8250692 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -379,25 +379,41 @@ static HANDLE get_app_key( const WCHAR *app_name )
/***************************************************************************
- * get_registry_value
+ * get_registry_string
*
- * Load the registry loadorder value for a given module.
+ * Load a registry string for a given module.
*/
-static enum loadorder get_registry_value( HANDLE hkey, const WCHAR *module )
+static WCHAR* get_registry_string( HANDLE hkey, const WCHAR *module, BYTE *buffer,
+ ULONG size )
{
UNICODE_STRING valueW;
- char buffer[80];
DWORD count;
+ WCHAR *ret = NULL;
RtlInitUnicodeString( &valueW, module );
-
- if (!NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation,
- buffer, sizeof(buffer), &count ))
+ if (size >= sizeof(WCHAR) &&
+ !NtQueryValueKey( hkey, &valueW, KeyValuePartialInformation,
+ buffer, size - sizeof(WCHAR), &count ))
{
- WCHAR *str = (WCHAR *)((KEY_VALUE_PARTIAL_INFORMATION *)buffer)->Data;
- return parse_load_order( str );
+ KEY_VALUE_PARTIAL_INFORMATION *info = (void *)buffer;
+ ret = (WCHAR *)info->Data;
+ ret[info->DataLength / sizeof(WCHAR)] = 0;
}
- return LO_INVALID;
+
+ return ret;
+}
+
+
+/***************************************************************************
+ * get_registry_load_order
+ *
+ * Load the registry loadorder value for a given module.
+ */
+static enum loadorder get_registry_load_order( HANDLE hkey, const WCHAR *module )
+{
+ BYTE buffer[81];
+ WCHAR *str = get_registry_string( hkey, module, buffer, sizeof(buffer) );
+ return str ? parse_load_order( str ) : LO_INVALID;
}
@@ -419,13 +435,13 @@ static enum loadorder get_load_order_value( HANDLE std_key, HANDLE app_key, cons
return ret;
}
- if (app_key && ((ret = get_registry_value( app_key, module )) != LO_INVALID))
+ if (app_key && ((ret = get_registry_load_order( app_key, module )) != LO_INVALID))
{
TRACE( "got app defaults %s for %s\n", debugstr_loadorder(ret), debugstr_w(module) );
return ret;
}
- if (std_key && ((ret = get_registry_value( std_key, module )) != LO_INVALID))
+ if (std_key && ((ret = get_registry_load_order( std_key, module )) != LO_INVALID))
{
TRACE( "got standard key %s for %s\n", debugstr_loadorder(ret), debugstr_w(module) );
return ret;
--
1.9.1

View File

@ -1,84 +0,0 @@
From 7fd1463fccfb8ef7dc9632ab779c49050906b5be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 13 Dec 2014 02:57:41 +0100
Subject: [PATCH] ntdll: Move code to determine module basename into separate
function.
---
dlls/ntdll/loadorder.c | 46 +++++++++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 16 deletions(-)
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index c013bb2b..eb7e6723 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -450,6 +450,34 @@ static enum loadorder get_load_order_value( HANDLE std_key, HANDLE app_key, cons
return ret;
}
+ /***************************************************************************
+ * get_module_basename (internal)
+ *
+ * Return the loadorder of a module.
+ * The system directory and '.dll' extension is stripped from the path.
+ */
+static WCHAR* get_module_basename( const WCHAR *path, WCHAR **basename )
+{
+ int len;
+ WCHAR *module;
+
+ /* Strip path information if the module resides in the system directory
+ */
+ if (!strncmpiW( system_dir, path, strlenW( system_dir )))
+ {
+ const WCHAR *p = path + strlenW( system_dir );
+ while (*p == '\\' || *p == '/') p++;
+ if (!strchrW( p, '\\' ) && !strchrW( p, '/' )) path = p;
+ }
+
+ if (!(len = strlenW(path))) return NULL;
+ if (!(module = RtlAllocateHeap( GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR) ))) return NULL;
+ strcpyW( module+1, path ); /* reserve module[0] for the wildcard char */
+ *basename = (WCHAR *)get_basename( module+1 );
+
+ if (len >= 4) remove_dll_ext( module + 1 + len - 4 );
+ return module;
+}
/***************************************************************************
* get_load_order (internal)
@@ -464,7 +492,6 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
HANDLE std_key, app_key = 0;
const WCHAR *path = nt_name->Buffer;
WCHAR *module, *basename;
- int len;
if (!init_done) init_load_order();
std_key = get_standard_key();
@@ -473,21 +500,8 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
TRACE("looking for %s\n", debugstr_w(path));
- /* Strip path information if the module resides in the system directory
- */
- if (!strncmpiW( system_dir, path, strlenW( system_dir )))
- {
- const WCHAR *p = path + strlenW( system_dir );
- while (*p == '\\' || *p == '/') p++;
- if (!strchrW( p, '\\' ) && !strchrW( p, '/' )) path = p;
- }
-
- if (!(len = strlenW(path))) return ret;
- if (!(module = RtlAllocateHeap( GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR) ))) return ret;
- strcpyW( module+1, path ); /* reserve module[0] for the wildcard char */
- basename = (WCHAR *)get_basename( module+1 );
-
- if (len >= 4) remove_dll_ext( module + 1 + len - 4 );
+ if (!(module = get_module_basename(path, &basename)))
+ return ret;
/* first explicit module name */
if ((ret = get_load_order_value( std_key, app_key, module+1 )) != LO_INVALID)
--
2.20.1

View File

@ -1,194 +0,0 @@
From 4dfc4b1420d91a8f288aaad946e85c170e7dd214 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 13 Dec 2014 03:18:35 +0100
Subject: [PATCH] ntdll: Implement get_redirect function.
---
dlls/ntdll/loadorder.c | 118 +++++++++++++++++++++++++++++++++++++---
dlls/ntdll/ntdll_misc.h | 1 +
2 files changed, 112 insertions(+), 7 deletions(-)
diff --git a/dlls/ntdll/loadorder.c b/dlls/ntdll/loadorder.c
index eb7e6723..c88666ad 100644
--- a/dlls/ntdll/loadorder.c
+++ b/dlls/ntdll/loadorder.c
@@ -344,11 +344,11 @@ static HANDLE open_app_reg_key( const WCHAR *sub_key, const WCHAR *app_name )
/***************************************************************************
- * get_standard_key
+ * get_override_standard_key
*
* Return a handle to the standard DllOverrides registry section.
*/
-static HANDLE get_standard_key(void)
+static HANDLE get_override_standard_key(void)
{
static const WCHAR DllOverridesW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
'D','l','l','O','v','e','r','r','i','d','e','s',0};
@@ -362,11 +362,11 @@ static HANDLE get_standard_key(void)
/***************************************************************************
- * get_app_key
+ * get_override_app_key
*
* Get the registry key for the app-specific DllOverrides list.
*/
-static HANDLE get_app_key( const WCHAR *app_name )
+static HANDLE get_override_app_key( const WCHAR *app_name )
{
static const WCHAR DllOverridesW[] = {'\\','D','l','l','O','v','e','r','r','i','d','e','s',0};
static HANDLE app_key = (HANDLE)-1;
@@ -378,6 +378,41 @@ static HANDLE get_app_key( const WCHAR *app_name )
}
+/***************************************************************************
+ * get_redirect_standard_key
+ *
+ * Return a handle to the standard DllRedirects registry section.
+ */
+static HANDLE get_redirect_standard_key(void)
+{
+ static const WCHAR DllRedirectsW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
+ 'D','l','l','R','e','d','i','r','e','c','t','s',0};
+ static HANDLE std_key = (HANDLE)-1;
+
+ if (std_key == (HANDLE)-1)
+ std_key = open_user_reg_key( DllRedirectsW );
+
+ return std_key;
+}
+
+
+/***************************************************************************
+ * get_redirect_app_key
+ *
+ * Get the registry key for the app-specific DllRedirects list.
+ */
+static HANDLE get_redirect_app_key( const WCHAR *app_name )
+{
+ static const WCHAR DllRedirectsW[] = {'\\','D','l','l','R','e','d','i','r','e','c','t','s',0};
+ static HANDLE app_key = (HANDLE)-1;
+
+ if (app_key == (HANDLE)-1)
+ app_key = open_app_reg_key( DllRedirectsW, app_name );
+
+ return app_key;
+}
+
+
/***************************************************************************
* get_registry_string
*
@@ -416,6 +451,32 @@ static enum loadorder get_registry_load_order( HANDLE hkey, const WCHAR *module
return str ? parse_load_order( str ) : LO_INVALID;
}
+ /***************************************************************************
+ * get_redirect_value
+ *
+ * Get the redirect value for the exact specified module string, looking in:
+ * 1. The per-application DllRedirects key
+ * 2. The standard DllRedirects key
+ */
+static WCHAR* get_redirect_value( HANDLE std_key, HANDLE app_key, const WCHAR *module,
+ BYTE *buffer, ULONG size )
+{
+ WCHAR *ret = NULL;
+
+ if (app_key && (ret = get_registry_string( app_key, module, buffer, size )))
+ {
+ TRACE( "got app defaults %s for %s\n", debugstr_w(ret), debugstr_w(module) );
+ return ret;
+ }
+
+ if (std_key && (ret = get_registry_string( std_key, module, buffer, size )))
+ {
+ TRACE( "got standard key %s for %s\n", debugstr_w(ret), debugstr_w(module) );
+ return ret;
+ }
+
+ return ret;
+}
/***************************************************************************
* get_load_order_value
@@ -494,11 +555,11 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
WCHAR *module, *basename;
if (!init_done) init_load_order();
- std_key = get_standard_key();
- if (app_name) app_key = get_app_key( app_name );
+ std_key = get_override_standard_key();
+ if (app_name) app_key = get_override_app_key( app_name );
if (!strncmpW( path, nt_prefixW, 4 )) path += 4;
- TRACE("looking for %s\n", debugstr_w(path));
+ TRACE("looking up loadorder for %s\n", debugstr_w(path));
if (!(module = get_module_basename(path, &basename)))
return ret;
@@ -532,3 +593,46 @@ enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_n
RtlFreeHeap( GetProcessHeap(), 0, module );
return ret;
}
+
+
+/***************************************************************************
+ * get_redirect (internal)
+ *
+ * Return the redirect value of a module.
+ * The system directory and '.dll' extension is stripped from the path.
+ */
+WCHAR* get_redirect( const WCHAR *app_name, const WCHAR *path, BYTE *buffer, ULONG size )
+{
+ WCHAR *ret = NULL;
+ HANDLE std_key, app_key = 0;
+ WCHAR *module, *basename;
+
+ std_key = get_redirect_standard_key();
+ if (app_name) app_key = get_redirect_app_key( app_name );
+
+ TRACE("looking up redirection for %s\n", debugstr_w(path));
+
+ if (!(module = get_module_basename(path, &basename)))
+ return ret;
+
+ /* first explicit module name */
+ if ((ret = get_redirect_value( std_key, app_key, module+1, buffer, size )))
+ goto done;
+
+ /* then module basename preceded by '*' */
+ basename[-1] = '*';
+ if ((ret = get_redirect_value( std_key, app_key, basename-1, buffer, size )))
+ goto done;
+
+ /* then module basename without '*' (only if explicit path) */
+ if (basename != module+1 && (ret = get_redirect_value( std_key, app_key, basename, buffer, size )))
+ goto done;
+
+ /* and last the hard-coded default */
+ ret = NULL;
+ TRACE( "no redirection found for %s\n", debugstr_w(path) );
+
+ done:
+ RtlFreeHeap( GetProcessHeap(), 0, module );
+ return ret;
+}
diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h
index 5b32abc5..eff7d579 100644
--- a/dlls/ntdll/ntdll_misc.h
+++ b/dlls/ntdll/ntdll_misc.h
@@ -217,6 +217,7 @@ enum loadorder
};
extern enum loadorder get_load_order( const WCHAR *app_name, const UNICODE_STRING *nt_name ) DECLSPEC_HIDDEN;
+extern WCHAR* get_redirect( const WCHAR *app_name, const WCHAR *path, BYTE *buffer, ULONG size ) DECLSPEC_HIDDEN;
struct debug_info
{
--
2.20.1

View File

@ -1,240 +0,0 @@
From 7867b70c1096e5cf40677b6c15ff2900fb2697f4 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 +++++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 23 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index c1976ef5..8ab33a11 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -110,6 +110,7 @@ struct builtin_load_info
{
const WCHAR *load_path;
const UNICODE_STRING *filename;
+ const WCHAR *fakemodule;
NTSTATUS status;
WINE_MODREF *wm;
};
@@ -134,7 +135,8 @@ static WINE_MODREF *cached_modref;
static WINE_MODREF *current_modref;
static WINE_MODREF *last_failed_modref;
-static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_MODREF** pwm );
+static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, LPCWSTR fakemodule,
+ DWORD flags, WINE_MODREF** pwm );
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 );
@@ -515,7 +517,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 );
- 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))
{
if (!imports_fixup_done && current_modref)
@@ -686,7 +688,7 @@ static BOOL import_dll( HMODULE module, const IMAGE_IMPORT_DESCRIPTOR *descr, LP
{
ascii_to_unicode( buffer, name, len );
buffer[len] = 0;
- status = load_dll( load_path, buffer, 0, &wmImp );
+ status = load_dll( load_path, buffer, NULL, 0, &wmImp );
}
else /* need to allocate a larger buffer */
{
@@ -694,7 +696,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;
- status = load_dll( load_path, ptr, 0, &wmImp );
+ status = load_dll( load_path, ptr, NULL, 0, &wmImp );
RtlFreeHeap( GetProcessHeap(), 0, ptr );
}
@@ -980,7 +982,7 @@ static NTSTATUS fixup_imports_ilonly( WINE_MODREF *wm, LPCWSTR load_path, void *
prev = current_modref;
current_modref = wm;
- if (!(status = load_dll( load_path, mscoreeW, 0, &imp ))) wm->deps[0] = imp;
+ if (!(status = load_dll( load_path, mscoreeW, NULL, 0, &imp ))) wm->deps[0] = imp;
current_modref = prev;
if (status)
{
@@ -1068,7 +1070,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.
*/
-static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name )
+static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name, const WCHAR *fakemodule )
{
WINE_MODREF *wm;
const WCHAR *p;
@@ -1082,7 +1084,7 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
wm->ldr.TlsIndex = -1;
wm->ldr.LoadCount = 1;
- RtlCreateUnicodeString( &wm->ldr.FullDllName, nt_name->Buffer + 4 /* \??\ prefix */ );
+ RtlCreateUnicodeString( &wm->ldr.FullDllName, fakemodule ? fakemodule : nt_name->Buffer + 4 /* \??\ prefix */ );
if ((p = strrchrW( wm->ldr.FullDllName.Buffer, '\\' ))) p++;
else p = wm->ldr.FullDllName.Buffer;
RtlInitUnicodeString( &wm->ldr.BaseDllName, p );
@@ -1752,7 +1754,7 @@ static void load_builtin_callback( void *module, const char *filename )
return;
}
- wm = alloc_module( module, &nt_name );
+ wm = alloc_module( module, &nt_name, builtin_load_info->fakemodule );
RtlFreeUnicodeString( &nt_name );
if (!wm)
{
@@ -2015,8 +2017,8 @@ static BOOL is_valid_binary( HMODULE module, const pe_image_info_t *info )
/******************************************************************************
* load_native_dll (internal)
*/
-static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name, HANDLE file,
- DWORD flags, WINE_MODREF** pwm, struct stat *st )
+static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name, LPCWSTR fakemodule,
+ HANDLE file, DWORD flags, WINE_MODREF** pwm, struct stat *st )
{
void *module;
HANDLE mapping;
@@ -2059,7 +2061,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam
/* create the MODREF */
- if (!(wm = alloc_module( module, nt_name )))
+ if (!(wm = alloc_module( module, nt_name, fakemodule )))
{
if (module) NtUnmapViewOfSection( NtCurrentProcess(), module );
return STATUS_NO_MEMORY;
@@ -2127,8 +2129,8 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, const UNICODE_STRING *nt_nam
/***********************************************************************
* load_builtin_dll
*/
-static NTSTATUS load_builtin_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name, HANDLE file,
- DWORD flags, WINE_MODREF** pwm )
+static NTSTATUS load_builtin_dll( LPCWSTR load_path, const UNICODE_STRING *nt_name, LPCWSTR fakemodule,
+ HANDLE file, DWORD flags, WINE_MODREF** pwm )
{
char error[256], dllname[MAX_PATH];
const WCHAR *name, *p;
@@ -2148,6 +2150,7 @@ static NTSTATUS load_builtin_dll( LPCWSTR load_path, const UNICODE_STRING *nt_na
*/
info.load_path = load_path;
info.filename = NULL;
+ info.fakemodule = fakemodule;
info.status = STATUS_SUCCESS;
info.wm = NULL;
@@ -2513,7 +2516,8 @@ found:
* Load a PE style module according to the load order.
* The loader_section must be locked while calling this function.
*/
-static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_MODREF** pwm )
+static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, LPCWSTR fakemodule,
+ DWORD flags, WINE_MODREF** pwm )
{
enum loadorder loadorder;
WINE_MODREF *main_exe;
@@ -2540,6 +2544,30 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
}
main_exe = get_modref( NtCurrentTeb()->Peb->ImageBaseAddress );
+
+ /* handle dll redirection */
+ if (!fakemodule)
+ {
+ BYTE buffer2[sizeof(KEY_VALUE_PARTIAL_INFORMATION) + MAX_PATH * sizeof(WCHAR)];
+ WCHAR *redirect = get_redirect( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL,
+ nt_name.Buffer, buffer2, sizeof(buffer2) );
+ if (redirect)
+ {
+ FIXME("Loader redirect from %s to %s\n", debugstr_w(libname), debugstr_w(redirect));
+
+ nts = load_dll( load_path, redirect, nt_name.Buffer, flags, pwm );
+
+ if (nts == STATUS_SUCCESS)
+ {
+ if (handle) NtClose( handle );
+ RtlFreeUnicodeString( &nt_name );
+ return nts;
+ }
+ else
+ ERR("Failed to load redirected DLL %s, falling back to %s\n", debugstr_w(redirect), debugstr_w(libname));
+ }
+ }
+
loadorder = get_load_order( main_exe ? main_exe->ldr.BaseDllName.Buffer : NULL, &nt_name );
if (handle && is_fake_dll( handle ))
@@ -2562,22 +2590,22 @@ static NTSTATUS load_dll( LPCWSTR load_path, LPCWSTR libname, DWORD flags, WINE_
if (!handle) nts = STATUS_DLL_NOT_FOUND;
else
{
- nts = load_native_dll( load_path, &nt_name, handle, flags, pwm, &st );
+ nts = load_native_dll( load_path, &nt_name, fakemodule, handle, flags, pwm, &st );
if (nts == STATUS_INVALID_IMAGE_NOT_MZ)
/* not in PE format, maybe it's a builtin */
- nts = load_builtin_dll( load_path, &nt_name, handle, flags, pwm );
+ nts = load_builtin_dll( load_path, &nt_name, fakemodule, handle, flags, pwm );
}
if (nts == STATUS_DLL_NOT_FOUND && loadorder == LO_NATIVE_BUILTIN)
- nts = load_builtin_dll( load_path, &nt_name, 0, flags, pwm );
+ nts = load_builtin_dll( load_path, &nt_name, fakemodule, 0, flags, pwm );
break;
case LO_BUILTIN:
case LO_BUILTIN_NATIVE:
case LO_DEFAULT: /* default is builtin,native */
- nts = load_builtin_dll( load_path, &nt_name, handle, flags, pwm );
+ nts = load_builtin_dll( load_path, &nt_name, fakemodule, handle, flags, pwm );
if (!handle) break; /* nothing else we can try */
/* file is not a builtin library, try without using the specified file */
if (nts != STATUS_SUCCESS)
- nts = load_builtin_dll( load_path, &nt_name, 0, flags, pwm );
+ nts = load_builtin_dll( load_path, &nt_name, fakemodule, 0, flags, pwm );
if (nts == STATUS_SUCCESS && loadorder == LO_DEFAULT &&
(MODULE_InitDLL( *pwm, DLL_WINE_PREATTACH, NULL ) != STATUS_SUCCESS))
{
@@ -2587,7 +2615,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)
- nts = load_native_dll( load_path, &nt_name, handle, flags, pwm, &st );
+ nts = load_native_dll( load_path, &nt_name, fakemodule, handle, flags, pwm, &st );
break;
}
@@ -2614,7 +2642,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
RtlEnterCriticalSection( &loader_section );
if (!path_name) path_name = NtCurrentTeb()->Peb->ProcessParameters->DllPath.Buffer;
- nts = load_dll( path_name, libname->Buffer, flags, &wm );
+ nts = load_dll( path_name, libname->Buffer, NULL, flags, &wm );
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{
@@ -3578,14 +3606,14 @@ void __wine_process_init(void)
wine_dll_set_callback( load_builtin_callback );
RtlInitUnicodeString( &nt_name, kernel32W );
- if ((status = load_builtin_dll( NULL, &nt_name, 0, 0, &wm )) != STATUS_SUCCESS)
+ if ((status = load_builtin_dll( NULL, &nt_name, NULL, 0, 0, &wm )) != STATUS_SUCCESS)
{
MESSAGE( "wine: could not load kernel32.dll, status %x\n", status );
exit(1);
}
RtlInitUnicodeString( &nt_name, wow64cpuW );
- if ((status = load_builtin_dll( NULL, &nt_name, 0, 0, &wow64cpu_wm )) == STATUS_SUCCESS)
+ if ((status = load_builtin_dll( NULL, &nt_name, NULL, 0, 0, &wow64cpu_wm )) == STATUS_SUCCESS)
Wow64Transition = wow64cpu_wm->ldr.BaseAddress;
else
WARN( "could not load wow64cpu.dll, status %#x\n", status );
--
2.20.1

View File

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

View File

@ -195,7 +195,6 @@ patch_enable_all ()
enable_ntdll_DOS_Attributes="$1"
enable_ntdll_Dealloc_Thread_Stack="$1"
enable_ntdll_DeviceType_Systemroot="$1"
enable_ntdll_DllRedirects="$1"
enable_ntdll_Exception="$1"
enable_ntdll_FileDispositionInformation="$1"
enable_ntdll_FileFsFullSizeInformation="$1"
@ -746,9 +745,6 @@ patch_enable ()
ntdll-DeviceType_Systemroot)
enable_ntdll_DeviceType_Systemroot="$2"
;;
ntdll-DllRedirects)
enable_ntdll_DllRedirects="$2"
;;
ntdll-Exception)
enable_ntdll_Exception="$2"
;;
@ -2033,13 +2029,6 @@ if test "$enable_ntdll_HashLinks" -eq 1; then
enable_ntdll_LDR_MODULE=1
fi
if test "$enable_ntdll_DllRedirects" -eq 1; then
if test "$enable_wow64cpu_Wow64Transition" -gt 1; then
abort "Patchset wow64cpu-Wow64Transition disabled, but ntdll-DllRedirects depends on that."
fi
enable_wow64cpu_Wow64Transition=1
fi
if test "$enable_ntdll_Builtin_Prot" -eq 1; then
if test "$enable_ntdll_User_Shared_Data" -gt 1; then
abort "Patchset ntdll-User_Shared_Data disabled, but ntdll-Builtin_Prot depends on that."
@ -4500,47 +4489,6 @@ if test "$enable_ntdll_DeviceType_Systemroot" -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, 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-DllRedirects
# |
# | This patchset has the following (direct or indirect) dependencies:
# | * wow64cpu-Wow64Transition
# |
# | Modified files:
# | * dlls/ntdll/loader.c, dlls/ntdll/loadorder.c, dlls/ntdll/ntdll_misc.h
# |
if test "$enable_ntdll_DllRedirects" -eq 1; then
patch_apply ntdll-DllRedirects/0001-ntdll-Move-logic-to-determine-loadorder-HKCU-app-key.patch
patch_apply ntdll-DllRedirects/0002-ntdll-Move-logic-to-read-loadorder-registry-values-i.patch
patch_apply ntdll-DllRedirects/0003-ntdll-Move-code-to-determine-module-basename-into-se.patch
patch_apply ntdll-DllRedirects/0004-ntdll-Implement-get_redirect-function.patch
patch_apply ntdll-DllRedirects/0005-ntdll-Implement-loader-redirection-scheme.patch
(
printf '%s\n' '+ { "Michael Müller", "ntdll: Move logic to determine loadorder HKCU/app key into separate functions.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Move logic to read loadorder registry values into separate function.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Move code to determine module basename into separate function.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Implement get_redirect function.", 1 },';
printf '%s\n' '+ { "Michael Müller", "ntdll: Implement loader redirection scheme.", 1 },';
) >> "$patchlist"
fi
# Patchset ntdll-Exception
# |
# | This patchset fixes the following Wine bugs:
@ -7758,6 +7706,24 @@ if test "$enable_wmvcore_WMCreateSyncReaderPriv" -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, 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: