MiConfigureMemoryInsertion
__int64 __fastcall MiConfigureMemoryInsertion(_QWORD *a1, unsigned int *a2, __int64 a3){
__int64 v3;
unsigned __int64 v5;
unsigned __int64 v7;
__int64 v8;
UINT8 *v9;
unsigned __int64 v10;
__int64 v11;
__int64 v12;
unsigned int *v13;
__int64 v14;
unsigned __int64 v15;
unsigned __int64 v16;
__int64 v18;
UINT8 *v19;
__int64 v20;
__int64 v21;
__int64 v22;
__int64 v23;
__int64 v24;
__int64 v25;
__int64 v26;
__int64 v27;
__int64 v28;
int v29;
__int64 v31;
__int64 v32;
v3 = *(_QWORD *)(a3 + 24);
v5 = *(_QWORD *)(a3 + 16);
*a1 = 0i64;
v32 = v3;
v7 = v3 + v5;
v8 = *a2;
if( *(_QWORD *)a3 )
v9 = (UINT8 *)&a2[4 * v8 + 4];
else
v9 = 0i64;
if( (int)v8 + 1 < (unsigned int)v8 )
return 3221225626i64;
v10 = *a2;
v11 = 0i64;
v31 = 1i64;
v12 = 0i64;
v13 = a2 + 6;
v14 = 1i64;
while( 1 )
{
v15 = *((_QWORD *)v13 - 1);
if( *(_QWORD *)v13 )
{
v16 = v15 + *(_QWORD *)v13;
if( v5 >= v15 )
{
if( v5 < v16 )
return 3221225496i64;
}
else if( v7 > v15 )
{
return 3221225496i64;
}
if( (v5 == v16 || v7 == v15)
&& (!v9 || *(_DWORD *)&v9[8 * v11] == *(_DWORD *)(a3 + 32)
&& *(_DWORD *)&v9[8 * v11 + 4] == *(_DWORD *)(a3 + 36)) )
{
if( v14 == 1 )
{
v12 = v11;
v14 = 0i64;
}
else
{
v14 = -1i64;
}
v31 = v14;
}
}
if( ++v11 >= v10 )
break;
v13 += 4;
}
LODWORD(v18) = MiAllocatePool((struct _SLIST_ENTRY *)0x40);
if( !v18 )
return 3221225626i64;
*(_QWORD *)v18 = &MiSystemPartition;
v19 = (UINT8 *)(a2 + 4);
*(_QWORD *)(v18 + 8) = 1i64;
v20 = v18 + 16;
*(_DWORD *)(v18 + 16) = v14 + v10;
v21 = v18 + 16 + 16 * ((unsigned int)(v14 + v10) + 1i64);
*(_QWORD *)(v18 + 24) = v32 + *((_QWORD *)a2 + 1);
v22 = v18 + 32;
if( v31 == -1 )
{
v23 = 4 * v12;
memmove((UINT8 *)v22, v19, 16 * v12 + 16);
if( v9 )
memmove((UINT8 *)v21, v9, 8 * v12 + 8);
*(_QWORD *)(v20 + v23 * 4 + 24) += v32 + *(_QWORD *)&a2[v23 + 10];
if( v12 + 2 != v10 )
{
v24 = v10 - v12;
memmove((UINT8 *)(v20 + v23 * 4 + 32), (UINT8 *)&a2[v23 + 12], 16 * v24 - 32);
if( v9 )
memmove((UINT8 *)(v21 + 8 * (v12 + 1)), &v9[8 * v12 + 16], 8 * v24 - 16);
}
}
else if( v31 )
{
v28 = 0i64;
v29 = 0;
do
{
if( !v29 && v32 + v5 <= *(_QWORD *)v19 )
{
*(_QWORD *)v22 = v5;
*(_QWORD *)(v22 + 8) = v32;
v22 += 16i64;
if( v9 )
{
*(_DWORD *)(v21 + 4) = *(_DWORD *)(a3 + 36);
*(_DWORD *)v21 = *(_DWORD *)(a3 + 32);
v21 += 8i64;
}
v29 = 1;
}
*(_OWORD *)v22 = *(_OWORD *)v19;
v22 += 16i64;
if( v9 )
{
*(_QWORD *)v21 = *(_QWORD *)&v9[8 * v28];
v21 += 8i64;
}
++v28;
v19 += 16;
}
while( v28 != *a2 );
if( !v29 )
{
*(_QWORD *)v22 = v5;
*(_QWORD *)(v22 + 8) = v32;
if( v9 )
{
*(_DWORD *)(v21 + 4) = *(_DWORD *)(a3 + 36);
*(_DWORD *)v21 = *(_DWORD *)(a3 + 32);
}
}
}
else
{
memmove((UINT8 *)v22, v19, 16 * v10);
if( v9 )
memmove((UINT8 *)v21, v9, 8 * v10);
v25 = 2 * v12;
v26 = *(_QWORD *)&a2[2 * v25 + 4];
v27 = *(_QWORD *)&a2[2 * v25 + 6];
*(_QWORD *)(v20 + 8 * v25 + 24) += v32;
if( v5 != v26 + v27 )
*(_QWORD *)(v20 + 8 * v25 + 16) = v5;
}
*a1 = v20;
return 0i64;
}Referenced by:
MiAddPhysicalMemory