VfBuildScatterGatherList

NTSTATUS __stdcall VfBuildScatterGatherList(
        _DMA_ADAPTER *DmaAdapter,
        _DEVICE_OBJECT *DeviceObject,
        _MDL *Mdl,
        VOID *CurrentVa,
        UINT64 Length,
        VOID *ExecutionRoutine,
        _DEVICE_OBJECT *a7,
        _IRP *a8,
        _SCATTER_GATHER_LIST *a9,
        VOID *a10,
        VOID *Context,
        UINT8 WriteToDevice,
        VOID *ScatterGatherBuffer,
        UINT64 ScatterGatherLength){
  _DEVICE_OBJECT *v14; 
  _MDL *v15; 
  _DEVICE_OBJECT *v17; 
  _MAP_REGISTER_FILE *v18; 
  VOID *RealDmaOperation; 
  INT64 v20; 
  _LIST_ENTRY *AdapterInformationInternal; 
  ULONG_PTR v23; 
  ULONG_PTR v24; 
  _QWORD *v25; 
  _DEVICE_OBJECT *v26; 
  __int64 v27; 
  VOID *v28; 
  unsigned __int64 v29; 
  _QWORD *v30; 
  _MAP_REGISTER_FILE *MapRegisterFile; 
  UINT8 v32; 
  _MAP_REGISTER_FILE *v33; 
  int v34; 
  UINT64 v35; 
  _DEVICE_OBJECT *NextDevice; 
  int v37; 
  NTSTATUS v38; 
  UINT64 *p_Blink; 
  unsigned __int64 v40; 
  __int64 v41; 
  _DEVICE_OBJECT **v42; 
  UINT8 Param3; 
  UINT64 v44; 
  VOID *MapRegisterBase; 
  __int64(__fastcall *v46)(_DMA_ADAPTER *, _DEVICE_OBJECT *, _MDL *, _DEVICE_OBJECT *, _DWORD, VOID *, _DEVICE_OBJECT *, _BYTE, _SCATTER_GATHER_LIST *, _DWORD); 
  _MDL *Mdla; 
  VOID *CurrentVaa; 

  CurrentVaa = CurrentVa;
  Mdla = Mdl;
  v14 = (_DEVICE_OBJECT *)CurrentVa;
  v15 = Mdl;
  v17 = 0i64;
  v18 = 0i64;
  RealDmaOperation = ViGetRealDmaOperation((ULONG_PTR)DmaAdapter, 0x70ui64);
  LOBYTE(v20) = 1;
  v46 = (__int64(__fastcall *)(_DMA_ADAPTER *, _DEVICE_OBJECT *, _MDL *, _DEVICE_OBJECT *, _DWORD, VOID *, _DEVICE_OBJECT *, _BYTE, _SCATTER_GATHER_LIST *, _DWORD))RealDmaOperation;
  AdapterInformationInternal = ViGetAdapterInformationInternal(DmaAdapter, v20);
  if( !AdapterInformationInternal )
  {
    v26 = a7;
LABEL_14:
    v28 = ExecutionRoutine;
    goto LABEL_15;
  }
  VF_ASSERT_IRQL(2u);
  if( !v15 )
    return -1073741811;
  _InterlockedIncrement((volatile signed __int32 *)&AdapterInformationInternal[10].Flink + 1);
  _InterlockedIncrement((volatile signed __int32 *)&AdapterInformationInternal[10].Blink);
  v15 = Mdla;
  VERIFY_BUFFER_LOCKED(Mdla);
  if( LODWORD(AdapterInformationInternal[12].Flink) == 3 )
  {
    v23 = ViCheckMdlLength(v15, 0i64, (unsigned int)Length);
    if( v23 )
    {
      v24 = v23;
      ViHalPreprocessOptions(
        &qword_140C12D18,
        (PSTR)"The provided MDL is not sufficient to satisfy the requested length",
        0x24ui64,
        v23,
        0i64,
        0i64,
        v44);
      VfReportIssueWithOptions(0xE6ui64, 0x24u, v24, 0, 0, &qword_140C12D18);
    }
  }
  v25 = ExAllocateFromNPagedLookasideList(&ViHalWaitBlockLookaside);
  v26 = a7;
  v17 = (_DEVICE_OBJECT *)v25;
  v14 = (_DEVICE_OBJECT *)CurrentVaa;
  if( !v25 )
    goto LABEL_14;
  v27 = (unsigned int)Length;
  v25[8] = 0i64;
  v28 = ExecutionRoutine;
  *v25 = v26;
  v29 = ((unsigned __int64)((unsigned __int16)v14 & 0xFFF) + v27 + 4095) >> 12;
  *((_DWORD *)v25 + 12) = v29;
  v25[1] = v28;
  v25[7] = AdapterInformationInternal;
  v30 = v25 + 9;
  v30[1] = v30;
  *v30 = v30;
  MapRegisterFile = ViAllocateMapRegisterFile((_ADAPTER_INFORMATION *)AdapterInformationInternal, (unsigned int)v29);
  MapRegisterBase = MapRegisterFile;
  v18 = MapRegisterFile;
  if( !MapRegisterFile )
  {
LABEL_9:
    ExFreeToNPagedLookasideList(&ViHalWaitBlockLookaside, v17);
    v17 = 0i64;
    v18 = 0i64;
    goto LABEL_15;
  }
  v32 = (unsigned __int8)a8;
  *((_BYTE *)MapRegisterFile + 25) = 1;
  Param3 = v32;
  v17->NextDevice = (_DEVICE_OBJECT *)&v17->gap4D[27];
  v33 = MapRegisterFile;
  v34 = Length;
  v35 = (unsigned int)Length;
  *(_QWORD *)&v17->gap4D[19] = v18;
  v17->AttachedDevice = v14;
  LODWORD(v17->CurrentIrp) = v34;
  if( !(unsigned int)ViMapDoubleBuffer(v33, v15, v14, v35, Param3) )
  {
    ViFreeMapRegisterFile((_ADAPTER_INFORMATION *)AdapterInformationInternal, v18);
    goto LABEL_9;
  }
  NextDevice = v17->NextDevice;
  v26 = v17;
  v28 = ViScatterGatherCallback;
  *(_OWORD *)&NextDevice->Type = *(_OWORD *)&v15->Next;
  *(_OWORD *)&NextDevice->NextDevice = *(_OWORD *)&v15->Process;
  *(_OWORD *)&NextDevice->CurrentIrp = *(_OWORD *)&v15->StartVa;
  ViSwap(&MapRegisterBase, &Mdla, &CurrentVaa);
  v14 = (_DEVICE_OBJECT *)CurrentVaa;
  v15 = Mdla;
LABEL_15:
  v37 = v46(DmaAdapter, DeviceObject, v15, v14, Length, v28, v26, (_BYTE)a8, a9, (_DWORD)a10);
  v38 = v37;
  if( AdapterInformationInternal && v37 < 0 )
  {
    DECREMENT_SCATTER_GATHER_LISTS((__int64)AdapterInformationInternal);
    if( v18 )
      ViFreeMapRegisterFile((_ADAPTER_INFORMATION *)AdapterInformationInternal, v18);
    if( v17 )
    {
      p_Blink = (UINT64 *)&AdapterInformationInternal[4].Blink;
      v40 = (unsigned __int8)KeAcquireSpinLockRaiseToDpc((UINT64 *)&AdapterInformationInternal[4].Blink);
      v41 = *(_QWORD *)&v17->DeviceType;
      v42 = *(_DEVICE_OBJECT ***)&v17->gap4D[3];
      if( *(_DEVICE_OBJECT **)(v41 + 8) != (_DEVICE_OBJECT *)&v17->DeviceType
        || *v42 != (_DEVICE_OBJECT *)&v17->DeviceType )
      {
        __fastfail(3u);
      }
      *v42 = (_DEVICE_OBJECT *)v41;
      *(_QWORD *)(v41 + 8) = v42;
      KxReleaseSpinLock(p_Blink);
      __writecr8(v40);
      ExFreeToNPagedLookasideList(&ViHalWaitBlockLookaside, v17);
    }
  }
  return v38;
}

Referenced by:

No references.