PiProcessCanceledRemoveForReset

NTSTATUS __stdcall PiProcessCanceledRemoveForReset(INT64 a1, INT64 a2, UINT64 **a3, INT64 *a4){
  NTSTATUS v4; 
  void *v5; 
  UINT64 v9; 
  _DWORD *DeviceNode; 
  _DEVICE_OBJECT *v11; 
  _DWORD *v12; 
  UINT64 v13; 
  _DEVICE_OBJECT *v14; 
  _DWORD *v15; 
  _DEVICE_OBJECT *DeviceObject[2]; 
  _DEVICE_RELATION_LEVEL RelationLevel; 
  _RELATION_LIST_MARKER Marker; 

  v4 = 0;
  v5 = (void *)(int)a1;
  DeviceObject[0] = 0i64;
  RelationLevel = RELATION_LEVEL_REMOVE_EJECT;
  Marker = (_RELATION_LIST_MARKER)1i64;
  while( IopEnumerateRelations((_RELATION_LIST *)a3, &Marker, DeviceObject, 0i64, 0i64) )
  {
    if( DeviceObject[0] )
      DeviceNode = DeviceObject[0]->DeviceObjectExtension->DeviceNode;
    else
      DeviceNode = 0i64;
    if( DeviceNode )
      DeviceNode[176] &= ~2u;
  }
  if( *(_DWORD *)*a3 == 1 )
  {
    v11 = *(_DEVICE_OBJECT **)(a2 + 152);
    if( v11 )
      v12 = v11->DeviceObjectExtension->DeviceNode;
    else
      v12 = 0i64;
    if( v12[75] == 788 )
      KeBugCheckEx(0xCAu, (PVOID)0xE, v5, (PVOID)*(int *)a4, a3);
    v11->Flags |= 0x4000000u;
    IopQueryDeviceState(v11, 0i64, v9);
  }
  else if( (*(_BYTE *)(*(_QWORD *)(a2 + 40) + 216i64) & 1) != 0 && *(_DWORD *)a4 == 5
         || (*(_DWORD *)(*(_QWORD *)(a2 + 40) + 216i64) & 2) != 0 )
  {
    Marker = (_RELATION_LIST_MARKER)1i64;
    while( IopEnumerateRelations((_RELATION_LIST *)a3, &Marker, DeviceObject, &RelationLevel, 0i64) )
    {
      v14 = DeviceObject[0];
      if( DeviceObject[0] )
        v15 = DeviceObject[0]->DeviceObjectExtension->DeviceNode;
      else
        v15 = 0i64;
      if( RelationLevel != RELATION_LEVEL_DEPENDENT && v15[75] != 788 )
      {
        DeviceObject[0]->Flags |= 0x4000000u;
        IopQueryDeviceState(v14, 0i64, v13);
      }
    }
  }
  else
  {
    return -2147483608;
  }
  return v4;
}

Referenced by:

PnpProcessQueryRemoveAndEject