| 104 | |
| 105 | |
| 106 | static HWND get_process_wnd(uint32_t pid) { |
| 107 | std::pair<HWND, uint32_t> params = { 0, pid }; |
| 108 | |
| 109 | BOOL bResult = EnumWindows([](HWND hwnd, LPARAM lParam) -> BOOL { |
| 110 | auto pParams = (std::pair<HWND, uint32_t>*)(lParam); |
| 111 | uint32_t processId = 0; |
| 112 | |
| 113 | if (GetWindowThreadProcessId(hwnd, reinterpret_cast<LPDWORD>(&processId)) && processId == pParams->second) { |
| 114 | SetLastError((uint32_t)-1); |
| 115 | pParams->first = hwnd; |
| 116 | return FALSE; |
| 117 | } |
| 118 | |
| 119 | return TRUE; |
| 120 | |
| 121 | }, (LPARAM)¶ms); |
| 122 | |
| 123 | if (!bResult && GetLastError() == -1 && params.first) |
| 124 | return params.first; |
| 125 | |
| 126 | return NULL; |
| 127 | } |
| 128 | |
| 129 | DWORD GetProcessId(const wchar_t* ImageName) { |
| 130 | HANDLE Snapshot{ CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) }; |
nothing calls this directly
no outgoing calls
no test coverage detected