Alexandre Julliard : ntdll: Delay attaching to dlls loaded because of a forwarded entry point.

Alexandre Julliard julliard at winehq.org
Tue Nov 21 16:33:50 CST 2017


Module: wine
Branch: master
Commit: ed893d3591802bb562d100b277f968be402af740
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ed893d3591802bb562d100b277f968be402af740

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Nov 21 13:13:35 2017 +0100

ntdll: Delay attaching to dlls loaded because of a forwarded entry point.

Based on a patch by Sebastian Lackner.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ntdll/loader.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 820398b..70f99e6 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -473,7 +473,21 @@ 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))
         {
-            if (process_attach( wm, NULL ) != STATUS_SUCCESS)
+            if (!imports_fixup_done && current_modref)
+            {
+                WINE_MODREF **deps;
+                if (current_modref->nDeps)
+                    deps = RtlReAllocateHeap( GetProcessHeap(), 0, current_modref->deps,
+                                              (current_modref->nDeps + 1) * sizeof(*deps) );
+                else
+                    deps = RtlAllocateHeap( GetProcessHeap(), 0, sizeof(*deps) );
+                if (deps)
+                {
+                    deps[current_modref->nDeps++] = wm;
+                    current_modref->deps = deps;
+                }
+            }
+            else if (process_attach( wm, NULL ) != STATUS_SUCCESS)
             {
                 LdrUnloadDll( wm->ldr.BaseAddress );
                 wm = NULL;
@@ -906,7 +920,7 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
 {
     int i, nb_imports;
     const IMAGE_IMPORT_DESCRIPTOR *imports;
-    WINE_MODREF *prev;
+    WINE_MODREF *prev, *imp;
     DWORD size;
     NTSTATUS status;
     ULONG_PTR cookie;
@@ -940,11 +954,12 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
     status = STATUS_SUCCESS;
     for (i = 0; i < nb_imports; i++)
     {
-        if (!import_dll( wm->ldr.BaseAddress, &imports[i], load_path, &wm->deps[i] ))
+        if (!import_dll( wm->ldr.BaseAddress, &imports[i], load_path, &imp ))
         {
-            wm->deps[i] = NULL;
+            imp = NULL;
             status = STATUS_DLL_NOT_FOUND;
         }
+        wm->deps[i] = imp;
     }
     current_modref = prev;
     if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );




More information about the wine-cvs mailing list