VirtualBox

Changeset 78334 in vbox for trunk/src/VBox/Runtime/r3/win


Ignore:
Timestamp:
Apr 26, 2019 7:53:32 PM (6 years ago)
Author:
vboxsync
Message:

IPRT/mem: Added RTMemPageAllocEx so we can try lock memory and try prevent it from being part of dumps/cores.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/win/alloc-win.cpp

    r76553 r78334  
    9696
    9797
     98RTDECL(void *) RTMemPageAllocExTag(size_t cb, uint32_t fFlags, const char *pszTag) RT_NO_THROW_DEF
     99{
     100    size_t const cbAligned = RT_ALIGN_Z(cb, PAGE_SIZE);
     101    RT_NOREF_PV(pszTag);
     102    AssertReturn(!(fFlags & ~RTMEMPAGEALLOC_F_VALID_MASK), NULL);
     103
     104#ifdef USE_VIRTUAL_ALLOC
     105    void *pv = VirtualAlloc(NULL, cbAligned, MEM_COMMIT, PAGE_READWRITE);
     106#else
     107    void *pv = _aligned_malloc(cbAligned, PAGE_SIZE);
     108#endif
     109    AssertMsgReturn(pv, ("cb=%d lasterr=%d\n", cb, GetLastError()), NULL);
     110
     111    if (fFlags & RTMEMPAGEALLOC_F_ADVISE_LOCKED)
     112    {
     113        BOOL const fOkay = VirtualLock(pv, cbAligned);
     114        AssertMsg(fOkay, ("pv=%p cb=%d lasterr=%d\n", pv, cb, GetLastError()));
     115        NOREF(fOkay);
     116    }
     117
     118    if (fFlags & RTMEMPAGEALLOC_F_ZERO)
     119        RT_BZERO(pv, cbAligned);
     120
     121    return pv;
     122}
     123
     124
    98125RTDECL(void *) RTMemPageAllocZTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    99126{
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