This commit is contained in:
Mino 2020-04-13 17:53:16 +09:00
parent 32af098159
commit 07538a0974
7 changed files with 336 additions and 279 deletions

View file

@ -18,6 +18,9 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
public static extern void BuildExplicitAccessWithNameW(out EXPLICIT_ACCESS_W pExplicitAccess, string pTrusteeName, uint AccessPermissions, ACCESS_MODE AccessMode, uint Inheritance);
[DllImport(Name, CallingConvention = CallingConvention.Winapi)]
public static extern uint GetSecurityInfo(IntPtr handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo);
public static extern uint GetSecurityInfo(IntPtr handle, SE_OBJECT_TYPE ObjectType, SECURITY_INFORMATION SecurityInfo, SID** ppsidOwner, SID** ppsidGroup, ACL** ppDacl, ACL** ppSacl, SECURITY_DESCRIPTOR** ppSecurityDescriptor);
[DllImport(Name, CallingConvention = CallingConvention.Winapi)]
public static extern uint SetSecurityInfo(IntPtr handle, SE_OBJECT_TYPE _OBJECT_TYPE, SECURITY_INFORMATION SecurityInfo, SID* psidOwner, SID* psidGroup, ACL* pDacl, ACL* pSacl);
}
}

View file

@ -24,6 +24,8 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
PROCESS_QUERY_INFORMATION = 0x400,
PROCESS_SUSPEND_RESUME = 0x800,
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000,
READ_CONTROL = 0x20000,
WRITE_DAC = 0x40000,
SYNCHRONIZE = 0x100000,
}
@ -124,4 +126,23 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
SE_REGISTRY_WOW64_32KEY,
SE_REGISTRY_WOW64_64KEY
}
internal enum SECURITY_INFORMATION : uint
{
// https://docs.rs/winapi/0.3.8/src/winapi/um/winnt.rs.html#2880
OWNER_SECURITY_INFORMATION = 0x00000001,
GROUP_SECURITY_INFORMATION = 0x00000002,
DACL_SECURITY_INFORMATION = 0x00000004,
SACL_SECURITY_INFORMATION = 0x00000008,
LABEL_SECURITY_INFORMATION = 0x00000010,
ATTRIBUTE_SECURITY_INFORMATION = 0x00000020,
SCOPE_SECURITY_INFORMATION = 0x00000040,
PROCESS_TRUST_LABEL_SECURITY_INFORMATION = 0x00000080,
ACCESS_FILTER_SECURITY_INFORMATION = 0x00000100,
BACKUP_SECURITY_INFORMATION = 0x00010000,
UNPROTECTED_SACL_SECURITY_INFORMATION = 0x10000000,
UNPROTECTED_DACL_SECURITY_INFORMATION = 0x20000000,
PROTECTED_SACL_SECURITY_INFORMATION = 0x40000000,
PROTECTED_DACL_SECURITY_INFORMATION = 0x80000000,
}
}

View file

@ -131,7 +131,7 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
public IntPtr Dacl;
}
[StructLayout(LayoutKind.Explicit)]
[StructLayout(LayoutKind.Sequential)]
internal unsafe struct TRUSTEE_W
{
public TRUSTEE_W* pMultipleTrustee;
@ -144,19 +144,36 @@ namespace Dalamud.Bootstrap.OS.Windows.Raw
[StructLayout(LayoutKind.Sequential)]
internal struct EXPLICIT_ACCESS_W
{
uint grfAccessPermissions;
ACCESS_MODE grfAccessMode;
uint grfInheritance;
TRUSTEE_W Trustee;
public uint grfAccessPermissions;
public ACCESS_MODE grfAccessMode;
public uint grfInheritance;
public TRUSTEE_W Trustee;
}
[StructLayout(LayoutKind.Sequential)]
internal struct SID
{
// NOTE: this structure actually has no fixed length and therefore should not be used directly.
// https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-sid
byte Revision;
byte SubAuthorityCount;
SID_IDENTIFIER_AUTHORITY IdentifierAuthority;
uint SubAuthority;
}
[StructLayout(LayoutKind.Sequential)]
internal struct SID_IDENTIFIER_AUTHORITY
{
public unsafe fixed byte Value[6];
}
[StructLayout(LayoutKind.Sequential)]
internal struct ACL
{
byte AclRevision;
byte Sbz1;
ushort AclSize;
ushort AceCount;
ushort Sbz2;
public byte AclRevision;
public byte Sbz1;
public ushort AclSize;
public ushort AceCount;
public ushort Sbz2;
}
}