VirtualBox

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


Ignore:
Timestamp:
Dec 29, 2022 6:33:45 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
154997
Message:

IPRT: Removed the RTMemExecAlloc interface.

File:
1 edited

Legend:

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

    r96407 r97907  
    5656
    5757
    58 RTDECL(void *) RTMemExecAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    59 {
    60     RT_NOREF_PV(pszTag);
    61 
    62     /*
    63      * Allocate first.
    64      */
    65     AssertMsg(cb, ("Allocating ZERO bytes is really not a good idea! Good luck with the next assertion!\n"));
    66 #ifdef USE_VIRTUAL_ALLOC
    67     cb = RT_ALIGN_Z(cb, PAGE_SIZE);
    68     void *pv = VirtualAlloc(NULL, cb, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
    69     AssertMsg(pv, ("VirtualAlloc(%zx) failed!!!\n", cb));
    70 #else
    71     cb = RT_ALIGN_Z(cb, 32);
    72     void *pv = malloc(cb);
    73     AssertMsg(pv, ("malloc(%d) failed!!!\n", cb));
    74     if (pv)
    75     {
    76         memset(pv, 0xcc, cb);
    77         void   *pvProt = (void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK);
    78         size_t  cbProt = ((uintptr_t)pv & PAGE_OFFSET_MASK) + cb;
    79         cbProt = RT_ALIGN_Z(cbProt, PAGE_SIZE);
    80         DWORD fFlags = 0;
    81         if (!VirtualProtect(pvProt, cbProt, PAGE_EXECUTE_READWRITE, &fFlags))
    82         {
    83             AssertMsgFailed(("VirtualProtect(%p, %#x,,) -> lasterr=%d\n", pvProt, cbProt, GetLastError()));
    84             free(pv);
    85             pv = NULL;
    86         }
    87     }
    88 #endif
    89     return pv;
    90 }
    91 
    92 
    93 RTDECL(void)    RTMemExecFree(void *pv, size_t cb) RT_NO_THROW_DEF
    94 {
    95     RT_NOREF_PV(cb);
    96 
    97     if (pv)
    98 #ifdef USE_VIRTUAL_ALLOC
    99         if (!VirtualFree(pv, 0, MEM_RELEASE))
    100             AssertMsgFailed(("pv=%p lasterr=%d\n", pv, GetLastError()));
    101 #else
    102         free(pv);
    103 #endif
    104 }
    105 
    106 
    10758RTDECL(void *) RTMemPageAllocTag(size_t cb, const char *pszTag) RT_NO_THROW_DEF
    10859{
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