From 1cf04bd70a1d702a66c80860991760cd279ec79d Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Tue, 30 Mar 2004 20:37:33 +0000 Subject: [PATCH] Fix builtin NE module refcounting of 32bit parent. --- dlls/kernel/ne_module.c | 49 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/dlls/kernel/ne_module.c b/dlls/kernel/ne_module.c index 21fd4fe61b1..ad94116c7b9 100644 --- a/dlls/kernel/ne_module.c +++ b/dlls/kernel/ne_module.c @@ -1167,41 +1167,38 @@ static HINSTANCE16 MODULE_LoadModule16( LPCSTR libname, BOOL implicit, BOOL lib_ if (strlen(basename) < sizeof(dllname)-4) { + int file_exists; + strcpy( dllname, basename ); p = strrchr( dllname, '.' ); if (!p) strcat( dllname, ".dll" ); for (p = dllname; *p; p++) if (*p >= 'A' && *p <= 'Z') *p += 32; - if (!(descr = find_dll_descr( dllname ))) + if (wine_dll_get_owner( dllname, owner, sizeof(owner), &file_exists ) == -1) { - int file_exists; - - if (wine_dll_get_owner( dllname, owner, sizeof(owner), &file_exists ) == -1) + if (file_exists) return 21; /* it may be a Win32 module then */ + } + else /* found 32-bit owner, try to load it */ + { + HMODULE mod32 = LoadLibraryA( owner ); + if (mod32) { - if (file_exists) return 21; /* it may be a Win32 module then */ + if (!(descr = find_dll_descr( dllname ))) FreeLibrary( mod32 ); + /* loading the 32-bit library can have the side effect of loading the module */ + /* if so, simply incr the ref count and return the module */ + if ((hModule = GetModuleHandle16( libname ))) + { + TRACE( "module %s already loaded by owner\n", libname ); + pModule = NE_GetPtr( hModule ); + if (pModule) pModule->count++; + return hModule; + } } - else /* found 32-bit owner, try to load it */ + else { - HMODULE mod32 = LoadLibraryA( owner ); - if (mod32) - { - if (!(descr = find_dll_descr( dllname ))) FreeLibrary( mod32 ); - /* loading the 32-bit library can have the side effect of loading the module */ - /* if so, simply incr the ref count and return the module */ - if ((hModule = GetModuleHandle16( libname ))) - { - TRACE( "module %s already loaded by owner\n", libname ); - pModule = NE_GetPtr( hModule ); - if (pModule) pModule->count++; - return hModule; - } - } - else - { - /* it's probably disabled by the load order config */ - WARN( "couldn't load owner %s for 16-bit dll %s\n", owner, dllname ); - return ERROR_FILE_NOT_FOUND; - } + /* it's probably disabled by the load order config */ + WARN( "couldn't load owner %s for 16-bit dll %s\n", owner, dllname ); + return ERROR_FILE_NOT_FOUND; } } }