Sign in to follow this  
Followers 0
Unc3nZureD

Get process user level

2 posts in this topic

How could I check the running privileges of a process? I mean if it's System level, Local service, Network service or simply user-level. Just like in the task manager :)
 

250px-System_idle_process.png

Share this post


Link to post
Share on other sites



Unc3nZureD,

This is the example from winapiex.au3 for func _WinAPI_GetProcessUser()...

#RequireAdmin

#Include <APIConstants.au3>
#Include <Array.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

Global $hToken, $Data, $aAdjust, $aList = 0

; Enable "SeDebugPrivilege" privilege for obtain full access rights to another processes
$hToken = _WinAPI_OpenProcessToken(BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY))
_WinAPI_AdjustTokenPrivileges($hToken, $SE_DEBUG_NAME, $SE_PRIVILEGE_ENABLED, $aAdjust)

; Retrieve user names for all processes the system
If Not (@error Or @extended) Then
    $aList = ProcessList()
    For $i = 1 To $aList[0][0]
        $Data = _WinAPI_GetProcessUser($aList[$i][1])
        If IsArray($Data) Then
            $aList[$i][1] = $Data[0]
        Else
            $aList[$i][1] = ''
        EndIf
    Next
EndIf

; Enable SeDebugPrivilege privilege by default
_WinAPI_AdjustTokenPrivileges($hToken, $aAdjust, 0, $aAdjust)
_WinAPI_CloseHandle($hToken)

_ArrayDisplay($aList, '_WinAPI_GetProcessUser')

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


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
Sign in to follow this  
Followers 0