Index: /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
===================================================================
--- /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c	(revision 6353)
+++ /trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c	(revision 6354)
@@ -21,5 +21,4 @@
 *******************************************************************************/
 #include <sys/conf.h>
-#include <sys/cmn_err.h>
 #include <sys/modctl.h>
 #include <sys/mutex.h>
@@ -35,5 +34,4 @@
 #include "VBoxGuestInternal.h"
 #include <VBox/log.h>
-#include <iprt/asm.h>
 #include <iprt/assert.h>
 #include <iprt/initterm.h>
@@ -567,5 +565,5 @@
         }
         *pDev = makedevice(getmajor(*pDev), instance);
-        Log((DEVICE_NAME "VBoxAddSolarisOpen: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
+        Log((DEVICE_NAME ":VBoxAddSolarisOpen success: g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
         return 0;
     }
@@ -737,5 +735,5 @@
         cbBuf = sizeof(VMMDevRequestHeader);
         requestType = 1;
-        LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_VMMREQUEST"));
+        LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_VMMREQUEST %#x", Cmd));
     }
 #ifdef VBOX_HGCM
@@ -744,13 +742,12 @@
         cbBuf = sizeof(VBoxGuestHGCMCallInfo);
         requestType = 2;
-        LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_HGCM_CALL", Cmd));
+        LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_HGCM_CALL %#x", Cmd));
     }
 #endif /* VBOX_HGCM */
     else if (VBOXGUEST_IOCTL_NUMBER(Cmd) == VBOXGUEST_IOCTL_NUMBER(VBOXGUEST_IOCTL_LOG(0)))
     {
-        /** Untested Code. Will be tested soon. */
         cbBuf = VBOXGUEST_IOCTL_SIZE(Cmd);
-        LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_LOG Cmd=%#x cbBuf=%d", Cmd, cbBuf));        
-        char* pszLogMsg = RTMemTmpAlloc(cbBuf);
+        LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_LOG Cmd=%#x cbBuf=%d", Cmd, cbBuf));
+        char *pszLogMsg = RTMemTmpAlloc(cbBuf);
         if (RT_UNLIKELY(!pszLogMsg))
         {
@@ -759,9 +756,10 @@
         }
         rc = ddi_copyin((void *)pArg, pszLogMsg, cbBuf, Mode);
-        if (rc == 0)
+        if (RT_UNLIKELY(rc))
+            LogRel((DEVICE_NAME ":ddi_copyin failed. rc=%d\n", rc));
+        else
             Log(("%.*s", cbBuf, pszLogMsg));
-        else
-            LogRel((DEVICE_NAME ":ddi_copyin failed. rc=%d\n", rc));
         RTMemTmpFree(pszLogMsg);
+        return rc;
     }
     else
@@ -808,9 +806,4 @@
         }
     }
-    if (RT_UNLIKELY(cbBuf > IOCPARM_LEN(Cmd)))
-    {
-        LogRel((DEVICE_NAME ":VBoxAddSolarisIOCtl: buffer size mismatch. size=%d expected=%d.\n", IOCPARM_LEN(Cmd), cbBuf));
-        return EINVAL;
-    }
 
     /*
@@ -834,5 +827,21 @@
         }
     }
-    /** @todo handle HGCM calls. */
+    else if (requestType == 2)
+    {
+        VBoxGuestHGCMCallInfo Hdr;
+        rc = ddi_copyin((void *)pArg, &Hdr, sizeof(Hdr), Mode);
+        if (RT_UNLIKELY(rc))
+        {
+            Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc));
+            return EINVAL;
+        }
+
+        if (RT_UNLIKELY(Hdr.cParms <= 0))
+        {
+            Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: Invalid request size. cParms=%d in HCGM call info header.\n", Hdr.cParms));
+            return EINVAL;
+        }
+        cbBuf += Hdr.cParms * sizeof(HGCMFunctionParameter);
+    }
 
     /*
@@ -901,5 +910,5 @@
     int rc;
     VBoxAddDevState *pState = (VBoxAddDevState *)pvState;
-    LogFlow((DEVICE_NAME "VBoxGuestSolarisAddIRQ\n"));
+    LogFlow((DEVICE_NAME ":VBoxGuestSolarisAddIRQ %p\n", pvState));
 
     /*
@@ -930,5 +939,5 @@
 static void VBoxGuestSolarisRemoveIRQ(dev_info_t *pDip, void *pvState)
 {
-    LogFlow((DEVICE_NAME ":VBoxGuestSolarisRemoveIRQ\n"));
+    LogFlow((DEVICE_NAME ":VBoxGuestSolarisRemoveIRQ pvState=%p\n"));
 
     VBoxAddDevState *pState = (VBoxAddDevState *)pvState;
@@ -945,5 +954,5 @@
 static uint_t VBoxGuestSolarisISR(caddr_t Arg)
 {
-    LogFlow((DEVICE_NAME ":VBoxGuestSolarisISR\n"));
+    LogFlow((DEVICE_NAME ":VBoxGuestSolarisISR Arg=%p\n", Arg));
 
     VBoxAddDevState *pState = (VBoxAddDevState *)Arg;
@@ -968,5 +977,5 @@
 DECLVBGL(int) VBoxGuestSolarisServiceCall(void *pvSession, unsigned iCmd, void *pvData, size_t cbData, size_t *pcbDataReturned)
 {
-    LogFlow((DEVICE_NAME ":VBoxGuestSolarisServiceCall\n"));
+    LogFlow((DEVICE_NAME ":VBoxGuestSolarisServiceCall %pvSesssion=%p Cmd=%u pvData=%p cbData=%d\n", pvSession, iCmd, pvData, cbData));
 
     PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession;
