Answers for "check if a process is with system rights windows 10 using c"

0

check if a process is with system rights windows 10 using c

BOOL IsElevated( ) {
    BOOL fRet = FALSE;
    HANDLE hToken = NULL;
    //opening the process:
    if( OpenProcessToken( GetCurrentProcess(),TOKEN_QUERY,&hToken ) ) {
       //u can replace GetCurrentProcess with ur pid process u wanna check :p
       TOKEN_ELEVATION Elevation;
        DWORD cbSize = sizeof( TOKEN_ELEVATION );
        if( GetTokenInformation( hToken, TokenElevation, &Elevation, sizeof( Elevation ), &cbSize ) ) {
            fRet = Elevation.TokenIsElevated;
            //set the value of fRet, if true the pid is running as admin
            //else if its false then its not
        }
    }
    //closing handle if opened 
    if( hToken ) {
        CloseHandle( hToken );
    }
    //returning the result 
    return fRet;
}
Posted by: Guest on July-23-2021

Code answers related to "check if a process is with system rights windows 10 using c"

Code answers related to "Assembly"

Browse Popular Code Answers by Language