Added ability to query lib locations to windows builds

This commit is contained in:
Adam Potolsky
2015-06-10 13:18:39 -07:00
parent 8366bb6247
commit fa0dfa0ded
4 changed files with 66 additions and 1 deletions

View File

@@ -23,6 +23,9 @@
#include "tchar.h"
#include <string>
#include <windows.h>
#include <psapi.h>
static const char* s_settingsKeyNames[] = {
_T("SOFTWARE"),
_T("Synergy"),
@@ -152,3 +155,39 @@ ArchSystemWindows::isWOW64() const
#endif
return false;
}
#pragma comment(lib, "psapi")
std::string
ArchSystemWindows::getLibsUsed(void) const
{
HMODULE hMods[1024];
HANDLE hProcess;
DWORD cbNeeded;
unsigned int i;
char hex[16];
DWORD pid = GetCurrentProcessId();
std::string msg = "pid:" + std::to_string((_ULonglong)pid) + "\n";
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
if (NULL == hProcess) {
return msg;
}
if (EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++) {
TCHAR szModName[MAX_PATH];
if (GetModuleFileNameEx(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))) {
sprintf(hex,"(0x%08X)",hMods[i]);
msg += szModName;
msg.append(hex);
msg.append("\n");
}
}
}
CloseHandle(hProcess);
return msg;
}