MiPerformFixups
VOID __stdcall MiPerformFixups(
VOID *BaseMappingVa,
PVOID ControlArea,
UINT64 ImagePteIndex,
UINT64 Diff,
UINT64 PrivateFixup,
UINT64 Direction){
__int64 v7;
ULONG_PTR v8;
__int64 v10;
unsigned int v11;
_OWORD *v12;
unsigned __int64 v13;
__int64 v14;
_IMAGE_BASE_RELOCATION *v15;
bool v16;
int v17;
int v18;
_QWORD *v19;
__int64 v20;
UINT64 v21;
__int128 v22;
__int128 v23;
__int64 v24;
NTSTATUS SystemRegionType;
__int64 v26;
__int64 v27;
UINT64 v28;
UINT64 v29;
INT64 v30[2];
__int64 v31;
__int64 v32;
__int128 v33;
v7 = (unsigned int)ImagePteIndex;
v8 = (unsigned int)ControlArea;
v10 = *(_QWORD *)(*((_QWORD *)ControlArea + 12) + 32i64);
if( (unsigned __int64)(unsigned int)ImagePteIndex < *(_QWORD *)(v10 + 56) )
{
v11 = (_DWORD)ImagePteIndex << 12;
while( 1 )
{
v12 = *(_OWORD **)(v10 + 96);
v13 = *(_QWORD *)(*(_QWORD *)v10 + 8 * v7);
if( v12 )
v14 = *((_QWORD *)v12 + v7 + 7);
else
v14 = 0i64;
if( v13 )
{
if( v13 > 1 )
{
v15 = *(_IMAGE_BASE_RELOCATION **)(*(_QWORD *)v10 + 8 * v7);
if( *(_BYTE *)(v10 + 68) )
MiApplyCompressedFixups(v8, BaseMappingVa, v15, Diff);
else
MiApplyRawFixups(v8, BaseMappingVa, v15, Diff);
}
LABEL_9:
v16 = (v13 & 1) == 0;
v17 = Direction;
if( !v16 )
{
LODWORD(v29) = Direction;
MiApplyStraddleFixups((_MI_DYNAMIC_RELOCATIONS *)v10, BaseMappingVa, v11, Diff, PrivateFixup, v29);
}
if( v14 )
{
v20 = *(_QWORD *)(*(_QWORD *)ControlArea + 32i64);
if( PrivateFixup )
{
v28 = PrivateFixup;
if( (Direction & 1) == 0 )
v28 = Diff;
v21 = v20 + v28;
}
else
{
v21 = v20 + Diff;
if( (Direction & 1) == 0 )
v21 = *(_QWORD *)(*(_QWORD *)ControlArea + 32i64);
}
v22 = v12[1];
*(_OWORD *)v30 = *v12;
v23 = v12[2];
v24 = v22;
if( PrivateFixup )
v24 = 0i64;
v32 = *((_QWORD *)&v22 + 1);
v31 = v24;
v33 = v23;
SystemRegionType = MiGetSystemRegionType(v21);
if( SystemRegionType != 12 && SystemRegionType != 1 )
v17 = Direction | 1;
MiApplyRetpolineFixups((UINT64)BaseMappingVa, v26, v27, v11, (INT64)v30, v14, v17);
}
v18 = *(_DWORD *)(v10 + 64);
if( (v18 & 0xFFFFF000) == v11 )
{
v19 = (char *)BaseMappingVa + (v18 & 0xFFF);
if( ((unsigned __int8)v19 & 1) != 0 )
*(_DWORD *)((char *)v19 - 1) += Diff;
else
*v19 += Diff;
}
BaseMappingVa = (char *)BaseMappingVa + 4096;
if( ((unsigned __int16)BaseMappingVa & 0xFFF) == 0 )
return;
v8 = (unsigned int)ControlArea;
v7 = (unsigned int)(v7 + 1);
v11 += 4096;
}
else
{
if( v14 )
goto LABEL_9;
BaseMappingVa = (char *)BaseMappingVa + 4096;
if( ((unsigned __int16)BaseMappingVa & 0xFFF) == 0 )
return;
v7 = (unsigned int)(v7 + 1);
v11 += 4096;
}
}
}
}Referenced by:
MiRelocateImagePfn
MiRevertRelocatedImagePfn
MiRevertRelocations