ViSpecialAllocateCommonBuffer

INT8 *__fastcall ViSpecialAllocateCommonBuffer(
        VOID *a1,
        INT64 *AllocateCommonBuffer,
        _DMA_ADAPTER *a3,
        UINT64 a4,
        _LARGE_INTEGER *a5,
        UINT8 a6,
        _ADAPTER_INFORMATION *AdapterInformation,
        VOID *CallingAddress,
        UINT64 Length,
        _LARGE_INTEGER *LogicalAddress,
        INT64 CacheEnabled){
  unsigned int v12; 
  __int64 v15; 
  VOID **PoolWithTag; 
  __int64 v17; 
  int v19; 
  int v20; 
  unsigned int v21; 
  __int64 v22; 
  INT8 *v23; 
  VOID *v24; 

  v12 = *((_DWORD *)AllocateCommonBuffer + 43) - *((_DWORD *)AllocateCommonBuffer + 44);
  v24 = 0i64;
  v15 = (unsigned int)a4;
  if( v12 >= 0x20 || (unsigned int)a4 > 0xFFFFDFFF )
    return 0i64;
  PoolWithTag = ExAllocatePoolWithTag(0x200ui64, 0x40ui64, 1449943368i64);
  if( !PoolWithTag )
  {
    VfUtilDbgPrint((INT8 *)"Couldn't track common buffer allocation\n");
    return 0i64;
  }
  if( (unsigned __int64)(v15 + 8) <= 0x1000 )
  {
    v19 = 4096;
LABEL_10:
    v20 = v19 - v15;
    goto LABEL_12;
  }
  if( (v15 & 0xFFF) != 0 )
  {
    v19 = ((v15 + 8) & 0xFFFFF000) + ((((_WORD)v15 + 8) & 0xFFF) != 0i64 ? 0x1000 : 0);
    goto LABEL_10;
  }
  v20 = 4096;
LABEL_12:
  LOBYTE(v17) = a6;
  v21 = v20 + v15 + 4096;
  v22 = ((__int64(__fastcall *)(INT64, _QWORD, VOID **, __int64))a1)(AllocateCommonBuffer[2], v21, &v24, v17);
  if( !v22 )
  {
    ExFreePoolWithTag(PoolWithTag, 0);
    return 0i64;
  }
  *((_WORD *)PoolWithTag + 1) = v20;
  v23 = (INT8 *)(v22 + 4096);
  *(_WORD *)PoolWithTag = 4096;
  PoolWithTag[3] = (VOID *)(v22 + 4096);
  *((_DWORD *)PoolWithTag + 2) = v15;
  *((_DWORD *)PoolWithTag + 1) = v21;
  PoolWithTag[2] = (VOID *)v22;
  PoolWithTag[4] = v24;
  PoolWithTag[5] = a3;
  ViInitializePadding((VOID *)v22, v21, (VOID *)(v22 + 4096), (unsigned int)v15);
  a5->QuadPart = (LONGLONG)v24 + 4096;
  ExInterlockedInsertHeadList(
    (PLIST_ENTRY)AllocateCommonBuffer + 5,
    (PLIST_ENTRY)PoolWithTag + 3,
    (PKSPIN_LOCK)AllocateCommonBuffer + 12);
  _InterlockedIncrement((volatile signed __int32 *)AllocateCommonBuffer + 43);
  return v23;
}

Referenced by:

No references.