mirror of
https://github.com/toneillcodes/windows-process-injection
synced 2026-06-21 14:11:25 +00:00
Add GetExplorerPID to utils.cpp
This commit is contained in:
+17
-1
@@ -75,4 +75,20 @@ int my_wcsicmp(const wchar_t* s1, const wchar_t* s2) {
|
||||
} while (c1 == c2);
|
||||
|
||||
return c1 - c2;
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to find Explorer PID
|
||||
DWORD GetExplorerPID() {
|
||||
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||
PROCESSENTRY32 pe = { sizeof(pe) };
|
||||
if (Process32First(hSnapshot, &pe)) {
|
||||
do {
|
||||
if (lstrcmpiW(pe.szExeFile, L"explorer.exe") == 0) {
|
||||
CloseHandle(hSnapshot);
|
||||
return pe.th32ProcessID;
|
||||
}
|
||||
} while (Process32Next(hSnapshot, &pe));
|
||||
}
|
||||
if (hSnapshot) CloseHandle(hSnapshot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user