Skip to content

Commit

Permalink
WIN32: osdFindSymbol() use psapi
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavidsaver committed Apr 16, 2020
1 parent 1492baa commit db2cd68
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configure/os/CONFIG.linux-x86.win32-x86-mingw
Expand Up @@ -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
2 changes: 1 addition & 1 deletion configure/os/CONFIG.win32-x86-mingw.win32-x86-mingw
Expand Up @@ -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
13 changes: 9 additions & 4 deletions modules/libcom/src/osi/os/WIN32/osdFindSymbol.c
Expand Up @@ -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 <windows.h>
#include <psapi.h>
Expand Down Expand Up @@ -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<ndlls; i++) {
ret = GetProcAddress(dlls[i], name);
}
Expand Down

0 comments on commit db2cd68

Please sign in to comment.