Jump to content

how to get pid from handles that get from enumprocesshandles ?


Recommended Posts

Posted (edited)

but _winapi_getprocessid always return 0 

here my script

$aData = _WinAPI_EnumProcessHandles(15016)
for $i = 1 to $aData[0][0]
   if $aData[$i][1] = '7' then
      $pid = _WinAPI_GetProcessID($aData[$i][0])     ;<= pid always 0 @_@      $aData[$i][0] is handle
      $aData[$i][1] = 'process with pid :' & $pid
   EndIf
Next
_ArrayDisplay($aData, '_WinAPI_EnumProcessHandles', '', Default, Default, 'Handle|Type|Attributes|Access')

Edited by HermanCegel
Link to post
Share on other sites

Hi @HermanCegel,

I believe you mix things up. Are you talking about "handles" or "process IDs"? Your screenshots shows PIDs (green rectangle), or am I wrong?
What do you want to do at the end? How to get process names can be done by simply ProcessList(). Maybe I missunderstood you or I miss something 🤔 ?

#include-once
#include <Array.au3>

Global $aListOfProcesses = ProcessList()
_ArrayDisplay($aListOfProcesses)

It would be helpful if you described what you ultimately want to accomplish, because there could be multiple ways to get there.

Best regards
Sven

________________
Stay innovative!

Edited by SOLVE-SMART

Stay innovative!

Spoiler

🌍 Au3Forums

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔍 Forum search

🔮 Me on GitHub

💬 Opinion about new forum sub category

 📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to post
Share on other sites

hi @SOLVE-SMART

greens rectangle show handles

 

so processID 796 (lsass.exe) have many handles that show in greens rectangle.

 

that handle in greens rectangle is another process that "openprocess" by lsass.exe.

 

what i want to know is how to get process name that "openprocess" by lsass.exe ?  i only get it handles (green rectangle) but confuse how to convert from handles to pid to processname..

Link to post
Share on other sites

Hi @HermanCegel,

8 minutes ago, HermanCegel said:

[...] what i want to know is how to get process name that "openprocess" by lsass.exe ?  i only get it handles (green rectangle) but confuse how to convert from handles to pid to processname [...]

understood 👍 . I am in rush at the moment, maybe I will have a look later again.

Best regards
Sven

________________
Stay innovative!

Stay innovative!

Spoiler

🌍 Au3Forums

📊 AutoIt limits/defaults

💎 Code Katas: [...] (comming soon)

🎭 Collection of GitHub users with AutoIt projects

🐞 False-Positives

🔍 Forum search

🔮 Me on GitHub

💬 Opinion about new forum sub category

 📑 UDF wiki list

✂ VSCode-AutoItSnippets

📑 WebDriver FAQs

👨‍🏫 WebDriver Tutorial (coming soon)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...