From db2cd68ce3ac9cf0b26a1505a5a39f368b103e7a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 31 Mar 2020 22:24:31 -0700 Subject: [PATCH] WIN32: osdFindSymbol() use psapi --- configure/os/CONFIG.linux-x86.win32-x86-mingw | 2 +- configure/os/CONFIG.win32-x86-mingw.win32-x86-mingw | 2 +- modules/libcom/src/osi/os/WIN32/osdFindSymbol.c | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/configure/os/CONFIG.linux-x86.win32-x86-mingw b/configure/os/CONFIG.linux-x86.win32-x86-mingw index bd75f5ebd..655b33f23 100644 --- a/configure/os/CONFIG.linux-x86.win32-x86-mingw +++ b/configure/os/CONFIG.linux-x86.win32-x86-mingw @@ -21,4 +21,4 @@ LOADABLE_SHRLIB_LDFLAGS = -shared \ GNU_LDLIBS_YES = # Link with system libraries -OP_SYS_LDLIBS = -lws2_32 -ladvapi32 -luser32 -lkernel32 -lwinmm -ldbghelp +OP_SYS_LDLIBS = -lpsapi -lws2_32 -ladvapi32 -luser32 -lkernel32 -lwinmm -ldbghelp diff --git a/configure/os/CONFIG.win32-x86-mingw.win32-x86-mingw b/configure/os/CONFIG.win32-x86-mingw.win32-x86-mingw index a08f19902..8430011c4 100644 --- a/configure/os/CONFIG.win32-x86-mingw.win32-x86-mingw +++ b/configure/os/CONFIG.win32-x86-mingw.win32-x86-mingw @@ -32,4 +32,4 @@ LOADABLE_SHRLIB_LDFLAGS = -shared \ GNU_LDLIBS_YES = # Link with system libraries -OP_SYS_LDLIBS = -lws2_32 -ladvapi32 -luser32 -lkernel32 -lwinmm -ldbghelp +OP_SYS_LDLIBS = -lpsapi -lws2_32 -ladvapi32 -luser32 -lkernel32 -lwinmm -ldbghelp diff --git a/modules/libcom/src/osi/os/WIN32/osdFindSymbol.c b/modules/libcom/src/osi/os/WIN32/osdFindSymbol.c index 743404611..80b3c292b 100644 --- a/modules/libcom/src/osi/os/WIN32/osdFindSymbol.c +++ b/modules/libcom/src/osi/os/WIN32/osdFindSymbol.c @@ -5,10 +5,15 @@ \*************************************************************************/ /* osi/os/WIN32/osdFindSymbol.c */ -/* avoid need to link against psapi.dll - * requires windows 7 or later +/* Avoid need to link against psapi.dll. requires windows 7 or later. + * MinGW doesn't provide wrappers until 6.0, so fallback to psapi.dll */ -#define NTDDI_VERSION NTDDI_WIN7 +#ifdef _MSC_VER +# define NTDDI_VERSION NTDDI_WIN7 +# define epicsEnumProcessModules K32EnumProcessModules +#else +# define epicsEnumProcessModules EnumProcessModules +#endif #include #include @@ -72,7 +77,7 @@ epicsShareFunc void * epicsShareAPI epicsFindSymbol(const char *name) /* As a handle returned by LoadLibrary() isn't available to us, * try all loaded modules in arbitrary order. */ - if(K32EnumProcessModules(GetCurrentProcess(), dlls, sizeof(dlls), &ndlls)) { + if(epicsEnumProcessModules(GetCurrentProcess(), dlls, sizeof(dlls), &ndlls)) { for(i=0; !ret && i