Index: /trunk/include/iprt/memobj.h
===================================================================
--- /trunk/include/iprt/memobj.h	(revision 391)
+++ /trunk/include/iprt/memobj.h	(revision 392)
@@ -126,8 +126,9 @@
  * @param   pv              User virtual address. This is rounded down to a page boundrary.
  * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
+ * @param   R0Process       The process to lock pages in. NIL_R0PROCESS is an alias for the current one.
  *
  * @remark  RTR0MemObjGetAddress() will return the rounded down address.
  */
-RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb);
+RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, RTR0PROCESS R0Process);
 
 /**
@@ -188,6 +189,7 @@
  * @param   uAlignment      The alignment of the reserved memory.
  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- */
-RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment);
+ * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
+ */
+RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
 
 /**
@@ -214,6 +216,7 @@
  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
- */
-RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
+ * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
+ */
+RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
 
 #endif /* IN_RING0 */
Index: /trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c
===================================================================
--- /trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c	(revision 391)
+++ /trunk/src/VBox/HostDrivers/Support/SUPDRVShared.c	(revision 392)
@@ -33,4 +33,5 @@
 #include <iprt/spinlock.h>
 #include <iprt/thread.h>
+#include <iprt/process.h>
 #include <iprt/log.h>
 #ifdef VBOX_WITHOUT_IDT_PATCHING
@@ -1727,5 +1728,5 @@
      */
     Mem.eType = MEMREF_TYPE_LOCKED;
-    rc = RTR0MemObjLockUser(&Mem.MemObj, pvR3, cb);
+    rc = RTR0MemObjLockUser(&Mem.MemObj, pvR3, cb, RTR0ProcHandleSelf());
     if (RT_SUCCESS(rc))
     {
@@ -1832,5 +1833,6 @@
     {
         int rc2;
-        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0, RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ);
+        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0,
+                               RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf());
         if (RT_SUCCESS(rc))
         {
@@ -1936,5 +1938,6 @@
     {
         int rc2;
-        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0, RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ);
+        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void *)-1, 0,
+                               RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf());
         if (RT_SUCCESS(rc))
         {
@@ -2046,5 +2049,6 @@
     {
         int rc2;
-        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void*)-1, 0, RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ);
+        rc = RTR0MemObjMapUser(&Mem.MapObjR3, Mem.MemObj, (void*)-1, 0,
+                               RTMEM_PROT_EXEC | RTMEM_PROT_WRITE | RTMEM_PROT_READ, RTR0ProcHandleSelf());
         if (RT_SUCCESS(rc))
         {
@@ -2220,5 +2224,6 @@
 #ifdef USE_NEW_OS_INTERFACE
             if (pSession->GipMapObjR3 == NIL_RTR0MEMOBJ)
-                rc = RTR0MemObjMapUser(&pSession->GipMapObjR3, pDevExt->GipMemObj, (void*)-1, 0, RTMEM_PROT_READ);
+                rc = RTR0MemObjMapUser(&pSession->GipMapObjR3, pDevExt->GipMemObj, (void*)-1, 0,
+                                       RTMEM_PROT_READ, RTR0ProcHandleSelf());
             if (RT_SUCCESS(rc))
             {
Index: /trunk/src/VBox/Runtime/include/internal/memobj.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/memobj.h	(revision 391)
+++ /trunk/src/VBox/Runtime/include/internal/memobj.h	(revision 392)
@@ -264,6 +264,7 @@
  * @param   pv              User virtual address, page aligned.
  * @param   cb              Number of bytes to lock, page aligned.
- */
-int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb);
+ * @param   R0Process       The process to lock pages in.
+ */
+int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, RTR0PROCESS R0Process);
 
 /**
@@ -317,6 +318,7 @@
  * @param   cb              The number of bytes to reserve, page aligned.
  * @param   uAlignment      The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
- */
-int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment);
+ * @param   R0Process       The process to reserve the memory in.
+ */
+int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process);
 
 /**
@@ -341,6 +343,7 @@
  * @param   uAlignment      The alignment of the reserved memory; PAGE_SIZE, _2M or _4M.
  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
- */
-int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt);
+ * @param   R0Process       The process to map the memory into.
+ */
+int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, PRTR0MEMOBJINTERNAL pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process);
 
 /**
Index: /trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp	(revision 391)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp	(revision 392)
@@ -423,7 +423,7 @@
 
 
-int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb)
-{
-    return rtR0MemObjNativeLock(ppMem, pv, cb, current_task());
+int rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, RTR0PROCESS R0Process)
+{
+    return rtR0MemObjNativeLock(ppMem, pv, cb, (task_t)R0Process);
 }
 
@@ -441,5 +441,5 @@
 
 
-int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
+int rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
 {
     return VERR_NOT_IMPLEMENTED;
@@ -490,5 +490,5 @@
 
 
-int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
+int rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
 {
     /*
@@ -499,6 +499,5 @@
     if (pMemToMapDarwin->pMemDesc)
     {
-        Assert(current_task() != kernel_task);
-        IOMemoryMap *pMemMap = pMemToMapDarwin->pMemDesc->map(current_task(), kIOMapAnywhere,
+        IOMemoryMap *pMemMap = pMemToMapDarwin->pMemDesc->map((task_t)R0Process, kIOMapAnywhere,
                                                               kIOMapAnywhere | kIOMapDefaultCache);
         if (pMemMap)
@@ -515,5 +514,5 @@
                 if (pMemDarwin)
                 {
-                    pMemDarwin->Core.u.Mapping.R0Process = RTR0ProcHandleSelf();
+                    pMemDarwin->Core.u.Mapping.R0Process = R0Process;
                     pMemDarwin->pMemMap = pMemMap;
                     *ppMem = &pMemDarwin->Core;
Index: /trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp	(revision 391)
+++ /trunk/src/VBox/Runtime/r0drv/memobj-r0drv.cpp	(revision 392)
@@ -27,4 +27,5 @@
 #include <iprt/memobj.h>
 #include <iprt/alloc.h>
+#include <iprt/process.h>
 #include <iprt/assert.h>
 #include <iprt/err.h>
@@ -389,8 +390,9 @@
  * @param   pv              User virtual address. This is rounded down to a page boundrary.
  * @param   cb              Number of bytes to lock. This is rounded up to nearest page boundrary.
+ * @param   R0Process       The process to lock pages in. NIL_R0PROCESS is an alias for the current one.
  *
  * @remark  RTR0MemObjGetAddress() will return the rounded down address.
  */
-RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb)
+RTR0DECL(int) RTR0MemObjLockUser(PRTR0MEMOBJ pMemObj, void *pv, size_t cb, RTR0PROCESS R0Process)
 {
     /* sanity checks. */
@@ -401,7 +403,9 @@
     AssertReturn(cb <= cbAligned, VERR_INVALID_PARAMETER);
     void * const pvAligned = (void *)((uintptr_t)pv & ~(uintptr_t)PAGE_OFFSET_MASK);
+    if (R0Process == NIL_RTR0PROCESS)
+        R0Process = RTR0ProcHandleSelf();
 
     /* do the allocation. */
-    return rtR0MemObjNativeLockUser(pMemObj, pvAligned, cbAligned);
+    return rtR0MemObjNativeLockUser(pMemObj, pvAligned, cbAligned, R0Process);
 }
 
@@ -522,6 +526,7 @@
  * @param   uAlignment      The alignment of the reserved memory.
  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
- */
-RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment)
+ * @param   R0Process       The process to reserve the memory in. NIL_R0PROCESS is an alias for the current one.
+ */
+RTR0DECL(int) RTR0MemObjReserveUser(PRTR0MEMOBJ pMemObj, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
 {
     /* sanity checks. */
@@ -536,7 +541,9 @@
     if (pvFixed != (void *)-1)
         AssertReturn(!((uintptr_t)pvFixed & (uAlignment - 1)), VERR_INVALID_PARAMETER);
+    if (R0Process == NIL_RTR0PROCESS)
+        R0Process = RTR0ProcHandleSelf();
 
     /* do the reservation. */
-    return rtR0MemObjNativeReserveUser(pMemObj, pvFixed, cbAligned, uAlignment);
+    return rtR0MemObjNativeReserveUser(pMemObj, pvFixed, cbAligned, uAlignment, R0Process);
 }
 
@@ -607,6 +614,7 @@
  *                          Supported values are 0 (alias for PAGE_SIZE), PAGE_SIZE, _2M and _4M.
  * @param   fProt           Combination of RTMEM_PROT_* flags (except RTMEM_PROT_NONE).
- */
-RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt)
+ * @param   R0Process       The process to map the memory into. NIL_R0PROCESS is an alias for the current one.
+ */
+RTR0DECL(int) RTR0MemObjMapUser(PRTR0MEMOBJ pMemObj, RTR0MEMOBJ MemObjToMap, void *pvFixed, size_t uAlignment, unsigned fProt, RTR0PROCESS R0Process)
 {
     /* sanity checks. */
@@ -626,9 +634,10 @@
     AssertReturn(fProt != RTMEM_PROT_NONE, VERR_INVALID_PARAMETER);
     AssertReturn(!(fProt & ~(RTMEM_PROT_READ | RTMEM_PROT_WRITE | RTMEM_PROT_EXEC)), VERR_INVALID_PARAMETER);
-
+    if (R0Process == NIL_RTR0PROCESS)
+        R0Process = RTR0ProcHandleSelf();
 
     /* do the mapping. */
     PRTR0MEMOBJINTERNAL pNew;
-    int rc = rtR0MemObjNativeMapUser(&pNew, pMemToMap, pvFixed, uAlignment, fProt);
+    int rc = rtR0MemObjNativeMapUser(&pNew, pMemToMap, pvFixed, uAlignment, fProt, R0Process);
     if (RT_SUCCESS(rc))
     {
