Handle Privileges In PowerBuilder
Example code script
n_cst_platform_privileges from nonvisualobject
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
forward global type n_cst_platform_privileges from nonvisualobject end type type shellexecuteinfo from structure within n_cst_platform_privileges end type type sididentifierauthority from structure within n_cst_platform_privileges end type type tokenelevation from structure within n_cst_platform_privileges end type type sidandattributes from structure within n_cst_platform_privileges end type type tokenmandatorylabel from structure within n_cst_platform_privileges end type type longreturn from structure within n_cst_platform_privileges end type end forward type shellexecuteinfo from structure long cbsize long fmask long hwnd string lpverb string lpfile string lpparameters string lpdirectory long nshow long hinstapp long lpidlist string lpclass long hkeyclass long dwhotkey long hicon long hprocess end type type sididentifierauthority from structure byte value[] end type type tokenelevation from structure long tokeniselevated end type type sidandattributes from structure unsignedlong sid unsignedlong attributes end type type tokenmandatorylabel from structure sidandattributes label end type type longreturn from structure long returnvalue end type global type n_cst_platform_privileges from nonvisualobject end type global n_cst_platform_privileges n_cst_platform_privileges type prototypes Function Boolean IsUserAnAdmin ( ) Library "shell32.dll" Function ULong GetModuleFileName (ULong hinstModule, Ref String lpszPath, ULong cchPath ) Library "KERNEL32.DLL" Alias For "GetModuleFileNameW" Function Long ShellExecuteEx(Ref shellexecuteinfo lpExecInfo) Library "shell32.dll" Alias For "ShellExecuteExW" Function Long GetLastError() Library "kernel32" Alias For "GetLastError" // Handle this call with Byte array or pointer Function Boolean CheckTokenMembership(ULong TokenHandle, ULong SidToCheck, Ref Boolean IsMember) Library "advapi32.dll" Function Boolean CheckTokenMembership(ULong TokenHandle, byte SidToCheck[], Ref Boolean IsMember) Library "advapi32.dll" Function ULong AllocateAndInitializeSid(sididentifierauthority pIdentifierAuthority, Long nSubAuthorityCount, ULong nSubAuthority0, ULong nSubAuthority1, ULong nSubAuthority2, ULong nSubAuthority3, ULong nSubAuthority4, ULong nSubAuthority5, ULong nSubAuthority6, ULong nSubAuthority7, Ref ULong lpPSid) Library "advapi32.dll" Subroutine FreeSid (ULong pSid ) Library "advapi32.dll" Function Long OpenProcessToken (Long ProcessHandle, Long DesiredAccess, Ref Long TokenHandle) Library "advapi32.dll" Function Long GetCurrentProcess () Library "kernel32" // GetTokenInformation could have different argument types Function Boolean GetTokenElevation(Long TokenHandle,Long TokenInformationClass,Ref tokenelevation tTokenInformation,ULong TokenInformationLength, Ref ULong ReturnLength) Library "advapi32.dll" Alias For "GetTokenInformation"; Function Boolean GetTokenElevationType(Long TokenHandle,Long TokenInformationClass,Ref Long tElevationType,ULong TokenInformationLength, Ref ULong ReturnLength) Library "advapi32.dll" Alias For "GetTokenInformation"; Function Boolean GetTokenLinkedToken(Long TokenHandle,Long TokenInformationClass,Ref Long tTokenHandle,ULong TokenInformationLength, Ref ULong ReturnLength) Library "advapi32.dll" Alias For "GetTokenInformation"; Function Boolean GetTokenIntegrityLevel(Long TokenHandle,Long TokenInformationClass,Ref tokenmandatorylabel tLabel,ULong TokenInformationLength, Ref ULong ReturnLength) Library "advapi32.dll" Alias For "GetTokenInformation"; Function ULong DuplicateToken(Long TokenHandle,Long ImpersonationLevel,Ref Long DuplicateTokenHandle) Library "advapi32.dll" Function Boolean CreateWellKnownSid(Long WellKnownSidType, Long DomainSid, Ref byte pSid[],Ref ULong cbSid) Library "advapi32.dll" Function ULong GetSidSubAuthority(ULong sid, ULong subAuthorityIndex) Library "advapi32.dll" Subroutine CopyMemoryLong (Ref ULong destination, Long Source, ULong size) Library "kernel32" Alias For "RtlMoveMemory" Function Long LocalFree (Long MemHandle) Library "kernel32.dll" end prototypes type variables Protected: // http: //www.pinvoke.net/default.aspx/user32/ShowState.html Constant Long SW_NORMAL = 1 // http: //www.pinvoke.net/default.aspx/Constants/WINERROR.html Constant Long ERROR_CANCELLED = 1223; // http: //www.pinvoke.net/default.aspx/advapi32/AllocateAndInitializeSid.html Constant Long NtSecurityAuthority = 5; Constant Long BuiltInDomainRid = 32 Constant Long DomainAliasRidAdmins = 544 Constant Long AuthenticatedUser = 11; // http: //www.pinvoke.net/default.aspx/Constants/WINNT.html Constant ULong TOKEN_DUPLICATE = 2; Constant ULong TOKEN_QUERY = 8; // http: //www.pinvoke.net/default.aspx/Enums/TOKEN_INFORMATION_CLASS.html Constant Long TokenElevationType = 18 Constant Long TokenLinkedToken = 19 Constant Long TokenElevation = 20 Constant Long TokenIntegrityLevel = 25 // http: //www.pinvoke.net/default.aspx/Enums/TOKEN_ELEVATION_TYPE.html Constant Long TokenElevationTypeDefault = 1 Constant Long TokenElevationTypeFull = 2 Constant Long TokenElevationTypeLimited = 3 // http: //www.pinvoke.net/default.aspx/Enums/SECURITY_IMPERSONATION_LEVEL.html Constant Long SecurityAnonymous = 0 Constant Long SecurityIdentification = 1 Constant Long SecurityImpersonation = 2 Constant Long SecurityDelegation = 3 // http: //www.pinvoke.net/default.aspx/Enums/WELL_KNOWN_SID_TYPE.html Constant Long WinBuiltinAdministratorsSid = 26 // http: //www.pinvoke.net/default.aspx/Constants/SECURITY_MANDATORY.html Constant Long SECURITY_MANDATORY_UNTRUSTED_RID = 0; Constant Long SECURITY_MANDATORY_LOW_RID = 4096; Constant Long SECURITY_MANDATORY_MEDIUM_RID = 8192; Constant Long SECURITY_MANDATORY_HIGH_RID = 12288; Constant Long SECURITY_MANDATORY_SYSTEM_RID = 16384; end variables forward prototypes protected function string of_getcurrentexe () public function boolean of_isuserinadmingroup () public function boolean of_isrunasadmin () public function boolean of_isprocesselevated () public function boolean of_isuseranadmin () public function long of_runwithhighprivileges (string as_path) public function long of_selfelevation () public function string of_getprocessintegritylevel () end prototypes protected function string of_getcurrentexe ();//==================================================================== // Function: n_cst_platform_privileges.of_getcurrentexe() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: string //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_getcurrentexe ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== ClassDefinition lcd String ls_fullpath ULong lul_handle, lul_length = 512 If Handle(GetApplication()) = 0 Then // running from the IDE lcd = GetApplication().ClassDefinition ls_fullpath = lcd.LibraryName Else // running from EXE lul_handle = Handle( GetApplication() ) ls_fullpath = Space(lul_length) GetModuleFilename( lul_handle, ls_fullpath, lul_length ) End If Return ls_fullpath end function public function boolean of_isuserinadmingroup ();//==================================================================== // Function: n_cst_platform_privileges.of_isuserinadmingroup() //-------------------------------------------------------------------- // Description: Checks if the current user is in admin group //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: boolean NULL if an error occured //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_isuserinadmingroup ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_process, ll_token, ll_tokenType, ll_tokenChecked, lul_tokenToCheck, ll_duplicatedToken, ll_null ULong lul_elevationTypeSize, lul_size = 4, lul_plinkedSize, lul_sidSize = 68 Boolean lb_isInGroup, lb_null byte lbta_adminsid[] environment lnv_environment SetNull(lb_null) SetNull(ll_null) If GetEnvironment(Ref lnv_environment) < 0 Then Return lb_null End If ll_process = GetCurrentProcess() If OpenProcessToken(ll_process, TOKEN_QUERY + TOKEN_DUPLICATE, Ref ll_token) < 0 Then Return lb_null End If If lnv_environment.OSMajorRevision >= 6 Then If Not GetTokenElevationType(ll_token, TokenElevationType, Ref ll_tokenType, lul_size, Ref lul_elevationTypeSize) Then Return lb_null End If If ll_tokenType = TokenElevationTypeLimited Then If Not GetTokenLinkedToken(ll_token, TokenLinkedToken, Ref lul_tokenToCheck, lul_size, Ref lul_plinkedSize) Then Return lb_null End If End If End If If lul_tokenToCheck = 0 Then DuplicateToken(ll_token, SecurityIdentification, Ref lul_tokenToCheck) End If lbta_adminsid[lul_sidSize] = 0 If Not CreateWellKnownSid(WinBuiltinAdministratorsSid, ll_null, Ref lbta_adminsid, Ref lul_sidSize) Then Return lb_null End If If Not CheckTokenMembership(lul_tokenToCheck, lbta_adminsid, Ref lb_isInGroup) Then Return lb_null End If Return lb_isInGroup = True end function public function boolean of_isrunasadmin ();//==================================================================== // Function: n_cst_platform_privileges.of_isrunasadmin() //-------------------------------------------------------------------- // Description: Checks if the application was started by "Run as Admin" //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: boolean NULL if an error occured //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_isrunasadmin ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== ULong lul_AuthenticatedUsersSid ULong lul_handle Boolean lb_runAsAdmin, lb_null sididentifierauthority lstr_ntAuhtority SetNull(lb_null) lstr_ntAuhtority.Value[1] = 0 lstr_ntAuhtority.Value[2] = 0 lstr_ntAuhtority.Value[3] = 0 lstr_ntAuhtority.Value[4] = 0 lstr_ntAuhtority.Value[5] = 0 lstr_ntAuhtority.Value[6] = NtSecurityAuthority lul_AuthenticatedUsersSid = 0 AllocateAndInitializeSid(Ref lstr_ntAuhtority, 2, BuiltInDomainRid, DomainAliasRidAdmins, 0, 0, 0, 0, 0, 0, Ref lul_AuthenticatedUsersSid) SetNull(lul_handle) If Not CheckTokenMembership(lul_handle, lul_AuthenticatedUsersSid, Ref lb_runAsAdmin) Then Return lb_null End If FreeSid(lul_AuthenticatedUsersSid) Return lb_runAsAdmin = True end function public function boolean of_isprocesselevated ();//==================================================================== // Function: n_cst_platform_privileges.of_isprocesselevated() //-------------------------------------------------------------------- // Description: Checks if the process was elevated //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: boolean NULL if an error occured //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_isprocesselevated ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Long ll_process, ll_token ULong lul_tokenElevationSize = 4, lul_size Boolean lb_null tokenelevation lstr_tokenelevation SetNull(lb_null) ll_process = GetCurrentProcess ( ) If OpenProcessToken(ll_process, TOKEN_QUERY, Ref ll_token) < 0 Then Return lb_null End If If Not GetTokenElevation(ll_token, tokenelevation, Ref lstr_tokenelevation, lul_tokenElevationSize, Ref lul_size) Then Return lb_null End If Return lstr_tokenelevation.TokenIsElevated = 1 end function public function boolean of_isuseranadmin ();//==================================================================== // Function: n_cst_platform_privileges.of_isuseranadmin() //-------------------------------------------------------------------- // Description: This is a simple wrapper method to check if the application runs as admin //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: boolean //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_isuseranadmin ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== return IsUserAnAdmin ( ) end function public function long of_runwithhighprivileges (string as_path);//==================================================================== // Function: n_cst_platform_privileges.of_runwithhighprivileges() //-------------------------------------------------------------------- // Description: Checks if the current user is in admin group //-------------------------------------------------------------------- // Arguments: // string as_path //-------------------------------------------------------------------- // Returns: long // 0 = Is already elevated // -1 = Unknown error // -2 = Canceled by user // 1 = OK //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_runwithhighprivileges ( string as_path ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== shellexecuteinfo lstr_shellexecuteinfo If This.of_isRunAsAdmin() Then Return 0 End If lstr_shellexecuteinfo.cbsize = 60 lstr_shellexecuteinfo.lpVerb = "runas" lstr_shellexecuteinfo.lpFile = as_path lstr_shellexecuteinfo.hwnd = Handle(This) lstr_shellexecuteinfo.nShow = SW_NORMAL If ShellExecuteEx(Ref lstr_shellexecuteinfo) <> 1 Then If GetLastError() = ERROR_CANCELLED Then Return -2 Else Return -1 End If End If Return 1 end function public function long of_selfelevation ();//==================================================================== // Function: n_cst_platform_privileges.of_selfelevation() //-------------------------------------------------------------------- // Description: Run current EXE with High Privileges //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: long //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_selfelevation ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== Return of_runWithHighPrivileges(of_getCurrentExe ( ) ) end function public function string of_getprocessintegritylevel ();//==================================================================== // Function: n_cst_platform_privileges.of_getprocessintegritylevel() //-------------------------------------------------------------------- // Description: //-------------------------------------------------------------------- // Arguments: //-------------------------------------------------------------------- // Returns: string // untrusted // low // medium // high // system // unknown // OR null if an error occured //-------------------------------------------------------------------- // Author: PB.BaoGa Date: 2023/03/14 //-------------------------------------------------------------------- // Usage: n_cst_platform_privileges.of_getprocessintegritylevel ( ) //-------------------------------------------------------------------- // Copyright (c) PB.BaoGa(TM), All rights reserved. //-------------------------------------------------------------------- // Modify History: // //==================================================================== String ls_null Long ll_process, ll_token ULong lul_level ULong lul_size = 0, lul_integritySize = 72, lul_sidSize = 68, lul_zero = 0, lul_levelSize = 4 ULong lul_levelPointer, lul_labelPtr, lul_cbSize tokenmandatorylabel lstr_label, lstr_empty SetNull(ls_null) ll_process = GetCurrentProcess ( ) If OpenProcessToken(ll_process, TOKEN_QUERY, Ref ll_token) < 0 Then Return ls_null End If // Initialize Structure lstr_label.Label.sid = 0 lstr_label.Label.attributes = 0 If GetTokenIntegrityLevel(ll_token, TokenIntegrityLevel, Ref lstr_label, lul_integritySize, Ref lul_cbSize) = False Then LocalFree(ll_token) Return ls_null End If lul_levelPointer = GetSidSubAuthority(lstr_label.Label.sid, 0) CopyMemoryLong(Ref lul_level, lul_levelPointer, 4) LocalFree(ll_token) Choose Case lul_level Case SECURITY_MANDATORY_UNTRUSTED_RID Return "untrusted" Case SECURITY_MANDATORY_LOW_RID Return "low" Case SECURITY_MANDATORY_MEDIUM_RID Return "medium" Case SECURITY_MANDATORY_HIGH_RID Return "high" Case SECURITY_MANDATORY_SYSTEM_RID Return "system" End Choose Return "unknown" end function on n_cst_platform_privileges.create call super::create TriggerEvent( this, "constructor" ) end on on n_cst_platform_privileges.destroy TriggerEvent( this, "destructor" ) call super::destroy end on |
w_main from window
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
forward global type w_main from window end type type st_isanadmin from statictext within w_main end type type st_4 from statictext within w_main end type type st_5 from statictext within w_main end type type st_integritylevel from statictext within w_main end type type st_isprocesselevated from statictext within w_main end type type st_2 from statictext within w_main end type type st_3 from statictext within w_main end type type st_isrunasadmin from statictext within w_main end type type st_userinadmingroup from statictext within w_main end type type st_1 from statictext within w_main end type type p_shield from picture within w_main end type type cb_1 from commandbutton within w_main end type type luid from structure within w_main end type type token_privileges from structure within w_main end type type luid_and_attributes from structure within w_main end type end forward type luid from structure unsignedlong lowpart unsignedlong highpart end type type token_privileges from structure long privilegecount luid_and_attributes privileges end type type luid_and_attributes from structure luid pluid long attributes end type global type w_main from window integer width = 1083 integer height = 956 boolean titlebar = true string title = "Self-Elevating" boolean controlmenu = true boolean minbox = true boolean maxbox = true boolean resizable = true long backcolor = 67108864 string icon = "AppIcon!" boolean center = true st_isanadmin st_isanadmin st_4 st_4 st_5 st_5 st_integritylevel st_integritylevel st_isprocesselevated st_isprocesselevated st_2 st_2 st_3 st_3 st_isrunasadmin st_isrunasadmin st_userinadmingroup st_userinadmingroup st_1 st_1 p_shield p_shield cb_1 cb_1 end type global w_main w_main type prototypes end prototypes type variables protected: n_cst_platform_privileges inv_privileges end variables on w_main.create this.st_isanadmin=create st_isanadmin this.st_4=create st_4 this.st_5=create st_5 this.st_integritylevel=create st_integritylevel this.st_isprocesselevated=create st_isprocesselevated this.st_2=create st_2 this.st_3=create st_3 this.st_isrunasadmin=create st_isrunasadmin this.st_userinadmingroup=create st_userinadmingroup this.st_1=create st_1 this.p_shield=create p_shield this.cb_1=create cb_1 this.Control[]={this.st_isanadmin,& this.st_4,& this.st_5,& this.st_integritylevel,& this.st_isprocesselevated,& this.st_2,& this.st_3,& this.st_isrunasadmin,& this.st_userinadmingroup,& this.st_1,& this.p_shield,& this.cb_1} end on on w_main.destroy destroy(this.st_isanadmin) destroy(this.st_4) destroy(this.st_5) destroy(this.st_integritylevel) destroy(this.st_isprocesselevated) destroy(this.st_2) destroy(this.st_3) destroy(this.st_isrunasadmin) destroy(this.st_userinadmingroup) destroy(this.st_1) destroy(this.p_shield) destroy(this.cb_1) end on event open; inv_privileges = Create n_cst_platform_privileges st_userinadmingroup.Text = String(inv_privileges.of_isuserinadmingroup( )) st_isrunasadmin.Text = String(inv_privileges.of_isRunAsAdmin( )) st_isprocesselevated.Text = String(inv_privileges.of_isprocesselevated( )) st_integritylevel.Text = inv_privileges.of_getprocessintegritylevel( ) st_isanadmin.Text = String(inv_privileges.of_isUserAnAdmin()) If inv_privileges.of_isRunAsAdmin() Then p_shield.Visible = False End If Return 0 end event event close; Destroy inv_privileges Return 0 end event type st_isanadmin from statictext within w_main integer x = 585 integer y = 416 integer width = 402 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 alignment alignment = right! boolean focusrectangle = false end type type st_4 from statictext within w_main integer x = 37 integer y = 416 integer width = 571 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "IsAnAdmin:" boolean focusrectangle = false end type type st_5 from statictext within w_main integer x = 37 integer y = 320 integer width = 571 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "Integrity Level:" boolean focusrectangle = false end type type st_integritylevel from statictext within w_main integer x = 585 integer y = 320 integer width = 402 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 alignment alignment = right! boolean focusrectangle = false end type type st_isprocesselevated from statictext within w_main integer x = 585 integer y = 224 integer width = 402 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 alignment alignment = right! boolean focusrectangle = false end type type st_2 from statictext within w_main integer x = 37 integer y = 224 integer width = 571 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "IsProcessElevated:" boolean focusrectangle = false end type type st_3 from statictext within w_main integer x = 37 integer y = 128 integer width = 571 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "IsRunAsAdmin:" boolean focusrectangle = false end type type st_isrunasadmin from statictext within w_main integer x = 585 integer y = 128 integer width = 402 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 alignment alignment = right! boolean focusrectangle = false end type type st_userinadmingroup from statictext within w_main integer x = 658 integer y = 32 integer width = 329 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 alignment alignment = right! boolean focusrectangle = false end type type st_1 from statictext within w_main integer x = 37 integer y = 32 integer width = 549 integer height = 64 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" long textcolor = 33554432 long backcolor = 67108864 string text = "IsUserInAdminGroup:" boolean focusrectangle = false end type type p_shield from picture within w_main integer x = 73 integer y = 640 integer width = 146 integer height = 128 boolean originalsize = true string picturename = "Shield.bmp" boolean focusrectangle = false end type event clicked;cb_1.triggerEvent(clicked!) end event type cb_1 from commandbutton within w_main integer x = 37 integer y = 608 integer width = 951 integer height = 192 integer taborder = 10 integer textsize = -10 integer weight = 400 fontcharset fontcharset = ansi! fontpitch fontpitch = variable! fontfamily fontfamily = swiss! string facename = "Tahoma" string text = "Self-Elevating" boolean flatstyle = true end type event clicked;If inv_privileges.of_selfelevation( ) = 1 Then Halt End If end event |
Find Projects On Github click here
Good Luck!
Subscribe
Login
0 Comments