| 71 | |
| 72 | |
| 73 | std::wstring GetProcessName(HANDLE hProcess) { |
| 74 | if (!hProcess || hProcess == INVALID_HANDLE_VALUE) { |
| 75 | LOG_A(LOG_WARNING, "GetProcessName: Invalid process handle"); |
| 76 | return std::wstring(L""); |
| 77 | } |
| 78 | |
| 79 | WCHAR exePath[MAX_PATH] = { 0 }; |
| 80 | if (GetModuleFileNameEx(hProcess, NULL, exePath, MAX_PATH)) { |
| 81 | //LOG_W(LOG_INFO, L"GetProcessName: Process name: %s", exePath); |
| 82 | return std::wstring(exePath); |
| 83 | } |
| 84 | else { |
| 85 | // Happens often |
| 86 | LOG_A(LOG_WARNING, "GetProcessName: Failed to get module filename. Error: %lu", GetLastError()); |
| 87 | return std::wstring(L""); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | |
| 92 | // Process: PEB Info |