1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
|
int EnableShutdownPrivileges( )
{
HANDLE token;
TOKEN_PRIVILEGES privileges;
if( !OpenProcessToken( GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES
| TOKEN_QUERY, &token ))
return -1;
LookupPrivilegeValue( NULL, SE_SHUTDOWN_NAME, &privileges.Privileges[ 0 ].Luid );
privileges.PrivilegeCount = 1;
privileges.Privileges[ 0 ].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges( token, FALSE, &privileges, 0, (PTOKEN_PRIVILEGES)NULL, 0 );
if( GetLastError() != ERROR_SUCCESS )
return -2;
} |