IoInitSystemPreDrivers

UINT8 __stdcall IoInitSystemPreDrivers(_LOADER_PARAMETER_BLOCK *LoaderBlock){
  unsigned __int64 v2; 
  int v3; 
  unsigned int ActiveProcessorCount; 
  __int64 v5; 
  unsigned int v6; 
  _DWORD *v7; 
  INT64 v8; 
  unsigned int v9; 
  int v10; 
  __int64 v11; 
  int v12; 
  _KIRQL v13; 
  char v14; 
  int v15; 
  INT64 v16; 
  INT64 v17; 
  _BYTE *v18; 
  ULONG v19; 
  NTSTATUS SystemDlls; 
  bool IsStateSeparationDevModeEnabled; 
  INT64 Size; 
  UINT64 Sizea; 
  UINT64 Sizeb; 
  VOID **Tag; 
  VOID **Taga; 
  VOID **Tagb; 
  VOID **Tagc; 
  _RTL_AVL_TABLE *Depth; 
  _RTL_AVL_TABLE *Deptha; 
  _RTL_AVL_TABLE *Depthb; 
  INT64 v33; 
  VOID *v34; 
  VOID *v35; 
  VOID *FreeRoutine; 
  VOID *KeyHandle; 
  UINT64 ResultLength; 
  PVOID Object; 
  _OBJECT_ATTRIBUTES ObjectAttributes; 
  _UNICODE_STRING DestinationString; 
  _STRING NtDeviceName; 
  _DRIVER_OBJECT *PreviousDriver; 
  ULONG_PTR Context; 
  ULONG_PTR v45; 
  __int128 v46; 
  __int64 v47; 
  _IO_STATUS_BLOCK IoStatusBlock; 
  _IO_PROC_INIT_VALUES InitValues; 

  *(_QWORD *)&NtDeviceName.Length = 0x1000000i64;
  v47 = 0i64;
  PreviousDriver = 0i64;
  *(&ObjectAttributes.Length + 1) = 0;
  *(&ObjectAttributes.Attributes + 1) = 0;
  KeyHandle = 0i64;
  v46 = 0i64;
  LOBYTE(FreeRoutine) = 0;
  DestinationString = 0i64;
  NtDeviceName.Buffer = (char *)IoInitSystem_deviceNameBuffer;
  IoStatusBlock = 0i64;
  memset(&InitValues, 0, sizeof(InitValues));
  ExInitializeResourceLite((INT64)&stru_140C452E0 + 1152);
  ExInitializeResourceLite((INT64)&stru_140C452E0 + 1280);
  ExInitializeResourceLite((INT64)&stru_140C452E0 + 1408);
  ExInitializeResourceLite((INT64)&stru_140C452E0 + 6976);
  ExInitializeResourceLite((INT64)&stru_140C452E0 + 704);
  ExInitializePushLock((PULONG_PTR)&stru_140C452E0 + 173);
  *(&stru_140C452E0 + 206) = 0i64;
  *(&stru_140C452E0 + 195) = (char *)&stru_140C452E0 + 1552;
  *(&stru_140C452E0 + 194) = (char *)&stru_140C452E0 + 1552;
  *(&stru_140C452E0 + 197) = (char *)&stru_140C452E0 + 1568;
  *(&stru_140C452E0 + 196) = (char *)&stru_140C452E0 + 1568;
  *(&stru_140C452E0 + 191) = (char *)&stru_140C452E0 + 1520;
  *(&stru_140C452E0 + 190) = (char *)&stru_140C452E0 + 1520;
  *(&stru_140C452E0 + 193) = (char *)&stru_140C452E0 + 1536;
  *(&stru_140C452E0 + 192) = (char *)&stru_140C452E0 + 1536;
  *(&stru_140C452E0 + 203) = (char *)&stru_140C452E0 + 1616;
  *(&stru_140C452E0 + 202) = (char *)&stru_140C452E0 + 1616;
  *(&stru_140C452E0 + 205) = (char *)&stru_140C452E0 + 1632;
  *(&stru_140C452E0 + 204) = (char *)&stru_140C452E0 + 1632;
  *(&stru_140C452E0 + 199) = (char *)&stru_140C452E0 + 1584;
  *(&stru_140C452E0 + 198) = (char *)&stru_140C452E0 + 1584;
  *(&stru_140C452E0 + 201) = (char *)&stru_140C452E0 + 1600;
  *(&stru_140C452E0 + 200) = (char *)&stru_140C452E0 + 1600;
  *(&stru_140C452E0 + 209) = (char *)&stru_140C452E0 + 1664;
  *(&stru_140C452E0 + 208) = (char *)&stru_140C452E0 + 1664;
  *(&stru_140C452E0 + 211) = (char *)&stru_140C452E0 + 1680;
  *(&stru_140C452E0 + 210) = (char *)&stru_140C452E0 + 1680;
  *(_QWORD *)&IoStatisticsLock = 0i64;
  *(&stru_140C452E0 + 213) = 0i64;
  *(&stru_140C452E0 + 107) = 0i64;
  *(&stru_140C452E0 + 424) = 0;
  *(&stru_140C452E0 + 286) = 0;
  v2 = __rdtsc() >> 4;
  v3 = 0;
  *(_QWORD *)((char *)&stru_140C452E0 + 1700) = (unsigned int)(v2 % 0x64) + 10;
  if( !*(&stru_140C452E0 + 711) )
  {
    *(&stru_140C452E0 + 711) = 14;
    v3 = 1;
    *(&stru_140C452E0 + 286) = 1;
  }
  if( !*(&stru_140C452E0 + 710) )
  {
    *(&stru_140C452E0 + 710) = 4;
    *(&stru_140C452E0 + 286) = v3 | 2;
  }
  if( (unsigned int)(dword_140C50A18 - 2) > 0x12A )
    dword_140C50A18 = 300;
  IopQueryProcessorInitValues(&InitValues);
  ExInitializeSystemLookasideList(
    (unsigned int)&IopCompletionLookasideList,
    512,
    56,
    544236361,
    InitValues.CompletionZoneSize,
    (__int64)&WheapDeferredInternalLogsEventLock + 2896);
  ExInitializeSystemLookasideList(
    (unsigned int)&IopLargeIrpLookasideList,
    512,
    InitValues.LargePacketSize,
    1819308617,
    InitValues.LargeIrpZoneSize,
    (__int64)&WheapDeferredInternalLogsEventLock + 2896);
  ExInitializeSystemLookasideList(
    (unsigned int)&IopMediumIrpLookasideList,
    512,
    InitValues.MediumPacketSize,
    1836085833,
    InitValues.MediumIrpZoneSize,
    (__int64)&WheapDeferredInternalLogsEventLock + 2896);
  ExInitializeSystemLookasideList(
    (unsigned int)&IopSmallIrpLookasideList,
    512,
    InitValues.SmallPacketSize,
    1936749129,
    InitValues.SmallIrpZoneSize,
    (__int64)&WheapDeferredInternalLogsEventLock + 2896);
  ExInitializeSystemLookasideList(
    (unsigned int)&IopMdlLookasideList,
    512,
    InitValues.MdlPacketSize,
    543974477,
    InitValues.MdlZoneSize,
    (__int64)&WheapDeferredInternalLogsEventLock + 2896);
  ExInitializeNPagedLookasideList(&IopSafeCompletionLookasideList, 0i64, 0i64, 0x200u, 32, 0x73556F49u, 0);
  FsRtlInitExtraCreateParameterLookasideList((char *)&WheapErrorSourceTable + 2856, 0i64, 0x11Eui64, 0x69536F49ui64);
  ExInitializeNPagedLookasideList(
    (PNPAGED_LOOKASIDE_LIST)((char *)&WheapErrorSourceTable + 2984),
    0i64,
    0i64,
    0x200u,
    48,
    0x7443704Fu,
    0);
  ActiveProcessorCount = KeQueryActiveProcessorCountEx(0xFFFFu);
  v5 = 0i64;
  v6 = ActiveProcessorCount;
  for( LODWORD(ResultLength) = 0; (unsigned int)v5 < v6; LODWORD(ResultLength) = v5 )
  {
    IoInitializeProcessor(*(&KiProcessorBlock + v5), &InitValues);
    v5 = (unsigned int)(ResultLength + 1);
  }
  IopErrorLogLock = 0i64;
  *(&stru_140C452E0 + 219) = (char *)&stru_140C452E0 + 1744;
  *(&stru_140C452E0 + 218) = (char *)&stru_140C452E0 + 1744;
  if( IopInitializeReserveIrps() )
  {
    if( (*(&stru_140C452E0 + 1144) & 3) != 0 )
    {
      *(&stru_140C452E0 + 432) = 400;
      *(&stru_140C452E0 + 255) = IopIrpStackProfilerDpcRoutine;
      *(&stru_140C452E0 + 286) |= 4u;
      *(&stru_140C452E0 + 433) = 2000;
      *(&stru_140C452E0 + 504) = 275;
      *(&stru_140C452E0 + 256) = 0i64;
      *(&stru_140C452E0 + 259) = 0i64;
      *(&stru_140C452E0 + 254) = 0i64;
    }
    v7 = IopRevocationExtension;
    memset(IopRevocationExtension, 0i64, 0x58u);
    *v7 = 4;
    v9 = IopDiskIoAttributionBaseIoSize;
    if( (unsigned int)IopDiskIoAttributionBaseIoSize >= 0x400000 )
    {
      v9 = 0x400000;
      IopDiskIoAttributionBaseIoSize = 0x400000;
    }
    if( v9 <= 0x1000 )
      IopDiskIoAttributionBaseIoSize = 4096;
    ObjectAttributes.Length = 48;
    ObjectAttributes.ObjectName = &CmRegistryMachineSystemCurrentControlSetServicesEventLog;
    ObjectAttributes.RootDirectory = 0i64;
    ObjectAttributes.Attributes = 576;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    if( ZwOpenKey(&KeyHandle, 0x20019ui64, &ObjectAttributes, v8, Size, (INT64)Tag, (INT64)Depth, v33) < 0 )
    {
      *(&stru_140C452E0 + 613) = 1;
    }
    else
    {
      RtlInitUnicodeString(&DestinationString, L"Start");
      LODWORD(Sizea) = 32;
      *(&stru_140C452E0 + 613) = NtQueryValueKey(
                                   KeyHandle,
                                   &DestinationString,
                                   KeyValuePartialInformation,
                                   IoInitSystem_valueBuffer,
                                   Sizea,
                                   &ResultLength) < 0
                              || dword_140D57944 != 4
                              || dword_140D5794C == 4;
      ObCloseHandle(KeyHandle, 0);
    }
    *(&stru_140C452E0 + 264) = 9i64;
    *(&stru_140C452E0 + 261) = (char *)&stru_140C452E0 + 2080;
    *(&stru_140C452E0 + 260) = (char *)&stru_140C452E0 + 2080;
    IopTimerLock = 0i64;
    *(&stru_140C452E0 + 279) = IopTimerDispatch;
    *(&stru_140C452E0 + 280) = (char *)&stru_140C452E0 + 2096;
    *(&stru_140C452E0 + 266) = (char *)&stru_140C452E0 + 2120;
    *(&stru_140C452E0 + 265) = (char *)&stru_140C452E0 + 2120;
    *(&stru_140C452E0 + 273) = (char *)&stru_140C452E0 + 2176;
    *(&stru_140C452E0 + 272) = (char *)&stru_140C452E0 + 2176;
    *(&stru_140C452E0 + 302) = IopHardErrorThread;
    *(&stru_140C452E0 + 305) = (char *)&stru_140C452E0 + 2432;
    *(&stru_140C452E0 + 304) = (char *)&stru_140C452E0 + 2432;
    *(&stru_140C452E0 + 309) = (char *)&stru_140C452E0 + 2464;
    *(&stru_140C452E0 + 308) = (char *)&stru_140C452E0 + 2464;
    *(&stru_140C452E0 + 286) = IopKeepAliveWorker;
    *(&stru_140C452E0 + 289) = (char *)&stru_140C452E0 + 2304;
    *(&stru_140C452E0 + 288) = (char *)&stru_140C452E0 + 2304;
    *(&stru_140C452E0 + 552) = 275;
    *(&stru_140C452E0 + 283) = 0i64;
    *(&stru_140C452E0 + 278) = 0i64;
    *(&stru_140C452E0 + 267) = 0i64;
    *(&stru_140C452E0 + 543) = 0;
    *(&stru_140C452E0 + 1084) = 0;
    *(&stru_140C452E0 + 303) = 0i64;
    *(&stru_140C452E0 + 300) = 0i64;
    *(&stru_140C452E0 + 306) = 0i64;
    *(&stru_140C452E0 + 2456) = 5;
    *(&stru_140C452E0 + 2458) = 8;
    *(&stru_140C452E0 + 615) = 0;
    *(&stru_140C452E0 + 620) = 0x7FFFFFFF;
    *(&stru_140C452E0 + 2488) = 0;
    *(&stru_140C452E0 + 287) = 0i64;
    *(&stru_140C452E0 + 284) = 0i64;
    *(&stru_140C452E0 + 290) = 0i64;
    *(&stru_140C452E0 + 2360) = 0;
    *(&stru_140C452E0 + 614) = 1;
    RtlInitUnicodeString(&DestinationString, L"\\Security\\TRKWKS_EVENT");
    ObjectAttributes.Length = 48;
    ObjectAttributes.ObjectName = &DestinationString;
    ObjectAttributes.RootDirectory = 0i64;
    ObjectAttributes.Attributes = 528;
    *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
    if( NtCreateEvent((UINT64)&KeyHandle, 0x1F0003ui64, (INT64)&ObjectAttributes, 0i64, 0) < 0 )
    {
      HeadlessKernelAddLogEntry(4ui64, 0i64);
    }
    else
    {
      Object = 0i64;
      ObReferenceObjectByHandle(KeyHandle, 0i64, (_OBJECT_TYPE *)ExEventObjectType, 0, &Object, 0i64);
      IopLinkTrackingServiceEvent = (__int64)Object;
      *(&stru_140C452E0 + 314) = (char *)&stru_140C452E0 + 2504;
      *(&stru_140C452E0 + 313) = (char *)&stru_140C452E0 + 2504;
      *(&stru_140C452E0 + 322) = (char *)&stru_140C452E0 + 2568;
      *(&stru_140C452E0 + 321) = (char *)&stru_140C452E0 + 2568;
      *(&stru_140C452E0 + 326) = (char *)&stru_140C452E0 + 2600;
      *(&stru_140C452E0 + 325) = (char *)&stru_140C452E0 + 2600;
      *(&stru_140C452E0 + 1248) = 0;
      *(&stru_140C452E0 + 2498) = 6;
      *(&stru_140C452E0 + 625) = 0;
      *(&stru_140C452E0 + 1280) = 0;
      *(&stru_140C452E0 + 2562) = 6;
      *(&stru_140C452E0 + 641) = 0;
      *(&stru_140C452E0 + 1296) = 1;
      *(&stru_140C452E0 + 2594) = 6;
      *(&stru_140C452E0 + 649) = 1;
      ObCloseHandle(KeyHandle, 0);
      if( IopCreateRootDirectories() )
      {
        if( IopInitializeSessionNotifications() < 0 )
        {
          *(&stru_140C452E0 + 1770) = 15;
        }
        else
        {
          IopInitializePlugPlayServices(LoaderBlock, 0i64);
          if( v10 < 0 )
          {
            HeadlessKernelAddLogEntry(7ui64, 0i64);
            *(&stru_140C452E0 + 1770) = 4;
          }
          else
          {
            KseInitialize(LoaderBlock, 0i64);
            PoInitDriverServices();
            off_140C00AC0[0]();
            PnpMarkHalDeviceNode();
            if( WMIInitialize(0i64, LoaderBlock) )
            {
              if( !RtlIsStateSeparationEnabled()
                || (IsStateSeparationDevModeEnabled = CmIsStateSeparationDevModeEnabled(),
                    LOBYTE(v11) = 1,
                    IsStateSeparationDevModeEnabled) )
              {
                LOBYTE(v11) = 0;
              }
              v12 = ExpInitializeStateSeparationPhase0(v11);
              if( (int)(v12 + 0x80000000) < 0 || v12 == -1073741637 )
              {
                EtwInitialize(0i64);
                if( (int)EtwRegister(
                            (_LPCGUID)&IoTraceProvider,
                            (PETWENABLECALLBACK)IopEtwEnableCallback,
                            0i64,
                            (PREGHANDLE)&stru_140C452E0 + 328) < 0 )
                {
                  *(&stru_140C452E0 + 1770) = 16;
                }
                else if( (int)EtwRegister((_LPCGUID)&IoMgrProvider, 0i64, 0i64, (PREGHANDLE)&stru_140C452E0 + 327) < 0 )
                {
                  *(&stru_140C452E0 + 1770) = 11;
                }
                else
                {
                  SeAuditBootConfiguration((_DEVICE_OBJECT *)LoaderBlock->Extension->BootOptions);
                  BootApplicationPersistentDataProcess(1ui64);
                  BapdRecordFirmwareBootStats();
                  KdInitialize(2i64, 0i64, &KdpContext);
                  TraceLoggingRegisterEx_EtwRegister_EtwSetInformation((char *)&stru_140C00F40 + 2864);
                  if( !*(&stru_140C452E0 + 613) )
                  {
                    v14 = KeAcquireSpinLockRaiseToDpc(&IopErrorLogLock);
                    if( (_UNKNOWN *)*(&stru_140C452E0 + 218) == (_UNKNOWN *)((char *)&stru_140C452E0 + 1744) )
                    {
                      *(&stru_140C452E0 + 614) = 0;
                    }
                    else
                    {
                      *(&stru_140C452E0 + 83) = 0i64;
                      *(&stru_140C452E0 + 82) = IopErrorLogThread;
                      *(&stru_140C452E0 + 80) = 0i64;
                      ExQueueWorkItem((PWORK_QUEUE_ITEM)&stru_140C452E0 + 20, DelayedWorkQueue);
                    }
                    LOBYTE(v13) = v14;
                    KeReleaseSpinLock(&IopErrorLogLock, v13);
                  }
                  WheaInitialize(LoaderBlock, 0i64);
                  if( IopStoreArcInformation(LoaderBlock) >= 0 )
                  {
                    IopInitializePlugPlayServices(LoaderBlock, 1i64);
                    if( v15 < 0 )
                    {
                      HeadlessKernelAddLogEntry(8ui64, 0i64);
                      *(&stru_140C452E0 + 1770) = 5;
                    }
                    else
                    {
                      RtlInitializeGenericTableAvl(
                        (PRTL_AVL_TABLE)((char *)&stru_140C452E0 + 2656),
                        (PRTL_AVL_COMPARE_ROUTINE)IopCompareIosbRanges,
                        (PRTL_AVL_ALLOCATE_ROUTINE)IopAllocateGenericTableEntry,
                        (PRTL_AVL_FREE_ROUTINE)IopFreeGenericTableEntry,
                        0i64);
                      *(&stru_140C452E0 + 696) = 1;
                      *(&stru_140C452E0 + 353) = (char *)&stru_140C452E0 + 2816;
                      *(&stru_140C452E0 + 352) = (char *)&stru_140C452E0 + 2816;
                      *(&stru_140C452E0 + 349) = 0i64;
                      *(&stru_140C452E0 + 700) = 0;
                      *(&stru_140C452E0 + 1404) = 1;
                      *(&stru_140C452E0 + 2810) = 6;
                      *(&stru_140C452E0 + 703) = 0;
                      KitpInitAitSampleRate(LoaderBlock);
                      if( (int)EtwRegister(
                                  (_LPCGUID)&MS_Windows_AIT_Provider,
                                  0i64,
                                  0i64,
                                  (PREGHANDLE)&stru_140CF2E80 + 657) < 0 )
                        *(&stru_140CF2E80 + 657) = 0i64;
                      KseInitialize(LoaderBlock, 1ui64);
                      if( HvlPhase2Initialize(LoaderBlock) >= 0 )
                      {
                        v45 = KeQueryActiveProcessorCountEx(0xFFFFu);
                        Context = v45;
                        KeIpiGenericCall((PKIPI_BROADCAST_WORKER)KeOptimizeSpecCtrlSettings, (ULONG_PTR)&Context);
                        VslpIumPhase4Initialize();
                        if( RegHandle )
                          EtwWriteStartScenario(
                            RegHandle,
                            &KMPnPEvt_DriverInitPhase_Start,
                            &PnpDriverInitPhaseActivityId,
                            0,
                            0i64);
                        stru_140C452E0 = 1;
                        qword_140C452C8 = (__int64)&qword_140C452C0;
                        qword_140C452C0 = &qword_140C452C0;
                        *(&stru_140C452E0 + 2) = (char *)&stru_140C452E0 + 8;
                        *(&stru_140C452E0 + 1) = (char *)&stru_140C452E0 + 8;
                        *(&stru_140C452E0 + 2) = 6;
                        *(&stru_140C452E0 + 1) = 1;
                        if( IopInitializePassiveInterruptServices() >= 0 )
                        {
                          SecureDump_PrepareForInit(v16, &FreeRoutine);
                          if( *(&stru_140CF2E80 + 4800) || (_BYTE)FreeRoutine )
                            CapsuleDumpAllowed = 0;
                          else
                            IopInitDumpCapsuleSupport();
                          if( (_DWORD)ExLeapSecondDataLastParseResult )
                            EtwTraceLeapSecondDataParseFailure((unsigned int)ExLeapSecondDataLastParseResult);
                          EtwTraceLeapSecondDataUpdate(
                            0i64,
                            (unsigned __int8)**(&ExBootDevicesRemovedEvent + 103),
                            *(unsigned int *)(*(&ExBootDevicesRemovedEvent + 103) + 4i64),
                            0i64);
                          IopInitializeIoRate();
                          PsAltSystemCallRegistrationLock._bf_0 = 0i64;
                          PsAltSystemCallHandlers[0] = (__int64)PsPicoAltSystemCallDispatch;
                          if( (unsigned int)IopInitializeBootDrivers(LoaderBlock, &PreviousDriver) )
                          {
                            if( IopLoadBootHotPatches() < 0 )
                            {
                              *(&stru_140C452E0 + 1770) = 21;
                            }
                            else
                            {
                              if( !PoInitSystem(2ui64, LoaderBlock) )
                                KeBugCheck(0xA0u);
                              SmInitSystem(1ui64);
                              EtwInitialize(1ui64);
                              LOBYTE(FreeRoutine) = 0;
                              if( VslVsmEnabled )
                              {
                                LODWORD(Sizeb) = 1;
                                if( NtPowerInformation(PlatformInformation, 0i64, 0i64, &FreeRoutine, Sizeb) >= 0 )
                                {
                                  if( (_BYTE)FreeRoutine )
                                  {
                                    ExSubscribeWnfStateChange(
                                      (INT8 **)&stru_140C452E0 + 957,
                                      (INT64 *)&WNF_PO_SCENARIO_CHANGE,
                                      1i64,
                                      0i64,
                                      (INT64)VslpConnectedStandbyWnfCallback,
                                      0i64);
                                    PoRegisterPowerSettingCallback(
                                      0i64,
                                      &GUID_LOW_POWER_EPOCH,
                                      (INT64)VslpConnectedStandbyPoCallback,
                                      0i64,
                                      0i64,
                                      Tagb,
                                      (UINT64)Deptha,
                                      v34,
                                      FreeRoutine,
                                      (VOID **)KeyHandle);
                                    PoRegisterPowerSettingCallback(
                                      0i64,
                                      &GUID_PDC_IDLE_RESILIENCY_ENGAGED,
                                      (INT64)VslpConnectedStandbyPoCallback,
                                      0i64,
                                      0i64,
                                      Tagc,
                                      (UINT64)Depthb,
                                      v35,
                                      FreeRoutine,
                                      (VOID **)KeyHandle);
                                  }
                                }
                              }
                              IopInitializeSystemVariableService(v18, v17);
                              if( !*(&stru_140CF2E80 + 4800) )
                              {
                                EtwRegister(
                                  (_LPCGUID)&LiveDumpProvGuid,
                                  (PETWENABLECALLBACK)IopLiveDumpTracingControlCallback,
                                  0i64,
                                  (PREGHANDLE)&stru_140CF2E80 + 602);
                                TraceLoggingRegisterEx_EtwRegister_EtwSetInformation(&dword_140C04498);
                              }
                              IopInitializeTriageDumpData();
                              if( IopInitCrashDumpDuringSysInit(LoaderBlock) >= 0 )
                                IopRemoveDumpCapsuleSupport();
                              if( !RtlIsStateSeparationEnabled() )
                                PpLastGoodDoBootProcessing();
                              v19 = NtGlobalFlag;
                              NtGlobalFlag |= 0x40000u;
                              SystemDlls = PsLocateSystemDlls();
                              NtGlobalFlag = v19;
                              if( SystemDlls < 0 )
                              {
                                HeadlessKernelAddLogEntry(0xAui64, 0i64);
                                *(&stru_140C452E0 + 1770) = 7;
                              }
                              else
                              {
                                PfSnBeginBootPhase(0i64);
                                if( IopReassignSystemRoot(LoaderBlock, &NtDeviceName) )
                                {
                                  if( IopProtectSystemPartition(LoaderBlock) )
                                  {
                                    if( *(&stru_140CF2E80 + 981) )
                                    {
                                      LODWORD(Taga) = 0;
                                      ObjectAttributes.ObjectName = (_UNICODE_STRING *)(PsLoadedModuleList + 72);
                                      ObjectAttributes.Length = 48;
                                      ObjectAttributes.RootDirectory = 0i64;
                                      ObjectAttributes.Attributes = 576;
                                      *(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
                                      LODWORD(Sizeb) = 1;
                                      if( ZwOpenFile(
                                             &KeyHandle,
                                             0x80000000ui64,
                                             &ObjectAttributes,
                                             &IoStatusBlock,
                                             Sizeb,
                                             (UINT64)Taga) >= 0 )
                                      {
                                        Object = 0i64;
                                        if( ObReferenceObjectByHandle(KeyHandle, 0x80ui64, 0i64, 0, &Object, 0i64) >= 0 )
                                        {
                                          PpPagePathAssign((_FILE_OBJECT *)Object);
                                          HalPutDmaAdapter((PADAPTER_OBJECT)Object);
                                        }
                                        ZwClose((_HANDLE)KeyHandle);
                                      }
                                    }
                                    if( WMIInitialize(1ui64, 0i64) )
                                    {
                                      WheaInitialize(LoaderBlock, 1ui64);
                                      return 1;
                                    }
                                  }
                                  else
                                  {
                                    HeadlessKernelAddLogEntry(0xDui64, 0i64);
                                    *(&stru_140C452E0 + 1770) = 10;
                                  }
                                }
                                else
                                {
                                  HeadlessKernelAddLogEntry(0xCui64, 0i64);
                                  *(&stru_140C452E0 + 1770) = 9;
                                }
                              }
                            }
                          }
                          else
                          {
                            HeadlessKernelAddLogEntry(9ui64, 0i64);
                            *(&stru_140C452E0 + 1770) = 6;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
      else
      {
        HeadlessKernelAddLogEntry(6ui64, 0i64);
        *(&stru_140C452E0 + 1770) = 3;
      }
    }
  }
  else
  {
    *(&stru_140C452E0 + 1770) = 1;
  }
  return 0;
}

Referenced by:

IoInitSystem