fix: https://bugs.winehq.org/show_bug.cgi?id=52094
tests:
``` #include <Windows.h>
#ifdef FROM_IMPORT #pragma comment(lib, "python3.lib") extern "C" int Py_IsInitialized(); #endif int main() { #ifdef FROM_IMPORT // test from import table Py_IsInitialized( ); #else // //Test ref count int (*Py_IsInitialized)();
HMODULE hmod_310 = LoadLibraryA( "C:\Python310\python310.dll" ); HMODULE hmod = LoadLibraryA( "C:\Python310\python3.dll" );
if ( !hmod ) return 0; *(FARPROC*)&Py_IsInitialized = GetProcAddress( hmod, "Py_IsInitialized" ); FreeLibrary( hmod_310 );
Py_IsInitialized( );
FreeLibrary( hmod );
// test dependencies hmod = LoadLibraryA( "C:\Python310\python3.dll" );
if ( !hmod ) return 0;
*(FARPROC*)&Py_IsInitialized = GetProcAddress( hmod, "Py_IsInitialized" );
Py_IsInitialized();
FreeLibrary( hmod ); #endif return 0; } ```
From: number201724 number201724@me.com
--- dlls/ntdll/loader.c | 69 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 52 insertions(+), 17 deletions(-)
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 59624bc70f8..4707fb9df3f 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -899,6 +899,36 @@ static NTSTATUS walk_node_dependencies( LDR_DDAG_NODE *node, void *context, return status; }
+/********************************************************************** + * find_module_dependency + */ +static WINE_MODREF* find_dependency_module( LDR_DDAG_NODE *node, LPCWSTR name ) +{ + SINGLE_LIST_ENTRY *entry; + LDR_DEPENDENCY *dep; + LDR_DATA_TABLE_ENTRY *mod; + UNICODE_STRING name_str; + + if (node && (entry = node->Dependencies.Tail)) + { + RtlInitUnicodeString( &name_str, name ); + + do + { + dep = CONTAINING_RECORD( entry, LDR_DEPENDENCY, dependency_to_entry ); + mod = CONTAINING_RECORD( dep->dependency_to->Modules.Flink, LDR_DATA_TABLE_ENTRY, NodeModuleLink ); + + if (RtlEqualUnicodeString( &name_str, &mod->BaseDllName, TRUE )) { + return CONTAINING_RECORD( mod, WINE_MODREF, ldr ); + } + + entry = entry->Next; + } while (entry != node->Dependencies.Tail); + } + + return NULL; +} + /************************************************************************* * find_forwarded_export * @@ -909,7 +939,7 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS { const IMAGE_EXPORT_DIRECTORY *exports; DWORD exp_size; - WINE_MODREF *wm; + WINE_MODREF *wm, *imp; WCHAR mod_name[256]; const char *end = strrchr(forward, '.'); FARPROC proc = NULL; @@ -917,29 +947,34 @@ static FARPROC find_forwarded_export( HMODULE module, const char *forward, LPCWS if (!end) return NULL; if (build_import_name( mod_name, forward, end - forward )) return NULL;
- if (!(wm = find_basename_module( mod_name ))) + imp = get_modref( module ); + + if (!(wm = find_dependency_module( imp->ldr.DdagNode, mod_name ))) { - WINE_MODREF *imp = get_modref( module ); - TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward ); - if (load_dll( load_path, mod_name, 0, &wm, imp->system ) == STATUS_SUCCESS && - !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) + if (!(wm = find_basename_module( mod_name ))) { - if (!imports_fixup_done && current_modref) + TRACE( "delay loading %s for '%s'\n", debugstr_w(mod_name), forward ); + if (load_dll( load_path, mod_name, 0, &wm, imp->system ) == STATUS_SUCCESS && + !(wm->ldr.Flags & LDR_DONT_RESOLVE_REFS)) { - add_module_dependency( current_modref->ldr.DdagNode, wm->ldr.DdagNode ); + if (process_attach( wm->ldr.DdagNode, NULL ) != STATUS_SUCCESS) { + LdrUnloadDll( wm->ldr.DllBase ); + wm = NULL; + } else { + add_module_dependency( imp->ldr.DdagNode, wm->ldr.DdagNode ); + } } - else if (process_attach( wm->ldr.DdagNode, NULL ) != STATUS_SUCCESS) + + if (!wm) { - LdrUnloadDll( wm->ldr.DllBase ); - wm = NULL; + ERR( "module not found for forward '%s' used by %s\n", + forward, debugstr_w(imp->ldr.FullDllName.Buffer) ); + return NULL; } } - - if (!wm) - { - ERR( "module not found for forward '%s' used by %s\n", - forward, debugstr_w(imp->ldr.FullDllName.Buffer) ); - return NULL; + else if (wm->ldr.LoadCount > 0) { + wm->ldr.LoadCount++; + add_module_dependency( imp->ldr.DdagNode, wm->ldr.DdagNode ); } } if ((exports = RtlImageDirectoryEntryToData( wm->ldr.DllBase, TRUE,
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=141037
Your paranoid android.
=== debian11b (64 bit WoW report) ===
d3d10_1: Unhandled exception: unimplemented function d3d10_1.dll.D3D10CreateEffectFromMemory called in 64-bit code (0x006fffffc8e9c8). Unhandled exception: unimplemented function d3d10_1.dll.D3D10ReflectShader called in 64-bit code (0x006fffffc8e9c8).
d3dx10_34: Unhandled exception: unimplemented function d3dx10_34.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_35: Unhandled exception: unimplemented function d3dx10_35.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_36: Unhandled exception: unimplemented function d3dx10_36.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_37: Unhandled exception: unimplemented function d3dx10_37.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_38: Unhandled exception: unimplemented function d3dx10_38.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_39: Unhandled exception: unimplemented function d3dx10_39.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_40: Unhandled exception: unimplemented function d3dx10_40.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_41: Unhandled exception: unimplemented function d3dx10_41.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_42: Unhandled exception: unimplemented function d3dx10_42.dll.D3DX10UnsetAllDeviceObjects called in 64-bit code (0x006fffffc8e9c8).
d3dx10_43: Unhandled exception: unimplemented function d3d10_1.dll.D3D10CreateEffectFromMemory called in 64-bit code (0x006fffffc8e9c8).
Superseded by !7. If you believe the issue has not been fixed, please let me know. Otherwise, feel free to close this MR.
This merge request was closed by Alexandre Julliard.