From b38f6ee50a2dd894b253d2788dc57a1c5721f8fb Mon Sep 17 00:00:00 2001 From: Hennes Rohling Date: Thu, 16 May 2002 11:10:29 +0000 Subject: #99182 SymGetModuleInfo does not retrieve full path on some NT platforms. Fallback with GetModuleFileName created. --- sal/osl/w32/module.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/sal/osl/w32/module.c b/sal/osl/w32/module.c index 2dad8258e441..595f451fcf1f 100644 --- a/sal/osl/w32/module.c +++ b/sal/osl/w32/module.c @@ -2,9 +2,9 @@ * * $RCSfile: module.c,v $ * - * $Revision: 1.11 $ + * $Revision: 1.12 $ * - * last change: $Author: hro $ $Date: 2001-11-16 12:33:12 $ + * last change: $Author: hro $ $Date: 2002-05-16 12:10:29 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -277,15 +277,25 @@ static sal_Bool SAL_CALL _osl_addressGetModuleURL_NT4( void *pv, rtl_uString **p ZeroMemory( &ModuleInfo, sizeof(ModuleInfo) ); ModuleInfo.SizeOfStruct = sizeof(ModuleInfo); - bSuccess = lpfnSymGetModuleInfo( GetCurrentProcess(), (DWORD)pv, &ModuleInfo ); + bSuccess = !!lpfnSymGetModuleInfo( GetCurrentProcess(), (DWORD)pv, &ModuleInfo ); if ( bSuccess ) { - rtl_uString *ustrSysPath = NULL; + /* #99182 On localized (non-english) NT4 and XP (!!!) for some libraries the LoadedImageName member of ModuleInfo isn't filled. Because + other members ModuleName and ImageName do not contain the full path we can cast the Member + BaseOfImage to a HMODULE (on NT it's the same) and use GetModuleFileName to retrieve the full + path of the loaded image */ - rtl_string2UString( &ustrSysPath, ModuleInfo.LoadedImageName, strlen(ModuleInfo.LoadedImageName), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); - osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); - rtl_uString_release( ustrSysPath ); + if ( ModuleInfo.LoadedImageName[0] || GetModuleFileNameA( (HMODULE)ModuleInfo.BaseOfImage, ModuleInfo.LoadedImageName, sizeof(ModuleInfo.LoadedImageName) ) ) + { + rtl_uString *ustrSysPath = NULL; + + rtl_string2UString( &ustrSysPath, ModuleInfo.LoadedImageName, strlen(ModuleInfo.LoadedImageName), osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS ); + osl_getFileURLFromSystemPath( ustrSysPath, pustrURL ); + rtl_uString_release( ustrSysPath ); + } + else + bSuccess = sal_False; } lpfnSymCleanup( GetCurrentProcess() ); -- cgit v1.2.3