ntdll: Don't add dependencies for system dlls.

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:44 +03:00 committed by Alexandre Julliard
parent 250c113169
commit aa234f3a58
2 changed files with 18 additions and 3 deletions

View File

@ -1409,7 +1409,7 @@ static void test_ddag_node(void)
} }
mod2 = CONTAINING_RECORD(dep_node->Modules.Flink, LDR_DATA_TABLE_ENTRY, NodeModuleLink); mod2 = CONTAINING_RECORD(dep_node->Modules.Flink, LDR_DATA_TABLE_ENTRY, NodeModuleLink);
todo_wine ok( !lstrcmpW( mod2->BaseDllName.Buffer, expected_exe_dependencies[i].dllname ), ok( !lstrcmpW( mod2->BaseDllName.Buffer, expected_exe_dependencies[i].dllname ),
"Got unexpected module %s.\n", debugstr_w(mod2->BaseDllName.Buffer)); "Got unexpected module %s.\n", debugstr_w(mod2->BaseDllName.Buffer));
se2 = dep_node->IncomingDependencies.Tail; se2 = dep_node->IncomingDependencies.Tail;
@ -1428,7 +1428,7 @@ static void test_ddag_node(void)
winetest_pop_context(); winetest_pop_context();
prev_node = dep_node; prev_node = dep_node;
} }
todo_wine ok( se == node->Dependencies.Tail, "Expected end of the list.\n" ); ok( se == node->Dependencies.Tail, "Expected end of the list.\n" );
} }
START_TEST(module) START_TEST(module)

View File

@ -182,6 +182,8 @@ static WINE_MODREF *cached_modref;
static WINE_MODREF *current_modref; static WINE_MODREF *current_modref;
static WINE_MODREF *last_failed_modref; static WINE_MODREF *last_failed_modref;
static LDR_DDAG_NODE *node_ntdll, *node_kernel32;
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( LDR_DDAG_NODE *node, LPVOID lpReserved ); static NTSTATUS process_attach( LDR_DDAG_NODE *node, LPVOID lpReserved );
@ -1280,7 +1282,10 @@ static NTSTATUS fixup_imports( WINE_MODREF *wm, LPCWSTR load_path )
imp = NULL; imp = NULL;
status = STATUS_DLL_NOT_FOUND; status = STATUS_DLL_NOT_FOUND;
} }
else add_module_dependency_after( wm->ldr.DdagNode, imp->ldr.DdagNode, dep_after ); else if (!is_import_dll_system( &wm->ldr, &imports[i] ))
{
add_module_dependency_after( wm->ldr.DdagNode, imp->ldr.DdagNode, dep_after );
}
} }
current_modref = prev; current_modref = prev;
if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie ); if (wm->ldr.ActivationContext) RtlDeactivateActivationContext( 0, cookie );
@ -2076,6 +2081,7 @@ static void build_ntdll_module(void)
wm = alloc_module( meminfo.AllocationBase, &nt_name, TRUE ); wm = alloc_module( meminfo.AllocationBase, &nt_name, TRUE );
assert( wm ); assert( wm );
wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS; wm->ldr.Flags &= ~LDR_DONT_RESOLVE_REFS;
node_ntdll = wm->ldr.DdagNode;
if (TRACE_ON(relay)) RELAY_SetupDLL( meminfo.AllocationBase ); if (TRACE_ON(relay)) RELAY_SetupDLL( meminfo.AllocationBase );
} }
@ -4004,6 +4010,7 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
NtTerminateProcess( GetCurrentProcess(), status ); NtTerminateProcess( GetCurrentProcess(), status );
} }
kernel32_handle = kernel32->ldr.DllBase; kernel32_handle = kernel32->ldr.DllBase;
node_kernel32 = kernel32->ldr.DdagNode;
RtlInitAnsiString( &func_name, "BaseThreadInitThunk" ); RtlInitAnsiString( &func_name, "BaseThreadInitThunk" );
if ((status = LdrGetProcedureAddress( kernel32_handle, &func_name, if ((status = LdrGetProcedureAddress( kernel32_handle, &func_name,
0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS) 0, (void **)&pBaseThreadInitThunk )) != STATUS_SUCCESS)
@ -4053,6 +4060,14 @@ void WINAPI LdrInitializeThunk( CONTEXT *context, ULONG_PTR unknown2, ULONG_PTR
if (wm->ldr.ActivationContext) if (wm->ldr.ActivationContext)
RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie ); RtlActivateActivationContext( 0, wm->ldr.ActivationContext, &cookie );
if ((status = process_attach( node_ntdll, context ))
|| (status = process_attach( node_kernel32, context )))
{
ERR( "Initializing system dll for %s failed, status %x\n",
debugstr_w(NtCurrentTeb()->Peb->ProcessParameters->ImagePathName.Buffer), status );
NtTerminateProcess( GetCurrentProcess(), status );
}
if ((status = walk_node_dependencies( wm->ldr.DdagNode, context, process_attach ))) if ((status = walk_node_dependencies( wm->ldr.DdagNode, context, process_attach )))
{ {
if (last_failed_modref) if (last_failed_modref)