mirror of
https://github.com/debauchee/barrier.git
synced 2026-06-30 17:06:29 +08:00
Added ability to query lib locations to windows builds
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user