| 286 | } |
| 287 | |
| 288 | static void QueryProcessName(uint32_t processId, ProcessInfo* info) |
| 289 | { |
| 290 | auto const& args = GetCommandLineArgs(); |
| 291 | |
| 292 | wchar_t path[MAX_PATH]; |
| 293 | const wchar_t* processName = L"<unknown>"; |
| 294 | HANDLE handle = NULL; |
| 295 | |
| 296 | if (args.mEtlFileName == nullptr) { |
| 297 | handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId); |
| 298 | if (handle != NULL) { |
| 299 | DWORD numChars = _countof(path); |
| 300 | if (QueryFullProcessImageNameW(handle, 0, path, &numChars)) { |
| 301 | for (;; --numChars) { |
| 302 | if (numChars == 0 || path[numChars - 1] == L'\\' || path[numChars - 1] == L'/') { |
| 303 | processName = &path[numChars]; |
| 304 | break; |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | info->mModuleName = processName; |
| 312 | info->mHandle = handle; |
| 313 | } |
| 314 | |
| 315 | static bool GetPresentProcessInfo( |
| 316 | std::shared_ptr<PresentEvent> const& presentEvent, |
no test coverage detected