Jump to content

Help: _WinAPI_GetCurrentProcess() return -1


stinger
 Share

Recommended Posts

I've wrote a sample code to get my proc handle but dont know why it always return 0xffffffff

Here's my code

#include <WinAPI.au3>
$hwnd = _WinAPI_GetCurrentProcess()
$procid = _WinAPI_GetCurrentProcessID()
MsgBox(0, "Info", $hwnd)
MsgBox(0, "Info", $procid)

GetCurrentProcessID is working good but GetCurrentProcess does not work, there's no error. Am i missing something ?

Link to comment
Share on other sites

This is a confusion in the description. _WinAPI_GetCurrentProcess() returns a pseudo handle of the current process, not a real handle.

#Include <WinAPI.au3>

$PID = _WinAPI_GetCurrentProcessID()
$hProcess = _WinAPI_GetCurrentProcess()
$Ret = DllCall('kernel32.dll', 'bool', 'DuplicateHandle', 'ptr', $hProcess, 'ptr', $hProcess, 'ptr', $hProcess, 'ptr*', 0, 'dword', 0, 'bool', 0, 'dword', 2)

ConsoleWrite('PID:           ' & $PID & @CR)
ConsoleWrite('Pseudo handle: ' & $hProcess & @CR)
ConsoleWrite('Real handle:   ' & $Ret[4] & @CR)
Edited by Yashied
Link to comment
Share on other sites

This is a confusion in the description. _WinAPI_GetCurrentProcess() returns a pseudo handle of the current process, not a real handle.

#Include <WinAPI.au3>

$PID = _WinAPI_GetCurrentProcessID()
$hProcess = _WinAPI_GetCurrentProcess()
$Ret = DllCall('kernel32.dll', 'bool', 'DuplicateHandle', 'ptr', $hProcess, 'ptr', $hProcess, 'ptr', $hProcess, 'ptr*', 0, 'dword', 0, 'bool', 0, 'dword', 2)

ConsoleWrite('PID:           ' & $PID & @CR)
ConsoleWrite('Pseudo handle: ' & $hProcess & @CR)
ConsoleWrite('Real handle:   ' & $Ret[4] & @CR)

Thanks alot for your reply.
Link to comment
Share on other sites

So... what's the difference to @AutoItPID?

Edit:

Reread the post and realized that you wanted to obtain the process handle :graduated:... and also that the "Delete" post does not seem to work.

Edited by KaFu
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...