PnpProcessCompletedEject

VOID *__fastcall PnpProcessCompletedEject(PVOID P){
  _SYSTEM_POWER_STATE v1; 
  int v2; 
  int v4; 
  __int64 v5; 
  _QWORD *v6; 
  PVOID *v7; 
  __int64 v8; 
  __int64 v9; 
  _RELATION_LIST *v10; 
  _QWORD *v11; 
  __int64 v12; 

  v1 = *((_DWORD *)P + 23);
  v2 = 0;
  if( (unsigned int)v1 > PowerSystemWorking )
  {
    *((_BYTE *)P + 89) = 0;
    IopWarmEjectDevice(*((_DEVICE_OBJECT **)P + 7), v1);
    v2 = v4;
  }
  v5 = *((_QWORD *)P + 12);
  if( v5 )
  {
    (*(void(__fastcall **)(_QWORD, __int64))(v5 + 32))(*(_QWORD *)(v5 + 8), 1i64);
    (*(void(__fastcall **)(_QWORD))(*((_QWORD *)P + 12) + 24i64))(*(_QWORD *)(*((_QWORD *)P + 12) + 8i64));
  }
  PpDevNodeLockTree(PPL_TREEOP_ALLOW_READS);
  v6 = *(_QWORD **)P;
  if( *(PVOID *)(*(_QWORD *)P + 8i64) != P || (v7 = (PVOID *)*((_QWORD *)P + 1), *v7 != P) )
    __fastfail(3u);
  *v7 = v6;
  v6[1] = v7;
  v8 = *((_QWORD *)P + 7);
  if( v8 )
    v9 = *(_QWORD *)(*(_QWORD *)(v8 + 312) + 40i64);
  else
    v9 = 0i64;
  v10 = (_RELATION_LIST *)*((_QWORD *)P + 8);
  if( v10 )
  {
    if( *((_BYTE *)P + 88) )
    {
      PpProfileMarkAllTransitioningDocksEjected();
      v10 = (_RELATION_LIST *)*((_QWORD *)P + 8);
    }
    PnpInvalidateRelationsInList(v10, EjectDevice, 0, 1);
    PnpTrackQueryRemoveDevices(*((_RELATION_LIST **)P + 8), 0);
    IopFreeRelationList(*((_RELATION_LIST **)P + 8));
    *(_QWORD *)(v9 + 696) = 0i64;
  }
  else
  {
    *((_BYTE *)P + 89) = 0;
  }
  PpDevNodeUnlockTree(PPL_TREEOP_ALLOW_READS);
  v11 = (_QWORD *)*((_QWORD *)P + 6);
  if( v11 )
  {
    v12 = v11[13];
    if( v12 )
    {
      PnpDisableWatchdog(v12);
      v11[13] = 0i64;
    }
    PnpCompleteDeviceEvent(v11, v2);
  }
  if( *((_BYTE *)P + 89) )
    PnpSetDeviceRemovalSafe(*((PVOID *)P + 7));
  HalPutDmaAdapter(*((PADAPTER_OBJECT *)P + 7));
  return ExFreePoolWithTag(P, 0);
}

Referenced by:

PnpProcessQueryRemoveAndEject