IommupHvInitializeLibrary
NTSTATUS __stdcall IommupHvInitializeLibrary(){
NTSTATUS v0;
int v1;
__int64 v2;
VOID **PoolWithTag;
VOID **v4;
INT64 v6;
unsigned int v7;
_QWORD *v8;
char *ContiguousNodeMemory;
__int64 v10;
char *v11;
__int64 v12;
unsigned int i;
VOID **v14;
UINT64 Protect;
UINT64 PreferredNode;
unsigned int v17;
__int128 v18;
__int64 v19;
v17 = 0;
v18 = 0i64;
v19 = 0i64;
v0 = 0;
if( !qword_140C4A218 )
return -1073741637;
qword_140C4A218(&v18);
if( (v18 & 1) == 0 )
return -1073741637;
v1 = DWORD2(v18);
if( HIDWORD(v19) && HIDWORD(v19) < DWORD2(v18) )
v1 = HIDWORD(v19);
v2 = v19;
if( !(_DWORD)v19 )
v2 = 1i64;
PoolWithTag = ExAllocatePoolWithTag(0x200ui64, (unsigned int)((_DWORD)v2 << 6), 1231839560i64);
v4 = PoolWithTag;
if( !PoolWithTag )
return -1073741670;
memset(PoolWithTag, 0i64, (_DWORD)v2 << 6);
v7 = 0;
if( (_DWORD)v2 )
{
v8 = v4 + 2;
while( 1 )
{
LODWORD(PreferredNode) = 0x80000000;
LODWORD(Protect) = 4;
*((_DWORD *)v8 - 4) = v7;
ContiguousNodeMemory = (char *)MmAllocateContiguousNodeMemory(
0x2000ui64,
0i64,
(_LARGE_INTEGER)-1i64,
0i64,
Protect,
PreferredNode);
*(v8 - 1) = ContiguousNodeMemory;
if( !ContiguousNodeMemory )
break;
*v8 = ContiguousNodeMemory + 4096;
LODWORD(v10) = MmGetPhysicalAddress((UINT64)ContiguousNodeMemory);
v0 = ((__int64(__fastcall *)(_QWORD, __int64, __int64, __int64, _DWORD))qword_140C4A268)(
v7,
102i64,
v10,
206i64,
0);
if( v0 < 0 )
goto LABEL_20;
++v17;
++v7;
v8 += 8;
if( v7 >= (unsigned int)v2 )
goto LABEL_15;
}
v0 = -1073741670;
LABEL_20:
for( i = 0; i < v17; ++i )
((void(__fastcall *)(_QWORD))qword_140C4A270)(i);
v14 = v4 + 1;
do
{
if( *v14 )
MmFreeContiguousMemory(*v14);
v14 += 8;
--v2;
}
while( v2 );
ExFreePoolWithTag(v4, 0x496C6148u);
}
else
{
LABEL_15:
*(&CmpDummyThreadEvent + 4121) = 1;
*(&CmpDummyThreadEvent + 1032) = v1;
*(&CmpDummyThreadEvent + 1031) = v2;
*(&CmpDummyThreadEvent + 517) = v4;
if( (_DWORD)v2 )
{
v11 = (char *)(v4 + 4);
v12 = (unsigned int)v2;
do
{
*((_QWORD *)v11 - 1) = 0i64;
*(_QWORD *)v11 = 0i64;
*((_DWORD *)v11 + 2) = 0;
*((_QWORD *)v11 + 2) = IommupHvGetPageFault;
*((_QWORD *)v11 + 3) = IommupHvDismissPageFault;
*((_DWORD *)v11 + 3) = 40;
v11 += 64;
--v12;
}
while( v12 );
}
HalpInterruptSetIdtEntry(0xCEui64, IommupHvInterruptRoutine, 12, v6, (UINT64 *)0xFFFFFFFFFFFFFFFFi64);
}
return v0;
}Referenced by:
IommuInitializeLibrary