HvpAllocateLogBuffers

INT64 __fastcall HvpAllocateLogBuffers(PVOID **a1, _DWORD *a2, UINT64 a3){
  unsigned int v4; 
  PVOID *v6; 
  __int64 v7; 
  __int64 v8; 
  char v9; 
  void *PoolWithTag; 
  PVOID *v11; 
  unsigned int v12; 
  PVOID *v14; 
  __int64 v15; 
  unsigned int v16; 
  __int64 v17; 
  PVOID *v18; 
  unsigned int v19; 
  __int64 v20; 
  unsigned int v21; 
  unsigned int v22; 
  bool v23; 
  VOID *v24; 
  PVOID *v25; 
  unsigned int NumberOfBytes; 
  v4 = a3;
  v6 = 0i64;
  v7 = 0i64;
  v8 = 0i64;
  v9 = 0;
  PoolWithTag = ExAllocatePoolWithTag(PagedPoolCacheAligned, (unsigned int)a3, 0x6F494D43ui64);
  if( PoolWithTag )
  {
    v8 = 1i64;
    v11 = (PVOID *)ExAllocatePoolWithTag(PagedPool, 0x18ui64, 0x6F494D43ui64);
    v6 = v11;
    if( v11 )
    {
      *(_DWORD *)v11 = 0;
      v11[1] = PoolWithTag;
      *((_DWORD *)v11 + 4) = v4;
      *a1 = v11;
      *a2 = 1;
LABEL_4:
      v6 = 0i64;
      v12 = 0;
      goto LABEL_5;
    }
    ExFreePoolWithTag(PoolWithTag, 0);
  }
LABEL_8:
  if( !v9 )
    goto LABEL_39;
  if( v6 )
  {
    if( (_DWORD)v8 )
    {
      v14 = v6 + 1;
      v15 = (unsigned int)v8;
      do
      {
        if( *v14 )
        {
          ExFreePoolWithTag(*v14, 0);
          *v14 = 0i64;
        }
        v14 += 3;
        --v15;
      }
      while( v15 );
    }
    ExFreePoolWithTag(v6, 0);
    v6 = 0i64;
  }
  v7 = (unsigned int)(v7 + 1);
  if( (_DWORD)v7 != 9 )
  {
LABEL_39:
    v16 = *((_DWORD *)LogEntryChunkSizes + v7) << 12;
    NumberOfBytes = v16;
    v17 = v4 / v16 + 1;
    if( !(v4 % v16) )
      v17 = v4 / v16;
    v8 = (unsigned int)v17;
    v18 = (PVOID *)ExAllocatePoolWithTag(PagedPool, 24 * v17, 0x6F494D43ui64);
    v6 = v18;
    if( v18 )
    {
      memset((INT64)v18, 0i64);
      v19 = v4;
      v20 = 0i64;
      while( (unsigned int)v20 < (unsigned int)v8 )
      {
        LODWORD(v6[3 * v20]) = 0;
        v21 = v19 - v16;
        v22 = 0;
        v23 = v19 < NumberOfBytes;
        if( v19 >= NumberOfBytes )
          v19 = NumberOfBytes;
        if( !v23 )
          v22 = v21;
        LODWORD(v6[3 * v20 + 2]) = v19;
        v24 = ExAllocatePoolWithTag(PagedPoolCacheAligned, v19, 0x6F494D43ui64);
        v6[3 * v20 + 1] = v24;
        if( !v24 )
        {
          v9 = 1;
          goto LABEL_8;
        }
        v19 = v22;
        v20 = (unsigned int)(v20 + 1);
        v16 = NumberOfBytes;
      }
      *a1 = v6;
      *a2 = v8;
      goto LABEL_4;
    }
  }
  v12 = -1073741801;
LABEL_5:
  if( v6 )
  {
    if( (_DWORD)v8 )
    {
      v25 = v6 + 1;
      do
      {
        if( *v25 )
        {
          ExFreePoolWithTag(*v25, 0);
          *v25 = 0i64;
        }
        v25 += 3;
        --v8;
      }
      while( v8 );
    }
    ExFreePoolWithTag(v6, 0);
  }
  return v12;
}

Referenced by:

HvpGenerateLogEntry