MmCallDllInitialize

VOID __fastcall MmCallDllInitialize(_KLDR_DATA_TABLE_ENTRY *DataTableEntry, _LIST_ENTRY *ModuleListHead){
  void *DllBase; 
  __int64(__fastcall *ExportedRoutineByName)(_UNICODE_STRING *); 
  unsigned __int16 Length; 
  wchar_t *Pool; 
  wchar_t *v8; 
  unsigned int v9; 
  wchar_t *Buffer; 
  unsigned __int16 v11; 
  WORD *v12; 
  unsigned int inited; 
  int v14; 
  _UNICODE_STRING Destination; 
  _UNICODE_STRING Source; 

  DllBase = DataTableEntry->DllBase;
  Destination = 0i64;
  Source = 0i64;
  ExportedRoutineByName = (__int64(__fastcall *)(_UNICODE_STRING *))RtlFindExportedRoutineByName(
                                                                       DllBase,
                                                                       (INT8 *)"DllInitialize");
  if( ExportedRoutineByName )
  {
    Length = DataTableEntry->BaseDllName.Length;
    if( (unsigned __int16)(Length + 2) > Length )
    {
      Source.MaximumLength = Length + 2;
      Pool = (wchar_t *)MiAllocatePool(256i64, (unsigned __int16)(Length + 2), 0x54446D4Dui64);
      Source.Buffer = Pool;
      v8 = Pool;
      if( Pool )
      {
        Buffer = DataTableEntry->BaseDllName.Buffer;
        Source.Length = DataTableEntry->BaseDllName.Length;
        v9 = Source.Length;
        memmove(Pool, Buffer, Source.Length);
        v11 = CmRegistryMachineSystemCurrentControlSetServices.Length + Source.Length;
        if( (unsigned __int16)(CmRegistryMachineSystemCurrentControlSetServices.Length + Source.Length) <= CmRegistryMachineSystemCurrentControlSetServices.Length )
        {
          ExFreePoolWithTag(v8, 0);
        }
        else if( (unsigned __int16)(v11 + 4) > v11
               && (Destination.MaximumLength = v11 + 4,
                   (Destination.Buffer = (wchar_t *)MiAllocatePool(64i64, (unsigned __int16)(v11 + 4), 0x54446D4Dui64)) != 0i64) )
        {
          Destination.Length = CmRegistryMachineSystemCurrentControlSetServices.Length;
          memmove(
            Destination.Buffer,
            CmRegistryMachineSystemCurrentControlSetServices.Buffer,
            CmRegistryMachineSystemCurrentControlSetServices.Length);
          RtlAppendUnicodeToString(&Destination, (WCHAR *)L"\\");
          v8[(unsigned __int64)v9 >> 1] = 0;
          v12 = wcschr(v8, 46);
          if( v12 )
          {
            Source.Length = 2 * (v12 - v8);
            LOWORD(v9) = Source.Length;
          }
          v8[(unsigned __int64)(unsigned __int16)v9 >> 1] = 0;
          RtlAppendUnicodeStringToString(&Destination, &Source);
          ExFreePoolWithTag(v8, 0);
          inited = VfDriverInitStarting();
          v14 = ExportedRoutineByName(&Destination);
          ExFreePoolWithTag(Destination.Buffer, 0);
          if( v14 >= 0 && !byte_140C4CA28 )
            VfDriverInitSuccess(inited, ModuleListHead);
        }
        else
        {
          ExFreePoolWithTag(v8, 0);
        }
      }
    }
  }
}

Referenced by:

MiLoadImportDll
PipInitializeDriverDependentDLLs