VfBuildMdlFromScatterGatherList

INT64 __fastcall VfBuildMdlFromScatterGatherList(
        _DMA_ADAPTER *DmaAdapter,
        _SCATTER_GATHER_LIST *ScatterGather,
        _MDL *OriginalMdl,
        _MDL **TargetMdl){
  _SCATTER_GATHER_LIST *v4; 
  _LIST_ENTRY *v8; 
  LIST_ENTRY *AdapterInformationInternal; 
  UINT64 v10; 
  _LIST_ENTRY **p_Blink; 
  UINT64 *v12; 
  _LIST_ENTRY *v13; 
  unsigned __int8 v14; 
  unsigned __int64 v15; 
  _LIST_ENTRY **v16; 
  __int64(__fastcall *v17)(_DMA_ADAPTER *, _SCATTER_GATHER_LIST *, _MDL *, _MDL **); 
  int v18; 
  unsigned int v19; 
  _LIST_ENTRY *Blink; 
  PMDL Mdl; 
  _MDL *v22; 
  v4 = ScatterGather;
  LOBYTE(ScatterGather) = 1;
  v8 = 0i64;
  AdapterInformationInternal = ViGetAdapterInformationInternal(DmaAdapter, (INT64)ScatterGather);
  if( AdapterInformationInternal )
  {
    if( v4->Reserved != -559026163i64 )
      goto LABEL_14;
    p_Blink = &AdapterInformationInternal[3].Blink;
    if( *p_Blink != (_LIST_ENTRY *)p_Blink )
    {
      v12 = (UINT64 *)&AdapterInformationInternal[4].Blink;
      KeAcquireSpinLockRaiseToDpc((UINT64 *)&AdapterInformationInternal[4].Blink, v10);
      v13 = *p_Blink;
      v15 = v14;
      while( 1 )
      {
        v16 = &v13[-5].Blink;
        if( p_Blink == v16 + 9 )
          break;
        if( v16[8] == (_LIST_ENTRY *)v4 )
        {
          v8 = v16[12];
          break;
        }
        v13 = v16[9];
      }
      KxReleaseSpinLock(v12);
      __writecr8(v15);
    }
  }
  if( v4->Reserved == -559026163i64 && v8 )
    v4->Reserved = (unsigned __int64)v8[3].Flink;
LABEL_14:
  LODWORD(v17) = ViGetRealDmaOperation(DmaAdapter, 0x78ui64);
  v18 = v17(DmaAdapter, v4, OriginalMdl, TargetMdl);
  v19 = v18;
  if( v8 )
  {
    v8[3].Flink = (_LIST_ENTRY *)v4->Reserved;
    v4->Reserved = -559026163i64;
  }
  if( v18 >= 0 && *TargetMdl == OriginalMdl && v8 )
  {
    if( v8[2].Blink )
    {
      return(unsigned int)-1073741709;
    }
    else
    {
      Blink = v8[3].Blink;
      Mdl = IoAllocateMdl(0i64, (ULONG)Blink[2].Blink, 0, 0, 0i64);
      v22 = Mdl;
      if( Mdl )
      {
        v8[2].Blink = (_LIST_ENTRY *)Mdl;
        memmove((UINT8 *)&Mdl[1], (UINT8 *)&Blink[3], 8 * ((unsigned __int64)LODWORD(Blink[2].Blink) >> 12));
        v22->ByteOffset += OriginalMdl->ByteOffset;
        v22->ByteCount -= v22->ByteOffset;
        v22->MdlFlags |= 2u;
        *TargetMdl = v22;
      }
      else
      {
        return(unsigned int)-1073741670;
      }
    }
  }
  return v19;
}

Referenced by:

No references.