I have a HANDLE
to a process, which might, or might not, be the handle of the currently running process. The following is known about the handle object:
PROCESS_TERMINATE
access right.GetCurrentProcess
.Is there a way to know whether the handle is of the current process?
I thought about using GetProcessId
, but unfortunately it fails with an access denied error, because the handle doesn't have the PROCESS_QUERY_LIMITED_INFORMATION
access right.
If you have sufficient access to the target process, you can create a new handle to it with the PROCESS_QUERY_LIMITED_INFORMATION
access right by using DuplicateHandle(). You can then use this handle to get the process ID.
Unless your process modifies its own security permissions, it should always have (at least) PROCESS_QUERY_LIMITED_INFORMATION
access to itself, so if duplicating the handle fails with an access denied error it is unlikely that the handle points to your process.
If you want to make absolutely certain, you can try opening a handle to your process by process ID - if that fails then someone is messing with the ACL and all bets are off. :-)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments