Process handle search Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Process handle search

27 Mar 2017, 01:54

Image
The above picture shows the process that have the handle of chrome.exe.

I want to get a list of process that have a handle to a particular process.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Process handle search

27 Mar 2017, 02:01

Something like this? GetProcessThreads.ahk
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Re: Process handle search

27 Mar 2017, 02:11

jNizM wrote:Something like this? GetProcessThreads.ahk

Well, can not get a list of handles instead of threads?
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Process handle search

27 Mar 2017, 14:01

Maybe that's what you are looking for:

Code: Select all

for process in ComObjGet("winmgmts:").ExecQuery("Select Handle, Name from Win32_Process WHERE Name='Chrome.exe'")
    processes .= process.Name . "  -  " . process.Handle . "`r`n"
MsgBox % processes

; see https://autohotkey.com/board/topic/8228-process-listfile-namescommand-lines/page-2 (lexikos answer)
my scripts
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Re: Process handle search

27 Mar 2017, 14:42

A_AhkUser wrote:Maybe that's what you are looking for:

Code: Select all

for process in ComObjGet("winmgmts:").ExecQuery("Select Handle, Name from Win32_Process WHERE Name='Chrome.exe'")
    processes .= process.Name . "  -  " . process.Handle . "`r`n"
MsgBox % processes

; see https://autohotkey.com/board/topic/8228-process-listfile-namescommand-lines/page-2 (lexikos answer)

Unfortunately, this does not show all the handles.
For example, when you do "openprocess" with the cheat engine, the "handle" should output the cheat engine process. However, this is not output.
A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: Process handle search

27 Mar 2017, 15:15

whynotregister wrote:Unfortunately, this does not show all the handles.
Not sure but maybe it is due to the fact that you lunched the processes from whom belong the aforementioned handles as administrator unlike the script itself.
my scripts
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Process handle search

28 Mar 2017, 02:18

Its a bit more complicated to get all handles...
You need SetPrivilege, OpenProcess, NtQuerySystemInformation/ZwQuerySystemInformation, NtQueryObject/ZwQueryObject
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Re: Process handle search

28 Mar 2017, 04:00

jNizM wrote:Its a bit more complicated to get all handles...
You need SetPrivilege, OpenProcess, NtQuerySystemInformation/ZwQuerySystemInformation, NtQueryObject/ZwQueryObject
How should I implement it?
As far as I know, it is possible to implement in user mode api.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Process handle search

28 Mar 2017, 04:11

Will post an example as soon I finished it.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Re: Process handle search

28 Mar 2017, 04:18

jNizM wrote:Will post an example as soon I finished it.
Very Thank you :D :D :D :D
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Process handle search  Topic is solved

28 Mar 2017, 05:53

Here is my first (not whole finished) attempt: GetProcessHandles
Maybe you need to start it as admin (runas admin function can be found in this forum too)
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Re: Process handle search

28 Mar 2017, 06:12

jNizM wrote:Here is my first (not whole finished) attempt: GetProcessHandles
Maybe you need to start it as admin (runas admin function can be found in this forum too)
It does not seem to work.

Code: Select all

#include GetProcessHandles.ahk
winget,pid,pid,ahk_exe Chrome.exe
if pid > 0
msgbox % GetProcessHandles(pid)
Did I write the wrong code?
Tested with administrator privileges.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Process handle search

28 Mar 2017, 07:18

Code: Select all

for i, v in GetProcessHandles(PID)
    MsgBox % v
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
whynotregister
Posts: 147
Joined: 05 Nov 2016, 22:42

Re: Process handle search

28 Mar 2017, 07:56

jNizM wrote:

Code: Select all

for i, v in GetProcessHandles(PID)
    MsgBox % v
Thank you very much. Nice script. :D :D :D :D :D :D :D :D :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Araphen, doanmvu, Google [Bot] and 339 guests