CmInitSystem1

UINT8 __stdcall CmInitSystem1(_LOADER_PARAMETER_BLOCK *LoaderBlock){
  LIST_ENTRY *v2; 
  LIST_ENTRY *v3; 
  WCHAR v4; 
  int *v5; 
  __int64 v6; 
  int ObjectTypes; 
  int v8; 
  int v9; 
  int Hive; 
  int v11; 
  INT64 v12; 
  int inited; 
  UINT8 v14; 
  void *v15; 
  NTSTATUS v16; 
  ULONG_PTR v17; 
  NTSTATUS v18; 
  ULONG_PTR v19; 
  NTSTATUS v20; 
  ULONG_PTR v21; 
  NTSTATUS v22; 
  ULONG_PTR v23; 
  NTSTATUS v24; 
  NTSTATUS ControlSet; 
  int v26; 
  INT64 v27; 
  ULONG_PTR v28; 
  int v29; 
  __int64 v30; 
  __int64 v31; 
  struct _LOOKASIDE_LIST_EX *v32; 
  NTSTATUS v33; 
  INT64 v34; 
  WCHAR v35; 
  int v36; 
  int ExtendedControlSets; 
  int v38; 
  int v39; 
  __int64 v40; 
  _NETWORK_LOADER_BLOCK *v41; 
  int v42; 
  int v43; 
  PUNICODE_STRING Class; 
  UINT64 CreateOptions; 
  UINT64 CreateOptionsa; 
  UINT64 CreateOptionsb; 
  UINT64 Flags; 
  UINT64 Flagsa; 
  void *KeyHandle; 
  INT64 a1; 
  struct _OBJECT_ATTRIBUTES ObjectAttributes; 
  struct _UNICODE_STRING DestinationString; 
  KAPC_STATE ApcState; 
  _DWORD result[76]; 
  __int128 BugCheckParameter4[27]; 
  KeyHandle = 0i64;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  a1 = 0i64;
  memset((INT64)result, 0i64);
  DestinationString = 0i64;
  memset((INT64)BugCheckParameter4, 0i64);
  memset(&ApcState, 0, sizeof(ApcState));
  CmpInitializeParseContext((__int64)result);
  CmIoFileObjectType = (__int64)&IoFileObjectType;
  if( InitIsWinPEMode )
  {
    CmpMiniNTBoot = InitIsWinPEMode;
    BYTE4(NlsMbCodePageTag) = 1;
    CmpForceSynchronousMachineHiveLoad = 1;
  }
  if( CmpVolatileBoot )
    BYTE4(NlsMbCodePageTag) = 1;
  CmpInitializeRegistryNames();
  CmpInitGlobalQuotaAllowed();
  CmpHiveListHeadLock = 0i64;
  qword_140D2D918 = (__int64)&CmpHiveListHead;
  CmpHiveListHead = (__int64)&CmpHiveListHead;
  CmpLoadHiveLock = 0i64;
  CmpShutdownLock = 0i64;
  ExInitializePushLock((EX_RUNDOWN_REF *)&CmpShutdownRundown);
  CmpActiveHiveRundownEvent.0 = 0i64;
  qword_140C47DA8 = (__int64)&CmpAppHiveLoadList;
  CmpAppHiveLoadList = (__int64)&CmpAppHiveLoadList;
  CmpActiveAppHiveUnloadEvent.0 = 0i64;
  CmpAppHiveLoadListLock = 0i64;
  ExInitializeResourceLite((PERESOURCE)&CmpRegistryLock);
  CmpPostLock.Count = 1;
  CmpPostLock.Event.Header.WaitListHead.Blink = &CmpPostLock.Event.Header.WaitListHead;
  CmpPostLock.Event.Header.WaitListHead.Flink = &CmpPostLock.Event.Header.WaitListHead;
  CmpAsyncKernelPostList.Buffer = (wchar_t *)&CmpAsyncKernelPostList;
  *(_QWORD *)&CmpAsyncKernelPostList.Length = &CmpAsyncKernelPostList;
  CmpWorkerEngineWorkItem.WorkerRoutine = (void(__fastcall *)(void *))CmpWorkerEngineWorker;
  CmpPostLock.Owner = 0i64;
  CmpPostLock.Contention = 0;
  LOWORD(CmpPostLock.Event.Header.Lock) = 1;
  CmpPostLock.Event.Header.Size = 6;
  CmpPostLock.Event.Header.SignalState = 0;
  CmpWorkerEngineWorkItem.Parameter = 0i64;
  CmpWorkerEngineWorkItem.List.Flink = 0i64;
  KeInitializeGuardedMutex(&CmpWorkerEngineLock);
  CmpWorkerEngineFinishedEvent.0 = 0i64;
  qword_140C47E58 = (__int64)CmpWorkerEngineListHead;
  *(_QWORD *)CmpWorkerEngineListHead = CmpWorkerEngineListHead;
  CmpInitializeNameCache(v3, v2);
  CmpInitCmPrivateAlloc();
  CmpInitSIDToHiveMapping();
  CmpAdminSystemFileSecurityDescriptor = CmpAdminSystemSecurityDescriptor();
  CmpInitializeTrustedInstallerSid();
  CmpInitializeDelayedCloseTable();
  CmpInitCallbacks();
  CmpInitializeMachineHiveLoadedCallbacks();
  CmpInitializeFreezeThaw();
  HvInitializeHashLibrary();
  CmpValidateGlobalFlushControlFlags();
  CmpInitializeGlobalKeyLockTracker();
  CmpInitializeTransactions();
  CmpVolumeManagerInitialize();
  v5 = dword_140C0154C;
  v6 = 8i64;
  do
  {
    RtlInitUnicodeString(&DestinationString, *(PCWSTR *)(v5 - 3), v4);
    *v5 = CmpHashUnicodeComponent(&DestinationString);
    v5 += 6;
    --v6;
  }
  while( v6 );
  ObjectTypes = CmpCreateObjectTypes();
  if( ObjectTypes < 0 )
    KeBugCheckEx(0x67u, 1ui64, 1ui64, ObjectTypes, 0i64);
  v8 = CmpInitializeLightWeightTransactionType();
  if( v8 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x18ui64, v8, 0i64);
  v9 = CmpInitializeRegistryProcess();
  if( v9 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x19ui64, v9, 0i64);
  CmpAttachToRegistryProcess(&ApcState);
  CmpLockRegistryExclusive();
  CmpInitializePreloadedHives(LoaderBlock, 0i64);
  LODWORD(Flags) = 0;
  Hive = CmpCreateHive(
           (INT64)&CmpMasterHive,
           0i64,
           1ui64,
           0i64,
           0i64,
           0i64,
           0i64,
           Flags,
           0i64,
           0i64,
           0i64,
           (INT64)BugCheckParameter4);
  if( Hive < 0 )
    KeBugCheckEx(0x67u, 1ui64, 2ui64, Hive, (ULONG_PTR)BugCheckParameter4);
  v11 = CmpInitializeKcbCache(CmpMasterHive, 0x80u);
  if( v11 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 3ui64, v11, 0i64);
  if( !CmpCreateRegistryRoot() )
    KeBugCheckEx(0x67u, 1ui64, 4ui64, 0i64, 0i64);
  v12 = HalSystemVectorDispatchEntry();
  inited = CmpInitSiloSupport(v12);
  if( inited < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x1Aui64, inited, 0i64);
  v15 = CmpHiveRootSecurityDescriptor(v14);
  LODWORD(CreateOptions) = 0;
  ObjectAttributes.ObjectName = &CmRegistryMachineName;
  ObjectAttributes.Length = 48;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.Attributes = 576;
  ObjectAttributes.SecurityDescriptor = v15;
  ObjectAttributes.SecurityQualityOfService = 0i64;
  v16 = ZwCreateKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, 0i64, (UNICODE_STRING *)nullclass, CreateOptions, 0i64);
  v17 = v16;
  if( v16 < 0 )
  {
    ExFreePoolWithTag(v15, 0);
    KeBugCheckEx(0x67u, 1ui64, 5ui64, v17, 0i64);
  }
  ZwClose(KeyHandle);
  ObjectAttributes.ObjectName = &CmRegistryUserName;
  LODWORD(CreateOptionsa) = 0;
  ObjectAttributes.Length = 48;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.Attributes = 576;
  ObjectAttributes.SecurityDescriptor = v15;
  ObjectAttributes.SecurityQualityOfService = 0i64;
  v18 = ZwCreateKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, 0i64, (UNICODE_STRING *)nullclass, CreateOptionsa, 0i64);
  v19 = v18;
  if( v18 < 0 )
  {
    ExFreePoolWithTag(v15, 0);
    KeBugCheckEx(0x67u, 1ui64, 6ui64, v19, 0i64);
  }
  ZwClose(KeyHandle);
  ObjectAttributes.ObjectName = &CmRegistryAppName;
  ObjectAttributes.Length = 48;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.Attributes = 576;
  ObjectAttributes.SecurityDescriptor = v15;
  ObjectAttributes.SecurityQualityOfService = 0i64;
  result[0] = 65;
  v20 = ObOpenObjectByName(
          (__int64)&ObjectAttributes,
          (__int64)CmKeyObjectType,
          0,
          0i64,
          0x2001Fu,
          (__int64)result,
          &KeyHandle);
  v21 = v20;
  if( v20 < 0 )
  {
    ExFreePoolWithTag(v15, 0);
    CmpCleanupParseContext((__int64)result, 0);
    KeBugCheckEx(0x67u, 1ui64, 7ui64, v21, 0i64);
  }
  CmpCleanupParseContext((__int64)result, 0);
  ZwClose(KeyHandle);
  ObjectAttributes.ObjectName = &CmRegistryContainersName;
  LODWORD(CreateOptionsb) = 0;
  ObjectAttributes.Length = 48;
  ObjectAttributes.RootDirectory = 0i64;
  ObjectAttributes.Attributes = 576;
  ObjectAttributes.SecurityDescriptor = v15;
  ObjectAttributes.SecurityQualityOfService = 0i64;
  v22 = ZwCreateKey(&KeyHandle, 0x2001Fui64, &ObjectAttributes, 0i64, (UNICODE_STRING *)nullclass, CreateOptionsb, 0i64);
  v23 = v22;
  if( v22 < 0 )
  {
    ExFreePoolWithTag(v15, 0);
    KeBugCheckEx(0x67u, 1ui64, 8ui64, v23, 0i64);
  }
  ZwClose(KeyHandle);
  CmpNoMasterCreates = 1;
  CmpInitializeLoadOptions(LoaderBlock);
  v24 = CmpInitializePreloadedHives(LoaderBlock, 1ui64);
  if( v24 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x14ui64, v24, 0i64);
  ControlSet = CmpCreateControlSet((_LOADER_PARAMETER_BLOCK *)L"SYSTEM");
  if( ControlSet < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0xDui64, ControlSet, 0i64);
  if( CmpLKGEnabled )
    KUSER_SHARED_DATA.SharedDataFlags |= 0x10u;
  if( CmStateSeparationEnabled )
    CmpUpdateStateSeparationHiveOptions();
  memset((INT64)BugCheckParameter4, 0i64);
  LODWORD(Flagsa) = 0;
  v26 = CmpCreateHive(
          (INT64)&a1,
          0i64,
          1ui64,
          0i64,
          0i64,
          0i64,
          0i64,
          Flagsa,
          0i64,
          0i64,
          0i64,
          (INT64)BugCheckParameter4);
  v28 = v26;
  if( v26 < 0 )
  {
    ExFreePoolWithTag(v15, 0);
    KeBugCheckEx(0x67u, 1ui64, 0x10ui64, v28, (ULONG_PTR)BugCheckParameter4);
  }
  LOBYTE(v27) = 1;
  LODWORD(Class) = KcbCacheSize;
  v29 = CmpLinkHiveToMaster(
          &CmRegistryMachineHardwareName,
          0i64,
          (_CMHIVE *)a1,
          v27,
          (UINT64)Class,
          0,
          0i64,
          v15,
          0i64,
          0i64,
          1u);
  if( v29 )
    KeBugCheckEx(0x67u, 1ui64, 0x11ui64, v29, 0i64);
  CmpAddToHiveFileList(a1, v30, v31, v32);
  ExFreePoolWithTag(v15, 0);
  qword_140C00F18 = a1;
  v33 = CmpInitializeHardwareConfiguration(LoaderBlock);
  if( v33 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x12ui64, v33, 0i64);
  v36 = CmpInitializeDriverStores((INT64)LoaderBlock, v34, v35);
  if( v36 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x13ui64, v36, 0i64);
  ExtendedControlSets = CmpCreateExtendedControlSets((INT64)LoaderBlock);
  if( ExtendedControlSets < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x1Bui64, ExtendedControlSets, 0i64);
  CmpCreateHardwareProfiles((INT64)LoaderBlock);
  CmSetInitMachineConfig(LoaderBlock);
  CmpUnlockRegistry();
  CmpMarkCurrentProfileDirty();
  v38 = CmpInitializeMachineDependentConfiguration(LoaderBlock);
  if( v38 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x15ui64, v38, 0i64);
  v39 = CmpSetSystemValues(LoaderBlock);
  if( v39 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x16ui64, v39, 0i64);
  CmpMigrateOOBELanguageToInstallationLanguage();
  ExFreePoolWithTag(CmpLoadOptions.Buffer, 0);
  v40 = *((_QWORD *)LoaderBlock + 30);
  if( *(_DWORD *)v40 >= 0x68u )
  {
    v41 = *(_NETWORK_LOADER_BLOCK **)(v40 + 96);
    if( v41 )
    {
      v42 = CmpSetNetworkValue(v41);
      if( v42 < 0 )
        KeBugCheckEx(0x67u, 1ui64, 0x17ui64, v42, 0i64);
    }
  }
  v43 = CmFcInitSystem2();
  if( v43 < 0 )
    KeBugCheckEx(0x67u, 1ui64, 0x1Aui64, v43, 0i64);
  CmpDetachFromRegistryProcess(&ApcState);
  return 1;
}

Referenced by:

Phase1InitializationDiscard