PiIommuAllocateExtension

__int64 __fastcall PiIommuAllocateExtension(__int64 a1, _QWORD *a2, _QWORD *a3){
  VOID **PoolWithTag; 
  int DeviceId; 
  __int64(__fastcall *v7)(_QWORD, unsigned int *); 
  char v8; 
  char v9; 
  char v10; 
  __int64 result; 
  unsigned int v12; 

  v12 = 0;
  PoolWithTag = ExAllocatePoolWithTag(1ui64, 0x28ui64, 1685089872i64);
  if( PoolWithTag )
  {
    *(_OWORD *)PoolWithTag = 0i64;
    *((_OWORD *)PoolWithTag + 1) = 0i64;
    PoolWithTag[4] = 0i64;
    DeviceId = PipIommuRetrieveDeviceId(a2, PoolWithTag);
    if( DeviceId < 0
      || (*((_BYTE *)*PoolWithTag + 4) & 2) != 0
      && (DeviceId = PipIommuRetrieveSecondaryDeviceId(a2, PoolWithTag + 3), DeviceId < 0)
      || ((v7 = (__int64(__fastcall *)(_QWORD, unsigned int *))a2[7]) == 0i64 ? (DeviceId = -1073741637) : (DeviceId = v7(a2[1], &v12)),
          DeviceId < 0) )
    {
      PiIommuFreeExtension((ULONG_PTR)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