/// <summary> /// Overridden process record method. /// </summary> protected override void ProcessRecord() { using (NtToken token = GetToken()) { NtType type = GetNtType(); if (type == null) { throw new ArgumentException("Must specify a type."); } var result = NtSecurity.AccessCheck(GetSecurityDescriptor(), token, AccessMask, Principal, type.GenericMapping, ObjectType).ToSpecificAccess(type.AccessRightsType); if (PassResult) { WriteObject(result); return; } var mask = result.SpecificGrantedAccess; if (MapToGeneric) { mask = result.SpecificGenericGrantedAccess; } if (ConvertToString) { string access_string = NtObjectUtils.GrantedAccessAsString(mask, type.GenericMapping, type.AccessRightsType, false); WriteObject(access_string); } else { WriteObject(mask); } } }
internal NtType(int id, ObjectTypeInformation info, NtTypeFactory type_factory) { Index = id; Name = info.Name.ToString(); InvalidAttributes = info.InvalidAttributes; GenericMapping = info.GenericMapping; ValidAccess = info.ValidAccess; SecurityRequired = info.SecurityRequired != 0; TotalNumberOfObjects = info.TotalNumberOfObjects; TotalNumberOfHandles = info.TotalNumberOfHandles; TotalPagedPoolUsage = info.TotalPagedPoolUsage; TotalNonPagedPoolUsage = info.TotalNonPagedPoolUsage; TotalNamePoolUsage = info.TotalNamePoolUsage; TotalHandleTableUsage = info.TotalHandleTableUsage; HighWaterNumberOfObjects = info.HighWaterNumberOfObjects; HighWaterNumberOfHandles = info.HighWaterNumberOfHandles; HighWaterPagedPoolUsage = info.HighWaterPagedPoolUsage; HighWaterNonPagedPoolUsage = info.HighWaterNonPagedPoolUsage; HighWaterNamePoolUsage = info.HighWaterNamePoolUsage; HighWaterHandleTableUsage = info.HighWaterHandleTableUsage; MaintainHandleCount = info.MaintainHandleCount != 0; MaintainTypeList = info.MaintainTypeList; PoolType = info.PoolType; PagedPoolUsage = info.PagedPoolUsage; NonPagedPoolUsage = info.NonPagedPoolUsage; _type_factory = type_factory; GenericRead = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericRead, GenericMapping, _type_factory.AccessRightsType, false); GenericWrite = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericWrite, GenericMapping, _type_factory.AccessRightsType, false); GenericExecute = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericExecute, GenericMapping, _type_factory.AccessRightsType, false); GenericAll = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericAll, GenericMapping, _type_factory.AccessRightsType, false); }
internal NtType(string name, GenericMapping generic_mapping, Type access_rights_type) { if (!access_rights_type.IsEnum) { throw new ArgumentException("Specify an enumerated type", "access_rights_type"); } _type_factory = new NtTypeFactory(access_rights_type, typeof(object)); Name = name; GenericMapping = generic_mapping; GenericRead = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericRead, GenericMapping, access_rights_type, false); GenericWrite = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericWrite, GenericMapping, access_rights_type, false); GenericExecute = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericExecute, GenericMapping, access_rights_type, false); GenericAll = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericAll, GenericMapping, access_rights_type, false); }
internal NtType(string name, GenericMapping generic_mapping, Type access_rights_type, Type container_access_rights_type, MandatoryLabelPolicy default_policy) { if (!access_rights_type.IsEnum) { throw new ArgumentException("Specify an enumerated type", "access_rights_type"); } _type_factory = new NtTypeFactory(access_rights_type, container_access_rights_type, typeof(object), false, default_policy); Name = name; ValidAccess = CalculateValidAccess(access_rights_type) | CalculateValidAccess(container_access_rights_type); GenericMapping = generic_mapping; GenericRead = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericRead, GenericMapping, access_rights_type, false); GenericWrite = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericWrite, GenericMapping, access_rights_type, false); GenericExecute = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericExecute, GenericMapping, access_rights_type, false); GenericAll = NtObjectUtils.GrantedAccessAsString(GenericMapping.GenericAll, GenericMapping, access_rights_type, false); DefaultMandatoryAccess = NtObjectUtils.GrantedAccessAsString(GetDefaultMandatoryAccess(), generic_mapping, access_rights_type, false); }
/// <summary> /// Overridden process record method. /// </summary> protected override void ProcessRecord() { using (NtToken token = GetToken()) { NtType type = GetNtType(); AccessMask mask = NtSecurity.GetAllowedAccess(GetSecurityDescriptor(), token, AccessMask, Principal, type.GenericMapping); if (MapToGeneric) { mask = type.GenericMapping.UnmapMask(mask); } if (ConvertToString) { string access_string = NtObjectUtils.GrantedAccessAsString(mask, type.GenericMapping, type.AccessRightsType, false); WriteObject(access_string); } else { WriteObject(mask.ToSpecificAccess(type.AccessRightsType)); } } }
/// <summary> /// Convert an enumerable access rights to a string /// </summary> /// <param name="granted_access">The granted access mask.</param> /// <param name="map_to_generic">True to try and convert to generic rights where possible.</param> /// <returns>The string format of the access rights</returns> public string AccessMaskToString(AccessMask granted_access, bool map_to_generic) { return(NtObjectUtils.GrantedAccessAsString(granted_access, GenericMapping, AccessRightsType, map_to_generic)); }