private unsafe LuidAndAttributes[] GetPrivileges() { UInt32 size = (UInt32)(4 + sizeof(LuidAndAttributes) * 36); byte[] buff = new byte[size]; buff[0] = 36; fixed(byte *buffP = buff) { bool success = GetTokenInformation(tokenHandle, TokenInformationClass.Privileges, buffP, size, out _); if (!success) { throw new Win32Exception(); } int privCount = buff[0]; var outBuff = new LuidAndAttributes[privCount]; var arrStart = (LuidAndAttributes *)(buffP + 4); for (int privIndex = 0; privIndex < privCount; privIndex++) { outBuff[privIndex] = arrStart[privIndex]; } return(outBuff); } }
public TokenPrivilege(UInt64 LUID, PrivilegeAttributes attributes) : this() { Count = 1; Privilege = new LuidAndAttributes(LUID, attributes); }