Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if handle belongs to the current process?

Is there any Win32 API to check if a given handle belongs to the current process?

like image 254
TheCodeJunkie Avatar asked Dec 04 '25 17:12

TheCodeJunkie


2 Answers

From a window handle you can use GetWindowThreadProcessId Function to get process id.
From a process handle you get the id with GetProcessId Function.

I don't know how easy is to get a process handle from some other handle. But I believe it'll have to do with kernel objects enumeration.

like image 108
Nick Dandoulakis Avatar answered Dec 07 '25 13:12

Nick Dandoulakis


A handle can "belong" to more than one process (Inherited handles in child process etc)

like image 22
Anders Avatar answered Dec 07 '25 15:12

Anders



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!