ntdll: Pass DDAG node to process_attach().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-11-02 13:26:41 +03:00 committed by Alexandre Julliard
parent 41c7652bbe
commit 06f925c599
1 changed files with 11 additions and 6 deletions

View File

@ -187,7 +187,7 @@ static WINE_MODREF *last_failed_modref;
static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext, static NTSTATUS load_dll( const WCHAR *load_path, const WCHAR *libname, const WCHAR *default_ext,
DWORD flags, WINE_MODREF** pwm ); DWORD flags, WINE_MODREF** pwm );
static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved ); static NTSTATUS process_attach( LDR_DDAG_NODE *node, LPVOID lpReserved );
static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports, static FARPROC find_ordinal_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
DWORD exp_size, DWORD ordinal, LPCWSTR load_path ); DWORD exp_size, DWORD ordinal, LPCWSTR load_path );
static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports, static FARPROC find_named_export( HMODULE module, const IMAGE_EXPORT_DIRECTORY *exports,
@ -648,7 +648,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS
WINE_MODREF **deps = grow_module_deps( current_modref, 1 ); WINE_MODREF **deps = grow_module_deps( current_modref, 1 );
if (deps) deps[current_modref->nDeps++] = wm; if (deps) deps[current_modref->nDeps++] = wm;
} }
else if (process_attach( wm, NULL ) != STATUS_SUCCESS) else if (process_attach( wm->ldr.DdagNode, NULL ) != STATUS_SUCCESS)
{ {
LdrUnloadDll( wm->ldr.DllBase ); LdrUnloadDll( wm->ldr.DllBase );
wm = NULL; wm = NULL;
@ -1438,14 +1438,19 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved
* *
* The loader_section must be locked while calling this function. * The loader_section must be locked while calling this function.
*/ */
static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved ) static NTSTATUS process_attach( LDR_DDAG_NODE *node, LPVOID lpReserved )
{ {
NTSTATUS status = STATUS_SUCCESS; NTSTATUS status = STATUS_SUCCESS;
LDR_DATA_TABLE_ENTRY *mod;
ULONG_PTR cookie; ULONG_PTR cookie;
WINE_MODREF *wm;
int i; int i;
if (process_detaching) return status; if (process_detaching) return status;
mod = CONTAINING_RECORD( node->Modules.Flink, LDR_DATA_TABLE_ENTRY, NodeModuleLink );
wm = CONTAINING_RECORD( mod, WINE_MODREF, ldr );
/* prevent infinite recursion in case of cyclical dependencies */ /* prevent infinite recursion in case of cyclical dependencies */
if ( ( wm->ldr.Flags & LDR_LOAD_IN_PROGRESS ) if ( ( wm->ldr.Flags & LDR_LOAD_IN_PROGRESS )
|| ( wm->ldr.Flags & LDR_PROCESS_ATTACHED ) ) || ( wm->ldr.Flags & LDR_PROCESS_ATTACHED ) )
@ -1462,7 +1467,7 @@ static NTSTATUS process_attach( WINE_MODREF *wm, LPVOID lpReserved )
for ( i = 0; i < wm->nDeps; i++ ) for ( i = 0; i < wm->nDeps; i++ )
{ {
if (!wm->deps[i]) continue; if (!wm->deps[i]) continue;
if ((status = process_attach( wm->deps[i], lpReserved )) != STATUS_SUCCESS) break; if ((status = process_attach( wm->deps[i]->ldr.DdagNode, lpReserved )) != STATUS_SUCCESS) break;
} }
if (!wm->ldr.InInitializationOrderLinks.Flink) if (!wm->ldr.InInitializationOrderLinks.Flink)
@ -2994,7 +2999,7 @@ NTSTATUS WINAPI DECLSPEC_HOTPATCH LdrLoadDll(LPCWSTR path_name, DWORD flags,
if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) if (nts == STATUS_SUCCESS && !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS))
{ {
nts = process_attach( wm, NULL ); nts = process_attach( wm->ldr.DdagNode, NULL );
if (nts != STATUS_SUCCESS) if (nts != STATUS_SUCCESS)
{ {
LdrUnloadDll(wm->ldr.DllBase); LdrUnloadDll(wm->ldr.DllBase);
@ -3957,7 +3962,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
for (i = 0; i < wm->nDeps; i++) for (i = 0; i < wm->nDeps; i++)
{ {
if (!wm->deps[i]) continue; if (!wm->deps[i]) continue;
if ((status = process_attach( wm->deps[i], context )) != STATUS_SUCCESS) if ((status = process_attach( wm->deps[i]->ldr.DdagNode, context )) != STATUS_SUCCESS)
{ {
if (last_failed_modref) if (last_failed_modref)
ERR( "%s failed to initialize, aborting\n", ERR( "%s failed to initialize, aborting\n",