MiMapContiguousMemory
VOID *__stdcall MiMapContiguousMemory(
LARGE_INTEGER PhysicalAddress,
UINT64 NumberOfBytes,
UINT64 ProtectionMask,
UINT64 GuardPte){
char v4;
unsigned int v5;
LARGE_INTEGER v7;
UINT64 v8;
void *v9;
unsigned int v10;
int v11;
INT64 v12;
int v13;
void *v14;
CHAR v15;
CHAR v17;
CHAR v18;
unsigned __int64 v19;
int v20;
int *a5;
int a6;
int v23;
INT64 a3;
__int64 v25;
UINT64 v26;
INT64 a1[5];
int v28;
int v29;
unsigned __int64 v30;
v26 = NumberOfBytes;
v4 = GuardPte;
v5 = ProtectionMask;
if( (_DWORD)ProtectionMask == -1 )
return 0i64;
if( (_DWORD)ProtectionMask == 24 )
return 0i64;
if( (ProtectionMask & 5) == 5 )
return 0i64;
if( (ProtectionMask & 0xFFFFFFF8) == 16 )
return 0i64;
v7.QuadPart = NumberOfBytes + PhysicalAddress.QuadPart;
if( v7.QuadPart <= (unsigned __int64)PhysicalAddress.QuadPart )
{
if( v7.QuadPart )
return 0i64;
}
v25 = PhysicalAddress.LowPart & 0xFFF;
v8 = (v25 + NumberOfBytes + 4095) >> 12;
v9 = (void *)(((unsigned __int64)PhysicalAddress.QuadPart >> 12) & 0xFFFFFFFFFi64);
if( (unsigned __int64)PhysicalAddress.QuadPart >> 12 < 0x1000000000i64 )
v9 = (void *)((unsigned __int64)PhysicalAddress.QuadPart >> 12);
a3 = (INT64)v9;
if( (ProtectionMask & 2) != 0 && (MiFlags & 0x10000) != 0 )
v5 = ProtectionMask & 0xFFFFFFFD;
a6 = 0;
if( (PhysicalAddress.LowPart & 0x1FFFFF) != 0
|| NumberOfBytes < 0x200000
|| (v11 = GuardPte & 1, (GuardPte & 1) != 0)
|| (a5 = &a6,
(v14 = (void *)MiMapContiguousMemoryLarge(v9, ((PhysicalAddress.LowPart & 0xFFF) + NumberOfBytes + 4095) >> 12)) == 0i64) )
{
v23 = 0;
v10 = v8;
v11 = v4 & 1;
if( (v4 & 1) != 0 )
{
v10 = v8 + 1;
if( (_DWORD)v8 == -1 )
return 0i64;
v23 = 1;
}
v12 = MiReservePtes((INT64)&qword_140C4EC80, v10);
if( v12 )
{
v13 = v23 | 2;
if( (v4 & 2) == 0 )
v13 = v23;
LODWORD(a5) = v13;
if( (int)MiFillSystemPtes(v12, v8, a3, v5, (INT64)a5, (INT64)&a6) >= 0 )
{
v14 = (void *)(v25 + (((v12 << 25) - ((_QWORD)MmGetPteBase() << 25)) >> 16));
goto LABEL_16;
}
MiReleasePtes((INT64)&qword_140C4EC80, v12, v10);
}
return 0i64;
}
LABEL_16:
v15 = a6 & 1;
if( (a6 & 1) != 0 )
MiMappingHasIoReferences(v14);
if( (dword_140CFA17C & 1) != 0 )
{
a1[0] = 0i64;
a1[1] = 0i64;
v28 = 0;
v17 = v15 | 2;
v30 = (unsigned __int64)PhysicalAddress.QuadPart >> 12;
v18 = 1;
a1[3] = (INT64)v14;
v19 = PhysicalAddress.QuadPart & 0xFFFFFFFFFFFFF000ui64;
v20 = PhysicalAddress.LowPart & 0xFFF;
a1[4] = v19;
a1[2] = v26;
if( !v11 )
v17 = v15;
v29 = v20;
if( v5 >> 3 == 1 )
{
v18 = 0;
}
else if( v5 >> 3 == 3 && (v5 & 7) != 0 )
{
v18 = 2;
}
MiInsertPteTracker((INT64)a1, 1i64, v17, v18);
}
return v14;
}Referenced by:
MiAllocateContiguousMemory
MmMapIoSpaceEx