-
Notifications
You must be signed in to change notification settings - Fork 72
/
AdjustPrivilege2.ahk
70 lines (65 loc) · 3.01 KB
/
AdjustPrivilege2.ahk
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
; Link: https://www.autohotkey.com/boards/viewtopic.php?f=42&t=66232&hilit=nested+class
; Author:
; Date:
; for: AHK_L
/*
*/
/*
Enables or disables a privilege in the current process.
Parameters:
Privilege:
0 SeUnsolicitedInputPrivilege
2 SeCreateTokenPrivilege
3 SeAssignPrimaryTokenPrivilege
4 SeLockMemoryPrivilege
5 SeIncreaseQuotaPrivilege
6 SeMachineAccountPrivilege
7 SeTcbPrivilege
8 SeSecurityPrivilege
9 SeTakeOwnershipPrivilege
10 SeLoadDriverPrivilege
11 SeSystemProfilePrivilege
12 SeSystemtimePrivilege
13 SeProfileSingleProcessPrivilege
14 SeIncreaseBasePriorityPrivilege
21 SeAuditPrivilege
17 SeBackupPrivilege
23 SeChangeNotifyPrivilege
30 SeCreateGlobalPrivilege
15 SeCreatePagefilePrivilege
16 SeCreatePermanentPrivilege
18 SeRestorePrivilege
19 SeShutdownPrivilege
35 SeCreateSymbolicLinkPrivilege
20 SeDebugPrivilege
22 SeSystemEnvironmentPrivilege
24 SeRemoteShutdownPrivilege
25 SeUndockPrivilege
26 SeSyncAgentPrivilege
27 SeEnableDelegationPrivilege
28 SeManageVolumePrivilege
29 SeImpersonatePrivilege
31 SeTrustedCredManAccessPrivilege
32 SeRelabelPrivilege
33 SeIncreaseWorkingSetPrivilege
34 SeTimeZonePrivilege
Enable:
FALSE Disable the specified privilege.
TRUE Enable the specified privilege.
IsThreadPrivilege:
FALSE Open current process.
TRUE Open current thread.
Return value:
If the function succeeds, the return value is non-zero.
If the function fails, the return value is zero. To get extended error information, check A_LastError (NTSTATUS).
*/
AdjustPrivilege(Privilege, Enable := TRUE, IsThreadPrivilege := FALSE)
{
A_LastError := DllCall("Ntdll.dll\RtlAdjustPrivilege", "UInt", Privilege ; ULONG.
, "UChar", !!Enable ; BOOLEAN.
, "UChar", !!IsThreadPrivilege ; BOOLEAN.
, "UCharP", 0 ; PBOOLEAN.
, "UInt")
; The last parameter is supposed to return the previous value, but it doesn't work.
return A_LastError == 0 ? TRUE : FALSE
} ; https://source.winehq.org/WineAPI/RtlAdjustPrivilege.html