MiResizeAweBitMap

INT64 __fastcall MiResizeAweBitMap(INT64 a1){
  _ETHREAD *CurrentThread; 
  ULONG_PTR v3; 
  _RTL_BITMAP_EX v4; 
  __int128 v5; 
  __int128 v6; 
  __int128 v7; 
  INT64 result; 
  __int128 *v9; 
  _RTL_BITMAP_EX *p_Destination; 
  _RTL_BITMAP_EX v11; 
  INT64 v12[2]; 
  _RTL_BITMAP_EX Destination; 
  __int128 v14; 
  __int128 v15; 
  __int128 v16; 
  CurrentThread = (_ETHREAD *)KeGetCurrentThread();
  if( (*(_DWORD *)a1 & 1) != 0 )
    v3 = *((_QWORD *)CurrentThread + 23);
  else
    v3 = 0i64;
  v4 = *(_RTL_BITMAP_EX *)(a1 + 16);
  *(_OWORD *)v12 = *(_OWORD *)a1;
  v5 = *(_OWORD *)(a1 + 32);
  Destination = v4;
  v6 = *(_OWORD *)(a1 + 48);
  v14 = v5;
  v7 = *(_OWORD *)(a1 + 64);
  v15 = v6;
  v16 = v7;
  result = MiCreateAweInfoBitMap((INT64)v12);
  if( (int)result >= 0 )
  {
    v9 = (__int128 *)(a1 + 16);
    if( v3 )
    {
      LOCK_ADDRESS_SPACE((__int64)CurrentThread, v3);
      if( (*(_DWORD *)(v3 + 1124) & 0x20) != 0 )
      {
        UNLOCK_ADDRESS_SPACE((__int64)CurrentThread, v3);
        MiDeleteAweBitMap(v3, &Destination);
        return 3221225738i64;
      }
    }
    MiLockAwePagesExclusive(a1, (INT64)CurrentThread);
    if( Destination.SizeOfBitMap > *(_QWORD *)v9 )
    {
      RtlCopyBitMapEx((_RTL_BITMAP_EX *)(a1 + 16), &Destination, 0i64);
      v11 = (_RTL_BITMAP_EX)*v9;
      *v9 = (__int128)Destination;
      MiUnlockAwePagesExclusive(a1, (INT64)CurrentThread);
      if( v3 )
        UNLOCK_ADDRESS_SPACE((__int64)CurrentThread, v3);
      if( !v11.Buffer )
        return 0i64;
      p_Destination = &v11;
    }
    else
    {
      MiUnlockAwePagesExclusive(a1, (INT64)CurrentThread);
      if( v3 )
        UNLOCK_ADDRESS_SPACE((__int64)CurrentThread, v3);
      p_Destination = &Destination;
    }
    MiDeleteAweBitMap(v3, p_Destination);
    return 0i64;
  }
  return result;
}

Referenced by:

MiAllocateUserPhysicalPages