VirtualBox

Changeset 70212 in vbox


Ignore:
Timestamp:
Dec 19, 2017 2:54:28 AM (7 years ago)
Author:
vboxsync
Message:

IPRT/r0drv/nt: Dynamically import 4 more function to make it work on NT 3.50 - just because we can :-)

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r70157 r70212  
    8989/** KeDeregisterProcessorChangeCallback - Introducted in Windows 7. */
    9090PFNKEDEREGISTERPROCESSORCHANGECALLBACK  g_pfnrtKeDeregisterProcessorChangeCallback;
     91/** KeSetImportanceDpc - Introducted in NT 3.51. */
     92decltype(KeSetImportanceDpc)           *g_pfnrtKeSetImportanceDpc;
     93/** KeSetTargetProcessorDpc - Introducted in NT 3.51. */
     94decltype(KeSetTargetProcessorDpc)      *g_pfnrtKeSetTargetProcessorDpc;
    9195/** Pointer to the MmProtectMdlSystemAddress kernel function if it's available.
    9296 * This API was introduced in XP. */
     
    100104/** MmAllocateContiguousMemorySpecifyCache - Introduced in Windows 2000. */
    101105decltype(MmAllocateContiguousMemorySpecifyCache) *g_pfnrtMmAllocateContiguousMemorySpecifyCache;
     106/** MmSecureVirtualMemory - Introduced in NT 3.51.   */
     107decltype(MmSecureVirtualMemory)        *g_pfnrtMmSecureVirtualMemory;
     108/** MmUnsecureVirtualMemory - Introduced in NT 3.51.   */
     109decltype(MmUnsecureVirtualMemory)      *g_pfnrtMmUnsecureVirtualMemory;
    102110/** RtlGetVersion, introduced in ??. */
    103111PFNRTRTLGETVERSION                      g_pfnrtRtlGetVersion;
     
    295303    GET_SYSTEM_ROUTINE(KeRegisterProcessorChangeCallback);
    296304    GET_SYSTEM_ROUTINE(KeDeregisterProcessorChangeCallback);
     305    GET_SYSTEM_ROUTINE(KeSetImportanceDpc);
     306    GET_SYSTEM_ROUTINE(KeSetTargetProcessorDpc);
    297307    GET_SYSTEM_ROUTINE(MmProtectMdlSystemAddress);
    298308    GET_SYSTEM_ROUTINE(MmAllocatePagesForMdl);
     
    300310    GET_SYSTEM_ROUTINE(MmMapLockedPagesSpecifyCache);
    301311    GET_SYSTEM_ROUTINE(MmAllocateContiguousMemorySpecifyCache);
     312    GET_SYSTEM_ROUTINE(MmSecureVirtualMemory);
     313    GET_SYSTEM_ROUTINE(MmUnsecureVirtualMemory);
    302314
    303315    GET_SYSTEM_ROUTINE_TYPE(RtlGetVersion, PFNRTRTLGETVERSION);
  • trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h

    r70157 r70212  
    8282extern PFNKEREGISTERPROCESSORCHANGECALLBACK    g_pfnrtKeRegisterProcessorChangeCallback;
    8383extern PFNKEDEREGISTERPROCESSORCHANGECALLBACK  g_pfnrtKeDeregisterProcessorChangeCallback;
     84extern decltype(KeSetImportanceDpc)           *g_pfnrtKeSetImportanceDpc;
     85extern decltype(KeSetTargetProcessorDpc)      *g_pfnrtKeSetTargetProcessorDpc;
    8486extern decltype(MmProtectMdlSystemAddress)    *g_pfnrtMmProtectMdlSystemAddress;
    8587extern decltype(MmAllocatePagesForMdl)        *g_pfnrtMmAllocatePagesForMdl;
     
    8789extern decltype(MmMapLockedPagesSpecifyCache) *g_pfnrtMmMapLockedPagesSpecifyCache;
    8890extern decltype(MmAllocateContiguousMemorySpecifyCache) *g_pfnrtMmAllocateContiguousMemorySpecifyCache;
     91extern decltype(MmSecureVirtualMemory)        *g_pfnrtMmSecureVirtualMemory;
     92extern decltype(MmUnsecureVirtualMemory)      *g_pfnrtMmUnsecureVirtualMemory;
     93
    8994extern PFNRTRTLGETVERSION                      g_pfnrtRtlGetVersion;
    9095#ifndef RT_ARCH_AMD64
     
    111116
    112117
     118int __stdcall rtMpPokeCpuUsingFailureNotSupported(RTCPUID idCpu);
    113119int __stdcall rtMpPokeCpuUsingDpc(RTCPUID idCpu);
    114120int __stdcall rtMpPokeCpuUsingBroadcastIpi(RTCPUID idCpu);
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r70157 r70212  
    9696                if (pMemNt->pvSecureMem)
    9797                {
    98                     MmUnsecureVirtualMemory(pMemNt->pvSecureMem);
     98                    g_pfnrtMmUnsecureVirtualMemory(pMemNt->pvSecureMem);
    9999                    pMemNt->pvSecureMem = NULL;
    100100                }
     
    159159            if (pMemNt->pvSecureMem)
    160160            {
    161                 MmUnsecureVirtualMemory(pMemNt->pvSecureMem);
     161                g_pfnrtMmUnsecureVirtualMemory(pMemNt->pvSecureMem);
    162162                pMemNt->pvSecureMem = NULL;
    163163            }
     
    602602        }
    603603
    604         if (R0Process != NIL_RTR0PROCESS)
     604        if (   R0Process != NIL_RTR0PROCESS
     605            && g_pfnrtMmSecureVirtualMemory
     606            && g_pfnrtMmUnsecureVirtualMemory)
    605607        {
    606608            /* Make sure the user process can't change the allocation. */
    607             pMemNt->pvSecureMem = MmSecureVirtualMemory(pv, cb,
    608                                                         fAccess & RTMEM_PROT_WRITE
    609                                                         ? PAGE_READWRITE
    610                                                         : PAGE_READONLY);
     609            pMemNt->pvSecureMem = g_pfnrtMmSecureVirtualMemory(pv, cb,
     610                                                               fAccess & RTMEM_PROT_WRITE
     611                                                               ? PAGE_READWRITE
     612                                                               : PAGE_READONLY);
    611613            if (!pMemNt->pvSecureMem)
    612614            {
     
    639641    if (pMemNt->pvSecureMem)
    640642    {
    641         MmUnsecureVirtualMemory(pMemNt->pvSecureMem);
     643        if (g_pfnrtMmUnsecureVirtualMemory)
     644            g_pfnrtMmUnsecureVirtualMemory(pMemNt->pvSecureMem);
    642645        pMemNt->pvSecureMem = NULL;
    643646    }
  • trunk/src/VBox/Runtime/r0drv/nt/mp-r0drv-nt.cpp

    r70153 r70212  
    593593        g_pfnrtHalRequestIpiW7Plus = NULL;
    594594
    595     g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingDpc;
    596595    if (   g_pfnrtHalRequestIpiW7Plus
    597596        && g_pfnrtKeInitializeAffinityEx
     
    607606        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingBroadcastIpi;
    608607    }
     608    else if (g_pfnrtKeSetTargetProcessorDpc)
     609    {
     610        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingDpc\n");
     611        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingDpc;
     612        /* Windows XP should send always send an IPI -> VERIFY */
     613    }
    609614    else
    610         DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingDpc\n");
    611     /* else: Windows XP should send always send an IPI -> VERIFY */
     615    {
     616        DbgPrint("IPRT: RTMpPoke => rtMpPokeCpuUsingFailureNotSupported\n");
     617        Assert(pOsVerInfo->uMajorVer == 3 && pOsVerInfo->uMinorVer <= 50);
     618        g_pfnrtMpPokeCpuWorker = rtMpPokeCpuUsingFailureNotSupported;
     619    }
    612620
    613621    return VINF_SUCCESS;
     
    13381346                        RTErrConvertFromNtStatus(rcNt));
    13391347    }
     1348    else if (g_pfnrtKeSetTargetProcessorDpc)
     1349        g_pfnrtKeSetTargetProcessorDpc(pDpc, RTMpCpuIdToSetIndex(idCpu));
    13401350    else
    1341         KeSetTargetProcessorDpc(pDpc, RTMpCpuIdToSetIndex(idCpu));
     1351        return VERR_NOT_SUPPORTED;
    13421352    return VINF_SUCCESS;
    13431353}
     
    14141424    {
    14151425        KeInitializeDpc(&paExecCpuDpcs[0], rtmpNtDPCWrapper, pArgs);
    1416         KeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
     1426        if (g_pfnrtKeSetImportanceDpc)
     1427            g_pfnrtKeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
    14171428        rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[0], idCpu);
    14181429        pArgs->idCpu = idCpu;
     
    14211432    {
    14221433        KeInitializeDpc(&paExecCpuDpcs[0], rtmpNtDPCWrapper, pArgs);
    1423         KeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
     1434        if (g_pfnrtKeSetImportanceDpc)
     1435            g_pfnrtKeSetImportanceDpc(&paExecCpuDpcs[0], HighImportance);
    14241436        rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[0], idCpu);
    14251437        pArgs->idCpu = idCpu;
    14261438
    14271439        KeInitializeDpc(&paExecCpuDpcs[1], rtmpNtDPCWrapper, pArgs);
    1428         KeSetImportanceDpc(&paExecCpuDpcs[1], HighImportance);
     1440        if (g_pfnrtKeSetImportanceDpc)
     1441            g_pfnrtKeSetImportanceDpc(&paExecCpuDpcs[1], HighImportance);
    14291442        if (RT_SUCCESS(rc))
    14301443            rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[1], (int)idCpu2);
     
    14381451            {
    14391452                KeInitializeDpc(&paExecCpuDpcs[i], rtmpNtDPCWrapper, pArgs);
    1440                 KeSetImportanceDpc(&paExecCpuDpcs[i], HighImportance);
     1453                if (g_pfnrtKeSetImportanceDpc)
     1454                    g_pfnrtKeSetImportanceDpc(&paExecCpuDpcs[i], HighImportance);
    14411455                rc = rtMpNtSetTargetProcessorDpc(&paExecCpuDpcs[i], RTMpCpuIdFromSetIndex(i));
    14421456            }
     
    16931707    KeInitializeEvent(&pArgs->DoneEvt, SynchronizationEvent, FALSE /* not signalled */);
    16941708    KeInitializeDpc(&pArgs->Dpc, rtMpNtOnSpecificDpcWrapper, pArgs);
    1695     KeSetImportanceDpc(&pArgs->Dpc, HighImportance);
     1709    if (g_pfnrtKeSetImportanceDpc)
     1710        g_pfnrtKeSetImportanceDpc(&pArgs->Dpc, HighImportance);
    16961711    rc = rtMpNtSetTargetProcessorDpc(&pArgs->Dpc, idCpu);
    16971712    if (RT_FAILURE(rc))
     
    18711886}
    18721887
     1888int rtMpPokeCpuUsingFailureNotSupported(RTCPUID idCpu)
     1889{
     1890    NOREF(idCpu);
     1891    return VERR_NOT_SUPPORTED;
     1892}
    18731893
    18741894int rtMpPokeCpuUsingDpc(RTCPUID idCpu)
     
    18871907        {
    18881908            KeInitializeDpc(&s_aPokeDpcs[i], rtMpNtPokeCpuDummy, NULL);
    1889             KeSetImportanceDpc(&s_aPokeDpcs[i], HighImportance);
     1909            if (g_pfnrtKeSetImportanceDpc)
     1910                g_pfnrtKeSetImportanceDpc(&s_aPokeDpcs[i], HighImportance);
    18901911            int rc = rtMpNtSetTargetProcessorDpc(&s_aPokeDpcs[i], idCpu);
    18911912            if (RT_FAILURE(rc))
     
    19011922    KeRaiseIrql(DISPATCH_LEVEL, &oldIrql);
    19021923
    1903     KeSetImportanceDpc(&s_aPokeDpcs[idCpu], HighImportance);
    1904     KeSetTargetProcessorDpc(&s_aPokeDpcs[idCpu], (int)idCpu);
     1924    if (g_pfnrtKeSetImportanceDpc)
     1925        g_pfnrtKeSetImportanceDpc(&s_aPokeDpcs[idCpu], HighImportance);
     1926    g_pfnrtKeSetTargetProcessorDpc(&s_aPokeDpcs[idCpu], (int)idCpu);
    19051927
    19061928    /* Assuming here that high importance DPCs will be delivered immediately; or at least an IPI will be sent immediately.
  • trunk/src/VBox/Runtime/r0drv/nt/timer-r0drv-nt.cpp

    r69111 r70212  
    533533            else
    534534                KeInitializeDpc(&pTimer->aSubTimers[iCpu].NtDpc, rtTimerNtOmniSlaveCallback, &pTimer->aSubTimers[iCpu]);
    535             KeSetImportanceDpc(&pTimer->aSubTimers[iCpu].NtDpc, HighImportance);
     535            if (g_pfnrtKeSetImportanceDpc)
     536                g_pfnrtKeSetImportanceDpc(&pTimer->aSubTimers[iCpu].NtDpc, HighImportance);
    536537            rc = rtMpNtSetTargetProcessorDpc(&pTimer->aSubTimers[iCpu].NtDpc, iCpu);
    537538        }
     
    548549
    549550        KeInitializeDpc(&pTimer->aSubTimers[0].NtDpc, rtTimerNtSimpleCallback, pTimer);
    550         KeSetImportanceDpc(&pTimer->aSubTimers[0].NtDpc, HighImportance);
     551        if (g_pfnrtKeSetImportanceDpc)
     552            g_pfnrtKeSetImportanceDpc(&pTimer->aSubTimers[0].NtDpc, HighImportance);
    551553        if (pTimer->fSpecificCpu)
    552554            rc = rtMpNtSetTargetProcessorDpc(&pTimer->aSubTimers[0].NtDpc, (int)pTimer->idCpu);
Note: See TracChangeset for help on using the changeset viewer.

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