Attempting to introduce a poor performance test or not (essentially equivalent to the trivial kill(pid, 0) .)
Hoped to be able to just call OpenProcess with the minimum desired access, then check either GetLastError() == ERROR_INVALID_PARAMETER or GetExitCodeProcess(...) != STILL_ACTIVE .
Good try ... Running on Windows XP with administrator privileges:
HANDLE hProc = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid); if (!hProc) { DWORD dwLastError = GetLastError(); }
... fails with dwLastError == ERROR_ACCESS_DENIED when the pid belongs to another user (not SYSTEM). Moreover, if the pid originally belonged to another user, but has since been completed, OpenProcess also fails with ERROR_ACCESS_DENIED (not ERROR_INVALID_PARAMETER .)
Do I need to use Process32First / Process32Next or EnumProcesses ?
I absolutely do not want to use SeDebugPrivilege .
Thank you in
security windows process winapi
vladr Mar 05 2018-10-10T00: 00Z
source share