VirtualBox

Changeset 70150 in vbox for trunk/src/VBox/Runtime/r0drv/nt


Ignore:
Timestamp:
Dec 15, 2017 2:10:17 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
119710
Message:

iprt/r0drv/memobj: Let initterm resolve MmProtectMdlSystemAddress.

Location:
trunk/src/VBox/Runtime/r0drv/nt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h

    r69111 r70150  
    8080extern PFNKEREGISTERPROCESSORCHANGECALLBACK    g_pfnrtKeRegisterProcessorChangeCallback;
    8181extern PFNKEDEREGISTERPROCESSORCHANGECALLBACK  g_pfnrtKeDeregisterProcessorChangeCallback;
     82extern decltype(MmProtectMdlSystemAddress)    *g_pfnrtMmProtectMdlSystemAddress;
    8283extern PFNRTRTLGETVERSION                      g_pfnrtRtlGetVersion;
    8384#ifndef RT_ARCH_AMD64
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r69111 r70150  
    7878} RTR0MEMOBJNT, *PRTR0MEMOBJNT;
    7979
    80 
    81 /*********************************************************************************************************************************
    82 *   Global Variables                                                                                                             *
    83 *********************************************************************************************************************************/
    84 /** Pointer to the MmProtectMdlSystemAddress kernel function if it's available.
    85  * This API was introduced in XP. */
    86 static decltype(MmProtectMdlSystemAddress) *g_pfnMmProtectMdlSystemAddress = NULL;
    87 /** Set if we've resolved the dynamic APIs. */
    88 static bool volatile g_fResolvedDynamicApis = false;
    89 static ULONG g_uMajorVersion = 5;
    90 static ULONG g_uMinorVersion = 1;
    91 
    92 
    93 static void rtR0MemObjNtResolveDynamicApis(void)
    94 {
    95     ULONG uBuildNumber  = 0;
    96     PsGetVersion(&g_uMajorVersion, &g_uMinorVersion, &uBuildNumber, NULL);
    97 
    98 #ifndef IPRT_TARGET_NT4 /* MmGetSystemRoutineAddress was introduced in w2k. */
    99 
    100     UNICODE_STRING RoutineName;
    101     RtlInitUnicodeString(&RoutineName, L"MmProtectMdlSystemAddress");
    102     g_pfnMmProtectMdlSystemAddress = (decltype(MmProtectMdlSystemAddress) *)MmGetSystemRoutineAddress(&RoutineName);
    103 
    104 #endif
    105     ASMCompilerBarrier();
    106     g_fResolvedDynamicApis = true;
    107 }
    10880
    10981
     
    861833    PRTR0MEMOBJNT pMemNt = (PRTR0MEMOBJNT)pMem;
    862834#endif
    863     if (!g_fResolvedDynamicApis)
    864         rtR0MemObjNtResolveDynamicApis();
    865835
    866836    /*
     
    873843     */
    874844    if (   pMemNt->cMdls
    875         && g_pfnMmProtectMdlSystemAddress
    876         && (g_uMajorVersion > 6 || (g_uMajorVersion == 6 && g_uMinorVersion >= 1)) /* Windows 7 and later. */
     845        && g_pfnrtMmProtectMdlSystemAddress
     846        && (g_uRtNtMajorVer > 6 || (g_uRtNtMajorVer == 6 && g_uRtNtMinorVer >= 1)) /* Windows 7 and later. */
    877847        && pMemNt->Core.pv != NULL
    878848        && (   pMemNt->Core.enmType == RTR0MEMOBJTYPE_PAGE
     
    926896            while (iMdl-- > 0)
    927897            {
    928                 rcNt = g_pfnMmProtectMdlSystemAddress(pMemNt->apMdls[i], fAccess);
     898                rcNt = g_pfnrtMmProtectMdlSystemAddress(pMemNt->apMdls[i], fAccess);
    929899                if (!NT_SUCCESS(rcNt))
    930900                    break;
     
    962932                    if (NT_SUCCESS(rcNt))
    963933                    {
    964                         rcNt = g_pfnMmProtectMdlSystemAddress(pMdl, fAccess);
     934                        rcNt = g_pfnrtMmProtectMdlSystemAddress(pMdl, fAccess);
    965935                        MmUnlockPages(pMdl);
    966936                    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette