Index: /trunk/include/iprt/process.h
===================================================================
--- /trunk/include/iprt/process.h	(revision 384)
+++ /trunk/include/iprt/process.h	(revision 385)
@@ -24,9 +24,4 @@
 #include <iprt/cdefs.h>
 #include <iprt/types.h>
-
-#ifndef IN_RING3
-# error "The RTProc APIs are Ring-3 only!"
-#endif
-
 
 __BEGIN_DECLS
@@ -85,4 +80,21 @@
 
 
+/**
+ * Get the current process identifier.
+ *
+ * @returns Process identifier.
+ */
+RTDECL(RTPROCESS) RTProcSelf(void);
+
+
+#ifdef IN_RING0
+/**
+ * Get the current process handle.
+ *
+ * @returns Ring-0 process handle.
+ */
+RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void);
+#endif
+
 
 #ifdef IN_RING3
@@ -102,11 +114,4 @@
  */
 RTR3DECL(RTPROCPRIORITY) RTProcGetPriority(void);
-
-/**
- * Get the identifier for the current process.
- *
- * @returns Process identifier.
- */
-RTR3DECL(RTPROCESS) RTProcSelf(void);
 
 /**
@@ -215,10 +220,10 @@
 RTR3DECL(char *) RTProcGetExecutableName(char *pszExecName, size_t cchExecName);
 
+#endif /* IN_RING3 */
+
+/** @} */
+
+__END_DECLS
+
 #endif
 
-/** @} */
-
-__END_DECLS
-
-#endif
-
Index: /trunk/include/iprt/types.h
===================================================================
--- /trunk/include/iprt/types.h	(revision 384)
+++ /trunk/include/iprt/types.h	(revision 385)
@@ -40,8 +40,8 @@
 
 # if defined(__LINUX__) && defined(__KERNEL__)
-    /* 
+    /*
      * Kludge for the linux kernel:
      *   1. sys/types.h doesn't mix with the kernel.
-     *   2. Starting with 2.6.19 linux/types.h typedefs bool and linux/stddef.h 
+     *   2. Starting with 2.6.19 linux/types.h typedefs bool and linux/stddef.h
      *      declares false and true as enum values.
      * We work around these issues here and nowhere else.
@@ -119,5 +119,5 @@
 # else
 typedef unsigned char bool;
-# endif 
+# endif
 # ifndef true
 #  define true  (1)
@@ -905,10 +905,17 @@
 #define NIL_RTNATIVETHREAD                          (~(RTNATIVETHREAD)0)
 
-/** Process handle. */
+/** Process identifier. */
 typedef RTHCUINTPTR                                 RTPROCESS;
-/** Pointer to a process handle. */
+/** Pointer to a process identifier. */
 typedef RTPROCESS                                  *PRTPROCESS;
-/** Nil process handle. */
+/** Nil process identifier. */
 #define NIL_RTPROCESS                               (~(RTPROCESS)0)
+
+/** Process ring-0 handle. */
+typedef RTR0UINTPTR                                 RTR0PROCESS;
+/** Pointer to a ring-0 process handle. */
+typedef RTR0PROCESS                                *PRTR0PROCESS;
+/** Nil ring-0 process handle. */
+#define NIL_RTR0PROCESS                             (~(RTR0PROCESS)0)
 
 /** @typedef RTSEMEVENT
Index: /trunk/src/VBox/Runtime/Makefile
===================================================================
--- /trunk/src/VBox/Runtime/Makefile	(revision 384)
+++ /trunk/src/VBox/Runtime/Makefile	(revision 385)
@@ -393,4 +393,5 @@
 VBoxRT_LIBS.darwin             = \
 	iconv
+VBoxRT_LDFLAGS.darwin          = -framework IOKit
 ifdef VBOX_USE_VCC80
 VBoxRT_LDFLAGS.win             = /MANIFEST
@@ -545,4 +546,5 @@
 	r0drv/linux/alloc-r0drv-linux.c \
 	r0drv/linux/initterm-r0drv-linux.c \
+	r0drv/linux/process-r0drv-linux.cpp \
 	r0drv/linux/RTLogWriteDebugger-r0drv-linux.c \
 	r0drv/linux/semaphore-r0drv-linux.c \
@@ -554,4 +556,5 @@
 	r0drv/nt/alloc-r0drv-nt.cpp \
 	r0drv/nt/initterm-r0drv-nt.cpp \
+	r0drv/nt/process-r0drv-nt.cpp \
 	r0drv/nt/RTLogWriteDebugger-r0drv-nt.cpp \
 	r0drv/nt/semaphore-r0drv-nt.cpp \
@@ -571,4 +574,5 @@
 	r0drv/darwin/memobj-r0drv-darwin.cpp \
 	r0drv/darwin/initterm-r0drv-darwin.cpp \
+	r0drv/darwin/process-r0drv-darwin.cpp \
 	r0drv/darwin/RTLogWriteDebugger-r0drv-darwin.cpp \
 	r0drv/darwin/semaphore-r0drv-darwin.cpp \
Index: /trunk/src/VBox/Runtime/include/internal/memobj.h
===================================================================
--- /trunk/src/VBox/Runtime/include/internal/memobj.h	(revision 384)
+++ /trunk/src/VBox/Runtime/include/internal/memobj.h	(revision 385)
@@ -156,6 +156,6 @@
         {
             /** The process that owns the locked memory.
-             * This is NIL_RTPROCESS if it's kernel memory. */
-            RTPROCESS   Process;
+             * This is NIL_RTR0PROCESS if it's kernel memory. */
+            RTR0PROCESS R0Process;
         } Lock;
 
@@ -173,6 +173,6 @@
         {
             /** The process that owns the reserved memory.
-             * This is NIL_RTPROCESS if it's kernel memory. */
-            RTPROCESS   Process;
+             * This is NIL_RTR0PROCESS if it's kernel memory. */
+            RTR0PROCESS R0Process;
         } ResVirt;
 
@@ -181,6 +181,6 @@
         {
             /** The process that owns the reserved memory.
-             * This is NIL_RTPROCESS if it's kernel memory. */
-            RTPROCESS   Process;
+             * This is NIL_RTR0PROCESS if it's kernel memory. */
+            RTR0PROCESS R0Process;
         } Mapping;
     } u;
Index: /trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp	(revision 384)
+++ /trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp	(revision 385)
@@ -32,4 +32,5 @@
 #include <iprt/param.h>
 #include <iprt/string.h>
+#include <iprt/process.h>
 #include "internal/memobj.h"
 
@@ -94,6 +95,6 @@
         {
 #ifdef USE_VM_MAP_WIRE
-            vm_map_t Map = pMemDarwin->Core.u.Lock.Process != NIL_RTPROCESS
-                         ? get_task_map((task_t)pMemDarwin->Core.u.Lock.Process)
+            vm_map_t Map = pMemDarwin->Core.u.Lock.R0Process != NIL_RTR0PROCESS
+                         ? get_task_map((task_t)pMemDarwin->Core.u.Lock.R0Process)
                          : kernel_map;
             kern_return_t kr = vm_map_unwire(Map,
@@ -377,5 +378,5 @@
         if (pMemDarwin)
         {
-            pMemDarwin->Core.u.Lock.Process = (RTPROCESS)Task;
+            pMemDarwin->Core.u.Lock.R0Process = (RTR0PROCESS)Task;
             *ppMem = &pMemDarwin->Core;
             return VINF_SUCCESS;
@@ -404,5 +405,5 @@
             if (pMemDarwin)
             {
-                pMemDarwin->Core.u.Lock.Process = (RTPROCESS)Task;
+                pMemDarwin->Core.u.Lock.R0Process = (RTR0PROCESS)Task;
                 pMemDarwin->pMemDesc = pMemDesc;
                 *ppMem = &pMemDarwin->Core;
@@ -470,5 +471,5 @@
                 if (pMemDarwin)
                 {
-                    pMemDarwin->Core.u.Mapping.Process = NIL_RTPROCESS;
+                    pMemDarwin->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;
                     pMemDarwin->pMemMap = pMemMap;
                     *ppMem = &pMemDarwin->Core;
@@ -514,5 +515,5 @@
                 if (pMemDarwin)
                 {
-                    pMemDarwin->Core.u.Mapping.Process = /*RTProcSelf()*/(RTPROCESS)current_task();
+                    pMemDarwin->Core.u.Mapping.R0Process = RTR0ProcHandleSelf();
                     pMemDarwin->pMemMap = pMemMap;
                     *ppMem = &pMemDarwin->Core;
@@ -546,5 +547,5 @@
     {
         ppnum_t PgNo;
-        if (pMemDarwin->Core.u.Lock.Process == NIL_RTPROCESS)
+        if (pMemDarwin->Core.u.Lock.R0Process == NIL_RTR0PROCESS)
             PgNo = pmap_find_phys(kernel_pmap, (uintptr_t)pMemDarwin->Core.pv + iPage * PAGE_SIZE);
         else
@@ -575,5 +576,5 @@
                 AssertReturn(s_offPmap >= 0, NIL_RTHCPHYS);
             }
-            pmap_t Pmap = *(pmap_t *)((uintptr_t)get_task_map((task_t)pMemDarwin->Core.u.Lock.Process) + s_offPmap);
+            pmap_t Pmap = *(pmap_t *)((uintptr_t)get_task_map((task_t)pMemDarwin->Core.u.Lock.R0Process) + s_offPmap);
             PgNo = pmap_find_phys(Pmap, (uintptr_t)pMemDarwin->Core.pv + iPage * PAGE_SIZE);
         }
Index: /trunk/src/VBox/Runtime/r0drv/linux/process-r0drv-linux.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/linux/process-r0drv-linux.cpp	(revision 385)
+++ /trunk/src/VBox/Runtime/r0drv/linux/process-r0drv-linux.cpp	(revision 385)
@@ -0,0 +1,39 @@
+/* $Id$ */
+/** @file
+ * InnoTek Portable Runtime - Process, Ring-0 Driver, Linux.
+ */
+
+/*
+ * Copyright (C) 2006 InnoTek Systemberatung GmbH
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation,
+ * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+ * distribution. VirtualBox OSE is distributed in the hope that it will
+ * be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * If you received this file as part of a commercial VirtualBox
+ * distribution, then only the terms of your commercial VirtualBox
+ * license agreement apply instead of the previous paragraph.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "the-linux-kernel.h"
+#include <iprt/process.h>
+
+
+RTDECL(RTPROCESS) RTProcSelf(void)
+{
+    return (RTPROCESS)current->tgid;
+}
+
+
+RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void)
+{
+    return (RTR0PROCESS)current->tgid;
+}
+
Index: /trunk/src/VBox/Runtime/r0drv/nt/process-r0drv-nt.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r0drv/nt/process-r0drv-nt.cpp	(revision 385)
+++ /trunk/src/VBox/Runtime/r0drv/nt/process-r0drv-nt.cpp	(revision 385)
@@ -0,0 +1,39 @@
+/* $Id$ */
+/** @file
+ * InnoTek Portable Runtime - Process, Ring-0 Driver, NT.
+ */
+
+/*
+ * Copyright (C) 2006 InnoTek Systemberatung GmbH
+ *
+ * This file is part of VirtualBox Open Source Edition (OSE), as
+ * available from http://www.virtualbox.org. This file is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU
+ * General Public License as published by the Free Software Foundation,
+ * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
+ * distribution. VirtualBox OSE is distributed in the hope that it will
+ * be useful, but WITHOUT ANY WARRANTY of any kind.
+ *
+ * If you received this file as part of a commercial VirtualBox
+ * distribution, then only the terms of your commercial VirtualBox
+ * license agreement apply instead of the previous paragraph.
+ */
+
+/*******************************************************************************
+*   Header Files                                                               *
+*******************************************************************************/
+#include "the-nt-kernel.h"
+#include <iprt/process.h>
+
+
+RTDECL(RTPROCESS) RTProcSelf(void)
+{
+    return (RTPROCESS)PsGetCurrentProcessId();
+}
+
+
+RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void)
+{
+    return (RTR0PROCESS)PsGetCurrentProcess();
+}
+
Index: /trunk/src/VBox/Runtime/r3/process.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/process.cpp	(revision 384)
+++ /trunk/src/VBox/Runtime/r3/process.cpp	(revision 385)
@@ -43,5 +43,5 @@
  * @returns Process identifier.
  */
-RTR3DECL(RTPROCESS) RTProcSelf(void)
+RTDECL(RTPROCESS) RTProcSelf(void)
 {
     RTPROCESS Self = g_ProcessSelf;
