OpenProcess - acces denied Topic is solved

Ask gaming related questions
User avatar
Posts: 163
Joined: 06 Jun 2016, 16:02

OpenProcess - acces denied

06 Feb 2018, 17:39

Using code as below:

Code: Select all

Window:="Game title"

UNKNOWN_MAGIC_NUMBER:=0x0010      ;0x0400

WinGet, pid, pid, %Window%
handle:=DllCall("OpenProcess", "UInt", UNKNOWN_MAGIC_NUMBER, "UInt", 0, "UInt", pid)


msgbox, 64, ,  pid = %pid% `nhandle = %handle% `nerror level = %el% `nlast error = %le%

For some random window, let it be chrome its opening process without problems but for the game title it returns last error as 5 which stands for "acces denied". Is there any way I can open this process in order to read its memory? So far tried running app as x32 and x64, with and without admin rights and nothing works. Searched forums but couldn't find solution.
User avatar
Posts: 163
Joined: 06 Jun 2016, 16:02

Re: OpenProcess - acces denied  Topic is solved

07 Feb 2018, 15:57

solved, need to insert this function and set admin rights again, win10 is retarded

Code: Select all

setSeDebugPrivilege(enable := True){

    h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", DllCall("GetCurrentProcessId"), "Ptr")
    ; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
    DllCall("Advapi32.dll\OpenProcessToken", "Ptr", h, "UInt", 32, "PtrP", t)
    VarSetCapacity(ti, 16, 0)  ; structure of privileges
    NumPut(1, ti, 0, "UInt")  ; one entry in the privileges array...
    ; Retrieves the locally unique identifier of the debug privilege:
    DllCall("Advapi32.dll\LookupPrivilegeValue", "Ptr", 0, "Str", "SeDebugPrivilege", "Int64P", luid)
    NumPut(luid, ti, 4, "Int64")
    if enable
    	NumPut(2, ti, 12, "UInt")  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
    ; Update the privileges of this process with the new access token:
    r := DllCall("Advapi32.dll\AdjustTokenPrivileges", "Ptr", t, "Int", false, "Ptr", &ti, "UInt", 0, "Ptr", 0, "Ptr", 0)
    DllCall("CloseHandle", "Ptr", t)  ; close this access token handle to save memory
    DllCall("CloseHandle", "Ptr", h)  ; close this process handle to save memory
    return r

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 17 guests