[Libreoffice-commits] core.git: sal/osl
Stephan Bergmann (via logerrit)
logerrit at kemper.freedesktop.org
Fri Aug 27 09:33:02 UTC 2021
sal/osl/w32/module.cxx | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
New commits:
commit 8d8e5ab9193785acc4e1cb05e0db7f97afde1e2b
Author: Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Fri Aug 27 10:28:11 2021 +0200
Commit: Stephan Bergmann <sbergman at redhat.com>
CommitDate: Fri Aug 27 11:32:29 2021 +0200
Use PSAPI functionality directly
Dynamically trying to obtain the two PSAPI functions was apparently originally
done because "This version can fail because PSAPI.DLL is not always part of
NT 4 despite MSDN Libary 6.0a say so", according to the comment added with
961512bd9ae008fdd8ab5cdf1ba6b5d25ffb0429 "#94875# Added additional method (for
NT4) to determine the module containing an address". (That comment was removed
again in 515d2579d305a6127c6c194319a58eac62437e33 "Replace legacy dynamically-
loaded functions with statically linked ones", which curiously left the dynamic
loading of PSAPI.DLL in place there, though.)
<https://docs.microsoft.com/en-us/windows/win32/api/psapi/nf-psapi-enumprocessmodules>
states that the PSAPI functionality is available in "Kernel32.dll on Windows 7
and Windows Server 2008 R2; Psapi.dll (if PSAPI_VERSION=1) on Windows 7 and
Windows Server 2008 R2; Psapi.dll on Windows Server 2008, Windows Vista, Windows
Server 2003 and Windows XP". I do not find any mention of PSAPI_VERSION across
our code base, so assume that PSAPI_VERSION=1 would be some legacy mode that we
do not use, so with our baseline of Windows 7 (cf. README.md), relying on the
PSAPI functionality being available without adding anything specific to
gb_Library_use_system_win32_libs,sal should presumably be OK.
Change-Id: I55ab29be2a3ee3984c6987e953819cb2e92e4aa8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121136
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman at redhat.com>
diff --git a/sal/osl/w32/module.cxx b/sal/osl/w32/module.cxx
index 620be0e6d664..ab50450daf7d 100644
--- a/sal/osl/w32/module.cxx
+++ b/sal/osl/w32/module.cxx
@@ -182,15 +182,6 @@ osl_getAsciiFunctionSymbol( oslModule Module, const char *pSymbol )
sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL )
{
- static HMODULE hModPsapi = LoadLibraryW( L"PSAPI.DLL" );
- static auto lpfnEnumProcessModules = reinterpret_cast<decltype(EnumProcessModules)*>(
- hModPsapi ? GetProcAddress(hModPsapi, "EnumProcessModules") : nullptr);
- static auto lpfnGetModuleInformation = reinterpret_cast<decltype(GetModuleInformation)*>(
- hModPsapi ? GetProcAddress(hModPsapi, "GetModuleInformation") : nullptr);
-
- if (!lpfnEnumProcessModules || !lpfnGetModuleInformation)
- return false;
-
bool bSuccess = false; /* Assume failure */
DWORD cbNeeded = 0;
HMODULE* lpModules = nullptr;
@@ -198,16 +189,16 @@ sal_Bool SAL_CALL osl_getModuleURLFromAddress( void *pv, rtl_uString **pustrURL
UINT iModule = 0;
MODULEINFO modinfo;
- lpfnEnumProcessModules(GetCurrentProcess(), nullptr, 0, &cbNeeded);
+ EnumProcessModules(GetCurrentProcess(), nullptr, 0, &cbNeeded);
lpModules = static_cast<HMODULE*>(_alloca(cbNeeded));
- lpfnEnumProcessModules(GetCurrentProcess(), lpModules, cbNeeded, &cbNeeded);
+ EnumProcessModules(GetCurrentProcess(), lpModules, cbNeeded, &cbNeeded);
nModules = cbNeeded / sizeof(HMODULE);
for (iModule = 0; !bSuccess && iModule < nModules; iModule++)
{
- lpfnGetModuleInformation(GetCurrentProcess(), lpModules[iModule], &modinfo,
+ GetModuleInformation(GetCurrentProcess(), lpModules[iModule], &modinfo,
sizeof(modinfo));
if (static_cast<BYTE*>(pv) >= static_cast<BYTE*>(modinfo.lpBaseOfDll)
More information about the Libreoffice-commits
mailing list