ntdll: import dll from dir of referring dll if not found in standard locations
Hongbo Ni
hongbo at njstar.com
Fri Aug 1 02:23:29 CDT 2008
This patch fixes bug 14699. It should fix all failed applications
which try to load a dll from specific folder, and the dll is link
another dll in the same folder.
---
dlls/ntdll/loader.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 5d47b19..a682d2e 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -644,6 +644,8 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
DWORD size;
NTSTATUS status;
ULONG_PTR cookie;
+ UNICODE_STRING mod_path;
+ WCHAR *path_end;
if (!(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) return STATUS_SUCCESS; /* already done */
wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS;
@@ -664,6 +666,11 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
wm->nDeps = nb_imports;
wm->deps = RtlAllocateHeap( GetProcessHeap(), 0, nb_imports*sizeof(WINE_MODREF *) );
+ /* get full path of current module */
+ RtlCreateUnicodeString( &mod_path, wm->ldr.FullDllName.Buffer );
+ if ((path_end = strrchrW( mod_path.Buffer, '\\' ))) *path_end = '\0';
+ else if ((path_end = strrchrW( mod_path.Buffer, '/' ))) *path_end = '\0';
+
/* load the imported modules. They are automatically
* added to the modref list of the process.
*/
@@ -673,8 +680,12 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
for (i = 0; i < nb_imports; i++)
{
if (!(wm->deps[i] = import_dll( wm->ldr.BaseAddress, &imports[i], load_path )))
- status = STATUS_DLL_NOT_FOUND;
+ {
+ if (!(wm->deps[i] = import_dll( wm->ldr.BaseAddress, &imports[i], mod_path.Buffer )))
+ status = STATUS_DLL_NOT_FOUND;
+ }
}
+ RtlFreeUnicodeString( &mod_path );
current_modref = prev;
if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );
return status;
--
More information about the wine-patches
mailing list