KeStartAllProcessors
VOID __stdcall KeStartAllProcessors(){
KPCR *Pcr;
const VOID *Base;
VOID **PoolWithTag;
unsigned int v3;
KPCR *v4;
struct _KPRCB *CurrentPrcb;
unsigned int v6;
__int64 v7;
__int64 v8;
__int64 v9;
__int64 v10;
unsigned int MaximumProcessorCount;
unsigned int v12;
unsigned int v13;
size_t v14;
unsigned int v15;
int v16;
VOID *v17;
VOID *v18;
__int64 v19;
_OWORD *v20;
NTSTATUS started;
UINT8 v22;
unsigned __int64 v23;
__int64 v24;
int v25;
__int64 v26;
__int64 v27;
_OWORD *v28;
__int128 v29;
unsigned int i;
_OWORD *v31;
VOID **v32;
__int64 v33;
__int64 v34;
_OWORD *v35;
__int128 v36;
unsigned int v37;
__int16 Node[2];
char Identifier[12];
UINT64 IdtOffset;
size_t v41;
VOID *IsrStack;
VOID *v43;
VOID *v44;
VOID *v45;
VOID *v46;
VOID *v47;
VOID *IndependentPages;
UINT64 v49;
VOID *PointerKernelStack;
VOID *KernelStack;
__int64 v52[2];
INT64 BugCheckParameter1[184];
v43 = 0i64;
v47 = 0i64;
v46 = 0i64;
v45 = 0i64;
v44 = 0i64;
Node[0] = 0;
*(_DWORD *)Identifier = 0;
memset(BugCheckParameter1, 0i64, sizeof(BugCheckParameter1));
Pcr = KeGetPcr();
IdtOffset = 0i64;
Base = Pcr->Prcb.ProcessorState.SpecialRegisters.Idtr.Base;
Size = Pcr->Prcb.ProcessorState.SpecialRegisters.Idtr.Limit + 1;
PoolWithTag = ExAllocatePoolWithTag(1ui64, Size, 538993995i64);
KiBootProcessorIdt = PoolWithTag;
if( !PoolWithTag )
goto LABEL_107;
memmove(PoolWithTag, Base, Size);
if( (unsigned int)KeRegisteredProcessors > 0x500 )
LODWORD(KeRegisteredProcessors) = 1280;
KiBarrierWait = 1;
if( !*(&CmpDummyThreadEvent + 7136) )
KiResetBootProcessorApicMask();
v3 = HalEnumerateProcessors((unsigned int)KeRegisteredProcessors);
if( KeNumprocSpecified && KeNumprocSpecified < v3 )
v3 = KeNumprocSpecified;
if( KeBootprocSpecified && KeBootprocSpecified < v3 )
v3 = KeBootprocSpecified;
v4 = KeGetPcr();
CurrentPrcb = KeGetCurrentPrcb();
v6 = 0;
if( KiInitializePrcbContext(CurrentPrcb, 0i64) < 0 )
goto LABEL_107;
if( !MmAllocateIsrStack(&CurrentPrcb->IsrStack, 0) )
goto LABEL_107;
IsrStack = (char *)KeGetPcr()->Prcb.ExceptionStack + 80;
if( !MmAllocateIsrStack(&IsrStack, 0) )
goto LABEL_107;
v7 = *(_QWORD *)((char *)v4->NtTib.StackBase + 36);
*(_QWORD *)&Identifier[4] = v7;
if( KiKvaShadow )
*(_QWORD *)&Identifier[4] = *(_QWORD *)(v7 + 8) + 32i64;
if( !MmAllocateIsrStack((VOID **)&Identifier[4], 0) )
goto LABEL_107;
v8 = *(_QWORD *)((char *)v4->NtTib.StackBase + 44);
*(_QWORD *)&Identifier[4] = v8;
if( KiKvaShadow )
*(_QWORD *)&Identifier[4] = *(_QWORD *)(v8 + 8) + 32i64;
if( !MmAllocateIsrStack((VOID **)&Identifier[4], 0) )
goto LABEL_107;
v9 = *(_QWORD *)((char *)v4->NtTib.StackBase + 52);
*(_QWORD *)&Identifier[4] = v9;
if( KiKvaShadow )
*(_QWORD *)&Identifier[4] = *(_QWORD *)(v9 + 8) + 32i64;
if( !MmAllocateIsrStack((VOID **)&Identifier[4], 0) )
goto LABEL_107;
v10 = *(_QWORD *)((char *)v4->NtTib.StackBase + 60);
*(_QWORD *)&Identifier[4] = v10;
if( KiKvaShadow )
*(_QWORD *)&Identifier[4] = *(_QWORD *)(v10 + 8) + 32i64;
if( !MmAllocateIsrStack((VOID **)&Identifier[4], 0) )
goto LABEL_107;
MaximumProcessorCount = HalQueryMaximumProcessorCount();
v12 = MaximumProcessorCount;
if( MaximumProcessorCount > 0x500 )
MaximumProcessorCount = 1280;
v13 = KeRegisteredProcessors * CurrentPrcb->CoresPerPhysicalProcessor * CurrentPrcb->LogicalProcessorsPerCore;
if( MaximumProcessorCount <= v13 )
v13 = MaximumProcessorCount;
if( KeNumprocSpecified && KeNumprocSpecified < v13 )
v13 = KeNumprocSpecified;
if( !KeDynamicPartitioningSupported && v13 > v3 )
v13 = v3;
if( !(unsigned int)KiAllocateCpuSetData(v13) )
goto LABEL_107;
v14 = KiComputeProcessorDataSize(v13, (UINT64 *)((char *)&IdtOffset + 4), &IdtOffset);
v52[0] = HIDWORD(IdtOffset);
v52[1] = (unsigned int)IdtOffset;
v41 = v14;
if( HvlStartBootLogicalProcessors((unsigned int)IdtOffset) < 0 )
goto LABEL_107;
v15 = 0;
while( (unsigned int)KeNumberProcessors_0 < v3 )
{
*(_DWORD *)Identifier = -1;
Node[0] = -1;
KiQueryProcessorNode(++v6, (UINT64 *)Identifier, (UINT16 *)Node);
if( !v16 )
{
++v15;
IndependentPages = (VOID *)MmAllocateIndependentPagesEx(v14, (unsigned __int16)Node[0], v52, 2u);
if( !IndependentPages )
goto LABEL_107;
if( !ExCreatePoolTagTable(v15, Node[0]) )
goto LABEL_107;
PointerKernelStack = MmCreateKernelStack(0i64, Node[0], 0i64);
v17 = PointerKernelStack;
if( !PointerKernelStack )
goto LABEL_107;
KernelStack = MmCreateKernelStack(0i64, Node[0], 0i64);
v18 = KernelStack;
if( !KernelStack )
goto LABEL_107;
v43 = 0i64;
if( !MmAllocateIsrStack(&v43, Node[0]) )
goto LABEL_107;
IsrStack = 0i64;
if( !MmAllocateIsrStack(&IsrStack, Node[0]) )
goto LABEL_107;
v47 = 0i64;
if( !MmAllocateIsrStack(&v47, Node[0]) )
goto LABEL_107;
v46 = 0i64;
if( !MmAllocateIsrStack(&v46, Node[0]) )
goto LABEL_107;
v45 = 0i64;
if( !MmAllocateIsrStack(&v45, Node[0]) )
goto LABEL_107;
v44 = 0i64;
if( !MmAllocateIsrStack(&v44, Node[0]) )
goto LABEL_107;
v49 = KeNodeBlock[(unsigned __int16)Node[0]];
v19 = KxInitializeProcessorState(
BugCheckParameter1,
KeLoaderBlock_0,
(__int64)IndependentPages,
0,
v41,
(unsigned __int16)Node[0],
v15,
v13,
SHIDWORD(IdtOffset),
IdtOffset,
(__int64)v17,
(__int64)v18,
(__int64)v43,
(__int64)IsrStack,
(__int64)v44,
(__int64)v46,
(__int64)v45,
(__int64)v47);
if( !v19 )
goto LABEL_107;
v20 = (_OWORD *)KeNodeBlock[(unsigned __int16)Node[0]];
if( HvlInitializeProcessor((_SLIST_HEADER *)v19, *(unsigned int *)Identifier)
|| !MmInitializeProcessor((_KPRCB *)v19)
|| KiInitializePrcbContext((_KPRCB *)v19, (unsigned __int16)Node[0]) < 0
|| KeInitializeTimerTable((_KPRCB *)v19) < 0 )
{
goto LABEL_107;
}
started = HalStartNextProcessor(BugCheckParameter1, v15, *(_MEMORY_CACHING_TYPE_ORIG *)Identifier);
if( started == 3 )
KeBugCheckEx(0x1DFu, BugCheckParameter1, (PVOID)3, (PVOID)v15, (PVOID)*(unsigned int *)Identifier);
if( started != 4 )
{
KiRemoveProcessorFromGroupDatabase((_KPRCB *)v19);
v26 = v49;
v27 = 3i64;
v28 = (_OWORD *)v49;
do
{
*v28 = *v20;
v28[1] = v20[1];
v28[2] = v20[2];
v28[3] = v20[3];
v28[4] = v20[4];
v28[5] = v20[5];
v28[6] = v20[6];
v28 += 8;
v29 = v20[7];
v20 += 8;
*(v28 - 1) = v29;
--v27;
}
while( v27 );
KeNodeBlock[(unsigned __int16)Node[0]] = v26;
HvlDeleteProcessor((_KPRCB *)v19, v26);
MmDeleteProcessor((_KPRCB *)v19);
ExDeletePoolTagTable(v15);
KiUnshadowProcessorAllocation(v19, (INT64)BugCheckParameter1);
MmFreeIndependentPages(IndependentPages, v41);
MmDeleteKernelStack(PointerKernelStack, 0i64);
MmDeleteKernelStack(KernelStack, 0i64);
if( v43 )
MmFreeIsrStack(v43);
if( IsrStack )
MmFreeIsrStack(IsrStack);
if( v44 )
MmFreeIsrStack(v44);
if( v45 )
MmFreeIsrStack(v45);
if( v46 )
MmFreeIsrStack(v46);
if( v47 )
MmFreeIsrStack(v47);
break;
}
while( KeLoaderBlock_0->Prcb )
_mm_pause();
KiConfigureProcessorBlock((_KPRCB *)v19, v22);
KiUpdateProcessorCount(v15, *(unsigned __int8 *)(v19 + 208));
v14 = v41;
}
if( v6 >= 0x4FF )
break;
}
if( (unsigned __int16)KeNumberNodes <= 1u )
{
v23 = *(_QWORD *)(KeNodeBlock[0] + 136) - ((*(_QWORD *)(KeNodeBlock[0] + 136) >> 1) & 0x5555555555555555i64);
if( (unsigned int)((0x101010101010101i64
* (((v23 & 0x3333333333333333i64)
+ ((v23 >> 2) & 0x3333333333333333i64)
+ (((v23 & 0x3333333333333333i64) + ((v23 >> 2) & 0x3333333333333333i64)) >> 4)) & 0xF0F0F0F0F0F0F0Fi64)) >> 32) >> 24 == (_DWORD)KeNumberProcessors_0 )
goto LABEL_59;
LABEL_107:
KeBugCheckEx(0x32u, 0i64, 0i64, (PVOID)0x14, 0i64);
}
for( i = 0; i < (unsigned __int16)KeNumberNodes; ++i )
{
v31 = (_OWORD *)((char *)&KiNodeInit + 384 * i);
if( (_OWORD *)KeNodeBlock[i] == v31 )
{
v32 = ExAllocatePoolWithTag(0x200ui64, 0x1C0ui64, 538993995i64);
v33 = (__int64)v32;
if( !v32 )
goto LABEL_107;
memset(v32, 0i64, 0x1C0u);
v34 = 3i64;
v35 = (_OWORD *)v33;
do
{
*v35 = *v31;
v35[1] = v31[1];
v35[2] = v31[2];
v35[3] = v31[3];
v35[4] = v31[4];
v35[5] = v31[5];
v35[6] = v31[6];
v35 += 8;
v36 = v31[7];
v31 += 8;
*(v35 - 1) = v36;
--v34;
}
while( v34 );
KeNodeBlock[i] = v33;
}
}
LABEL_59:
if( (unsigned __int16)KeNumberNodes < 0x40u )
memset(
(VOID *)(0x140000000i64 + 8i64 * (unsigned __int16)KeNumberNodes + 13771648),
0i64,
8 * (64 - (unsigned __int16)KeNumberNodes));
KiConfigureAllSchedulingInformation();
LOBYTE(v24) = 1;
((void(__fastcall *)(__int64, _QWORD))off_140C006B0[0])(v24, 0i64);
if( !(_DWORD)KeMaximumProcessors )
{
if( !KeDynamicPartitioningSupported || v12 <= (unsigned int)KeNumberProcessors_0 )
{
v25 = KeNumberProcessors_0;
LABEL_64:
LODWORD(KeMaximumProcessors) = v25;
goto LABEL_65;
}
v37 = KeRegisteredProcessors
* KiProcessorBlock->CoresPerPhysicalProcessor
* KiProcessorBlock->LogicalProcessorsPerCore;
LODWORD(KeMaximumProcessors) = v37;
if( v37 > KiMaximumGroupSize * (unsigned int)(unsigned __int16)KiMaximumGroups )
{
LODWORD(KeMaximumProcessors) = KiMaximumGroupSize * (unsigned __int16)KiMaximumGroups;
v37 = KiMaximumGroupSize * (unsigned __int16)KiMaximumGroups;
}
if( v37 > v12 )
{
LODWORD(KeMaximumProcessors) = v12;
v37 = v12;
}
v25 = 1280;
if( v37 > 0x500 )
goto LABEL_64;
}
LABEL_65:
if( !KeDynamicPartitioningSupported )
KiMaximumGroups = KiActiveGroups;
KiBootProcessorsStarted = 1;
KiBootProcessorCount = KeQueryActiveProcessorCountEx(0xFFFFu);
KiBarrierWait = 0;
}Referenced by:
No references.