Index: trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c	(revision 6131)
+++ trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c	(revision 6132)
@@ -162,4 +162,8 @@
     /** VMMDev Version. */
     uint32_t                u32Version;
+#ifndef USE_SESSION_HASH
+    /** Pointer to the session handle. */
+    PVBOXGUESTSESSION       pSession;
+#endif
 } VBoxAddDevState;
 
@@ -174,8 +178,10 @@
 /** Spinlock protecting g_apSessionHashTab. */
 static RTSPINLOCK           g_Spinlock = NIL_RTSPINLOCK;
+#ifdef USE_SESSION_HASH
 /** Hash table */
 static PVBOXGUESTSESSION    g_apSessionHashTab[19];
 /** Calculates the index into g_apSessionHashTab.*/
 #define SESSION_HASH(sfn) ((sfn) % RT_ELEMENTS(g_apSessionHashTab))
+#endif /* USE_SESSION_HASH */
 
 /** GCC C++ hack. */
@@ -238,4 +244,5 @@
 
             instance = ddi_get_instance(pDip);
+#ifdef USE_SESSION_HASH
             rc = ddi_soft_state_zalloc(g_pVBoxAddSolarisState, instance);
             if (rc != DDI_SUCCESS)
@@ -252,4 +259,12 @@
                 return DDI_FAILURE;
             }
+#else
+            pState = RTMemAllocZ(sizeof(VBoxAddDevState));
+            if (!pState)
+            {
+                VBA_LOGNOTE("RTMemAllocZ failed to allocate %d bytes\n", sizeof(VBoxAddDevState));
+                return DDI_FAILURE;
+            }
+#endif
 
             /*
@@ -405,5 +420,9 @@
             int rc;
             int instance = ddi_get_instance(pDip);
+#ifdef USE_SESSION_HASH
             VBoxAddDevState *pState = ddi_get_soft_state(g_pVBoxAddSolarisState, instance);
+#else
+            VBoxAddDevState *pState = ddi_get_driver_private(g_pDip);
+#endif
             if (pState)
             {
@@ -412,5 +431,9 @@
                 ddi_regs_map_free(&pState->PciMMIOHandle);
                 ddi_remove_minor_node(pDip, NULL);
+#ifdef USE_SESSION_HASH
                 ddi_soft_state_free(g_pVBoxAddSolarisState, instance);
+#else
+                RTMemFree(pState);
+#endif
 
                 rc = RTSpinlockDestroy(g_Spinlock);
@@ -480,4 +503,36 @@
     VBA_LOGCONT("VBoxAddSolarisOpen\n");
 
+#ifndef USE_SESSION_HASH
+    VBoxAddDevState *pState = NULL;
+    unsigned iOpenInstance;
+    for (iOpenInstance = 0; iOpenInstance < 4096; iOpenInstance++)
+    {
+        if (    !ddi_get_soft_state(g_pVBoxAddSolarisState, iOpenInstance) /* faster */
+            &&  ddi_soft_state_zalloc(g_pVBoxAddSolarisState, iOpenInstance) == DDI_SUCCESS)
+        {
+            pState = ddi_get_soft_state(g_pVBoxAddSolarisState, iOpenInstance);
+            break;
+        }
+    }
+    if (!pState)
+    {
+        VBA_LOGNOTE("VBoxAddSolarisOpen: too many open instances.");
+        return ENXIO;
+    }
+
+    /*
+     * Create a new session.
+     */
+    rc = VBoxGuestCreateUserSession(&g_DevExt, &pSession);
+    if (RT_SUCCESS(rc))
+    {
+        pState->pSession = pSession;
+        VBA_LOGCONT("VBoxAddSolarisOpen: pSession=%p pState=%p\n", pSession, pState);
+        return 0;
+    }
+
+    /* Failed, clean up. */
+    ddi_soft_state_free(g_pVBoxAddSolarisState, iOpenInstance);
+#else
     /*
      * Create a new session.
@@ -500,4 +555,5 @@
         return 0;
     }
+#endif
     LogRel(("VBoxAddSolarisOpen: VBoxGuestCreateUserSession failed. rc=%d\n", rc));
     return rc;
@@ -509,4 +565,5 @@
     VBA_LOGCONT("VBoxAddSolarisClose pid=%d\n", (int)RTProcSelf());
 
+#ifdef USE_SESSION_HASH
     /*
      * Remove from the hash table.
@@ -551,4 +608,22 @@
         return VERR_INVALID_PARAMETER;
     }
+#else
+    PVBOXGUESTSESSION pSession;
+    VBoxAddDevState *pState = ddi_get_soft_state(g_pVBoxAddSolarisState, getminor(Dev));
+    if (!pState)
+    {
+        VBA_LOGNOTE("VBoxAddSolarisClose: failed to get pState.\n");
+        return DDI_FAILURE;
+    }
+
+    pSession = pState->pSession;
+    pState->pSession = NULL;
+    ddi_soft_state_free(g_pVBoxAddSolarisState, getminor(Dev));
+    if (!pSession)
+    {
+        VBA_LOGNOTE("VBoxAddSolarisClose: failed to get pSession.\n");
+        return DDI_FAILURE;
+    }
+#endif
 
     /*
@@ -598,4 +673,5 @@
 
     /** @todo use the faster way to find pSession (using the soft state) */
+#ifdef USE_SESSION_HASH
     RTSPINLOCKTMP       Tmp = RTSPINLOCKTMP_INITIALIZER;
     const RTPROCESS     Process = RTProcSelf();
@@ -620,4 +696,22 @@
         return EINVAL;
     }
+#else
+    /*
+     * Get the session from the soft state item.
+     */
+    VBoxAddDevState *pState = ddi_get_soft_state(g_pVBoxAddSolarisState, getminor(Dev));
+    if (!pState)
+    {
+        VBA_LOGNOTE("VBoxAddSolarisIOCtl: no state data for %d\n", getminor(Dev));
+        return EINVAL;
+    }
+
+    PVBOXGUESTSESSION pSession = pState->pSession;
+    if (!pSession)
+    {
+        VBA_LOGNOTE("VBoxAddSolarisIOCtl: no session data for %d\n", getminor(Dev));
+        return DDI_SUCCESS;
+    }
+#endif
 
     /** @todo I'll remove this size check after testing. */
@@ -691,5 +785,5 @@
 #endif
 
-    cbBuf = IOCPARM_LEN(Cmd);    
+    cbBuf = IOCPARM_LEN(Cmd);
     void *pvBuf = RTMemTmpAlloc(cbBuf);
     if (RT_UNLIKELY(!pvBuf))
Index: trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk
===================================================================
--- trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk	(revision 6131)
+++ trunk/src/VBox/Additions/common/VBoxService/Makefile.kmk	(revision 6132)
@@ -39,4 +39,5 @@
 	$(VBOX_LIB_VBGL_R3) \
 	$(VBOX_LIB_IPRT_GUEST_R3)
+VBoxService_LIBS.solaris  = daemon
 
 include	$(PATH_KBUILD)/subfooter.kmk
Index: trunk/src/VBox/Additions/common/VBoxService/VBoxService-solaris.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxService/VBoxService-solaris.cpp	(revision 6131)
+++ trunk/src/VBox/Additions/common/VBoxService/VBoxService-solaris.cpp	(revision 6132)
@@ -26,7 +26,9 @@
 #include <signal.h>
 #include <fcntl.h>
+#include <libdaemon/dfork.h>
+#include <libdaemon/dsignal.h>
 
 /**
- * Solaris daemon() call. Probably might work for other Unix.
+ * Solaris daemon() call uses libdaemon.
  *
  * @returns 0 on success
@@ -34,4 +36,17 @@
 int daemon(int nochdir, int noclose)
 {
+    pid_t pid = daemon_fork();
+    if (pid < 0)
+    {
+        daemon_retval_done();
+        return -1;
+    }
+
+    if (pid)
+        exit(0);
+
+    daemon_close_all(-1);
+    return 0;
+#if 0
     if (getppid() == 1) /* We already belong to init process */
         return -1;
@@ -52,5 +67,5 @@
     int size = getdtablesize();
     if (size < 0)
-        size = 3;
+        size = 2;
 
     for (int i = size; i >= 0; i--)
@@ -74,4 +89,5 @@
     }
     return 0;
+#endif
 }
 
