MmMapMdl
NTSTATUS __stdcall MmMapMdl(_MDL *MemoryDescriptorList, UINT64 Win32Protect, VOID *a3, INT64 r9_0, VOID *a5, INT64 a4){
_SLIST_ENTRY *v7;
void(__fastcall *v8)(__int64, void *);
__int64 v9;
unsigned int ProtectionMask;
unsigned __int64 v12;
unsigned int v13;
_MMPTE *PteBase;
PSLIST_ENTRY UltraMdlContext;
unsigned __int64 v16;
_MMPTE *v17;
VOID *v18;
_KTBFLUSH_TYPE v19;
int v20;
_MI_PFN_CACHE_ATTRIBUTE v21;
UINT64 v22;
__int64 v23;
unsigned __int64 Long;
int v25;
INT64 v26;
INT64 a6[9];
LODWORD(a6[0]) = 0;
v7 = 0i64;
ProtectionMask = MiMakeProtectionMask((unsigned int)Win32Protect);
if( ProtectionMask == -1
|| ProtectionMask == 24
|| (ProtectionMask & 7) == 5
|| (ProtectionMask & 2) != 0
|| (ProtectionMask & 0xFFFFFFF8) == 16 )
{
return -1073741755;
}
if( (MemoryDescriptorList->MdlFlags & 5) != 0 )
{
v8(v9, MemoryDescriptorList->MappedSystemVa);
return 0;
}
else
{
v12 = (((MemoryDescriptorList->ByteOffset + LODWORD(MemoryDescriptorList->StartVa)) & 0xFFF)
+ (unsigned __int64)MemoryDescriptorList->ByteCount
+ 4095) >> 12;
v13 = v12;
if( MmProtectFreedNonPagedPool == 1 )
v13 = v12 + 1;
PteBase = MmGetPteBase();
if( v13 <= 0x200
&& (UltraMdlContext = MiGetUltraMdlContext(), (v7 = UltraMdlContext) != 0i64)
&& (MiGetUltraMapping((_MI_ZERO_THREAD_CONTEXT *)&UltraMdlContext->Next + 2, 3i64),
(v17 = (_MMPTE *)((char *)PteBase + ((v16 >> 9) & 0x7FFFFFFFF8i64))) != 0i64)
|| (v17 = MiReservePtes((_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432), v13)) != 0i64 )
{
v18 = (VOID *)(MemoryDescriptorList->ByteOffset + ((__int64)(((_QWORD)v17 << 25) - ((_QWORD)PteBase << 25)) >> 16));
LODWORD(v26) = 0;
HIDWORD(a6[0]) = MiFillSystemPtes(
(UINT64)v17,
v12,
(INT64)&MemoryDescriptorList[1],
ProtectionMask,
v26,
(INT64)a6);
if( a6[0] >= 0 )
{
v20 = a6[0] & 1;
if( (a6[0] & 1) != 0 )
{
MiMappingHasIoReferences(v18);
MemoryDescriptorList->MdlFlags |= 0x800u;
}
if( (dword_140CFA17C & 1) != 0 )
{
v21 = MiProtectionToCacheAttribute(ProtectionMask);
MiInsertPteTracker(MemoryDescriptorList, MiPteTrackerMdl, v22, v21);
}
HIDWORD(a6[0]) = 0;
((void(__fastcall *)(INT64, VOID *))a3)(r9_0, v18);
if( v20 )
MiZeroAndFlushPtes(v18, v12);
}
if( v7 )
{
if( v13 )
{
v23 = v13;
do
{
Long = ZeroPte.u.Long;
LOBYTE(v25) = MiPteInShadowRange((UINT64)v17);
if( v25 && (KeGetCurrentThread()->ApcState.Process->Flags3 & 0x1000) != 0 && (ZeroPte.u.Long & 1) != 0 )
Long = ZeroPte.u.Long | 0x8000000000000000ui64;
v17->u.Long = Long;
++v17;
--v23;
}
while( v23 );
}
MiFreeUltraMdlContext(v7);
v17 = 0i64;
}
if( v17 )
MiReleasePtes((_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432), v17, v13, v19);
return HIDWORD(a6[0]);
}
else
{
return -1073741670;
}
}
}Referenced by:
No references.