IoCreateDeviceSecure

NTSTATUS __stdcall IoCreateDeviceSecure(
        INT64 a1,
        INT64 rdx0,
        INT64 a3,
        INT64 a4,
        INT64 a5,
        INT8 a6,
        INT64 a7,
        INT64 Guid,
        PDEVICE_OBJECT DeviceObject){
  PDEVICE_OBJECT v9; 
  UINT32 v10; 
  PDEVICE_OBJECT v11; 
  VOID **v12; 
  int SecureDeviceClassSettings; 
  char v14; 
  unsigned __int64 v15; 
  VOID **v16; 
  UINT64 v17; 
  NTSTATUS v19; 
  VOID **PoolWithTag; 
  UINT64 DeviceCharacteristics; 
  UINT32 DeviceType[4]; 
  UINT32 v24[2]; 
  INT64 a2[3]; 
  UINT32 DeviceExtensionSize; 
  unsigned int v29; 

  v29 = a4;
  DeviceExtensionSize = rdx0;
  v9 = DeviceObject;
  v10 = a5;
  *(_QWORD *)&DeviceObject->Type = 0i64;
  v11 = 0i64;
  v12 = 0i64;
  DeviceObject = 0i64;
  *(_QWORD *)v24 = 0i64;
  *(_OWORD *)DeviceType = 0i64;
  if( !a3 && (a5 & 0x80u) == 0i64 )
  {
    SecureDeviceClassSettings = -1073741811;
LABEL_32:
    v14 = DeviceType[0];
    goto LABEL_21;
  }
  if( Guid )
  {
    SecureDeviceClassSettings = IopCreateSecureDeviceClassSettings((_GUID *)Guid, a1, DeviceType);
    if( SecureDeviceClassSettings < 0 )
      goto LABEL_32;
  }
  v14 = DeviceType[0];
  if( (DeviceType[0] & 2) != 0 )
    goto LABEL_10;
  v15 = *(unsigned __int16 *)a7;
  if( *(unsigned __int16 *)(a7 + 2) != v15 + 2 || (v16 = *(VOID ***)(a7 + 8), *((_WORD *)v16 + (v15 >> 1))) )
  {
    PoolWithTag = ExAllocatePoolWithTag(1ui64, v15 + 2, 1665560393i64);
    v12 = PoolWithTag;
    if( !PoolWithTag )
    {
      SecureDeviceClassSettings = -1073741670;
      goto LABEL_21;
    }
    memmove(PoolWithTag, *(const VOID **)(a7 + 8), *(unsigned __int16 *)a7);
    *((_WORD *)v12 + ((unsigned __int64)*(unsigned __int16 *)a7 >> 1)) = 0;
    v16 = v12;
  }
  SecureDeviceClassSettings = SeConvertStringSecurityDescriptorToSecurityDescriptor(v16);
  if( SecureDeviceClassSettings >= 0 )
  {
    v14 = 2;
    DeviceType[0] = 2;
    *(_QWORD *)&DeviceType[2] = 0i64;
    MEMORY[2] |= 8u;
    if( !Guid
      || (a2[0] = 2i64,
          a2[2] = 0i64,
          a2[1] = 0i64,
          SecureDeviceClassSettings = IopUpdateSecureDeviceClassState((_GUID *)Guid, (INT64)a2),
          SecureDeviceClassSettings >= 0) )
    {
LABEL_10:
      v17 = v29;
      if( (DeviceType[0] & 1) != 0 )
        v17 = DeviceType[1];
      if( (DeviceType[0] & 4) != 0 )
        v10 = v24[0];
      if( (DeviceType[0] & 8) != 0 )
        a6 = v24[1];
      LODWORD(DeviceCharacteristics) = v10;
      v19 = IoCreateDevice(
              (_DRIVER_OBJECT *)a1,
              DeviceExtensionSize,
              (_UNICODE_STRING *)a3,
              v17,
              DeviceCharacteristics,
              a6,
              &DeviceObject);
      v11 = DeviceObject;
      SecureDeviceClassSettings = v19;
      if( v19 >= 0 )
      {
        if( (v14 & 2) == 0
          || (SecureDeviceClassSettings = IopGetSecurityDescriptorInformation(*(PSECURITY_DESCRIPTOR *)&DeviceType[2]),
              SecureDeviceClassSettings >= 0)
          && (SecureDeviceClassSettings = ObSetSecurityObjectByPointer(v11, 0i64, *(VOID **)&DeviceType[2]),
              SecureDeviceClassSettings >= 0) )
        {
          *(_QWORD *)&v9->Type = v11;
          v11 = 0i64;
        }
      }
    }
  }
LABEL_21:
  if( (v14 & 2) != 0 )
    ExFreePoolWithTag(*(PVOID *)&DeviceType[2], 0);
  if( v11 )
    IoDeleteDevice(v11);
  if( v12 )
    ExFreePoolWithTag(v12, 0);
  return SecureDeviceClassSettings;
}

Referenced by:

No references.