SaveNodeDistanceInformation
VOID __stdcall SaveNodeDistanceInformation(){
__int64 v0;
unsigned int v1;
__int64 *v2;
__int64 v3;
__int64 v4;
__int16 v5;
__int16 v6;
unsigned int v7;
unsigned int v8;
VOID **PoolWithTag;
VOID **v10;
_UNICODE_STRING *Disposition;
int v12;
unsigned int v13;
unsigned int v14;
__int64 v15;
unsigned __int64 v16;
VOID *v17;
VOID **v18;
VOID **v19;
__int64 v20;
unsigned int v21;
__int64 v22;
__int64 *v23;
__int64 v24;
__int64 v25;
__int64 v26;
_WORD *v27;
unsigned __int64 v28;
unsigned __int64 *v29;
__int64 v30;
__int64 v31;
_QWORD *v32;
unsigned __int64 v33;
__int64 *v34;
__int64 v35;
__int64 *v36;
__int64 v37;
__int64 v38;
__int64 v39;
int v40;
int v41;
__int64 v42;
__int64 *v43;
__int64 v44;
int v45;
int v46;
__int64 v47;
__int16 v48;
__int64 v49;
unsigned int v50;
__int64 v51;
unsigned int v52;
__int64 v53;
char v54;
unsigned int v55;
__int64 *v56;
int v57;
int v58;
unsigned int v59;
int v60;
int v61;
__int64 *v62;
__int64 v63;
__int64 v64;
__int64 v65;
__int64 v66;
__int64 v67;
__int64 *v68;
__int64 v69;
__int64 v70;
int v71;
int v72;
_UNICODE_STRING *Class;
UINT64 CreateOptions;
UINT64 CreateOptionsa;
VOID *KeyHandle;
UINT64 ResultLength;
__int64 v78;
__int64 *v79;
__int64 v80;
_UNICODE_STRING ValueName;
_UNICODE_STRING DestinationString;
_OBJECT_ATTRIBUTES ObjectAttributes;
char KeyValueInformation[4];
int v85;
int v86;
unsigned int v87;
KeyHandle = (VOID *)-1i64;
v0 = (unsigned __int16)KeNumberNodes;
LODWORD(ResultLength) = 0;
v1 = 0;
DestinationString = 0i64;
memset(&ObjectAttributes, 0, sizeof(ObjectAttributes));
ValueName = 0i64;
if( !KeNumberNodes )
goto LABEL_8;
v2 = KeNodeBlock;
v3 = (unsigned __int16)KeNumberNodes;
do
{
v4 = *v2++;
v5 = *(_WORD *)(v4 + 146);
v6 = *(_WORD *)(v4 + 148);
v7 = v1 + 1;
if( v5 != v6 )
v7 = v1;
v1 = v7;
--v3;
}
while( v3 );
if( v7 != 1 )
{
LABEL_8:
v8 = (unsigned __int16)KeNumberNodes * (unsigned __int16)KeNumberNodes;
PoolWithTag = ExAllocatePoolWithTag(1ui64, 8i64 * (int)v8, 1634563406i64);
v10 = PoolWithTag;
if( PoolWithTag )
{
memmove(PoolWithTag, *(&KiSwapEvent + 58), 8 * v8);
Disposition = 0i64;
v12 = 0;
if( (_DWORD)v0 != 1 )
{
do
{
v13 = v12 + 1;
v14 = v12 + 1;
if( v12 + 1 < (unsigned int)v0 )
{
v15 = v13 + v12 * (_DWORD)v0;
do
{
v16 = (unsigned __int64)v10[v15];
if( v16 != -1i64 )
{
v17 = (VOID *)(((unsigned __int64)*(&v10[v12] + v14 * (unsigned int)v0) >> 1) + (v16 >> 1));
v10[v15] = v17;
*(&v10[v12] + v14 * (unsigned int)v0) = v17;
}
++v14;
v15 = (unsigned int)(v15 + 1);
}
while( v14 < (unsigned int)v0 );
}
++v12;
}
while( v13 < (int)v0 - 1 );
Disposition = 0i64;
}
HIDWORD(ResultLength) = 2 * v1 * (v1 + 2) + 4;
v18 = ExAllocatePoolWithTag(1ui64, HIDWORD(ResultLength), 538993995i64);
v19 = v18;
if( v18 )
{
v20 = v1 + 1;
*(_DWORD *)v18 = v1;
v21 = 1;
v22 = (__int64)v18 + 4 * v20;
v78 = v22;
if( (_DWORD)v0 )
{
v23 = KeNodeBlock;
v24 = v0;
do
{
if( *(_WORD *)(*v23 + 146) == *(_WORD *)(*v23 + 148) )
{
v25 = v21++;
*((_DWORD *)v18 + v25) = *(_DWORD *)(*v23 + 168);
}
++v23;
--v24;
}
while( v24 );
Disposition = 0i64;
}
if( v1 * v1 )
{
v26 = v1 * v1;
v27 = (_WORD *)v18 + 2 * v20;
while( v26 )
{
*v27++ = -1;
--v26;
}
Disposition = 0i64;
}
v28 = 1i64;
if( v8 )
{
v29 = (unsigned __int64 *)v10;
v30 = v8;
v31 = v8;
do
{
if( v28 < *v29 && *v29 != -1i64 )
v28 = *v29;
++v29;
--v31;
}
while( v31 );
if( v28 > 0x1000000000000i64 )
{
v28 >>= 16;
v32 = v10;
do
{
if( *v32 != -1i64 )
*v32 >>= 16;
++v32;
--v30;
}
while( v30 );
}
Disposition = 0i64;
}
v33 = 0x8000000000000000ui64 / v28;
if( v8 )
{
v34 = (__int64 *)v10;
Disposition = (_UNICODE_STRING *)v8;
do
{
if( *v34 == -1 )
v35 = 0xFFFFi64;
else
v35 = (v33 * *v34) >> 48;
*v34++ = v35;
Disposition = (_UNICODE_STRING *)((char *)Disposition - 1);
}
while( Disposition );
}
if( (_DWORD)v0 )
{
v36 = KeNodeBlock;
v37 = v0;
v79 = KeNodeBlock;
v38 = v0;
v80 = v0;
do
{
v39 = *v36;
if( *(_WORD *)(*v36 + 146) == *(_WORD *)(*v36 + 148) )
{
v40 = (int)Disposition;
v41 = (int)Disposition;
if( v1 )
{
while( 1 )
{
v42 = (unsigned int)(v41 + 1);
if( *((_DWORD *)v19 + v42) == *(_DWORD *)(v39 + 168) )
break;
++v41;
if( (unsigned int)v42 >= v1 )
goto LABEL_55;
}
v40 = v1 * v41;
}
LABEL_55:
v43 = KeNodeBlock;
v44 = v38;
do
{
v45 = *(unsigned __int16 *)(*v43 + 146);
if( (_WORD)v45 == *(_WORD *)(*v43 + 148) )
{
if( *(&v10[v45] + (unsigned int)v0 * *(unsigned __int16 *)(v39 + 146)) == (VOID *)0xFFFF )
{
v22 = v78;
}
else
{
v46 = 0;
if( v1 )
{
do
{
v47 = (unsigned int)(v46 + 1);
if( *((_DWORD *)v19 + v47) == *(_DWORD *)(*v43 + 168) )
break;
++v46;
}
while( (unsigned int)v47 < v1 );
}
v48 = *((_WORD *)&v10[v45] + 4 * (unsigned int)v0 * *(unsigned __int16 *)(v39 + 146));
v49 = (unsigned int)(v40 + v46);
v22 = v78;
*(_WORD *)(v78 + 2 * v49) = v48;
if( !v48 )
*(_WORD *)(v22 + 2 * v49) = 2;
}
}
++v43;
--v44;
}
while( v44 );
v36 = v79;
v38 = v0;
v37 = v80;
Disposition = 0i64;
}
++v36;
--v37;
v79 = v36;
v80 = v37;
}
while( v37 );
LODWORD(v20) = v1 + 1;
}
v50 = (unsigned int)Disposition;
if( v1 )
{
do
{
v51 = v50 * (unsigned int)v20;
++v50;
*(_WORD *)(v22 + 2 * v51) = (_WORD)Disposition;
}
while( v50 < v1 );
}
v52 = 10;
RtlInitUnicodeString(&DestinationString, L"\\registry\\machine\\SYSTEM\\CurrentControlSet\\Control\\NUMA");
RtlInitUnicodeString(&ValueName, L"Variation Threshold");
LODWORD(CreateOptions) = (_DWORD)Disposition;
ObjectAttributes.ObjectName = &DestinationString;
ObjectAttributes.Length = 48;
ObjectAttributes.RootDirectory = Disposition;
ObjectAttributes.Attributes = 576;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
if( ZwCreateKey(
&KeyHandle,
0xF003Fui64,
&ObjectAttributes,
0i64,
Disposition,
CreateOptions,
(UINT64 *)&Disposition->Length) < 0 )
{
v53 = -1i64;
KeyHandle = (VOID *)-1i64;
}
else
{
LODWORD(Class) = 20;
if( ZwQueryValueKey(
KeyHandle,
&ValueName,
KeyValuePartialInformation,
KeyValueInformation,
(UINT64)Class,
&ResultLength) >= 0
&& v85 == 4
&& v86 == 4 )
{
v52 = v87;
if( v87 - 1 > 0x31 )
v52 = 10;
}
v53 = (__int64)KeyHandle;
}
v54 = (char)Disposition;
v55 = (unsigned int)Disposition;
if( (_DWORD)v0 )
{
v56 = KeNodeBlock;
while( 1 )
{
if( *(_WORD *)(*v56 + 146) == *(_WORD *)(*v56 + 148) )
{
v57 = (int)Disposition;
while( 1 )
{
if( *(_WORD *)(KeNodeBlock[v57] + 146) == *(_WORD *)(KeNodeBlock[v57] + 148) && v55 != v57 )
{
v58 = *((_DWORD *)&v10[v55 * (unsigned int)v0] + 2 * v57);
v59 = *((_DWORD *)KeNodeDistance + v57 + v55 * (unsigned __int16)KeNumberNodes);
v60 = v59 - v58;
if( (int)(v58 - v59) >= 0 )
v60 = v58 - v59;
if( 100 * v60 / v52 > v59 )
break;
}
if( ++v57 >= (unsigned int)v0 )
goto LABEL_90;
}
v54 = 1;
LABEL_90:
LODWORD(Disposition) = 0;
if( v54 )
break;
}
++v55;
++v56;
if( v55 >= (unsigned int)v0 )
goto LABEL_106;
}
if( v53 != -1 )
{
RtlInitUnicodeString(&ValueName, L"Node Distance");
LODWORD(CreateOptionsa) = HIDWORD(ResultLength);
ZwSetValueKey((VOID *)v53, &ValueName, 0i64, 3ui64, v19, CreateOptionsa);
}
v61 = (unsigned __int16)KeNumberNodes;
v62 = KeNodeBlock;
v63 = v0;
do
{
v64 = *v62;
v65 = *(unsigned __int16 *)(*v62 + 148);
if( *(_WORD *)(*v62 + 146) != (_WORD)v65 )
v64 = KeNodeBlock[v65];
v66 = v63;
v67 = (unsigned int)(v61 * (_DWORD)Disposition);
v68 = KeNodeBlock;
do
{
v69 = *v68;
v70 = *(unsigned __int16 *)(*v68 + 148);
if( *(_WORD *)(*v68 + 146) != (_WORD)v70 )
v69 = KeNodeBlock[v70];
v71 = *(unsigned __int16 *)(v64 + 146);
v72 = *(unsigned __int16 *)(v69 + 146);
if( (_WORD)v71 == (_WORD)v72 )
*((_DWORD *)KeNodeDistance + v67) = 0;
else
*((_DWORD *)KeNodeDistance + v67) = v10[(unsigned int)(v72 + v0 * v71)];
v67 = (unsigned int)(v67 + 1);
++v68;
--v66;
}
while( v66 );
LODWORD(Disposition) = (_DWORD)Disposition + 1;
++v62;
v63 = v0;
}
while( (unsigned int)Disposition < (unsigned int)v0 );
}
}
LABEL_106:
ExFreePoolWithTag(v10, 0);
if( v19 )
ExFreePoolWithTag(v19, 0);
}
if( KeyHandle != (VOID *)-1i64 )
ZwClose((_HANDLE)KeyHandle);
}
}Referenced by:
Phase1InitializationIoReady