I have UINT id of a process. With a call to OpenProcess(PROCESS_TERMINATE|SYNCHRONIZE, id) I should get its HANDLE for further use in calls to WaitForSingleObject and TerminateProcess. Everything is ok until I try to terminate a “hanging” process of a SYSTEM owner, i.e. the only thing I get is GetLastError() == 0x00000005 (access denied) instead of HANDLE to a process .
The system denies... I can guess the matters going on whatsoever. taskmgr.exe running under the same account (as my program) is able to shutdown this freakish process anyway. My application cannot do any such thing. I would appreciate everyone who saves my time with a simple hint.
Thanks.
PS this might be important: I use functions from tlhelp32.h for taking a snapshot of processes in order to find my target. A snapshot is still opened while I'm trying to gain access with permission to shut the process down.
Although, my code works fine with processes running under the same user account. I need to make a sequence of calls to adjust the privileges, I guess; but I wouldn’t like to waist a lot of time for the experiments like this. I’m tired.
The system denies... I can guess the matters going on whatsoever. taskmgr.exe running under the same account (as my program) is able to shutdown this freakish process anyway. My application cannot do any such thing. I would appreciate everyone who saves my time with a simple hint.
Thanks.
PS this might be important: I use functions from tlhelp32.h for taking a snapshot of processes in order to find my target. A snapshot is still opened while I'm trying to gain access with permission to shut the process down.
Although, my code works fine with processes running under the same user account. I need to make a sequence of calls to adjust the privileges, I guess; but I wouldn’t like to waist a lot of time for the experiments like this. I’m tired.