Paul Gofman : ntdll: Allocate DDAG node for module.
Alexandre Julliard
julliard at winehq.org
Wed Nov 3 16:42:01 CDT 2021
Module: wine
Branch: master
Commit: 41c7652bbefd8099a47fdc110d24c6c91861cd93
URL: https://source.winehq.org/git/wine.git/?a=commit;h=41c7652bbefd8099a47fdc110d24c6c91861cd93
Author: Paul Gofman <pgofman at codeweavers.com>
Date: Tue Nov 2 13:26:40 2021 +0300
ntdll: Allocate DDAG node for module.
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/tests/module.c | 6 +++---
dlls/ntdll/loader.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 3 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..ebb0f4250f9 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -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",
More information about the wine-cvs
mailing list