PiIommuAllocateExtension

INT64 __fastcall PiIommuAllocateExtension(INT64 a1, INT64 a2, _QWORD *a3){
  _OWORD *PoolWithTag; 
  int DeviceId; 
  __int64(__fastcall *v7)(_QWORD, unsigned int *); 
  char v8; 
  char v9; 
  char v10; 
  INT64 result; 
  unsigned int v12; 
  v12 = 0;
  PoolWithTag = ExAllocatePoolWithTag(PagedPool, 0x28ui64, 0x64706E50ui64);
  if( PoolWithTag )
  {
    *PoolWithTag = 0i64;
    PoolWithTag[1] = 0i64;
    *((_QWORD *)PoolWithTag + 4) = 0i64;
    DeviceId = PipIommuRetrieveDeviceId(a2, PoolWithTag);
    if( DeviceId < 0
      || (*(_BYTE *)(*(_QWORD *)PoolWithTag + 4i64) & 2) != 0
      && (DeviceId = PipIommuRetrieveSecondaryDeviceId(a2, (_QWORD *)PoolWithTag + 3), DeviceId < 0)
      || ((v7 = *(__int64(__fastcall **)(_QWORD, unsigned int *))(a2 + 56)) == 0i64 ? (DeviceId = -1073741637) : (DeviceId = v7(*(_QWORD *)(a2 + 8), &v12)),
          DeviceId < 0) )
    {
      PiIommuFreeExtension(PoolWithTag);
      PoolWithTag = 0i64;
    }
    else
    {
      *((_BYTE *)PoolWithTag + 16) ^= (*((_BYTE *)PoolWithTag + 16) ^ (8 * (v12 >> 1))) & 8;
      v8 = *((_BYTE *)PoolWithTag + 16) ^ (*((_BYTE *)PoolWithTag + 16) ^ (4 * v12)) & 4;
      *((_BYTE *)PoolWithTag + 16) = v8;
      v9 = v8 ^ (v8 ^ (32 * (v12 >> 3))) & 0x20;
      *((_BYTE *)PoolWithTag + 16) = v9;
      v10 = v9 ^ (v9 ^ (16 * (v12 >> 2))) & 0x10;
      *((_BYTE *)PoolWithTag + 16) = v10;
      if( (v10 & 0x24) != 0 )
        PnpTraceIommuDeviceProperties();
    }
  }
  else
  {
    DeviceId = -1073741670;
  }
  result = (unsigned int)DeviceId;
  *a3 = PoolWithTag;
  return result;
}

Referenced by:

PiDmaGuardProcessNewDeviceNode