MiZeroWithSystemPtes

UINT64 __fastcall MiZeroWithSystemPtes(UINT64 a1, UINT64 a2, INT64 a3){
  INT64 PfnPageSizeIndex; 
  UINT64 v6; 
  UINT64 v7; 
  unsigned __int8 *v8; 
  UINT64 v10; 
  UINT64 *v11; 
  __int64 v12; 
  int ProtectionPfnCompatible; 
  __int64 v14; 
  UINT64 ValidPte; 
  UINT64 j; 
  UINT64 i; 
  UINT64 v18; 
  int result; 
  __int16 result_4; 
  int v21; 
  int v22; 
  __int64 v23; 
  __int64 v24; 
  if( (*(_QWORD *)(a3 + 40) & 0x1000000000i64) == 0 )
    goto LABEL_6;
  PfnPageSizeIndex = MiGetPfnPageSizeIndex(a3);
  if( (_DWORD)PfnPageSizeIndex == -1 )
    PfnPageSizeIndex = 3i64;
  if( (unsigned int)PfnPageSizeIndex < 3 )
    v6 = MiLargePageSizes[PfnPageSizeIndex];
  else
LABEL_6:
    v6 = 1i64;
  v7 = (a3 - (__int64)MmGetPfnDb()) / 48;
  if( a1 )
  {
    v10 = a2;
    v11 = (UINT64 *)a1;
    if( a2 >= v6 )
      v10 = v6;
    v18 = v10;
    v12 = (__int64)((a1 << 25) - ((_QWORD)MmGetPteBase() << 25)) >> 16;
    ProtectionPfnCompatible = MiMakeProtectionPfnCompatible(4ui64, (_MMPFN *)a3);
    v14 = 0i64;
    ValidPte = MiMakeValidPte(a1, v7, ProtectionPfnCompatible | 0xA0000000);
    for( i = 0i64; i < v6; ++i )
    {
      *v11++ = ValidPte;
      ++v14;
      ValidPte ^= (ValidPte ^ (ValidPte + 4096)) & 0xFFFFFFFFF000i64;
      if( v14 == a2 )
      {
        memset((INT64)&result, 0i64);
        MiZeroMemory((VOID *)v12, (__int64)((__int64)v11 - a1) >> 3 << 12);
        if( i + 1 == v6 )
        {
          v12 = 0i64;
          break;
        }
        for( j = 0i64; j < a2; ++j )
          *(_QWORD *)(a1 + 8 * j) = ZeroPte;
        v22 = 0;
        result = 0;
        result_4 = 0;
        v23 = 0i64;
        v24 = 0i64;
        v21 = 20;
        MiInsertTbFlushEntry((INT64)&result, v12, a2, 0i64);
        MiFlushTbList((__int64)&result);
        v14 = 0i64;
        v11 = (UINT64 *)a1;
      }
    }
    if( v12 )
      MiZeroMemory((VOID *)v12, (__int64)((__int64)v11 - a1) >> 3 << 12);
    return v18;
  }
  else
  {
    if( v6 )
    {
      v8 = (unsigned __int8 *)(a3 + 34);
      do
      {
        MiZeroPhysicalPage(v7++, 1ui64, (_MI_PFN_CACHE_ATTRIBUTE)(*v8 >> 6));
        v8 += 48;
        --v6;
      }
      while( v6 );
    }
    return 0i64;
  }
}

Referenced by:

MiZeroInParallelWorker