MiUnlockDriverCode

__int64 __fastcall MiUnlockDriverCode(__int64 a1){
  void *v1; 
  __int64 result; 
  __int64 v4; 
  unsigned int v5; 
  unsigned int *v6; 
  unsigned int v7; 
  PVOID v8; 
  MMPTE *PteAddress; 
  MMPTE *v10; 
  v1 = *(void **)(a1 + 48);
  result = MI_IS_PHYSICAL_ADDRESS(v1);
  if( !(_DWORD)result )
  {
    result = MiGetSystemRegionType((UINT64)v1);
    if( (_DWORD)result != 1 )
    {
      result = (__int64)RtlImageNtHeader(v1);
      v4 = result;
      v5 = 0;
      if( *(_WORD *)(result + 6) )
      {
        v6 = (unsigned int *)(result + *(unsigned __int16 *)(result + 20) + 32i64);
        do
        {
          if( *(_DWORD *)(*(_QWORD *)(a1 + 224) + 4i64 * v5) )
          {
            v7 = v6[2];
            if( v7 < *v6 )
              v7 = *v6;
            MiGetPteAddress((PVOID)(((unsigned __int64)v1 + v6[1] + v7 + 4095) & 0xFFFFFFFFFFFFF000ui64));
            PteAddress = MiGetPteAddress(v8);
            MiUnlockCodePage(PteAddress, v10);
          }
          result = *(unsigned __int16 *)(v4 + 6);
          ++v5;
          v6 += 10;
        }
        while( v5 < (unsigned int)result );
      }
    }
  }
  return result;
}

Referenced by:

MiUnloadSystemImage