Skip to content

Commit

Permalink
Disable psapi in UWP (unsupported)
Browse files Browse the repository at this point in the history
  • Loading branch information
enen92 committed Jun 17, 2024
1 parent 7bc748f commit 587b6b8
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
// platform specific support for getLoadedLibraries
#if defined(_WIN32) || defined(__CYGWIN__)
// clang-format off
#include <winapifamily.h>
#include <windows.h>
#include <psapi.h>
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_APP)
#include <psapi.h>
#endif
// clang-format on
#if __LP64__
#ifdef _WIN64
Expand Down Expand Up @@ -121,16 +124,18 @@ static std::vector<std::string> getLoadedLibraries() {
std::string path;

#if defined(_WIN32) || defined(__CYGWIN__)
// enumerate loaded libraries and determine path to executable
HMODULE handles[200];
DWORD cbNeeded;
if (EnumProcessModules(GetCurrentProcess(), handles, static_cast<DWORD>(std::size(handles)), &cbNeeded)) {
char szFilename[_MAX_PATH];
for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) {
GetModuleFileNameA(handles[h], szFilename, static_cast<DWORD>(std::size(szFilename)));
pushPath(szFilename, libs, paths);
// enumerate loaded libraries and determine path to executable (unsupported on UWP)
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_APP)
HMODULE handles[200];
DWORD cbNeeded;
if (EnumProcessModules(GetCurrentProcess(), handles, static_cast<DWORD>(std::size(handles)), &cbNeeded)) {
char szFilename[_MAX_PATH];
for (DWORD h = 0; h < cbNeeded / sizeof(handles[0]); h++) {
GetModuleFileNameA(handles[h], szFilename, static_cast<DWORD>(std::size(szFilename)));
pushPath(szFilename, libs, paths);
}
}
}
#endif
#elif defined(__APPLE__)
// man 3 dyld
uint32_t count = _dyld_image_count();
Expand Down

0 comments on commit 587b6b8

Please sign in to comment.