IopEjectDevice

VOID __stdcall IopEjectDevice(_DEVICE_OBJECT *DeviceObject, _PENDING_RELATIONS_LIST_ENTRY *PendingEntry){
  DOCK_INTERFACE *DockInterface; 
  _BYTE *v5; 
  VOID *v6; 
  INT64 v7; 
  VOID **Irp; 
  _IRP *v9; 
  _IO_STACK_LOCATION *CurrentStackLocation; 
  _ETHREAD *CurrentThread; 
  _IO_STACK_LOCATION *v12; 

  DockInterface = PendingEntry->DockInterface;
  if( PendingEntry->LightestSleepState == PowerSystemWorking )
  {
    if( DockInterface )
    {
      DockInterface->ProfileDepartureSetMode(DockInterface->Context, PDS_UPDATE_ON_INTERFACE);
      PendingEntry->DockInterface->ProfileDepartureUpdate(PendingEntry->DockInterface->Context);
      if( PendingEntry->DisplaySafeRemovalDialog )
        PendingEntry->DisplaySafeRemovalDialog = 0;
    }
    LODWORD(v5) = IoGetAttachedDeviceReferenceWithTag(DeviceObject, 0x69706E50u);
    v6 = v5;
    LOBYTE(v7) = v5[76];
    Irp = IoAllocateIrp(v7, 0);
    v9 = (_IRP *)Irp;
    if( Irp )
    {
      IovUtilWatermarkIrp((_IRP *)Irp, 1ui64);
      CurrentStackLocation = v9->Tail.CurrentStackLocation;
      v9->IoStatus.Information = 0i64;
      --CurrentStackLocation;
      v9->IoStatus.Status = -1073741637;
      memset(CurrentStackLocation, 0i64, sizeof(_IO_STACK_LOCATION));
      *(_WORD *)&CurrentStackLocation->MajorFunction = 4379;
      CurrentThread = (_ETHREAD *)KeGetCurrentThread();
      v9->UserIosb = 0i64;
      v9->UserEvent = 0i64;
      v9->Tail.Thread = CurrentThread;
      v9->RequestorMode = 0;
      PendingEntry->Lock = IRPLOCK_CANCELABLE;
      PendingEntry->EjectIrp = v9;
      PnpQueuePendingEject(&PendingEntry->Link);
      v12 = v9->Tail.CurrentStackLocation;
      v12[-1].CompletionRoutine = (int(__fastcall *)(_DEVICE_OBJECT *, _IRP *, void *))IopDeviceEjectComplete;
      v12[-1].Context = PendingEntry;
      v12[-1].Control = -32;
      IofCallDriver((UINT64)v6, (UINT64)v9);
    }
    else
    {
      PendingEntry->EjectIrp = 0i64;
      PendingEntry->Link.Blink = &PendingEntry->Link;
      PendingEntry->Link.Flink = &PendingEntry->Link;
      PnpQueuePendingEject(&PendingEntry->Link);
      PendingEntry->WorkItem.List.Flink = 0i64;
      PendingEntry->WorkItem.WorkerRoutine = (void(__fastcall *)(void *))PnpProcessCompletedEject;
      PendingEntry->WorkItem.Parameter = PendingEntry;
      ExQueueWorkItem(&PendingEntry->WorkItem, DelayedWorkQueue);
    }
    ObfDereferenceObjectWithTag(v6, 0x69706E50ui64);
  }
  else
  {
    if( DockInterface )
      DockInterface->ProfileDepartureSetMode(DockInterface->Context, PDS_UPDATE_ON_EJECT);
    PendingEntry->EjectIrp = 0i64;
    PendingEntry->Link.Blink = &PendingEntry->Link;
    PendingEntry->Link.Flink = &PendingEntry->Link;
    PnpQueuePendingEject(&PendingEntry->Link);
    PendingEntry->WorkItem.List.Flink = 0i64;
    PendingEntry->WorkItem.WorkerRoutine = (void(__fastcall *)(void *))PnpProcessCompletedEject;
    PendingEntry->WorkItem.Parameter = PendingEntry;
    ExQueueWorkItem(&PendingEntry->WorkItem, DelayedWorkQueue);
  }
}

Referenced by:

PnpProcessQueryRemoveAndEject