PipSendTargetDeviceQueryRemoveNotification

INT64 __fastcall PipSendTargetDeviceQueryRemoveNotification(INT64 a1, INT64 a2, UNICODE_STRING *a3, INT64 a4){
  unsigned int v5; 
  unsigned int v8; 
  int v9; 
  __int64 *i; 
  __int64 v11; 
  __int64 v12; 
  char *v14; 
  void *VetoingDriver[7]; 
  VetoingDriver[0] = 0i64;
  v5 = (unsigned int)a3;
  v8 = 0;
  v9 = 0;
  if( !(_DWORD)a3 )
    return v8;
  for( i = (__int64 *)a2; ; ++i )
  {
    v11 = *i;
    if( *i )
      v12 = *(_QWORD *)(*(_QWORD *)(v11 + 312) + 40i64);
    else
      v12 = 0i64;
    if( v12 )
    {
      a3 = (UNICODE_STRING *)*(unsigned int *)(v12 + 300);
      if( (((_DWORD)a3 - 769) & 0xFFFFFFEE) == 0 && (_DWORD)a3 != 785 )
        goto LABEL_9;
    }
    if( *(_BYTE *)(a1 + 72) )
      break;
    v8 = PnpNotifyTargetDeviceChange(
           &GUID_TARGET_DEVICE_QUERY_REMOVE,
           (DEVICE_OBJECT *)v11,
           0i64,
           (DRIVER_OBJECT **)VetoingDriver);
    if( (v8 & 0x80000000) != 0 )
      goto LABEL_15;
LABEL_9:
    if( ++v9 >= v5 )
      return v8;
  }
  v8 = -1073741536;
LABEL_15:
  v14 = (char *)VetoingDriver[0];
  *(_DWORD *)a4 = 7;
  if( v14 )
  {
    RtlCopyUnicodeString((UNICODE_STRING *)(a4 + 8), (UNICODE_STRING *)(v14 + 56), a3);
  }
  else
  {
    memset(*(_QWORD *)(a4 + 16), 0i64);
    *(_WORD *)(a4 + 8) = 0;
  }
  if( v9 )
    PiSendTargetDeviceRemoveCanceledNotification(a2, (unsigned int)(v9 - 1));
  return v8;
}

Referenced by:

PipProcessQueryRemovalInKernelMode