PnpSetCustomTargetEvent

NTSTATUS __stdcall PnpSetCustomTargetEvent(
        PDEVICE_OBJECT DeviceObject,
        PKEVENT SyncEvent,
        PULONG Result,
        PDEVICE_CHANGE_COMPLETE_CALLBACK Callback,
        PVOID Context,
        PTARGET_DEVICE_CUSTOM_NOTIFICATION NotificationStructure){
  __int64 v9; 
  unsigned int v10; 
  _DWORD *DeviceEventEntry; 
  UINT8 *v12; 
  UINT8 *v13; 
  if( SyncEvent )
    *Result = 259;
  if( PnpShutdownEvent.Header.SignalState )
    return -1073741431;
  if( DeviceObject )
    v9 = *(_QWORD *)(*((_QWORD *)DeviceObject + 39) + 40i64);
  else
    v9 = 0i64;
  v10 = NotificationStructure->Size + ((*(unsigned __int16 *)(v9 + 40) + 89) & 0xFFFFFFF8);
  DeviceEventEntry = PnpCreateDeviceEventEntry(v10 + 112);
  if( !DeviceEventEntry )
    return -1073741670;
  ObfReferenceObjectWithTag(DeviceObject, 0x56706E50u);
  *((_QWORD *)DeviceEventEntry + 4) = Callback;
  *((_QWORD *)DeviceEventEntry + 5) = Context;
  *((_QWORD *)DeviceEventEntry + 3) = SyncEvent;
  DeviceEventEntry[36] = 0;
  DeviceEventEntry[32] = 3;
  *((GUID *)DeviceEventEntry + 7) = GUID_PNP_CUSTOM_NOTIFICATION;
  *((_QWORD *)DeviceEventEntry + 17) = Result;
  DeviceEventEntry[37] = v10;
  *((_QWORD *)DeviceEventEntry + 19) = DeviceObject;
  v12 = *(UINT8 **)(v9 + 48);
  if( v12 )
    memmove((UINT8 *)DeviceEventEntry + 168, v12, *(unsigned __int16 *)(v9 + 40));
  v13 = (UINT8 *)DeviceEventEntry + v10 + 112 - (unsigned __int64)NotificationStructure->Size;
  *((_QWORD *)DeviceEventEntry + 20) = v13;
  memmove(v13, (UINT8 *)NotificationStructure, NotificationStructure->Size);
  return PnpInsertEventInQueue((__int64)DeviceEventEntry);
}

Referenced by:

IoReportTargetDeviceChange
IoReportTargetDeviceChangeAsynchronous
PnpReportTargetDeviceChangeAsyncWorker