MCPcopy Create free account
hub / github.com/Spuckwaffel/Kernel-Thread-Driver / get_process_wnd

Function get_process_wnd

UM/Driver.h:106–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106static 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)&params);
122
123 if (!bResult && GetLastError() == -1 && params.first)
124 return params.first;
125
126 return NULL;
127}
128
129DWORD GetProcessId(const wchar_t* ImageName) {
130 HANDLE Snapshot{ CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected