VirtualBox

Changeset 65413 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jan 24, 2017 10:26:59 AM (8 years ago)
Author:
vboxsync
Message:

IPRT/r0drv/nt: Preps for using NonPagedPoolNx.

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

Legend:

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

    r62477 r65413  
    3636#include <iprt/err.h>
    3737#include "r0drv/alloc-r0drv.h"
     38#include "internal-r0drv-nt.h"
    3839
    3940
     
    4344DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
    4445{
    45     if (fFlags & RTMEMHDR_FLAG_ANY_CTX)
    46         return VERR_NOT_SUPPORTED;
    47 
    48     PRTMEMHDR pHdr = (PRTMEMHDR)ExAllocatePoolWithTag(NonPagedPool, cb + sizeof(*pHdr), IPRT_NT_POOL_TAG);
    49     if (RT_UNLIKELY(!pHdr))
     46    if (!(fFlags & RTMEMHDR_FLAG_ANY_CTX))
     47    {
     48#if 0 /* This allegedly makes the driver verifier happier... */
     49        POOL_TYPE enmPoolType = NonPagedPool;
     50        if (!(fFlags & RTMEMHDR_FLAG_EXEC) && g_uRtNtVersion >= RTNT_MAKE_VERSION(8,0))
     51            enmPoolType = NonPagedPoolNx;
     52        PRTMEMHDR pHdr = (PRTMEMHDR)ExAllocatePoolWithTag(enmPoolType, cb + sizeof(*pHdr), IPRT_NT_POOL_TAG);
     53#else
     54        PRTMEMHDR pHdr = (PRTMEMHDR)ExAllocatePoolWithTag(NonPagedPool, cb + sizeof(*pHdr), IPRT_NT_POOL_TAG);
     55#endif
     56        if (pHdr)
     57        {
     58            pHdr->u32Magic  = RTMEMHDR_MAGIC;
     59            pHdr->fFlags    = fFlags;
     60            pHdr->cb        = (uint32_t)cb; Assert(pHdr->cb == cb);
     61            pHdr->cbReq     = (uint32_t)cb;
     62            *ppHdr = pHdr;
     63            return VINF_SUCCESS;
     64        }
    5065        return VERR_NO_MEMORY;
    51 
    52     pHdr->u32Magic  = RTMEMHDR_MAGIC;
    53     pHdr->fFlags    = fFlags;
    54     pHdr->cb        = (uint32_t)cb; Assert(pHdr->cb == cb);
    55     pHdr->cbReq     = (uint32_t)cb;
    56     *ppHdr = pHdr;
    57     return VINF_SUCCESS;
     66    }
     67    return VERR_NOT_SUPPORTED;
    5868}
    5969
  • trunk/src/VBox/Runtime/r0drv/nt/initterm-r0drv-nt.cpp

    r64281 r65413  
    104104uint32_t                                g_offrtNtPbDpcQueueDepth;
    105105
     106/** The major version number. */
     107uint8_t                                 g_uRtNtMajorVer;
     108/** The minor version number. */
     109uint8_t                                 g_uRtNtMinorVer;
     110/** The build number. */
     111uint32_t                                g_uRtNtBuildNo;
     112
    106113
    107114/**
     
    306313    RTNTSDBOSVER OsVerInfo;
    307314    rtR0NtGetOsVersionInfo(&OsVerInfo);
     315
     316    /* Publish the version info in globals. */
     317    g_uRtNtVersion  = RTNT_MAKE_VERSION(OsVerInfo.uMajorVer, OsVerInfo.uMinorVer);
     318    g_uRtNtMinorVer = OsVerInfo.uMinorVer;
     319    g_uRtNtMajorVer = OsVerInfo.uMajorVer;
     320    g_uRtNtBuildNo  = OsVerInfo.uBuildNo;
    308321
    309322    /*
  • trunk/src/VBox/Runtime/r0drv/nt/internal-r0drv-nt.h

    r64281 r65413  
    9292extern uint32_t                                g_offrtNtPbDpcQueueDepth;
    9393
     94/** Makes an NT version for checking against g_uRtNtVersion. */
     95#define RTNT_MAKE_VERSION(uMajor, uMinor)       RT_MAKE_U32(uMinor, uMajor)
     96
     97extern uint32_t                                g_uRtNtVersion;
     98extern uint8_t                                 g_uRtNtMajorVer;
     99extern uint8_t                                 g_uRtNtMinorVer;
     100extern uint32_t                                g_uRtNtBuildNo;
     101
    94102
    95103int __stdcall rtMpPokeCpuUsingDpc(RTCPUID idCpu);
  • trunk/src/VBox/Runtime/r0drv/nt/the-nt-kernel.h

    r62477 r65413  
    6464#endif
    6565
     66/* Missing if we're compiling against older WDKs. */
     67#ifndef NonPagedPoolNx
     68# define NonPagedPoolNx     ((POOL_TYPE)512)
     69#endif
     70
    6671/*
    6772 * When targeting NT4 we have to undo some of the nice macros
     
    7782# undef ExFreePool
    7883  NTKERNELAPI VOID NTAPI ExFreePool(IN PVOID P);
     84# undef NonPagedPoolNx
     85# define NonPagedPoolNx NonPagedPool
    7986#endif /* IPRT_TARGET_NT4 */
    8087
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