MiDriverLoadSucceeded

INT64 __fastcall MiDriverLoadSucceeded(INT64 a1, INT64 a2, UNICODE_STRING *a3, INT64 a4, INT64 a5, CHAR a6){
  _CONTROL_AREA *v9; 
  __int64 v10; 
  char v11; 
  _FILE_OBJECT *v12; 
  __int64 v13; 
  WCHAR *v14; 
  WCHAR *v15; 
  __m128i v16; 
  int v17; 
  WCHAR v18; 
  INT64 result; 
  struct _UNICODE_STRING DestinationString; 
  _IMAGE_INFO_EX ExtendedInfo; 
  memset(&ExtendedInfo, 0, sizeof(ExtendedInfo));
  if( a6 == 1 )
  {
    *(_DWORD *)(a1 + 104) |= 0x41004000u;
    v9 = MiSectionControlArea((_SECTION *)a2);
    v10 = *(_QWORD *)v9;
    LOBYTE(ExtendedInfo.ImageInfo.Properties) = 3;
    v11 = *(_BYTE *)(v10 + 15);
    ExtendedInfo.ImageInfo.ImageSelector = 0;
    ExtendedInfo.ImageInfo.ImageSectionNumber = 0;
    ExtendedInfo.ImageInfo.ImageSize = *(unsigned int *)(a1 + 64);
    ExtendedInfo.ImageInfo.ImageBase = *(PVOID *)(a1 + 48);
    ExtendedInfo.ImageInfo.Properties = ExtendedInfo.ImageInfo.Properties & 0xFFF80FFF | ((v11 & 0xF1 | ((v11 & 0xE) << 7) | 1) << 8);
    v12 = MiReferenceControlAreaFile(v9);
    PsCallImageNotifyRoutines(a3, 0i64, &ExtendedInfo, v12);
    MiDereferenceControlAreaFile((__int64)v9, (unsigned __int64)v12);
    LODWORD(v13) = MiCacheImageSymbols(*(PVOID *)(a1 + 48));
    if( v13 )
    {
      DestinationString = 0i64;
      LODWORD(v14) = MiAllocatePool((struct _SLIST_ENTRY *)0x100);
      v15 = v14;
      if( v14 )
      {
        if( *(_WORD *)a4 <= 0x16u || wcsnicmp(*(const wchar_t **)(a4 + 8), L"\\SystemRoot", 0xBui64) )
        {
          v17 = RtlStringCbPrintfW(v15, 0x100ui64, (WCHAR *)L"%wZ");
        }
        else
        {
          v16 = *(__m128i *)a4;
          *(_QWORD *)&DestinationString.Length = *(_QWORD *)a4;
          DestinationString.Buffer = (wchar_t *)(_mm_srli_si128(v16, 8).m128i_u64[0] + 22);
          DestinationString.Length -= 22;
          RtlGetNtSystemRoot();
          v17 = RtlStringCbPrintfW(v15, 0x100ui64, (WCHAR *)L"%ws%wZ");
        }
        if( v17 >= 0 )
        {
          RtlInitUnicodeString(&DestinationString, v15, v18);
          if( (unsigned int)DbgLoadImageSymbolsUnicode(&DestinationString, *(PVOID *)(a1 + 48)) == 1 )
            *(_DWORD *)(a1 + 104) |= 0x100000u;
        }
        ExFreePoolWithTag(v15, 0);
      }
    }
  }
  if( !*((_QWORD *)MiSectionControlArea(*(_SECTION **)(a1 + 112)) + 18) || (*(_DWORD *)(a1 + 104) & 0x8000000) == 0 )
    MiProtectSystemImage(a1);
  result = MiGetSystemRegionType(*(_QWORD *)(a1 + 48));
  if( (_DWORD)result == 1 )
    return MiSessionUpdateImageCharges(a1);
  return result;
}

Referenced by:

MiApplyHotPatchToLoadedDriver
MmLoadSystemImageEx