IopCreateDefaultDeviceSecurityDescriptor
NTSTATUS __stdcall IopCreateDefaultDeviceSecurityDescriptor(
UINT64 DeviceType,
UINT64 DeviceCharacteristics,
UINT8 *Buffer,
ACL **AllocatedAcl,
ACL **AllocatedSacl,
UINT64 *SecurityInformation,
UINT64 a7){
UINT64 *v7;
int v9;
ACL **v10;
UINT64 v11;
NTSTATUS SecurityDescriptorPerType;
bool v14;
unsigned __int16 v15;
unsigned __int8 *v16;
UINT8 *PoolWithTag;
ACL *v18;
enum _NT_PRODUCT_TYPE ProductType;
LOBYTE(ProductType) = (_BYTE)Buffer;
v7 = (UINT64 *)a7;
v9 = DeviceType;
if( a7 )
*(_DWORD *)a7 = 0;
v10 = AllocatedSacl;
*AllocatedSacl = 0i64;
if( (unsigned int)DeviceType > 0x14 )
{
if( (_DWORD)DeviceType != 45 )
{
if( (_DWORD)DeviceType == 32 )
goto LABEL_10;
if( (_DWORD)DeviceType != 36 )
{
v14 = (_DWORD)DeviceType == 53;
LABEL_18:
if( !v14 )
goto LABEL_19;
}
}
LABEL_20:
if( (_DWORD)DeviceType != 7 || (DeviceCharacteristics & 1) == 0 )
goto LABEL_10;
LABEL_25:
ProductType = 0;
v15 = *(_WORD *)(*(_QWORD *)SePublicDefaultUnrestrictedDacl + 2i64);
if( !RtlGetNtProductType(&ProductType) )
return 0;
if( ProductType == NtProductWinNt )
{
v16 = (unsigned __int8 *)SeInteractiveSid;
}
else
{
if( v9 != 2 )
{
LABEL_31:
PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, v15, 0x65536F49ui64);
v18 = (ACL *)PoolWithTag;
if( !PoolWithTag )
return 0;
memmove(
PoolWithTag,
(UINT8 *)SePublicDefaultUnrestrictedDacl,
*(unsigned __int16 *)(*(_QWORD *)SePublicDefaultUnrestrictedDacl + 2i64));
v14 = ProductType == NtProductWinNt;
v18->AclSize = v15;
if( v14 )
{
RtlpAddKnownAce(v18, 2ui64, 0i64, 0xC0010000ui64, (VOID *)SeInteractiveSid, 0);
}
else if( v9 == 2 )
{
RtlpAddKnownAce(v18, 2ui64, 0i64, 0x80000000ui64, SeWorldSid, 0);
}
RtlCreateSecurityDescriptor(AllocatedAcl, 1ui64);
RtlSetDaclSecurityDescriptor(AllocatedAcl, 1u, v18, 0);
if( v7 )
*(_DWORD *)v7 |= 4u;
*v10 = v18;
SecurityDescriptorPerType = 0;
goto LABEL_12;
}
v16 = (unsigned __int8 *)SeWorldSid;
}
v15 += 4 * (v16[1] + 4);
goto LABEL_31;
}
if( (_DWORD)DeviceType == 20 )
goto LABEL_20;
if( (_DWORD)DeviceType == 2 )
goto LABEL_25;
if( (_DWORD)DeviceType != 3 )
{
if( (_DWORD)DeviceType != 7 )
{
if( (unsigned int)DeviceType <= 7 )
{
LABEL_19:
v11 = 4i64;
goto LABEL_11;
}
if( (unsigned int)DeviceType <= 9 )
goto LABEL_10;
v14 = (_DWORD)DeviceType == 18;
goto LABEL_18;
}
goto LABEL_20;
}
LABEL_10:
v11 = 2i64;
LABEL_11:
SecurityDescriptorPerType = IopCreateSecurityDescriptorPerType(AllocatedAcl, v11, (_ACL **)SecurityInformation, v7);
LABEL_12:
if( SecurityDescriptorPerType >= 0 )
return(int)AllocatedAcl;
return 0;
}Referenced by:
IoCreateDevice
PipChangeDeviceObjectFromRegistryProperties