VirtualBox

忽略:
時間撮記:
2009-10-7 下午09:22:10 (15 年 以前)
作者:
vboxsync
訊息:

IPRT,VMM,SUPDrv,VBGLR0: Added a parameter to RTR0MemObjLockUser/Kernel that indicates read/write intent so we can correctly lock readonly memory on Windows and OS/2. (Guest property strings, see #4238.)

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Runtime/r0drv/nt/memobj-r0drv-nt.cpp

    r23065 r23610  
    501501 * @return IPRT status code.
    502502 *
    503  * @param ppMem     Where to store the memory object pointer.
    504  * @param pv        First page.
    505  * @param cb        Number of bytes.
    506  * @param R0Process The process \a pv and \a cb refers to.
     503 * @param   ppMem           Where to store the memory object pointer.
     504 * @param   pv              First page.
     505 * @param   cb              Number of bytes.
     506 * @param   fAccess         The desired access, a combination of RTMEM_PROT_READ
     507 *                          and RTMEM_PROT_WRITE.
     508 * @param   R0Process       The process \a pv and \a cb refers to.
    507509 */
    508 static int rtR0MemObjNtLock(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, RTR0PROCESS R0Process)
     510static int rtR0MemObjNtLock(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
    509511{
    510512    /*
     
    549551        __try
    550552        {
    551             MmProbeAndLockPages(pMdl, R0Process == NIL_RTR0PROCESS ? KernelMode : UserMode, IoModifyAccess);
     553            MmProbeAndLockPages(pMdl,
     554                                R0Process == NIL_RTR0PROCESS ? KernelMode : UserMode,
     555                                fAccess == RTMEM_PROT_READ
     556                                ? IoReadAccess
     557                                : fAccess == RTMEM_PROT_WRITE
     558                                ? IoWriteAccess
     559                                : IoModifyAccess);
    552560
    553561            pMemNt->apMdls[iMdl] = pMdl;
     
    561569        }
    562570
    563         if (R0Process != NIL_RTR0PROCESS )
     571        if (R0Process != NIL_RTR0PROCESS)
    564572        {
    565573            /* Make sure the user process can't change the allocation. */
    566             pMemNt->pvSecureMem = MmSecureVirtualMemory(pv, cb, PAGE_READWRITE);
     574            pMemNt->pvSecureMem = MmSecureVirtualMemory(pv, cb,
     575                                                        fAccess & RTMEM_PROT_WRITE
     576                                                        ? PAGE_READWRITE
     577                                                        : PAGE_READONLY);
    567578            if (!pMemNt->pvSecureMem)
    568579            {
     
    604615
    605616
    606 int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, RTR0PROCESS R0Process)
     617int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
    607618{
    608619    AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
    609620    /* (Can use MmProbeAndLockProcessPages if we need to mess with other processes later.) */
    610     return rtR0MemObjNtLock(ppMem, (void *)R3Ptr, cb, R0Process);
    611 }
    612 
    613 
    614 int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
    615 {
    616     return rtR0MemObjNtLock(ppMem, pv, cb, NIL_RTR0PROCESS);
     621    return rtR0MemObjNtLock(ppMem, (void *)R3Ptr, cb, fAccess, R0Process);
     622}
     623
     624
     625int rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess)
     626{
     627    return rtR0MemObjNtLock(ppMem, pv, cb, fAccess, NIL_RTR0PROCESS);
    617628}
    618629
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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