ntdll: Skip unused import descriptors when loading libraries.

Sebastian Lackner sebastian at fds-team.de
Wed Feb 10 01:24:46 CST 2016


Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---

For bug https://bugs.winehq.org/show_bug.cgi?id=39792

This change has been tested in Staging for about a month now. Manual testing on
Windows confirms that import descriptors referencing non-existent libraries does
not matter, as long as they are empty.

 dlls/ntdll/loader.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index bf1d365..1193e2e 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -901,7 +901,18 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
     status = STATUS_SUCCESS;
     for (i = 0; i < nb_imports; i++)
     {
-        if (!(wm->deps[i] = import_dll( wm->ldr.BaseAddress, &imports[i], load_path )))
+        const IMAGE_IMPORT_DESCRIPTOR *descr = &imports[i];
+        const IMAGE_THUNK_DATA *import_list = get_rva( wm->ldr.BaseAddress, descr->u.OriginalFirstThunk ?
+                                                       (DWORD)descr->u.OriginalFirstThunk : (DWORD)descr->FirstThunk );
+        if (!import_list->u1.Ordinal)
+        {
+            const char *name = get_rva( wm->ldr.BaseAddress, descr->Name );
+            WARN( "Skipping unused import %s\n", debugstr_a(name) );
+            wm->deps[i] = NULL;
+            continue;
+        }
+
+        if (!(wm->deps[i] = import_dll( wm->ldr.BaseAddress, descr, load_path )))
             status = STATUS_DLL_NOT_FOUND;
     }
     current_modref = prev;
-- 
2.7.0



More information about the wine-patches mailing list