KiStartDynamicProcessor
NTSTATUS __stdcall KiStartDynamicProcessor(UINT64 ApicId, UINT16 NsNodeNumber, UINT64 NtNumber){
unsigned int v3;
UINT16 v4;
unsigned __int64 v5;
UINT64 v6;
__int64 v7;
_OWORD *v8;
_KPRCB *v9;
VOID *v10;
int v11;
int v12;
size_t v13;
VOID *v14;
VOID *v15;
WORD **v16;
VOID *v17;
_LOADER_PARAMETER_BLOCK *v18;
_KE_PROCESSOR_CHANGE_NOTIFY_STATE v19;
NTSTATUS started;
WORD **v21;
_OWORD *v22;
__int64 v23;
__int128 v24;
_ETW_TRACING_BLOCK *EtwSupport;
UINT64 ApicIda;
UINT64 ApicIdb;
INT64 Status;
INT64 Statusa;
UINT16 Node;
UINT64 ProcessorId;
size_t Size;
UINT64 IdtOffset;
VOID *IndependentPages;
VOID *IsrStack;
VOID *v37;
VOID *v38;
VOID *v39;
VOID *v40;
VOID *v41;
VOID *PoolTagTable;
VOID *PointerKernelStack;
VOID *KernelStack;
__int128 v45[22];
INT8 ProcessorState[1472];
v4 = NtNumber;
LODWORD(ProcessorId) = NsNodeNumber;
v5 = v3;
IdtOffset = 0i64;
memset(v45, 0i64, sizeof(v45));
memset(ProcessorState, 0i64, sizeof(ProcessorState));
v7 = 0i64;
PoolTagTable = 0i64;
v8 = 0i64;
IndependentPages = 0i64;
v9 = 0i64;
v37 = 0i64;
v10 = 0i64;
PointerKernelStack = 0i64;
IsrStack = 0i64;
Size = 0;
Node = 0;
v41 = 0i64;
v40 = 0i64;
v39 = 0i64;
v38 = 0i64;
if( (unsigned int)KeNumberProcessors_0 >= 0x500
|| KeNumprocSpecified && (unsigned int)KeNumberProcessors_0 >= KeNumprocSpecified )
{
v11 = -1073741223;
goto LABEL_46;
}
v11 = HalRegisterDynamicProcessor();
if( v11 < 0 )
{
LABEL_49:
KiBarrierWait = 0;
if( v7 )
{
v6 = 128i64;
v22 = (_OWORD *)v7;
v23 = 3i64;
do
{
*v22 = *v8;
v22[1] = v8[1];
v22[2] = v8[2];
v22[3] = v8[3];
v22[4] = v8[4];
v22[5] = v8[5];
v22[6] = v8[6];
v22 += 8;
v24 = v8[7];
v8 += 8;
*(v22 - 1) = v24;
--v23;
}
while( v23 );
KeNodeBlock[Node] = v7;
}
if( v9 )
{
HvlDeleteProcessor(v9, v6);
MmDeleteProcessor(v9);
EtwSupport = (_ETW_TRACING_BLOCK *)v9->EtwSupport;
if( EtwSupport )
{
EtwpCCSwapDeleteProcessor(EtwSupport);
ExFreePoolWithTag(v9->EtwSupport, 0);
v9->EtwSupport = 0i64;
}
}
v14 = IndependentPages;
v13 = Size;
goto LABEL_57;
}
Node = v4;
KiQueryProcessorNode((unsigned int)v5, &ProcessorId, &Node);
v11 = v12;
if( v12 )
goto LABEL_46;
KiAdjustGroupConfiguration(KeNodeBlock[Node]);
v13 = KiComputeProcessorDataSize((unsigned int)KeMaximumProcessors, (UINT64 *)((char *)&IdtOffset + 4), &IdtOffset);
Size = v13;
IndependentPages = (VOID *)MmAllocateIndependentPagesEx(v13, Node, 0i64, 0);
v14 = IndependentPages;
if( !IndependentPages )
{
v11 = -1073741670;
KiBarrierWait = 0;
return v11;
}
PoolTagTable = ExCreatePoolTagTable((unsigned int)v5, Node);
if( PoolTagTable )
{
PointerKernelStack = MmCreateKernelStack(0i64, Node, 0i64);
v15 = PointerKernelStack;
if( !PointerKernelStack
|| (KernelStack = MmCreateKernelStack(0i64, Node, 0i64), (v10 = KernelStack) == 0i64)
|| !MmAllocateIsrStack(&IsrStack, Node)
|| !MmAllocateIsrStack(&v37, Node)
|| !MmAllocateIsrStack(&v41, Node)
|| !MmAllocateIsrStack(&v40, Node)
|| !MmAllocateIsrStack(&v39, Node)
|| !MmAllocateIsrStack(&v38, Node) )
{
v11 = -1073741670;
KiBarrierWait = 0;
LABEL_57:
if( PoolTagTable )
ExDeletePoolTagTable((unsigned int)v5);
goto LABEL_59;
}
v7 = KeNodeBlock[Node];
v45[1] = *(_OWORD *)&PsLoadedModuleList;
v9 = (_KPRCB *)KxInitializeProcessorState(
ProcessorState,
v45,
(__int64)v14,
1u,
Size,
Node,
v5,
KeMaximumProcessors,
SHIDWORD(IdtOffset),
IdtOffset,
(__int64)v15,
(__int64)v10,
(__int64)IsrStack,
(__int64)v37,
(__int64)v38,
(__int64)v40,
(__int64)v39,
(__int64)v41);
if( !v9 )
{
v11 = -1073741670;
goto LABEL_49;
}
v8 = (_OWORD *)KeNodeBlock[Node];
if( !MmInitializeProcessor(v9) )
{
v11 = -1073741823;
goto LABEL_47;
}
v11 = KiInitializePrcbContext(v9, Node);
if( v11 < 0 )
goto LABEL_47;
v11 = KeInitializeTimerTable(v9);
if( v11 < 0
|| (v11 = ExInitializeProcessor(v9, 1u), v11 < 0)
|| (v11 = ObInitializeProcessor(v9), v11 < 0)
|| (v11 = IoInitializeProcessor(v9, 0i64), v11 < 0)
|| (v11 = CcInitializeProcessor(v9), v11 < 0)
|| (v11 = EtwInitializeProcessor(v9), v11 < 0)
|| (v11 = WheaInitializeProcessor(v9, 0i64, v16), v11 < 0)
|| (v11 = HvlInitializeProcessor((_SLIST_HEADER *)v9, (unsigned int)ProcessorId), v11 < 0) )
{
LABEL_47:
if( v9 )
KiRemoveProcessorFromGroupDatabase(v9);
goto LABEL_49;
}
v17 = ExPageLockHandle;
v9->ProcessorProfileControlArea = 0i64;
v9->ProfileEventIndexAddress = &v9->ProfileEventIndexAddress;
MiLockPagableImageSection(v17, 1u);
KiAddProcessorToGroupSchedulingDatabase((INT64)v9);
v18 = KeLoaderBlock_0;
KiBarrierWait = 1;
if( !KeLoaderBlock_0 )
{
KeLoaderBlock_0 = (_LOADER_PARAMETER_BLOCK *)v45;
v45[1] = *(_OWORD *)&PsLoadedModuleList;
}
LODWORD(Status) = 0;
LODWORD(ApicIda) = ProcessorId;
v11 = KiDynamicProcessorAddNotification(0, v9->Number, v9->Group, v9->GroupIndex, ApicIda, Status);
v19 = 2;
if( v11 >= 0 )
{
started = HalStartDynamicProcessor(ProcessorState, (unsigned int)v5, (unsigned int)ProcessorId, Node);
if( started == 3 )
KeBugCheckEx(0x1DFu, ProcessorState, (PVOID)3, (PVOID)v5, (PVOID)(unsigned int)ProcessorId);
if( started == 2 )
{
v11 = -1073741823;
}
else
{
while( *((_QWORD *)&v45[8] + 1) )
_mm_pause();
KiInitializeDynamicProcessor(v9);
v19 = 1;
}
}
LODWORD(Statusa) = v11;
LODWORD(ApicIdb) = ProcessorId;
KiDynamicProcessorAddNotification(v19, v9->Number, v9->Group, v9->GroupIndex, ApicIdb, Statusa);
if( v11 >= 0 )
{
WheaInitializeProcessor(v9, 1ui64, v21);
CmInitializeProcessor((__int64)v9);
KiDynamicProcessorInitialization((INT64)v9);
}
KeLoaderBlock_0 = v18;
MmUnlockPagableImageSection(ExPageLockHandle);
v10 = KernelStack;
LABEL_46:
if( v11 >= 0 )
return v11;
goto LABEL_47;
}
v11 = -1073741670;
KiBarrierWait = 0;
LABEL_59:
if( v14 )
{
if( v9 )
KiUnshadowProcessorAllocation((INT64)v9, (INT64)ProcessorState);
MmFreeIndependentPages(v14, v13);
}
if( PointerKernelStack )
MmDeleteKernelStack(PointerKernelStack, 0i64);
if( v10 )
MmDeleteKernelStack(v10, 0i64);
if( IsrStack )
MmFreeIsrStack(IsrStack);
if( v37 )
MmFreeIsrStack(v37);
if( v38 )
MmFreeIsrStack(v38);
if( v39 )
MmFreeIsrStack(v39);
if( v40 )
MmFreeIsrStack(v40);
if( v41 )
MmFreeIsrStack(v41);
return v11;
}Referenced by:
KeStartDynamicProcessor