Vista 에서 Process 의 Privilege 확인 Code
CODE2009. 7. 7. 12:16
#include#include typedef enum _TOKEN_ELEVATION_TYPE { TokenElevationTypeDefault = 1, TokenElevationTypeFull, TokenElevationTypeLimited } TOKEN_ELEVATION_TYPE; DWORD GetElevationType(HANDLE hProcess) { HANDLE hToken = NULL; DWORD dwElevType = 0; DWORD dwSize = 0; BOOL bResult = 0; bResult = OpenProcessToken(hProcess, TOKEN_QUERY, &hToken); if(bResult == 0) { //Err //GetLastError(); return 0; } bResult = GetTokenInformation(hToken, /*TokenElevationType*/(_TOKEN_INFORMATION_CLASS)18, &dwElevType, sizeof(dwElevType), &dwSize); if(bResult == 0) { //Err //GetLastError(); return 0; } if(hToken) CloseHandle(hToken); return dwElevType; } int main(int argc, char* argv[]) { DWORD dwElev = 0; dwElev = GetElevationType(GetCurrentProcess()); switch (dwElev) { case TokenElevationTypeDefault: printf("TokenElevationTypeDefault\n"); break; case TokenElevationTypeFull: printf("TokenElevationTypeFull\n"); break; case TokenElevationTypeLimited: printf("TokenElevationTypeLimited\n"); break; } return 0; }