HalPutScatterGatherList

VOID __stdcall HalPutScatterGatherList(
        PADAPTER_OBJECT DmaAdapter,
        PSCATTER_GATHER_LIST ScatterGather,
        BOOL WriteToDevice){
  unsigned int LibraryVersion; 
  unsigned __int64 Reserved; 
  PSCATTER_GATHER_LIST v7; 
  _HALP_DMA_TRANSLATION_ENTRY *v8; 
  INT64 v9; 
  INT64 v10; 
  unsigned int v11; 
  unsigned int v12; 
  INT64 v13; 
  unsigned int v14; 
  unsigned int v15; 
  unsigned int v16; 
  unsigned int v17; 
  INT64 v18; 
  unsigned __int8 v19; 
  _LARGE_INTEGER MaximumPhysicalAddress; 
  unsigned int ContiguousPiece; 
  __int64 v22; 
  INT64 v23; 
  NTSTATUS AdapterCacheAlignment; 
  __int64 v25; 
  unsigned __int64 v26; 
  __int64 v27; 
  _MDL *v28; 
  _MDL *Next; 
  UINT64 Length; 
  UINT64 WriteToDevicea; 
  _LARGE_INTEGER v32; 
  unsigned int v33; 
  _HALP_DMA_TRANSLATION_ENTRY *TranslationBase; 

  LibraryVersion = DmaAdapter->AdapterObject.LibraryVersion;
  if( LibraryVersion != 2 && LibraryVersion != 3 )
    LibraryVersion = -1;
  if( LibraryVersion != 2 )
  {
    HalPutScatterGatherListV3(DmaAdapter, ScatterGather, WriteToDevice);
    return;
  }
  Reserved = ScatterGather->Reserved;
  if( !Reserved )
  {
    v7 = ScatterGather;
LABEL_7:
    ExFreePoolWithTag(v7, 0);
    return;
  }
  if( Reserved == 1 )
    return;
  v8 = *(_HALP_DMA_TRANSLATION_ENTRY **)(Reserved + 24);
  v9 = *(_QWORD *)(Reserved + 32);
  v10 = *(_QWORD *)(Reserved + 8);
  v11 = *(_DWORD *)(Reserved + 40);
  TranslationBase = v8;
  v12 = *(_DWORD *)(v10 + 32) + *(_DWORD *)(v10 + 40) + *(_DWORD *)(v10 + 44) - v9;
  if( v11 )
  {
    while( !v12 )
    {
LABEL_36:
      v10 = *(_QWORD *)v10;
      if( v10 )
      {
        v9 = *(_QWORD *)(v10 + 32) + *(unsigned int *)(v10 + 44);
        v12 = *(_DWORD *)(v10 + 40);
        if( v11 )
          continue;
      }
      goto LABEL_38;
    }
    v13 = *(_QWORD *)v10;
    v14 = v11;
    if( v12 <= v11 )
      v14 = v12;
    v15 = v11;
    if( v13 )
      v15 = v14;
    v16 = v11 - v14;
    v17 = 0;
    LODWORD(Length) = v15;
    if( v13 )
      v17 = v16;
    v33 = v17;
    IoFlushAdapterBuffers((INT64)DmaAdapter, v10, (INT64)v8, v9, Length, WriteToDevice);
    v8 = TranslationBase;
    v18 = (v9 & 0xFFF)
        + (*(_QWORD *)(v10 + 8i64 * (unsigned int)((unsigned __int64)(v9 - *(_QWORD *)(v10 + 32)) >> 12) + 48) << 12);
    v19 = DmaAdapter->ScatterGather;
    MaximumPhysicalAddress = DmaAdapter->AdapterObject.MaximumPhysicalAddress;
    v32 = MaximumPhysicalAddress;
    while( 1 )
    {
      if( v19 )
      {
        LODWORD(WriteToDevicea) = v15;
        LOBYTE(Length) = WriteToDevice;
        ContiguousPiece = HalpDmaNextContiguousPiece(DmaAdapter, (_MDL *)v10, v8, (VOID *)v9, Length, WriteToDevicea);
        v8 = TranslationBase;
        MaximumPhysicalAddress = v32;
      }
      else
      {
        ContiguousPiece = v15;
      }
      v22 = ContiguousPiece;
      v15 -= ContiguousPiece;
      v23 = ContiguousPiece + v18;
      if( MaximumPhysicalAddress.QuadPart < (unsigned __int64)(v23 - 1) )
        goto LABEL_29;
      if( WriteToDevice || DmaAdapter->CacheCoherent )
        goto LABEL_34;
      AdapterCacheAlignment = HalpDmaGetAdapterCacheAlignment(DmaAdapter);
      v8 = TranslationBase;
      v25 = (unsigned int)(AdapterCacheAlignment - 1);
      if( (v25 & v18) != 0 || (v23 & v25) != 0 )
      {
LABEL_29:
        v26 = ((unsigned __int64)(v9 & 0xFFF) + v22 + 4095) >> 12;
        if( (_DWORD)v26 )
        {
          v27 = (unsigned int)v26;
          do
          {
            v8 = v8->Next;
            --v27;
          }
          while( v27 );
          TranslationBase = v8;
        }
      }
      MaximumPhysicalAddress = v32;
LABEL_34:
      v9 += v22;
      v18 = v23;
      if( !v15 )
      {
        v11 = v33;
        goto LABEL_36;
      }
    }
  }
LABEL_38:
  IoFreeMapRegisters(&DmaAdapter->AdapterObject.DmaHeader, *(PVOID *)(Reserved + 24), *(_DWORD *)(Reserved + 44));
  v28 = *(_MDL **)(Reserved + 16);
  if( v28 )
  {
    do
    {
      Next = v28->Next;
      if( (v28->MdlFlags & 1) != 0 )
        MmUnmapLockedPages(v28->MappedSystemVa, v28);
      IoFreeMdl(v28);
      v28 = Next;
    }
    while( Next );
  }
  if( (*(_DWORD *)Reserved & 1) == 0 )
  {
    v7 = (PSCATTER_GATHER_LIST)Reserved;
    goto LABEL_7;
  }
}

Referenced by:

No references.