PnpSetPowerVetoEvent

__int64 __fastcall PnpSetPowerVetoEvent(int a1, __int64 a2, __int64 a3, _QWORD *a4, int a5, const VOID **a6){
  __int64 v9; 
  int v10; 
  int v11; 
  VOID **DeviceEventEntry; 
  unsigned __int64 v13; 
  char *v14; 
  GUID v15; 

  if( *(&PnpReplaceEvent + 1665) )
    return 3221225865i64;
  v9 = *(_QWORD *)(a4[39] + 40i64);
  if( !v9 )
    return 3221225712i64;
  if( a6 )
    v10 = *(unsigned __int16 *)a6;
  else
    v10 = 0;
  v11 = v10 + *(unsigned __int16 *)(v9 + 40) + 84;
  DeviceEventEntry = PnpCreateDeviceEventEntry(v11 + 112);
  if( !DeviceEventEntry )
    return 3221225626i64;
  ObfReferenceObjectWithTag(a4, 0x56706E50ui64);
  *((_DWORD *)DeviceEventEntry + 40) = a5;
  DeviceEventEntry[3] = 0i64;
  *((_DWORD *)DeviceEventEntry + 37) = v11;
  DeviceEventEntry[19] = a4;
  DeviceEventEntry[17] = 0i64;
  memmove((char *)DeviceEventEntry + 164, *(const VOID **)(v9 + 48), *(unsigned __int16 *)(v9 + 40));
  v13 = (unsigned __int64)*(unsigned __int16 *)(v9 + 40) >> 1;
  *((_WORD *)DeviceEventEntry + v13 + 82) = 0;
  if( a6 )
  {
    v14 = (char *)DeviceEventEntry + 2 * v13;
    memmove(v14 + 166, a6[1], *(unsigned __int16 *)a6);
    *(_WORD *)&v14[2 * ((unsigned __int64)*(unsigned __int16 *)a6 >> 1) + 166] = 0;
  }
  if( a1 == 7 )
  {
    v15 = GUID_DEVICE_WARM_EJECT_VETOED;
  }
  else if( a1 == 3 )
  {
    v15 = GUID_DEVICE_HIBERNATE_VETOED;
  }
  else
  {
    v15 = GUID_DEVICE_STANDBY_VETOED;
  }
  *((_DWORD *)DeviceEventEntry + 32) = 6;
  *((GUID *)DeviceEventEntry + 7) = v15;
  return PnpInsertEventInQueue((__int64)DeviceEventEntry);
}

Referenced by:

IoNotifyPowerOperationVetoed
IopWarmEjectDevice