# HG changeset patch # User Claus Gittinger # Date 1387296759 -3600 # Node ID 6871784b7a5ba26cad399ec3a03bc5c835789d1c # Parent 605d272f5e1c96a4940eafb745b0698b25a2aa62 class: Win32OperatingSystem changed: #isRunningWithElevatedAdminRights diff -r 605d272f5e1c -r 6871784b7a5b Win32OperatingSystem.st --- a/Win32OperatingSystem.st Tue Dec 17 16:45:11 2013 +0100 +++ b/Win32OperatingSystem.st Tue Dec 17 17:12:39 2013 +0100 @@ -10824,6 +10824,52 @@ " ! +isRunningWithElevatedAdminRights + "return true, if a NORMAL user is running with elevated admin rights." + +%{ + + HANDLE h_Process; + HANDLE h_Token; + TOKEN_ELEVATION t_TokenElevation; + TOKEN_ELEVATION_TYPE e_ElevationType; + DWORD dw_TokenLength; + + h_Process = GetCurrentProcess(); + if (OpenProcessToken(h_Process,TOKEN_READ,&h_Token) == FALSE) { + printf("Error: Couldn't open the process token\n"); + goto getOutOfHere; + } + if (GetTokenInformation(h_Token,TokenElevation,&t_TokenElevation,sizeof(t_TokenElevation),&dw_TokenLength) == FALSE) { + printf("Error: Couldn't retrieve the elevation right of the current process token\n"); + CloseHandle(h_Token); + goto getOutOfHere; + } + if (t_TokenElevation.TokenIsElevated != 0) { + if (GetTokenInformation(h_Token,TokenElevationType,&e_ElevationType,sizeof(e_ElevationType),&dw_TokenLength) == FALSE) { + printf("Error: Couldn't retrieve the elevation token class\n"); + CloseHandle(h_Token); + goto getOutOfHere; + } else { + if (e_ElevationType == TokenElevationTypeFull || e_ElevationType == TokenElevationTypeDefault) { + CloseHandle(h_Token); + RETURN(true); + } + CloseHandle(h_Token); + RETURN(false); + } + } else { + CloseHandle(h_Token); + RETURN(false); + } +getOutOfHere: ; +%}. + "/ self primitiveFailed. + ^ false + + "Modified: / 17-12-2013 / 17:12:23 / cg" +! + isRunningWithRootOrAdminRights "read some registry entry which only Admin can read; if we can, we are; otherwise, we are not." @@ -10873,49 +10919,6 @@ "Created: / 28-11-2013 / 14:00:02 / cg" ! -isRunningWithElevatedAdminRights - "return true, if a NORMAL user is running with elevated admin rights." - -%{ - - HANDLE h_Process; - HANDLE h_Token; - TOKEN_ELEVATION t_TokenElevation; - TOKEN_ELEVATION_TYPE e_ElevationType; - DWORD dw_TokenLength; - - h_Process = GetCurrentProcess(); - if (OpenProcessToken(h_Process,TOKEN_READ,&h_Token) == FALSE) { - printf("Error: Couldn't open the process token\n"); - goto getOutOfHere; - } - if (GetTokenInformation(h_Token,TokenElevation,&t_TokenElevation,sizeof(t_TokenElevation),&dw_TokenLength) == FALSE) { - printf("Error: Couldn't retrieve the elevation right of the current process token\n"); - CloseHandle(h_Token); - goto getOutOfHere; - } - if (t_TokenElevation.TokenIsElevated != 0) { - if (GetTokenInformation(h_Token,TokenElevationType,&e_ElevationType,sizeof(e_ElevationType),&dw_TokenLength) == FALSE) { - printf("Error: Couldn't retrieve the elevation token class\n"); - CloseHandle(h_Token); - goto getOutOfHere; - } else { - if (e_ElevationType == TokenElevationTypeFull || e_ElevationType == TokenElevationTypeDefault) { - CloseHandle(h_Token); - RETURN(true); - } - CloseHandle(h_Token); - RETURN(false); - } - } else { - CloseHandle(h_Token); - RETURN(false); - } -getOutOfHere: ; -%}. - self primitiveFailed. -! - userInfoOf:aNameOrID "{ Pragma: +optSpace }" @@ -17484,15 +17487,15 @@ !Win32OperatingSystem class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.485 2013-12-17 15:10:33 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.486 2013-12-17 16:12:39 cg Exp $' ! version_CVS - ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.485 2013-12-17 15:10:33 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Win32OperatingSystem.st,v 1.486 2013-12-17 16:12:39 cg Exp $' ! version_SVN - ^ '$Id: Win32OperatingSystem.st,v 1.485 2013-12-17 15:10:33 cg Exp $' + ^ '$Id: Win32OperatingSystem.st,v 1.486 2013-12-17 16:12:39 cg Exp $' ! !