HvpViewMapCreateViewsForRegion
INT64 __fastcall HvpViewMapCreateViewsForRegion(INT64 a1, INT64 a2, INT64 a3, CHAR a4){
PPRIVILEGE_SET v4;
INT64 MemoryAllocationGranularity;
PPRIVILEGE_SET v9;
PPRIVILEGE_SET *v10;
__int64 v11;
__int64 v12;
__int64 v13;
INT64 v14;
INT64 v15;
INT64 v16;
__int64 j;
__int64 k;
__int64 v19;
INT64 v20;
INT64 v21;
int View;
INT64 v23;
PPRIVILEGE_SET *v24;
PPRIVILEGE_SET v25;
INT64 v26;
unsigned __int64 v27;
bool v28;
unsigned __int64 v29;
__int64 v30;
PPRIVILEGE_SET v31;
VOID *v33;
__int64 v34;
VOID *v35;
INT64 i;
PPRIVILEGE_SET v37;
PPRIVILEGE_SET *v38;
PPRIVILEGE_SET Privileges;
PPRIVILEGE_SET *v40;
CHAR a5;
a5 = a4;
v4 = 0i64;
Privileges = 0i64;
v38 = &v37;
v37 = (PPRIVILEGE_SET)&v37;
MemoryAllocationGranularity = CmSiGetMemoryAllocationGranularity();
v40 = (PPRIVILEGE_SET *)MemoryAllocationGranularity;
v10 = (PPRIVILEGE_SET *)MemoryAllocationGranularity;
v11 = 0x200000i64;
if( v12 < v13 )
{
v14 = -MemoryAllocationGranularity;
for( i = v14; ; v14 = i )
{
v15 = a2 & v14;
v16 = a3 - v15;
if( v11 <= a3 - v15 )
{
v20 = v11 + v15;
v21 = v11 + v15;
}
else
{
for( j = (__int64)v10; j < v16; j *= 2i64 )
;
for( k = 2 * j; v15 + k - a3 <= a3 / 8; k *= 2i64 )
j = k;
v19 = v11;
if( j < v11 )
v19 = j;
v20 = v15 + v19;
if( (*(_DWORD *)(a1 + 32) & 1) != 0 && v20 >= *(_QWORD *)(a1 + 16) )
v20 = *(_QWORD *)(a1 + 16);
v21 = a3;
}
View = HvpViewMapCreateView(a1, v15, v20, (CHAR **)&Privileges);
if( View < 0 )
{
v10 = v40;
v4 = Privileges;
if( v11 <= (__int64)v40 )
goto LABEL_42;
v11 /= 2i64;
}
else
{
v23 = v21;
v4 = Privileges;
View = HvpViewMapMakeViewRangeValid(a1, Privileges, a2, v23, a5);
if( View < 0 )
goto LABEL_42;
v24 = v38;
if( *v38 != (PPRIVILEGE_SET)&v37 )
goto LABEL_57;
v4->Privilege[0].Luid = (_LUID)v38;
*(_QWORD *)&v4->PrivilegeCount = &v37;
a2 = v20;
v10 = v40;
*v24 = v4;
v38 = (PPRIVILEGE_SET *)v4;
v4 = 0i64;
Privileges = 0i64;
}
if( a2 >= a3 )
break;
}
v9 = v37;
}
v25 = *(PPRIVILEGE_SET *)&v9->PrivilegeCount;
if( (PPRIVILEGE_SET *)v9->Privilege[0].Luid != &v37 || (PPRIVILEGE_SET)v25->Privilege[0].Luid != v9 )
LABEL_57:
__fastfail(3u);
v37 = *(PPRIVILEGE_SET *)&v9->PrivilegeCount;
v10 = &v37;
v25->Privilege[0].Luid = (_LUID)&v37;
if( v9 != (PPRIVILEGE_SET)&v37 )
{
v26 = a1 + 40;
v4 = 0i64;
do
{
v27 = *(_QWORD *)v26;
if( (*(_BYTE *)(a1 + 48) & 1) != 0 && v27 )
v27 ^= v26;
v28 = 0;
if( v27 )
{
while( 1 )
{
if( *(_QWORD *)&v9[2].PrivilegeCount < *(_QWORD *)(v27 + 40) )
{
v29 = *(_QWORD *)v27;
if( (*(_BYTE *)(a1 + 48) & 1) != 0 )
{
if( !v29 )
goto LABEL_36;
v29 ^= v27;
}
if( !v29 )
{
LABEL_36:
v28 = 0;
break;
}
}
else
{
v29 = *(_QWORD *)(v27 + 8);
if( (*(_BYTE *)(a1 + 48) & 1) != 0 )
{
if( !v29 )
goto LABEL_37;
v29 ^= v27;
}
if( !v29 )
{
LABEL_37:
v28 = 1;
break;
}
}
v27 = v29;
}
}
RtlRbInsertNodeEx((unsigned __int64 *)(a1 + 40), v27, v28, (unsigned __int64)v9);
v9 = v37;
if( (PPRIVILEGE_SET *)v37->Privilege[0].Luid != &v37 )
goto LABEL_57;
v30 = *(_QWORD *)&v37->PrivilegeCount;
if( *(PPRIVILEGE_SET *)(*(_QWORD *)&v37->PrivilegeCount + 8i64) != v37 )
goto LABEL_57;
v37 = *(PPRIVILEGE_SET *)&v37->PrivilegeCount;
v10 = &v37;
*(_QWORD *)(v30 + 8) = &v37;
}
while( v9 != (PPRIVILEGE_SET)&v37 );
}
View = 0;
LABEL_42:
if( v4 )
{
v33 = *(VOID **)&v4[2].Privilege[0].Attributes;
if( v33 )
CmSiUnmapViewOfSection((INT64)v10, *(PVOID **)(a1 + 24), v33);
CmSiFreeMemory(v4);
}
v31 = v37;
if( v37 != (PPRIVILEGE_SET)&v37 )
{
v34 = *(_QWORD *)&v37->PrivilegeCount;
if( (PPRIVILEGE_SET *)v37->Privilege[0].Luid == &v37 )
{
while( *(PPRIVILEGE_SET *)(v34 + 8) == v31 )
{
v37 = (PPRIVILEGE_SET)v34;
*(_QWORD *)(v34 + 8) = &v37;
if( v31 == (PPRIVILEGE_SET)&v37 )
return(unsigned int)View;
v35 = *(VOID **)&v31[2].Privilege[0].Attributes;
if( v35 )
CmSiUnmapViewOfSection((INT64)&v37, *(PVOID **)(a1 + 24), v35);
CmSiFreeMemory(v31);
v31 = v37;
if( (PPRIVILEGE_SET *)v37->Privilege[0].Luid != &v37 )
break;
v34 = *(_QWORD *)&v37->PrivilegeCount;
}
}
goto LABEL_57;
}
return(unsigned int)View;
}Referenced by:
HvpViewMapExtendStorage
HvpViewMapStart