MiMakeIoRangePermanent
NTSTATUS __fastcall MiMakeIoRangePermanent(_RTL_BALANCED_NODE *Node){
UINT64 v1;
NTSTATUS v3;
int v4;
char *v5;
unsigned __int8 v6;
char *v7;
_QWORD *v8;
bool i;
unsigned __int64 v10;
_QWORD *v11;
__int64 v12;
UINT64 v13;
_WORD *v14;
__int64 v15;
_RTL_BALANCED_NODE *v16;
_RTL_BALANCED_NODE *v17;
__int64 v18;
_RTL_BALANCED_NODE *v19;
BOOL v20;
unsigned __int64 ParentValue;
_RTL_BALANCED_NODE *v22;
unsigned __int64 v23;
unsigned __int64 v24;
_QWORD *v25;
BOOL v26;
_QWORD *v27;
_RTL_BALANCED_NODE *v28;
unsigned __int8 v30;
_RTL_BALANCED_NODE *Tree;
v1 = (UINT64)Node[1].Children[0];
v3 = 0;
v4 = *(_DWORD *)&Node[1]._bf_0;
v5 = (char *)Node[1].Children[1] - v1;
Tree = 0i64;
v30 = ExAcquireSpinLockExclusive((INT64 *)&stru_140C4DB30 + 458);
v6 = v30;
v7 = v5 + 1;
if( !v7 )
{
LABEL_31:
v25 = (_QWORD *)*(&stru_140C4DB30 + 470);
v26 = 0;
if( *(&stru_140C4DB30 + 470) )
{
while( 1 )
{
if( Node[1].Children[1] < (_RTL_BALANCED_NODE *)v25[3] )
{
v27 = (_QWORD *)*v25;
if( !*v25 )
break;
}
else
{
if( Node[1].Children[0] <= (_RTL_BALANCED_NODE *)v25[4] )
{
++*(&stru_140C4DB30 + 938);
v3 = -1073741800;
goto LABEL_37;
}
v27 = (_QWORD *)v25[1];
if( !v27 )
{
v26 = 1;
break;
}
}
v25 = v27;
}
}
RtlAvlInsertNodeEx((_RTL_BALANCED_NODE **)&stru_140C4DB30 + 470, (UINT64)v25, v26, Node);
goto LABEL_37;
}
do
{
v8 = (_QWORD *)*(&stru_140C4DB30 + 460);
for( i = *(&stru_140C4DB30 + 460) == 0i64; !i; i = v11 == 0i64 )
{
v10 = v8[5];
if( v1 < v10 )
{
v11 = (_QWORD *)*v8;
}
else
{
if( v1 < v10 + 512 )
{
v12 = v8[6];
v13 = (v1 & 0xFFFFFFFFFi64) - v10;
v14 = (_WORD *)(v12 + 2 * v13);
if( (unsigned __int64)&v7[v1] <= v10 + 512 )
v15 = 2i64 * (_QWORD)&v7[v13];
else
v15 = 1024i64;
while( (unsigned __int64)v14 < v12 + v15 )
{
if( (*v14 & 0x3FFF) != 0 )
{
if( (unsigned __int16)*v14 >> 14 != v4 )
{
++*(&stru_140C4DB30 + 937);
v3 = -1073741800;
v7 = 0i64;
goto LABEL_29;
}
}
else
{
*v14 = 0x4000;
}
++v14;
++v1;
--v7;
}
goto LABEL_29;
}
v11 = (_QWORD *)v8[1];
}
v8 = v11;
}
v16 = MiRemoveUnmappedIoNode((_RTL_BALANCED_NODE **)&stru_140C4DB30 + 461, v1);
v17 = v16;
if( !v16 )
{
v18 = v1 & 0x1FF;
goto LABEL_26;
}
v19 = Tree;
v20 = 0;
ParentValue = v16[1].ParentValue;
if( !Tree )
goto LABEL_25;
while( ParentValue < v19[1].ParentValue )
{
v22 = v19->Children[0];
if( !v19->Children[0] )
goto LABEL_25;
LABEL_39:
v19 = v22;
}
v22 = v19->Children[1];
if( v22 )
goto LABEL_39;
v20 = 1;
LABEL_25:
RtlAvlInsertNodeEx(&Tree, (UINT64)v19, v20, v17);
v18 = (v1 & 0xFFFFFFFFFi64) - v17[1].ParentValue;
LABEL_26:
v23 = 512 - v18;
v24 = (unsigned __int64)v7;
if( v23 <= (unsigned __int64)v7 )
v24 = v23;
v7 -= v24;
v1 += v24;
LABEL_29:
;
}
while( v7 );
v6 = v30;
if( v3 >= 0 )
goto LABEL_31;
LABEL_37:
ExReleaseSpinLockExclusiveFromDpcLevel((INT64 *)&stru_140C4DB30 + 458);
__writecr8(v6);
while( Tree )
{
v28 = Tree;
RtlAvlRemoveNode((UINT64 *)&Tree, (INT64 *)Tree);
ExFreePoolWithTag(v28, 0);
}
return v3;
}Referenced by:
MiMakeIoRangePermanentDpc