PnpSetTargetDeviceRemove

__int64 __fastcall PnpSetTargetDeviceRemove(
        PVOID Object,
        int a2,
        int a3,
        int a4,
        int a5,
        int a6,
        int a7,
        __int64 a8,
        __int64 a9,
        __int64 a10,
        __int64 a11,
        __int64 a12,
        __int64 a13,
        __int64 a14){
  __int64 v15; 
  unsigned int v19; 
  CHAR *CriticalMemory; 
  __int64 v21; 
  v15 = 0i64;
  if( a11 )
    *(_DWORD *)a11 = 259;
  if( PnpShutdownEvent.Header.SignalState
    && !_InterlockedCompareExchange64((volatile signed __int64 *)PnpDeviceActionThread, 0i64, 0i64) )
  {
    return 3221225865i64;
  }
  if( Object )
    v15 = *(_QWORD *)(*((_QWORD *)Object + 39) + 40i64);
  v19 = *(unsigned __int16 *)(v15 + 40) + 194;
  CriticalMemory = PnpAllocateCriticalMemory(a2 != 0 ? 3 : 0, PagedPool, v19, 0x4B706E50ui64);
  v21 = (__int64)CriticalMemory;
  if( !CriticalMemory )
    return 3221225626i64;
  memset((INT64)CriticalMemory, 0i64);
  PnpInitializeTargetDeviceRemoveEvent((void *)v21, v19, Object, a2, a3, a4, a5, a6, a7, a8, a11, a12, a13);
  *(_QWORD *)(v21 + 32) = a9;
  *(_QWORD *)(v21 + 40) = a10;
  if( a14 )
  {
    *(_QWORD *)a14 = v21;
    ++*(_DWORD *)(v21 + 64);
  }
  return PnpInsertEventInQueue(v21);
}

Referenced by:

IopQueueDeviceResetEvent
IopRetryDeviceRemovalForReset
PiDevCfgProcessDeviceCallback
PnpQueueQueryAndRemoveEvent
PnpRequestDeviceRemoval