MiEncodeProtoFill

VOID __stdcall MiEncodeProtoFill(_MMPTE *ProtoPtes, UINT64 ProtoAllocationBytes, _MMPTE TempPte){
  _MMPTE *PteBase; 
  UINT64 v5; 
  UINT64 v6; 
  UINT64 v7; 
  UINT64 v8; 
  _MMSUPPORT_INSTANCE *AnyMultiplexedVm; 
  UINT64 v10; 
  char v11; 
  char v12; 
  unsigned __int64 Long; 
  int v14; 
  char v15; 

  PteBase = MmGetPteBase();
  v5 = (UINT64)PteBase + (((unsigned __int64)ProtoPtes >> 9) & 0x7FFFFFFFF8i64);
  v6 = ProtoAllocationBytes >> 12;
  v7 = 0i64;
  v8 = v5 + 8 * v6;
  AnyMultiplexedVm = MiGetAnyMultiplexedVm(MiWorkingSetTypePagedPool, (VOID *)v6);
  MiLockWorkingSetShared();
  v15 = v11;
  v12 = v11;
  if( v5 >= v8 )
    goto LABEL_8;
  do
  {
    if( !v7 )
      goto LABEL_10;
    if( (v5 & 0xFFF) == 0 )
    {
      MiUnlockPageTableInternal((INT64)AnyMultiplexedVm, v7);
LABEL_10:
      v7 = (UINT64)PteBase + ((v5 >> 9) & 0x7FFFFFFFF8i64);
      MiLockPageTableInternal((INT64)AnyMultiplexedVm, v7, 0i64);
    }
    Long = TempPte.u.Long;
    LOBYTE(v14) = MiPteInShadowRange(v5);
    if( v14 && (KeGetCurrentThread()->ApcState.Process->Flags3 & 0x1000) != 0 && (TempPte.u.Long & 1) != 0 )
      Long = TempPte.u.Long | 0x8000000000000000ui64;
    *(_QWORD *)v5 = Long;
    v5 += 8i64;
    PteBase = MmGetPteBase();
  }
  while( v5 < v8 );
  v12 = v15;
  if( v7 )
    MiUnlockPageTableInternal((INT64)AnyMultiplexedVm, v7);
LABEL_8:
  LOBYTE(v10) = v12;
  MiUnlockWorkingSetShared(AnyMultiplexedVm, v10);
}

Referenced by:

MiInitializePrototypePtes