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:
| function EnableAllPrivileges : string; var c1, c2, c3 : dword; ptp : PTokenPrivileges; i1 : integer; arrCh : array [0..MAX_PATH] of char; begin result := ''; if OpenProcessToken(windows.GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY, c1) then try c2 := 0; GetTokenInformation(c1, TokenPrivileges, nil, 0, c2); if c2 <> 0 then begin ptp := AllocMem(c2); if GetTokenInformation(c1, TokenPrivileges, ptp, c2, c2) then begin for i1 := 0 to integer(ptp^.PrivilegeCount) - 1 do begin c3 := MAX_PATH; if LookupPrivilegeName(nil, ptp^.Privileges[i1].Luid, arrCh, c3) then result := result + #$D#$A + arrCh + ' ' else result := result + #$D#$A + '??? '; result := result + booleanToChar(ptp^.Privileges[i1].Attributes and SE_PRIVILEGE_ENABLED <> 0); ptp^.Privileges[i1].Attributes := ptp^.Privileges[i1].Attributes or SE_PRIVILEGE_ENABLED; end; AdjustTokenPrivileges(c1, false, ptp^, c2, PTokenPrivileges(nil)^, cardinal(pointer(nil)^)); end; FreeMem(ptp); end; finally CloseHandle(c1) end; Delete(result, 1, 2); end; |