MiInitNucleus
NTSTATUS __stdcall MiInitNucleus(PVOID BugCheckParameter2){
_MMPTE *PxeSelfRef;
union {unsigned __int64 Long;volatile unsigned __int64 VolatileLong;_MMPTE_HARDWARE Hard;_MMPTE_PROTOTYPE Proto;_MMPTE_SOFTWARE Soft;_MMPTE_TIMESTAMP TimeStamp;_MMPTE_TRANSITION Trans;_MMPTE_SUBSECTION Subsect;_MMPTE_LIST List;} v3;
_EPROCESS *Process;
__int16 v5;
unsigned int *v6;
unsigned int i;
unsigned int v8;
_DWORD *v9;
_QWORD *v10;
__int64 v11;
char *v12;
unsigned int v13;
unsigned int v14;
__int64 v15;
PHYSICAL_MEMORY_DESCRIPTOR *NodeLists;
char v17;
INT64 v18;
UINT64 v19;
_QWORD *p_NumberOfRuns;
unsigned __int64 Long;
int v22;
unsigned __int64 j;
__int64 v24;
UINT8 v25;
PHYSICAL_MEMORY_DESCRIPTOR *v26;
size_t v27;
VOID *Pool;
VOID *v29;
size_t v30;
VOID *v31;
VOID *v32;
VOID *Free;
VOID *v35;
INT64 Flags;
UINT64 Size;
INT64 Tag;
UINT8 IncludeType[8];
INT64 v40;
Tag = (INT64)&MiVisiblePartition;
MiInitializeSystemDefaults((INT64)BugCheckParameter2);
PxeSelfRef = MmGetPxeSelfRef();
v3.Long = (unsigned __int64)PxeSelfRef->u;
MiPteInShadowRange((UINT64)PxeSelfRef);
Process = KeGetCurrentThread()->ApcState.Process;
v5 = __readcr3();
Process->Pcb.DirectoryTableBase = v3.Long & 0xFFFFFFFFF000i64 | v5 & 0xFFF;
MiLowHalVa = MiExamineHalVa();
v6 = (unsigned int *)((char *)&stru_140C4DB30 + 424);
for( i = 0; i < 3; ++i )
{
*v6 = i;
v6[1] = i;
v6[2] = i;
v6[3] = i;
v6 += 4;
}
v8 = 0;
v9 = (_DWORD *)((char *)&stru_140C4DB30 + 472);
do
*v9++ = v8++;
while( v8 <= 3 );
*(&stru_140C4DB30 + 121) = 1;
MiInitializeBootDefaults((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
if( (((unsigned __int8)&stru_140C4DB30 + 3280) & 0xF) != 0 )
goto LABEL_71;
*(&stru_140C4DB30 + 412) = 0i64;
*(&stru_140C4DB30 + 205) = 0i64;
v10 = (_QWORD *)((char *)&stru_140C4DB30 + 6720);
v11 = 16i64;
do
{
v10[1] = v10;
*v10 = v10;
v10 += 2;
--v11;
}
while( v11 );
*(&stru_140C4DB30 + 470) = 0i64;
*(&stru_140C4DB30 + 461) = 0i64;
*(&stru_140C4DB30 + 463) = (char *)&stru_140C4DB30 + 3696;
*(&stru_140C4DB30 + 462) = (char *)&stru_140C4DB30 + 3696;
*(_OWORD *)((char *)&stru_140C4DB30 + 3672) = 0i64;
MiInitializeDynamicVa();
if( dword_140CFA19C == 6881367 )
{
KUSER_SHARED_DATA.NtProductType = NtProductWinNt;
dword_140CFA19C = 0;
}
else
{
KUSER_SHARED_DATA.NtProductType = (dword_140CFA19C != 6357068) + 2;
dword_140CFA19C = 1;
}
Size = 0i64;
*(&stru_140C4DB30 + 25) = -1i64;
if( ((int(__fastcall *)(__int64, __int64, UINT64 *, _QWORD))off_140C00A68[0])(30i64, 16i64, &Size, 0i64) >= 0
&& (v12 = (char *)Size) != 0i64 )
{
v13 = 0;
if( *(_QWORD *)Size != -1i64 )
{
v14 = (unsigned __int16)KeNumberNodes;
v15 = 0i64;
do
{
if( *(_DWORD *)&v12[v15 + 8] >= v14 )
{
*(_DWORD *)&v12[v15 + 8] = 0;
v12 = (char *)Size;
}
*(&stru_140C4DB30 + 38) = v13++;
v15 = 16i64 * v13;
}
while( *(_QWORD *)&v12[v15] != -1i64 );
}
}
else
{
v12 = (char *)&stru_140C4DB30 + 184;
Size = (UINT64)&stru_140C4DB30 + 184;
}
*(&stru_140C4DB30 + 27) = v12;
MiInitializeChannelRangesTemporary();
MiMemoryLicense((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
qword_140D577F8 = KeQueryPerformanceCounter(0i64);
MiRemoveLargeFreeLoaderDescriptors((INT64)BugCheckParameter2);
qword_140D57800 = KeQueryPerformanceCounter(0i64);
LODWORD(NodeLists) = MiFindLargestLoaderDescriptor((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 3;
LABEL_22:
LOBYTE(NodeLists) = 0;
return(int)NodeLists;
}
MiCheckLargePageOk((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
*(&stru_140C4DB30 + 52) = -1i64;
MiProtectSharedUserPage();
MiCreateResidentPfnTemplate((INT64)&stru_140C4DB30 + 1936);
MiCreateResidentBasePfnTemplate((INT64)&stru_140C4DB30 + 1984);
qword_140D57808 = KeQueryPerformanceCounter(0i64);
LODWORD(NodeLists) = MiCreatePfnDatabase((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 6;
goto LABEL_22;
}
qword_140D57810 = KeQueryPerformanceCounter(0i64);
MiInitializePfnsForValidMappings((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
qword_140D57818 = KeQueryPerformanceCounter(0i64);
MiSwitchToPfns((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
qword_140D57820 = KeQueryPerformanceCounter(0i64);
MxRelocatePageTables((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2);
qword_140D57828 = KeQueryPerformanceCounter(0i64);
MiZeroBootMappings();
MiInitializeDecayPfns();
if( (((unsigned __int8)&stru_140C4DB30 + 3104) & 0xF) != 0 )
LABEL_71:
RtlRaiseStatus(-2147483646);
*(&stru_140C4DB30 + 194) = 0i64;
MiInitializeSections(&Irp);
MiInitializeCommitment(&Irp);
MiInitializeDummyPages();
LODWORD(NodeLists) = MiInitializeSystemPtes();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 9;
goto LABEL_22;
}
LODWORD(NodeLists) = MiInitializeNonPagedPool();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 7;
goto LABEL_22;
}
LODWORD(NodeLists) = MiMapDummyPages();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 5;
goto LABEL_22;
}
v17 = BYTE2(MiFlags);
qword_140D57830 = KeQueryPerformanceCounter(0i64);
LODWORD(NodeLists) = ExInitializePoolHeapManagement((v17 & 1) << 10);
if( (int)NodeLists < 0 )
{
*(&stru_140C4DB30 + 2570) = 2;
goto LABEL_22;
}
MiInitializeKernelStacks();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 20;
goto LABEL_22;
}
LODWORD(NodeLists) = MiCreateTopLevelUltraMappings(v19, v18);
if( !(_DWORD)NodeLists )
goto LABEL_70;
LODWORD(NodeLists) = MmInitializeProcessor(KeGetCurrentPrcb());
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 10;
goto LABEL_22;
}
NodeLists = (PHYSICAL_MEMORY_DESCRIPTOR *)MiReservePtes(
(_MI_SYSTEM_PTE_TYPE *)((char *)&stru_140C4DB30 + 4432),
1ui64);
*(&stru_140C4DB30 + 339) = NodeLists;
p_NumberOfRuns = &NodeLists->NumberOfRuns;
if( !NodeLists )
{
*(&stru_140C4DB30 + 2570) = 11;
goto LABEL_22;
}
Long = ZeroPte.u.Long;
LOBYTE(v22) = MiPteInShadowRange((UINT64)NodeLists);
if( v22 && (KeGetCurrentThread()->ApcState.Process->Flags3 & 0x1000) != 0 && (ZeroPte.u.Long & 1) != 0 )
Long = ZeroPte.u.Long | 0x8000000000000000ui64;
*p_NumberOfRuns = Long;
MiFreeUnusedPfnPages(0i64);
for( j = 0i64; j < 0x29; ++j )
{
v24 = 0x1C5C0C00048i64;
if( _bittest64(&v24, j) )
v25 = 0;
else
v25 = 1;
IncludeType[j] = v25;
}
qword_140D57838 = KeQueryPerformanceCounter(0i64);
NodeLists = MmInitializeMemoryLimits((_LOADER_PARAMETER_BLOCK *)BugCheckParameter2, IncludeType);
if( !NodeLists || (NodeLists = MiConvertInitialMemoryBlock(&Irp, NodeLists), (v26 = NodeLists) == 0i64) )
{
*(&stru_140C4DB30 + 2570) = 12;
goto LABEL_22;
}
NodeLists = MiCreateNodeLists(&Irp, NodeLists);
*(_QWORD *)&qword_140C50AE0 = NodeLists;
if( !NodeLists )
{
*(&stru_140C4DB30 + 2570) = 13;
goto LABEL_22;
}
MiComputeNodeMemory(&Irp);
LODWORD(NodeLists) = MiFillPfnGaps();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 18;
goto LABEL_22;
}
LODWORD(NodeLists) = MiInitializeGapFrames(0xFFFFFFFFFFFFFFFFui64, (UINT64 *)&stru_140C4DB30 + 503);
if( !(_DWORD)NodeLists )
{
LABEL_70:
*(&stru_140C4DB30 + 2570) = 19;
goto LABEL_22;
}
qword_140D57840 = KeQueryPerformanceCounter(0i64);
LODWORD(NodeLists) = MiInitializePageFaultResources();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 21;
goto LABEL_22;
}
LODWORD(NodeLists) = MiBuildPagedPool();
if( !(_DWORD)NodeLists )
goto LABEL_22;
MmPhysicalMemoryBlock = v26;
MiCreatePfnBitMaps();
if( !(_DWORD)NodeLists )
{
*(&stru_140C4DB30 + 2570) = 15;
goto LABEL_22;
}
qword_140D57848 = KeQueryPerformanceCounter(0i64);
MiMarkLargePageRanges();
qword_140D57850 = KeQueryPerformanceCounter(0i64);
MiInitializeWsSwapping(&Irp);
if( (_UNKNOWN *)*(&stru_140C4DB30 + 27) != (_UNKNOWN *)((char *)&stru_140C4DB30 + 184) )
{
v27 = 16 * (*(&stru_140C4DB30 + 38) + 2);
Pool = MiAllocatePool(64i64, v27, 0x20206D4Dui64);
v29 = Pool;
if( Pool )
{
memmove(Pool, *(&stru_140C4DB30 + 27), v27);
*(&stru_140C4DB30 + 27) = v29;
}
}
if( *(&stru_140C4DB30 + 28) )
{
v30 = 16 * (*(&stru_140C4DB30 + 41) + 2);
v31 = MiAllocatePool(64i64, v30, 0x20206D4Dui64);
v32 = v31;
if( v31 )
{
memmove(v31, *(&stru_140C4DB30 + 28), v30);
*(&stru_140C4DB30 + 28) = v32;
}
}
LODWORD(Flags) = 0;
LOWORD(v35) = 0;
LODWORD(Free) = 1800170829;
ExInitializeNPagedLookasideListInternal(
(_NPAGED_LOOKASIDE_LIST *)((char *)&stru_140C4DB30 + 3152),
0i64,
NonPagedPool,
0x200ui64,
0x90ui64,
Free,
v35,
Flags,
Size,
Tag,
*(INT64 *)IncludeType,
v40);
LOBYTE(NodeLists) = 1;
return(int)NodeLists;
}Referenced by:
MmInitSystem