PnpQueryRemoveLockedDeviceNode

__int64 __fastcall PnpQueryRemoveLockedDeviceNode(__int64 a1, int a2, _DWORD *a3, struct _UNICODE_STRING *a4){
  DEVICE_OBJECT *v8; 
  NTSTATUS v9; 
  _PNP_DEVNODE_STATE *v10; 
  unsigned int v11; 
  __int64 result; 
  UNICODE_STRING *v13; 
  DRIVER_OBJECT *FailingDriver; 
  switch( *(_DWORD *)(a1 + 300) )
  {
    case 0x303:
    case 0x304:
    case 0x306:
    case 0x307:
    case 0x308:
      PipSetDevNodeUserFlags(a1, 512);
      v8 = *(DEVICE_OBJECT **)(a1 + 32);
      FailingDriver = 0i64;
      v9 = PiIrpQueryRemoveDevice(v8, &FailingDriver);
      v11 = v9;
      if( v9 < 0 )
      {
        if( a2 == 54 && v9 == -1073740537 )
        {
          PipSetDevNodeState((_DEVICE_NODE *)a1, DeviceNodeQueryRemoved, v10);
          *(_DWORD *)(a1 + 704) |= 2u;
        }
        else
        {
          IopRemoveDevice(v8, 3ui64);
          *a3 = 6;
          RtlCopyUnicodeString(a4, (UNICODE_STRING *)(a1 + 40), v13);
          if( FailingDriver && a4->MaximumLength - a4->Length >= FailingDriver->DriverName.Length + 4 )
            RtlAppendUnicodeStringToString(a4, &FailingDriver->DriverName);
        }
      }
      else
      {
        PipSetDevNodeState((_DEVICE_NODE *)a1, DeviceNodeQueryRemoved, v10);
        if( a2 == 54 && (*(_DWORD *)(a1 + 704) & 2) != 0 )
          v11 = -1073740537;
      }
      PipClearDevNodeUserFlags(a1, 512);
      result = v11;
      break;
    default:
      result = 0i64;
      break;
  }
  return result;
}

Referenced by:

PnpDeleteLockedDeviceNode