KeStartAllProcessors
NTSTATUS __stdcall KeStartAllProcessors(PVOID BugCheckParameter2){
KPCR *Pcr;
UINT8 *v2;
UINT8 *PoolWithTag;
unsigned int v4;
KPCR *v5;
struct _KPRCB *CurrentPrcb;
unsigned int v7;
__int64 v8;
__int64 v9;
__int64 v10;
__int64 v11;
unsigned int MaximumProcessorCount;
unsigned int v13;
unsigned int v14;
unsigned int v15;
unsigned int v16;
PVOID a11;
PVOID a12;
__int64 v19;
_OWORD *v20;
_BYTE *v21;
int started;
_BYTE *v23;
unsigned __int64 v24;
__int64 v25;
int v26;
NTSTATUS result;
SIZE_T v28;
__int64 v29;
_OWORD *v30;
__int128 v31;
unsigned int i;
__int64 *v33;
_OWORD *v34;
_OWORD *v35;
__int64 v36;
_OWORD *v37;
__int128 v38;
unsigned int v39;
ULONG_PTR BugCheckParameter4;
INT64 a6;
INT64 a7;
INT64 a8;
INT64 a9;
INT64 a10;
__int16 Node[2];
char v47[12];
UINT64 IdtOffset;
unsigned int v49;
PVOID IsrStack;
PVOID a13;
PVOID a15;
PVOID a17;
PVOID a16;
PVOID a18;
INT64 IndependentPages;
_OWORD *v57;
PVOID PointerKernelStack;
PVOID KernelStack;
_QWORD a3[2];
ULONG_PTR BugCheckParameter1[184];
a13 = 0i64;
a18 = 0i64;
a16 = 0i64;
a17 = 0i64;
a15 = 0i64;
Node[0] = 0;
*(_DWORD *)v47 = 0;
memset((INT64)BugCheckParameter1, 0i64);
Pcr = KeGetPcr();
IdtOffset = 0i64;
v2 = (UINT8 *)*((_QWORD *)Pcr + 93);
LODWORD(KiBootProcessorIdtSize) = *((unsigned __int16 *)Pcr + 371) + 1;
PoolWithTag = (UINT8 *)ExAllocatePoolWithTag(PagedPool, (unsigned int)KiBootProcessorIdtSize, 0x2020654Bui64);
KiBootProcessorIdt = PoolWithTag;
if( !PoolWithTag )
goto LABEL_107;
memmove(PoolWithTag, v2, (unsigned int)KiBootProcessorIdtSize);
if( (unsigned int)KeRegisteredProcessors > 0x500 )
LODWORD(KeRegisteredProcessors) = 1280;
*(_DWORD *)KiBarrierWait = 1;
if( !HalpInterruptHyperThreading )
KiResetBootProcessorApicMask();
v4 = HalEnumerateProcessors((unsigned int)KeRegisteredProcessors);
if( KeNumprocSpecified && KeNumprocSpecified < v4 )
v4 = KeNumprocSpecified;
if( KeBootprocSpecified && KeBootprocSpecified < v4 )
v4 = KeBootprocSpecified;
v5 = KeGetPcr();
CurrentPrcb = KeGetCurrentPrcb();
v7 = 0;
if( KiInitializePrcbContext(CurrentPrcb, 0i64) < 0 )
goto LABEL_107;
if( !MmAllocateIsrStack((PVOID *)CurrentPrcb + 4283, 0) )
goto LABEL_107;
IsrStack = (PVOID)(*((_QWORD *)KeGetPcr() + 4117) + 80i64);
if( !MmAllocateIsrStack(&IsrStack, 0) )
goto LABEL_107;
v8 = *(_QWORD *)(*((_QWORD *)v5 + 1) + 36i64);
*(_QWORD *)&v47[4] = v8;
if( (_BYTE)KiKvaShadow )
*(_QWORD *)&v47[4] = *(_QWORD *)(v8 + 8) + 32i64;
if( !MmAllocateIsrStack((PVOID *)&v47[4], 0) )
goto LABEL_107;
v9 = *(_QWORD *)(*((_QWORD *)v5 + 1) + 44i64);
*(_QWORD *)&v47[4] = v9;
if( (_BYTE)KiKvaShadow )
*(_QWORD *)&v47[4] = *(_QWORD *)(v9 + 8) + 32i64;
if( !MmAllocateIsrStack((PVOID *)&v47[4], 0) )
goto LABEL_107;
v10 = *(_QWORD *)(*((_QWORD *)v5 + 1) + 52i64);
*(_QWORD *)&v47[4] = v10;
if( (_BYTE)KiKvaShadow )
*(_QWORD *)&v47[4] = *(_QWORD *)(v10 + 8) + 32i64;
if( !MmAllocateIsrStack((PVOID *)&v47[4], 0) )
goto LABEL_107;
v11 = *(_QWORD *)(*((_QWORD *)v5 + 1) + 60i64);
*(_QWORD *)&v47[4] = v11;
if( (_BYTE)KiKvaShadow )
*(_QWORD *)&v47[4] = *(_QWORD *)(v11 + 8) + 32i64;
if( !MmAllocateIsrStack((PVOID *)&v47[4], 0) )
goto LABEL_107;
MaximumProcessorCount = HalQueryMaximumProcessorCount();
v13 = MaximumProcessorCount;
if( MaximumProcessorCount > 0x500 )
MaximumProcessorCount = 1280;
v14 = KeRegisteredProcessors * *((_DWORD *)CurrentPrcb + 38) * *((_DWORD *)CurrentPrcb + 39);
if( MaximumProcessorCount <= v14 )
v14 = MaximumProcessorCount;
if( KeNumprocSpecified && KeNumprocSpecified < v14 )
v14 = KeNumprocSpecified;
if( !KeDynamicPartitioningSupported && v14 > v4 )
v14 = v4;
if( !(unsigned int)KiAllocateCpuSetData(v14) )
goto LABEL_107;
v15 = KiComputeProcessorDataSize(v14, (UINT64 *)((char *)&IdtOffset + 4), &IdtOffset);
a3[0] = HIDWORD(IdtOffset);
a3[1] = (unsigned int)IdtOffset;
v49 = v15;
if( (int)HvlStartBootLogicalProcessors((unsigned int)IdtOffset) < 0 )
goto LABEL_107;
v16 = 0;
while( (unsigned int)KeNumberProcessors_0 < v4 )
{
*(_DWORD *)v47 = -1;
Node[0] = -1;
if( !KiQueryProcessorNode(++v7, (UINT64 *)v47, (UINT16 *)Node) )
{
++v16;
IndependentPages = MmAllocateIndependentPagesEx(v15, (unsigned __int16)Node[0], a3, 2ui64);
if( !IndependentPages )
goto LABEL_107;
if( !ExCreatePoolTagTable(v16, Node[0]) )
goto LABEL_107;
PointerKernelStack = (PVOID)MmCreateKernelStack(0, (unsigned __int16)Node[0], 0i64);
a11 = PointerKernelStack;
if( !PointerKernelStack )
goto LABEL_107;
KernelStack = (PVOID)MmCreateKernelStack(0, (unsigned __int16)Node[0], 0i64);
a12 = KernelStack;
if( !KernelStack )
goto LABEL_107;
a13 = 0i64;
if( !MmAllocateIsrStack(&a13, Node[0]) )
goto LABEL_107;
IsrStack = 0i64;
if( !MmAllocateIsrStack(&IsrStack, Node[0]) )
goto LABEL_107;
a18 = 0i64;
if( !MmAllocateIsrStack(&a18, Node[0]) )
goto LABEL_107;
a16 = 0i64;
if( !MmAllocateIsrStack(&a16, Node[0]) )
goto LABEL_107;
a17 = 0i64;
if( !MmAllocateIsrStack(&a17, Node[0]) )
goto LABEL_107;
a15 = 0i64;
if( !MmAllocateIsrStack(&a15, Node[0]) )
goto LABEL_107;
v57 = (_OWORD *)*((_QWORD *)&KeNodeBlock + (unsigned __int16)Node[0]);
LODWORD(a9) = HIDWORD(IdtOffset);
LODWORD(a10) = IdtOffset;
LODWORD(a8) = v14;
LODWORD(a7) = v16;
LODWORD(a6) = (unsigned __int16)Node[0];
LODWORD(BugCheckParameter4) = v49;
v19 = KxInitializeProcessorState(
BugCheckParameter1,
KeLoaderBlock_0,
IndependentPages,
0i64,
BugCheckParameter4,
a6,
a7,
a8,
a9,
a10,
(INT64)a11,
(INT64)a12,
(INT64)a13,
(INT64)IsrStack,
(INT64)a15,
(INT64)a16,
(INT64)a17,
(INT64)a18);
if( !v19 )
goto LABEL_107;
v20 = (_OWORD *)*((_QWORD *)&KeNodeBlock + (unsigned __int16)Node[0]);
if( HvlInitializeProcessor((_QWORD *)v19, *(int *)v47)
|| !(unsigned int)MmInitializeProcessor(v19)
|| KiInitializePrcbContext((_KPRCB *)v19, (unsigned __int16)Node[0]) < 0
|| (int)KeInitializeTimerTable(v19, v21) < 0 )
{
goto LABEL_107;
}
started = HalStartNextProcessor(BugCheckParameter1, v16, *(unsigned int *)v47);
if( started == 3 )
KeBugCheckEx(0x1DFu, (ULONG_PTR)BugCheckParameter1, 3ui64, v16, *(unsigned int *)v47);
if( started != 4 )
{
KiRemoveProcessorFromGroupDatabase((_KPRCB *)v19, v23);
v28 = (SIZE_T)v57;
v29 = 3i64;
v30 = v57;
do
{
*v30 = *v20;
v30[1] = v20[1];
v30[2] = v20[2];
v30[3] = v20[3];
v30[4] = v20[4];
v30[5] = v20[5];
v30[6] = v20[6];
v30 += 8;
v31 = v20[7];
v20 += 8;
*(v30 - 1) = v31;
--v29;
}
while( v29 );
*((_QWORD *)&KeNodeBlock + (unsigned __int16)Node[0]) = v28;
HvlDeleteProcessor(v19, v28, (MEMORY_CACHING_TYPE)128);
MmDeleteProcessor(v19);
ExDeletePoolTagTable(v16);
KiUnshadowProcessorAllocation(v19, (INT64)BugCheckParameter1);
MmFreeIndependentPages((PVOID)IndependentPages, v49);
MmDeleteKernelStack(PointerKernelStack, 0i64);
MmDeleteKernelStack(KernelStack, 0i64);
if( a13 )
MmFreeIsrStack(a13);
if( IsrStack )
MmFreeIsrStack(IsrStack);
if( a15 )
MmFreeIsrStack(a15);
if( a17 )
MmFreeIsrStack(a17);
if( a16 )
MmFreeIsrStack(a16);
if( a18 )
MmFreeIsrStack(a18);
break;
}
while( *((_QWORD *)KeLoaderBlock_0 + 17) )
_mm_pause();
KiConfigureProcessorBlock((_KPRCB *)v19, (UINT8)v23);
KiUpdateProcessorCount(v16, *(unsigned __int8 *)(v19 + 208));
v15 = v49;
}
if( v7 >= 0x4FF )
break;
}
if( (unsigned __int16)KeNumberNodes <= 1u )
{
v24 = *(_QWORD *)(*(_QWORD *)&KeNodeBlock + 136i64)
- ((*(_QWORD *)(*(_QWORD *)&KeNodeBlock + 136i64) >> 1) & 0x5555555555555555i64);
if( (unsigned int)((0x101010101010101i64
* (((v24 & 0x3333333333333333i64)
+ ((v24 >> 2) & 0x3333333333333333i64)
+ (((v24 & 0x3333333333333333i64) + ((v24 >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 32) >> 24 == (_DWORD)KeNumberProcessors_0 )
goto LABEL_59;
LABEL_107:
KeBugCheckEx(0x32u, 0i64, 0i64, 0x14ui64, 0i64);
}
for( i = 0; i < (unsigned __int16)KeNumberNodes; ++i )
{
v33 = &KiNodeInit[48 * i];
if( *((__int64 **)&KeNodeBlock + i) == v33 )
{
v34 = ExAllocatePoolWithTag(NonPagedPoolNx, 0x1C0ui64, 0x2020654Bui64);
v35 = v34;
if( !v34 )
goto LABEL_107;
memset((INT64)v34, 0i64);
v36 = 3i64;
v37 = v35;
do
{
*v37 = *(_OWORD *)v33;
v37[1] = *((_OWORD *)v33 + 1);
v37[2] = *((_OWORD *)v33 + 2);
v37[3] = *((_OWORD *)v33 + 3);
v37[4] = *((_OWORD *)v33 + 4);
v37[5] = *((_OWORD *)v33 + 5);
v37[6] = *((_OWORD *)v33 + 6);
v37 += 8;
v38 = *((_OWORD *)v33 + 7);
v33 += 16;
*(v37 - 1) = v38;
--v36;
}
while( v36 );
*((_QWORD *)&KeNodeBlock + i) = v35;
}
}
LABEL_59:
if( (unsigned __int16)KeNumberNodes < 0x40u )
memset(0x140000000i64 + 8i64 * (unsigned __int16)KeNumberNodes + 13771648, 0i64);
KiConfigureAllSchedulingInformation();
LOBYTE(v25) = 1;
((void(__fastcall *)(__int64, _QWORD))off_140C006B0[0])(v25, 0i64);
if( !(_DWORD)KeMaximumProcessors )
{
if( !KeDynamicPartitioningSupported || v13 <= (unsigned int)KeNumberProcessors_0 )
{
v26 = KeNumberProcessors_0;
LABEL_64:
LODWORD(KeMaximumProcessors) = v26;
goto LABEL_65;
}
v39 = KeRegisteredProcessors * *((_DWORD *)KiProcessorBlock + 38) * *((_DWORD *)KiProcessorBlock + 39);
LODWORD(KeMaximumProcessors) = v39;
if( v39 > KiMaximumGroupSize * (unsigned int)(unsigned __int16)KiMaximumGroups )
{
LODWORD(KeMaximumProcessors) = KiMaximumGroupSize * (unsigned __int16)KiMaximumGroups;
v39 = KiMaximumGroupSize * (unsigned __int16)KiMaximumGroups;
}
if( v39 > v13 )
{
LODWORD(KeMaximumProcessors) = v13;
v39 = v13;
}
v26 = 1280;
if( v39 > 0x500 )
goto LABEL_64;
}
LABEL_65:
if( !KeDynamicPartitioningSupported )
KiMaximumGroups = KiActiveGroups;
KiBootProcessorsStarted = 1;
result = KeQueryActiveProcessorCountEx(0xFFFFu);
KiBootProcessorCount = result;
*(_DWORD *)KiBarrierWait = 0;
return result;
}Referenced by:
Phase1InitializationDiscard