IopAllocatePassiveInterruptBlock

NTSTATUS __stdcall IopAllocatePassiveInterruptBlock(
        _INTERRUPT_CONNECTION_DATA *ConnectionData,
        _GROUP_AFFINITY *Affinity){
  bool v2; 
  INTERRUPT_CONNECTION_TYPE Type; 
  unsigned int Vector; 
  int inserted; 
  VOID **PoolWithTag; 
  VOID **v9; 
  INTERRUPT_CONNECTION_TYPE v10; 
  char NewPassiveBlock; 

  v2 = ConnectionData->Count == 1;
  NewPassiveBlock = 0;
  if( !v2 )
    return -1073741585;
  Type = ConnectionData->Vectors[0].Type;
  if( Type )
  {
    if( Type != InterruptTypeMessageRequest )
      return -1073741585;
  }
  Vector = ConnectionData->Vectors[0].Vector;
  if( IopFindPassiveInterruptBlock(Vector) )
    return 0;
  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0xC8ui64, 1651077195i64);
  v9 = PoolWithTag;
  if( !PoolWithTag )
    return -1073741670;
  memset(PoolWithTag + 2, 0i64, 0xB8u);
  v9[1] = v9;
  *v9 = v9;
  *((_DWORD *)v9 + 4) = ConnectionData->Vectors[0].Type;
  *((_DWORD *)v9 + 5) = Vector;
  *((_DWORD *)v9 + 8) = ConnectionData->Vectors[0].Mode;
  *(_GROUP_AFFINITY *)(v9 + 5) = *Affinity;
  v10 = ConnectionData->Vectors[0].Type;
  if( v10 )
  {
    if( v10 == InterruptTypeMessageRequest )
      *((_BYTE *)v9 + 28) = 0;
  }
  else
  {
    *((_DWORD *)v9 + 6) = ConnectionData->Vectors[0].ControllerInput.Gsiv;
    *((_BYTE *)v9 + 28) = ((__int64(__fastcall *)(_QWORD))off_140C00780[0])(0i64);
  }
  KeInitializeEvent((INT64)(v9 + 21), 1, 1u);
  KeInitializeDpc((PRKDPC)(v9 + 13), IopPassiveInterruptDpc, v9);
  v9[7] = 0i64;
  v9[9] = 0i64;
  v9[11] = IopPassiveInterruptWorker;
  v9[12] = v9;
  *((_BYTE *)v9 + 105) = 2;
  inserted = IopInsertPassiveInterruptBlock(v9, &NewPassiveBlock);
  if( inserted < 0 || !NewPassiveBlock )
    ExFreePoolWithTag(v9, 0x6269704Bu);
  return inserted;
}

Referenced by:

IopConnectInterrupt