8 internal static class Advapi32
17 internal struct LUID_AND_ATTRIBUTES
24 internal struct TOKEN_PRIVILEGE
39 [DllImport(
"advapi32.dll", BestFitMapping =
false,
CharSet =
CharSet.Unicode, EntryPoint =
"LookupPrivilegeValueW", SetLastError =
true)]
42 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, ExactSpelling =
true, SetLastError =
true)]
45 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, EntryPoint =
"ConvertSecurityDescriptorToStringSecurityDescriptorW", ExactSpelling =
true, SetLastError =
true)]
46 internal static extern bool ConvertSdToStringSd(
byte[] securityDescriptor, uint requestedRevision, uint securityInformation, out
IntPtr resultString, ref uint resultStringLength);
48 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, EntryPoint =
"ConvertStringSecurityDescriptorToSecurityDescriptorW", ExactSpelling =
true, SetLastError =
true)]
49 internal static extern bool ConvertStringSdToSd(
string stringSd, uint stringSdRevision, out
IntPtr resultSd, ref uint resultSdLength);
51 [DllImport(
"advapi32.dll", EntryPoint =
"GetSecurityInfo", ExactSpelling =
true, SetLastError =
true)]
54 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, EntryPoint =
"SetSecurityInfo", ExactSpelling =
true, SetLastError =
true)]
57 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, EntryPoint =
"GetNamedSecurityInfoW", ExactSpelling =
true, SetLastError =
true)]
60 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, EntryPoint =
"SetNamedSecurityInfoW", ExactSpelling =
true, SetLastError =
true)]
61 internal static extern uint
SetSecurityInfoByName(
string name, uint objectType, uint securityInformation,
byte[] owner,
byte[] group,
byte[] dacl,
byte[] sacl);
63 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, ExactSpelling =
true, SetLastError =
true)]
66 [DllImport(
"advapi32.dll", SetLastError =
true)]
69 [DllImport(
"advapi32.dll",
CharSet =
CharSet.Unicode, SetLastError =
true)]
72 [DllImport(
"advapi32.dll", SetLastError =
true)]
75 [DllImport(
"advapi32.dll", SetLastError =
true)]
78 [DllImport(
"advapi32.dll", SetLastError =
true)]
87 [DllImport(
"kernel32.dll")]
static uint SetSecurityInfoByHandle(SafeHandle handle, uint objectType, uint securityInformation, byte[] owner, byte[] group, byte[] dacl, byte[] sacl)
static uint GetSecurityDescriptorLength(IntPtr byteArray)
static uint SetSecurityInfoByName(string name, uint objectType, uint securityInformation, byte[] owner, byte[] group, byte[] dacl, byte[] sacl)
static bool SetThreadToken(IntPtr ThreadHandle, SafeTokenHandle hToken)
static bool DuplicateTokenEx(SafeTokenHandle ExistingTokenHandle, TokenAccessLevels DesiredAccess, IntPtr TokenAttributes, SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, System.Security.Principal.TokenType TokenType, ref SafeTokenHandle DuplicateTokenHandle)
static bool OpenThreadToken(IntPtr ThreadHandle, TokenAccessLevels dwDesiredAccess, bool bOpenAsSelf, out SafeTokenHandle phThreadToken)
static bool ConvertSdToStringSd(byte[] securityDescriptor, uint requestedRevision, uint securityInformation, out IntPtr resultString, ref uint resultStringLength)
static unsafe bool AdjustTokenPrivileges(SafeTokenHandle TokenHandle, bool DisableAllPrivileges, TOKEN_PRIVILEGE *NewState, uint BufferLength, TOKEN_PRIVILEGE *PreviousState, uint *ReturnLength)
static uint GetSecurityInfoByHandle(SafeHandle handle, uint objectType, uint securityInformation, out IntPtr sidOwner, out IntPtr sidGroup, out IntPtr dacl, out IntPtr sacl, out IntPtr securityDescriptor)
static bool OpenProcessToken(IntPtr ProcessToken, TokenAccessLevels DesiredAccess, out SafeTokenHandle TokenHandle)
static bool RevertToSelf()
static bool ConvertStringSdToSd(string stringSd, uint stringSdRevision, out IntPtr resultSd, ref uint resultSdLength)
SECURITY_IMPERSONATION_LEVEL
static uint GetSecurityInfoByName(string name, uint objectType, uint securityInformation, out IntPtr sidOwner, out IntPtr sidGroup, out IntPtr dacl, out IntPtr sacl, out IntPtr securityDescriptor)
static bool LookupPrivilegeValue([MarshalAs(UnmanagedType.LPTStr)] string lpSystemName, [MarshalAs(UnmanagedType.LPTStr)] string lpName, out LUID lpLuid)
static void SetLastError(int errorCode)
static bool CloseHandle(IntPtr handle)
static IntPtr GetCurrentProcess()
LUID_AND_ATTRIBUTES Privileges