Attach notifications must be send after all recursive dependencies are
loaded and not before.
diff --git a/loader/module.c b/loader/module.c
index f9de51c..575dd3b 100644
--- a/loader/module.c
+++ b/loader/module.c
@@ -1212,8 +1212,20 @@
return 0;
}
+ EnterCriticalSection(&PROCESS_Current()->crit_section);
+
wm = MODULE_LoadLibraryExA( libname, hfile, flags );
+ if(wm && !MODULE_DllProcessAttach(wm, NULL))
+ {
+ WARN(module, "Attach failed for module '%s', \n", libname);
+ MODULE_FreeLibrary(wm);
+ SetLastError(ERROR_DLL_INIT_FAILED);
+ wm = NULL;
+ }
+
+ LeaveCriticalSection(&PROCESS_Current()->crit_section);
+
return wm ? wm->module : 0;
}
@@ -1290,14 +1302,6 @@
/* decrement the dependencies through the MODULE_FreeLibrary call. */
pwm->refCount++;
- if(!MODULE_DllProcessAttach(pwm, NULL))
- {
- WARN(module, "Attach failed for module '%s', \n", libname);
- MODULE_FreeLibrary(pwm);
- SetLastError(ERROR_DLL_INIT_FAILED);
- pwm = NULL;
- }
-
LeaveCriticalSection(&PROCESS_Current()->crit_section);
return pwm;
}