ntdll: Allocate DDAG node for module.

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:40 +03:00 committed by Alexandre Julliard
parent ef6e33f89f
commit 41c7652bbe
2 changed files with 17 additions and 3 deletions

View File

@ -1358,7 +1358,7 @@ static void test_ddag_node(void)
if (!(node = mod->DdagNode))
{
skip( "DdagNode is NULL, skipping tests.\n" );
win_skip( "DdagNode is NULL, skipping tests.\n" );
return;
}
@ -1376,11 +1376,11 @@ static void test_ddag_node(void)
ok( !node->IncomingDependencies.Tail, "Expected empty incoming dependencies list.\n" );
/* node->Dependencies.Tail is NULL on Windows 10 1507-1607 32 bit test, maybe due to broken structure layout. */
ok( !!node->Dependencies.Tail || broken( sizeof(void *) == 4 && !node->Dependencies.Tail),
todo_wine ok( !!node->Dependencies.Tail || broken( sizeof(void *) == 4 && !node->Dependencies.Tail ),
"Expected nonempty dependencies list.\n" );
if (!node->Dependencies.Tail)
{
win_skip( "Empty dependencies list.\n" );
skip( "Empty dependencies list.\n" );
return;
}
ok( node->LoadCount == -1, "Got unexpected LoadCount %d.\n", node->LoadCount );

View File

@ -1232,6 +1232,16 @@ static WINE_MODREF *alloc_module( HMODULE hModule, const UNICODE_STRING *nt_name
RtlFreeHeap( GetProcessHeap(), 0, wm );
return NULL;
}
if (!(wm->ldr.DdagNode = RtlAllocateHeap( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wm->ldr.DdagNode) )))
{
RtlFreeHeap( GetProcessHeap(), 0, buffer );
RtlFreeHeap( GetProcessHeap(), 0, wm );
return NULL;
}
InitializeListHead(&wm->ldr.DdagNode->Modules);
InsertTailList(&wm->ldr.DdagNode->Modules, &wm->ldr.NodeModuleLink);
memcpy( buffer, nt_name->Buffer + 4 /* \??\ prefix */, nt_name->Length - 4 * sizeof(WCHAR) );
buffer[nt_name->Length/sizeof(WCHAR) - 4] = 0;
if ((p = wcsrchr( buffer, '\\' ))) p++;
@ -3518,6 +3528,10 @@ static void free_modref( WINE_MODREF *wm )
if (wm->ldr.InInitializationOrderLinks.Flink)
RemoveEntryList(&wm->ldr.InInitializationOrderLinks);
RemoveEntryList(&wm->ldr.NodeModuleLink);
if (IsListEmpty(&wm->ldr.DdagNode->Modules))
RtlFreeHeap( GetProcessHeap(), 0, wm->ldr.DdagNode );
TRACE(" unloading %s\n", debugstr_w(wm->ldr.FullDllName.Buffer));
if (!TRACE_ON(module))
TRACE_(loaddll)("Unloaded module %s : %s\n",