Signed-off-by: Paul Gofman <pgofman(a)codeweavers.com> --- dlls/kernel32/tests/module.c | 6 +++--- dlls/ntdll/loader.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/dlls/kernel32/tests/module.c b/dlls/kernel32/tests/module.c index fd369ff33e9..7c4b690fb39 100644 --- a/dlls/kernel32/tests/module.c +++ b/dlls/kernel32/tests/module.c @@ -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 ); diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index dd41d6b66d2..c946b39574a 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1203,7 +1203,6 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path ) return status; } - /************************************************************************* * alloc_module * @@ -1232,6 +1231,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 +3527,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", -- 2.31.1