HalpAllocateMapRegisters

__int64 __fastcall HalpAllocateMapRegisters(
        PDMA_ADAPTER DmaAdapter,
        ULONG NumberOfMapRegisters,
        __int64 a3,
        __int64 a4){
  _QWORD *v4; 
  _DMA_OPERATIONS *DmaOperations; 
  unsigned int v7; 
  ULONG v10; 
  unsigned int v11; 
  _QWORD *v12; 
  __int64 MapRegisters; 
  unsigned int v14; 
  __int64 v15; 
  __int64 v16; 
  __int64 v17; 
  __int64 v18; 
  v4 = (_QWORD *)a4;
  DmaOperations = DmaAdapter[9].DmaOperations;
  v7 = a3;
  if( LODWORD(DmaAdapter[23].DmaOperations) != -1 )
    return 3221225488i64;
  if( (_DWORD)a3 * NumberOfMapRegisters && LOBYTE(DmaAdapter[27].Version) )
  {
    if( (unsigned int)a3 * NumberOfMapRegisters > 0x800 )
      return 3221225626i64;
    v10 = *(_DWORD *)&DmaAdapter[14].Version;
    if( !v10 )
      return 3221225626i64;
    if( NumberOfMapRegisters > v10 )
      return 3221225485i64;
    v11 = 0;
    if( (_DWORD)a3 )
    {
      v12 = (_QWORD *)a4;
      do
      {
        MapRegisters = HalpDmaAllocateMapRegisters((__int64)DmaAdapter, NumberOfMapRegisters, a3, a4);
        *v12 = MapRegisters;
        if( !MapRegisters )
        {
          v14 = (NumberOfMapRegisters + 16) << 12;
          if( LOBYTE(DmaAdapter[27].Size) )
            HalpDmaGrowScatterMapBuffers((PHYSICAL_ADDRESS *)DmaOperations, v14);
          else
            HalpDmaGrowContiguousMapBuffers((__int64)DmaOperations, v14);
          v17 = HalpDmaAllocateMapRegisters((__int64)DmaAdapter, NumberOfMapRegisters, v15, v16);
          *v12 = v17;
          if( !v17 )
            break;
        }
        ++v11;
        v12 += 2;
      }
      while( v11 < v7 );
    }
    if( v11 != v7 )
    {
      while( v11 )
        IoFreeMapRegisters(DmaAdapter, (PVOID)v4[2 * --v11], NumberOfMapRegisters);
      return 3221225626i64;
    }
  }
  else if( (_DWORD)a3 )
  {
    v18 = (unsigned int)a3;
    do
    {
      *v4 = 0i64;
      v4 += 2;
      --v18;
    }
    while( v18 );
  }
  return 0i64;
}

Referenced by:

No references.