ViPendingCompleteAfterWait

VOID __stdcall ViPendingCompleteAfterWait(VOID *Context){
  _IOV_DATABASE_HEADER *v2; 
  char v3; 
  _IRP *v4; 
  __int64 v5; 
  _IO_STACK_LOCATION *CurrentStackLocation; 
  _ADAPTER_OBJECT *v7; 
  bool v8; 
  _IRP *v9; 
  _CCHAR v10; 
  int(__fastcall *CompletionRoutine)(_DEVICE_OBJECT *, _IRP *, void *); 
  UINT8 OldIrql; 

  if( *((_DWORD *)Context + 42) == 1 )
    KeWaitForSingleObject((UINT64)Context + 104, 0, 0, 0, 0i64);
  v2 = *(_IOV_DATABASE_HEADER **)Context;
  v3 = KeAcquireSpinLockRaiseToDpc((UINT64 *)(*(_QWORD *)Context + 8i64));
  v4 = *(_IRP **)v2;
  v5 = *((_QWORD *)v2 + 27);
  *((_BYTE *)v2 + 16) = v3;
  CurrentStackLocation = v4->Tail.CurrentStackLocation;
  v2[14] &= ~0x10u;
  if( !v5 || (v7 = *(_ADAPTER_OBJECT **)(v5 + 40)) == 0i64 )
    v7 = 0i64;
  v8 = v2[6]-- == 1;
  OldIrql = 0;
  if( v8 )
  {
    ViIrpDatabaseAcquireLockExclusive(&OldIrql);
    v9 = *(_IRP **)v2;
    (*((void(__fastcall **)(_IOV_DATABASE_HEADER *, _QWORD, __int64))v2 + 6))(v2, *(_QWORD *)v2, 1i64);
    *(_QWORD *)v2 = 0i64;
    VfUtilAddressRangeRemoveCheckEmpty(
      (_VF_ADDRESS_RANGE *)(ViIrpDatabaseAddressRanges + 16i64 * (unsigned __int8)(-125 * ((unsigned __int64)v9 >> 12))),
      (UINT8 *)v9);
    ViIrpDatabaseReleaseLockExclusive(OldIrql);
  }
  _InterlockedDecrement(v2 + 5);
  VfIrpDatabaseEntryReleaseLock(v2);
  CompletionRoutine = CurrentStackLocation[-1].CompletionRoutine;
  if( !CompletionRoutine
    || CompletionRoutine(*((_DEVICE_OBJECT **)Context + 1), v4, CurrentStackLocation[-1].Context) != -1073741802 )
  {
    LOBYTE(v10) = *((_BYTE *)Context + 172);
    IofCompleteRequest(v4, v10);
  }
  if( v7 )
    HalPutDmaAdapter(v7);
  ExFreePoolWithTag(Context, 0);
}

Referenced by:

ViPendingCompleteAtDPC
ViPendingWorkerThread