VirtualBox

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

IPRT/r0drv/nt: Preps for using NonPagedPoolNx.

File:
1 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
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