IopInitializeSystemDrivers

UINT64 __stdcall IopInitializeSystemDrivers(){
  UINT8 IsManufacturingModeEnabled; 
  VOID **SystemDriverList; 
  VOID **v2; 
  VOID **v3; 
  void *v4; 
  _DRIVER_OBJECT *v5; 
  _KEY_VALUE_FULL_INFORMATION *v6; 
  _TREE_ENTRY *v7; 
  int v8; 
  void *v9; 
  int v11; 
  _UNICODE_STRING KeyName; 
  _UNICODE_STRING GroupName; 
  _UNICODE_STRING DriverName; 
  INT64 DriverEntryStatus; 
  _KEY_VALUE_FULL_INFORMATION *Information; 
  VOID *Handle; 

  LODWORD(DriverEntryStatus) = 0;
  Handle = 0i64;
  Information = 0i64;
  GroupName = 0i64;
  KeyName = 0i64;
  DriverName = 0i64;
  PnpDiagnosticTrace(&KMPnPEvt_SystemStart_Start, 0, 0i64);
  IsManufacturingModeEnabled = ExIsManufacturingModeEnabled();
  SystemDriverList = CmGetSystemDriverList(*(&ExBootDevicesRemovedEvent + 142) & -(__int64)(IsManufacturingModeEnabled != 0));
  v2 = SystemDriverList;
  if( SystemDriverList )
  {
    v3 = SystemDriverList;
    v4 = *SystemDriverList;
    if( v4 )
    {
      do
      {
        if( IopGetDriverNameFromKeyNode(v4, &DriverName) >= 0
          && (v5 = IopReferenceDriverObjectByName(&DriverName), RtlFreeAnsiString(&DriverName), v5) )
        {
          ObfDereferenceObjectWithTag(v5, 0x746C6644ui64);
        }
        else
        {
          *(_DWORD *)&KeyName.Length = 655368;
          KeyName.Buffer = L"Enum";
          if( IopOpenRegistryKeyEx(&Handle, *v2, &KeyName, 0x20019ui64) < 0 )
            goto LABEL_6;
          v11 = 0;
          if( IopGetRegistryValue(Handle, (PWCHAR)L"INITSTARTFAILED", 0i64, &Information) >= 0 )
          {
            if( Information->DataLength == 4 )
              v11 = *(ULONG *)((char *)&Information->TitleIndex + Information->DataOffset);
            ExFreePoolWithTag(Information, 0);
          }
          ZwClose((_HANDLE)Handle);
          if( !v11 )
          {
LABEL_6:
            if( IopGetRegistryValue(*v2, (PWCHAR)L"Group", 0i64, &Information) < 0 )
            {
              v7 = 0i64;
            }
            else
            {
              v6 = Information;
              if( Information->DataLength )
              {
                GroupName.Length = Information->DataLength;
                GroupName.MaximumLength = GroupName.Length;
                GroupName.Buffer = (wchar_t *)((char *)Information + Information->DataOffset);
                v7 = PipLookupGroupName(&GroupName, 1ui64);
              }
              else
              {
                v7 = 0i64;
              }
              ExFreePoolWithTag(v6, 0);
            }
            v8 = PipCheckDependencies(*v2);
            v9 = *v2;
            if( v8 )
            {
              if( IopLoadDriver(v9, 1u, 0, &DriverEntryStatus) >= 0 && v7 )
                ++v7[7];
            }
            else
            {
              ZwClose((_HANDLE)v9);
            }
            InbvIndicateProgress();
            goto LABEL_15;
          }
        }
        ZwClose((_HANDLE)*v2);
LABEL_15:
        v4 = *++v2;
      }
      while( *v2 );
    }
    ExFreePoolWithTag(v3, 0);
  }
  PnpRequestDeviceAction(*(PVOID *)(*(&PnpReplaceEvent + 831) + 32i64), 17, 0, 0i64, 0i64, 0i64, 0i64);
  if( !PnpBootOptions )
    PnpWaitForDevicesToStart();
  PnpRequestDeviceAction(*(PVOID *)(*(&PnpReplaceEvent + 831) + 32i64), 18, 0, 0i64, 0i64, 0i64, 0i64);
  if( *(&stru_140C452E0 + 62) )
    PipFreeGroupTree(*(&stru_140C452E0 + 62));
  PnpDiagnosticTrace(&KMPnPEvt_SystemStart_Stop, 0, 0i64);
  return 1i64;
}

Referenced by:

IoInitSystem