Index: trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCr.cpp
===================================================================
--- trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCr.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/WINNT/Graphics/Video/mp/wddm/VBoxMPCr.cpp	(revision 68458)
@@ -840,8 +840,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_SET_VERSION;
-    parms.hdr.cParms      = SHCRGL_CPARMS_SET_VERSION;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32ClientID, SHCRGL_GUEST_FN_SET_VERSION, SHCRGL_CPARMS_SET_VERSION);
 
     parms.vMajor.type      = VMMDevHGCMParmType_32bit;
@@ -870,8 +867,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_GET_CAPS_LEGACY;
-    parms.hdr.cParms      = SHCRGL_CPARMS_GET_CAPS_LEGACY;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32ClientID, SHCRGL_GUEST_FN_GET_CAPS_LEGACY, SHCRGL_CPARMS_GET_CAPS_LEGACY);
 
     parms.Caps.type      = VMMDevHGCMParmType_32bit;
@@ -910,8 +904,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_GET_CAPS_NEW;
-    parms.hdr.cParms      = SHCRGL_CPARMS_GET_CAPS_NEW;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32ClientID, SHCRGL_GUEST_FN_GET_CAPS_NEW, SHCRGL_CPARMS_GET_CAPS_NEW);
 
     parms.Caps.type      = VMMDevHGCMParmType_LinAddr;
@@ -948,8 +939,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_SET_PID;
-    parms.hdr.cParms      = SHCRGL_CPARMS_SET_PID;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32ClientID, SHCRGL_GUEST_FN_SET_PID, SHCRGL_CPARMS_SET_PID);
 
     parms.u64PID.type     = VMMDevHGCMParmType_64bit;
Index: trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibClipboard.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibClipboard.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibClipboard.cpp	(revision 68458)
@@ -97,8 +97,5 @@
     VBoxClipboardGetHostMsg Msg;
 
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = VBOX_SHARED_CLIPBOARD_FN_GET_HOST_MSG;
-    Msg.hdr.cParms = 2;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_GET_HOST_MSG, 2);
     VbglHGCMParmUInt32Set(&Msg.msg, 0);
     VbglHGCMParmUInt32Set(&Msg.formats, 0);
@@ -146,8 +143,5 @@
     VBoxClipboardReadData Msg;
 
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = VBOX_SHARED_CLIPBOARD_FN_READ_DATA;
-    Msg.hdr.cParms = 3;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_READ_DATA, 3);
     VbglHGCMParmUInt32Set(&Msg.format, fFormat);
     VbglHGCMParmPtrSet(&Msg.ptr, pv, cb);
@@ -186,8 +180,5 @@
     VBoxClipboardFormats Msg;
 
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = VBOX_SHARED_CLIPBOARD_FN_FORMATS;
-    Msg.hdr.cParms = 1;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_FORMATS, 1);
     VbglHGCMParmUInt32Set(&Msg.formats, fFormats);
 
@@ -214,8 +205,5 @@
 {
     VBoxClipboardWriteData Msg;
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA;
-    Msg.hdr.cParms = 2;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, VBOX_SHARED_CLIPBOARD_FN_WRITE_DATA, 2);
     VbglHGCMParmUInt32Set(&Msg.format, fFormat);
     VbglHGCMParmPtrSet(&Msg.ptr, pv, cb);
Index: trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibDragAndDrop.cpp	(revision 68458)
@@ -56,5 +56,5 @@
 *   Forward declarations                                                                                                         *
 *********************************************************************************************************************************/
-
+/** @todo r=bird: What's this? publicly accessible symbol that's not in a header? Shouldn't this be a static function perhaps? */
 VBGLR3DECL(int) VbglR3DnDHGSendProgress(PVBGLR3GUESTDNDCMDCTX pCtx, uint32_t uStatus, uint8_t uPercent, int rcErr);
 
@@ -72,9 +72,5 @@
     VBOXDNDNEXTMSGMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_DND_GET_NEXT_HOST_MSG;
-    Msg.hdr.cParms      = 3;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GET_NEXT_HOST_MSG, 3);
     Msg.uMsg.SetUInt32(0);
     Msg.cParms.SetUInt32(0);
@@ -119,12 +115,7 @@
     VBOXDNDHGACTIONMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = uMsg;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 7;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, uMsg, 7);
         Msg.u.v1.uScreenId.SetUInt32(0);
         Msg.u.v1.uX.SetUInt32(0);
@@ -137,6 +128,5 @@
     else
     {
-        Msg.hdr.cParms = 8;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, uMsg, 8);
         Msg.u.v3.uContext.SetUInt32(0);
         Msg.u.v3.uScreenId.SetUInt32(0);
@@ -188,15 +178,9 @@
     VBOXDNDHGLEAVEMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_EVT_LEAVE;
-
     if (pCtx->uProtocol < 3)
-    {
-        Msg.hdr.cParms = 0;
-    }
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_EVT_LEAVE, 0);
     else
     {
-        Msg.hdr.cParms = 1;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_EVT_LEAVE, 1);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -216,16 +200,9 @@
     VBOXDNDHGCANCELMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_EVT_CANCEL;
-
     if (pCtx->uProtocol < 3)
-    {
-        Msg.hdr.cParms = 0;
-    }
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_EVT_CANCEL, 0);
     else
     {
-        Msg.hdr.cParms = 1;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_EVT_CANCEL, 1);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -253,12 +230,7 @@
     VBOXDNDHGSENDDIRMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_SND_DIR;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 3;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_DIR, 3);
         Msg.u.v1.pvName.SetPtr(pszDirname, cbDirname);
         Msg.u.v1.cbName.SetUInt32(cbDirname);
@@ -267,6 +239,5 @@
     else
     {
-        Msg.hdr.cParms = 4;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_DIR, 4);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -321,10 +292,7 @@
     VBOXDNDHGSENDFILEDATAMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_SND_FILE_DATA;
-
     if (pCtx->uProtocol <= 1)
     {
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_FILE_DATA, 5);
         Msg.u.v1.pvName.SetPtr(pszFilename, cbFilename);
         Msg.u.v1.cbName.SetUInt32(0);
@@ -332,17 +300,15 @@
         Msg.u.v1.cbData.SetUInt32(0);
         Msg.u.v1.fMode.SetUInt32(0);
-
-        Msg.hdr.cParms = 5;
     }
     else if (pCtx->uProtocol == 2)
     {
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_FILE_DATA, 3);
         Msg.u.v2.uContext.SetUInt32(0);
         Msg.u.v2.pvData.SetPtr(pvData, cbData);
         Msg.u.v2.cbData.SetUInt32(cbData);
-
-        Msg.hdr.cParms = 3;
     }
     else if (pCtx->uProtocol >= 3)
     {
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_FILE_DATA, 5);
         Msg.u.v3.uContext.SetUInt32(0);
         Msg.u.v3.pvData.SetPtr(pvData, cbData);
@@ -350,6 +316,4 @@
         Msg.u.v3.pvChecksum.SetPtr(NULL, 0);
         Msg.u.v3.cbChecksum.SetUInt32(0);
-
-        Msg.hdr.cParms = 5;
     }
     else
@@ -408,18 +372,10 @@
     VBOXDNDHGSENDFILEHDRMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_SND_FILE_HDR;
-
     int rc;
-
     if (pCtx->uProtocol <= 1)
-    {
         rc = VERR_NOT_SUPPORTED;
-    }
     else
     {
-        Msg.hdr.cParms = 6;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_FILE_HDR, 6);
         Msg.uContext.SetUInt32(0); /** @todo Not used yet. */
         Msg.pvName.SetPtr(pszFilename, cbFilename);
@@ -780,13 +736,8 @@
     VBOXDNDHGSENDDATAMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_SND_DATA;
-
     int rc;
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms  = 5;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_DATA, 5);
         Msg.u.v1.uScreenId.SetUInt32(0);
         Msg.u.v1.pvFormat.SetPtr(pDataHdr->pvMetaFmt, pDataHdr->cbMetaFmt);
@@ -849,6 +800,5 @@
     else /* Protocol v3 and up. */
     {
-        Msg.hdr.cParms = 5;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_DATA, 5);
         Msg.u.v3.uContext.SetUInt32(0);
         Msg.u.v3.pvData.SetPtr(pvData, cbData);
@@ -893,9 +843,5 @@
     VBOXDNDHGSENDDATAHDRMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_SND_DATA_HDR;
-    Msg.hdr.cParms      = 12;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_DATA_HDR, 12);
     Msg.uContext.SetUInt32(0);
     Msg.uFlags.SetUInt32(0);
@@ -944,9 +890,5 @@
     VBOXDNDHGSENDMOREDATAMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_HG_SND_MORE_DATA;
-    Msg.hdr.cParms      = 2;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_HG_SND_MORE_DATA, 2);
     Msg.pvData.SetPtr(pvData, cbData);
     Msg.cbData.SetUInt32(0);
@@ -1235,18 +1177,12 @@
     VBOXDNDGHREQPENDINGMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_GH_REQ_PENDING;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 1;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_GH_REQ_PENDING, 1);
         Msg.u.v1.uScreenId.SetUInt32(0);
     }
     else
     {
-        Msg.hdr.cParms = 2;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_GH_REQ_PENDING, 2);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -1289,12 +1225,7 @@
     VBOXDNDGHDROPPEDMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = HOST_DND_GH_EVT_DROPPED;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 3;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_GH_EVT_DROPPED, 3);
         Msg.u.v1.pvFormat.SetPtr(pszFormat, cbFormat);
         Msg.u.v1.cbFormat.SetUInt32(0);
@@ -1303,6 +1234,5 @@
     else
     {
-        Msg.hdr.cParms = 4;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, HOST_DND_GH_EVT_DROPPED, 4);
         Msg.u.v3.uContext.SetUInt32(0);
         Msg.u.v3.pvFormat.SetPtr(pszFormat, cbFormat);
@@ -1417,12 +1347,7 @@
         VBOXDNDCONNECTMSG Msg;
         RT_ZERO(Msg);
-        Msg.hdr.result      = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = pCtx->uClientID;
-        Msg.hdr.u32Function = GUEST_DND_CONNECT;
-
         if (pCtx->uProtocol < 3)
         {
-            Msg.hdr.cParms = 2;
-
+            VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_CONNECT, 2);
             Msg.u.v2.uProtocol.SetUInt32(pCtx->uProtocol);
             Msg.u.v2.uFlags.SetUInt32(0); /* Unused at the moment. */
@@ -1430,6 +1355,5 @@
         else
         {
-            Msg.hdr.cParms = 3;
-
+            VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_CONNECT, 3);
             /** @todo Context ID not used yet. */
             Msg.u.v3.uContext.SetUInt32(0);
@@ -1609,20 +1533,13 @@
     VBOXDNDHGACKOPMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_DND_HG_ACK_OP;
-
     LogFlowFunc(("uProto=%RU32\n", pCtx->uProtocol));
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 1;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_HG_ACK_OP, 1);
         Msg.u.v1.uAction.SetUInt32(uAction);
     }
     else
     {
-        Msg.hdr.cParms = 2;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_HG_ACK_OP, 2);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -1641,26 +1558,19 @@
     AssertPtrReturn(pCtx,       VERR_INVALID_POINTER);
     AssertPtrReturn(pcszFormat, VERR_INVALID_POINTER);
+    if (!RTStrIsValidEncoding(pcszFormat))
+        return VERR_INVALID_PARAMETER;
+
+    const uint32_t cbFormat = (uint32_t)strlen(pcszFormat) + 1; /* Include termination */
 
     VBOXDNDHGREQDATAMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_DND_HG_REQ_DATA;
-
-    if (!RTStrIsValidEncoding(pcszFormat))
-        return VERR_INVALID_PARAMETER;
-
-    const uint32_t cbFormat = (uint32_t)strlen(pcszFormat) + 1; /* Include termination */
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 1;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_HG_REQ_DATA, 1);
         Msg.u.v1.pvFormat.SetPtr((void*)pcszFormat, cbFormat);
     }
     else
     {
-        Msg.hdr.cParms = 3;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_HG_REQ_DATA, 3);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -1683,12 +1593,7 @@
     VBOXDNDHGEVTPROGRESSMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = uStatus;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 3;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, uStatus, 3); /** @todo r=bird: Do we really mean to execute 'uStatus' here? */
         Msg.u.v1.uStatus.SetUInt32(uStatus);
         Msg.u.v1.uPercent.SetUInt32(uPercent);
@@ -1697,6 +1602,5 @@
     else
     {
-        Msg.hdr.cParms = 4;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, uStatus, 4); /** @todo r=bird: Do we really mean to execute 'uStatus' here? */
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -1714,4 +1618,5 @@
 
 #ifdef VBOX_WITH_DRAG_AND_DROP_GH
+
 VBGLR3DECL(int) VbglR3DnDGHSendAckPending(PVBGLR3GUESTDNDCMDCTX pCtx,
                                           uint32_t uDefAction, uint32_t uAllActions, const char* pcszFormats, uint32_t cbFormats)
@@ -1726,12 +1631,7 @@
     VBOXDNDGHACKPENDINGMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_DND_GH_ACK_PENDING;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 3;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_ACK_PENDING, 3);
         Msg.u.v1.uDefAction.SetUInt32(uDefAction);
         Msg.u.v1.uAllActions.SetUInt32(uAllActions);
@@ -1740,6 +1640,5 @@
     else
     {
-        Msg.hdr.cParms = 5;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_ACK_PENDING, 5);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -1775,9 +1674,5 @@
         VBOXDNDGHSENDDATAHDRMSG Msg;
         RT_ZERO(Msg);
-        Msg.hdr.result      = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = pCtx->uClientID;
-        Msg.hdr.u32Function = GUEST_DND_GH_SND_DATA_HDR;
-        Msg.hdr.cParms      = 12;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_DATA_HDR, 12);
         Msg.uContext.SetUInt32(0);                           /** @todo Not used yet. */
         Msg.uFlags.SetUInt32(0);                             /** @todo Not used yet. */
@@ -1805,12 +1700,7 @@
         VBOXDNDGHSENDDATAMSG Msg;
         RT_ZERO(Msg);
-        Msg.hdr.result      = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = pCtx->uClientID;
-        Msg.hdr.u32Function = GUEST_DND_GH_SND_DATA;
-
         if (pCtx->uProtocol >= 3)
         {
-            Msg.hdr.cParms = 5;
-
+            VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_DATA, 5);
             Msg.u.v3.uContext.SetUInt32(0);      /** @todo Not used yet. */
             Msg.u.v3.pvChecksum.SetPtr(NULL, 0); /** @todo Not used yet. */
@@ -1819,5 +1709,5 @@
         else
         {
-            Msg.hdr.cParms = 2;
+            VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_DATA, 2);
 
             /* Total amount of bytes to send (meta data + all directory/file objects). */
@@ -1878,12 +1768,7 @@
     VBOXDNDGHSENDDIRMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_DND_GH_SND_DIR;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 3;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_DIR, 3);
         Msg.u.v1.pvName.SetPtr((void *)strPath.c_str(), (uint32_t)cbPath);
         Msg.u.v1.cbName.SetUInt32((uint32_t)cbPath);
@@ -1892,6 +1777,5 @@
     else
     {
-        Msg.hdr.cParms = 4;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_DIR, 4);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -1933,9 +1817,5 @@
         VBOXDNDGHSENDFILEHDRMSG MsgHdr;
         RT_ZERO(MsgHdr);
-        MsgHdr.hdr.result      = VERR_WRONG_ORDER;
-        MsgHdr.hdr.u32ClientID = pCtx->uClientID;
-        MsgHdr.hdr.u32Function = GUEST_DND_GH_SND_FILE_HDR;
-        MsgHdr.hdr.cParms      = 6;
-
+        VBGL_HGCM_HDR_INIT(&MsgHdr.hdr, pCtx->uClientID, GUEST_DND_GH_SND_FILE_HDR, 6);
         MsgHdr.uContext.SetUInt32(0);                                                    /* Context ID; unused at the moment. */
         MsgHdr.pvName.SetPtr((void *)strPath.c_str(), (uint32_t)(strPath.length() + 1));
@@ -1961,14 +1841,9 @@
         VBOXDNDGHSENDFILEDATAMSG Msg;
         RT_ZERO(Msg);
-        Msg.hdr.result      = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = pCtx->uClientID;
-        Msg.hdr.u32Function = GUEST_DND_GH_SND_FILE_DATA;
-
         switch (pCtx->uProtocol)
         {
             case 3:
             {
-                Msg.hdr.cParms = 5;
-
+                VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_FILE_DATA, 5);
                 Msg.u.v3.uContext.SetUInt32(0);
                 Msg.u.v3.pvChecksum.SetPtr(NULL, 0);
@@ -1979,6 +1854,5 @@
             case 2:
             {
-                Msg.hdr.cParms  = 3;
-
+                VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_FILE_DATA, 3);
                 Msg.u.v2.uContext.SetUInt32(0);
                 break;
@@ -1987,6 +1861,5 @@
             default: /* Protocol v1 */
             {
-                Msg.hdr.cParms  = 5;
-
+                VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_SND_FILE_DATA, 5);
                 Msg.u.v1.pvName.SetPtr((void *)strPath.c_str(), (uint32_t)(strPath.length() + 1));
                 Msg.u.v1.cbName.SetUInt32((uint32_t)(strPath.length() + 1));
@@ -2203,18 +2076,12 @@
     VBOXDNDGHEVTERRORMSG Msg;
     RT_ZERO(Msg);
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_DND_GH_EVT_ERROR;
-
     if (pCtx->uProtocol < 3)
     {
-        Msg.hdr.cParms = 1;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_EVT_ERROR, 1);
         Msg.u.v1.rc.SetUInt32((uint32_t)rcErr); /* uint32_t vs. int. */
     }
     else
     {
-        Msg.hdr.cParms = 2;
-
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_DND_GH_EVT_ERROR, 2);
         /** @todo Context ID not used yet. */
         Msg.u.v3.uContext.SetUInt32(0);
@@ -2238,4 +2105,5 @@
     return rc;
 }
+
 #endif /* VBOX_WITH_DRAG_AND_DROP_GH */
 
Index: trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestCtrl.cpp	(revision 68458)
@@ -104,10 +104,7 @@
 
     HGCMMsgCmdWaitFor Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = uClientId;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT; /* Tell the host we want our next command. */
-    Msg.hdr.cParms      = 2;              /* Just peek for the next message! */
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId,
+                       GUEST_MSG_WAIT,      /* Tell the host we want our next command. */
+                       2);                  /* Just peek for the next message! */
     VbglHGCMParmUInt32Set(&Msg.msg, 0);
     VbglHGCMParmUInt32Set(&Msg.num_parms, 0);
@@ -145,9 +142,6 @@
     HGCMMsgCmdFilterSet Msg;
 
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = uClientId;
-    Msg.hdr.u32Function = GUEST_MSG_FILTER_SET; /* Tell the host we want to set a filter. */
-    Msg.hdr.cParms      = 4;
-
+    /* Tell the host we want to set a filter. */
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_SET, 4);
     VbglHGCMParmUInt32Set(&Msg.value, uValue);
     VbglHGCMParmUInt32Set(&Msg.mask_add, uMaskAdd);
@@ -170,11 +164,7 @@
 VBGLR3DECL(int) VbglR3GuestCtrlMsgFilterUnset(uint32_t uClientId)
 {
+    /* Tell the host we want to unset the filter. */
     HGCMMsgCmdFilterUnset Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = uClientId;
-    Msg.hdr.u32Function = GUEST_MSG_FILTER_UNSET; /* Tell the host we want to unset the filter. */
-    Msg.hdr.cParms      = 1;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_FILTER_UNSET, 1);
     VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
 
@@ -202,10 +192,5 @@
 
     HGCMMsgCmdReply Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_REPLY;
-    Msg.hdr.cParms      = 4;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_REPLY, 4);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.rc, (uint32_t)rc); /* int vs. uint32_t */
@@ -235,10 +220,6 @@
     HGCMMsgCmdSkip Msg;
 
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = uClientId;
-    Msg.hdr.u32Function = GUEST_MSG_SKIP; /* Tell the host we want to skip
-                                             the current assigned command. */
-    Msg.hdr.cParms      = 1;
-
+    /* Tell the host we want to skip the current assigned command. */
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_MSG_SKIP, 1);
     VbglHGCMParmUInt32Set(&Msg.flags, 0 /* Flags, unused */);
 
@@ -260,10 +241,5 @@
 {
     HGCMMsgCancelPendingWaits Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = uClientId;
-    Msg.hdr.u32Function = GUEST_CANCEL_PENDING_WAITS;
-    Msg.hdr.cParms      = 0;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, uClientId, GUEST_CANCEL_PENDING_WAITS, 0);
     int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
     if (RT_SUCCESS(rc))
@@ -291,10 +267,5 @@
 
     HGCMMsgSessionClose Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_SESSION_CLOSE;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_SESSION_CLOSE, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.flags, fFlags);
@@ -317,10 +288,5 @@
 
     HGCMMsgSessionNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_SESSION_NOTIFY;
-    Msg.hdr.cParms      = 3;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_SESSION_NOTIFY, 3);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, uType);
@@ -361,10 +327,5 @@
 
     HGCMMsgSessionOpen Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.protocol, 0);
@@ -411,10 +372,5 @@
 
     HGCMMsgSessionClose Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.flags, 0);
@@ -457,10 +413,5 @@
 
     HGCMMsgPathRename Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmPtrSet(&Msg.source, pszSource, cbSource);
@@ -518,10 +469,5 @@
 
     HGCMMsgProcExec Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmPtrSet(&Msg.cmd, pszCmd, cbCmd);
@@ -604,10 +550,5 @@
 
     HGCMMsgProcOutput Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.pid, 0);
@@ -658,10 +599,5 @@
 
     HGCMMsgProcInput Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.pid, 0);
@@ -702,10 +638,5 @@
 
     HGCMMsgDirRemove Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmPtrSet(&Msg.path, pszPath, cbPath);
@@ -753,10 +684,5 @@
 
     HGCMMsgFileOpen Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmPtrSet(&Msg.filename, pszFileName, cbFileName);
@@ -794,10 +720,5 @@
 
     HGCMMsgFileClose Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -831,10 +752,5 @@
 
     HGCMMsgFileRead Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -870,10 +786,5 @@
 
     HGCMMsgFileReadAt Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -913,10 +824,5 @@
 
     HGCMMsgFileWrite Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -955,10 +861,5 @@
 
     HGCMMsgFileWriteAt Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -998,10 +899,5 @@
 
     HGCMMsgFileSeek Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -1037,10 +933,5 @@
 
     HGCMMsgFileTell Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.handle, 0);
@@ -1072,10 +963,5 @@
 
     HGCMMsgProcTerminate Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.pid, 0);
@@ -1108,10 +994,5 @@
 
     HGCMMsgProcWaitFor Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_MSG_WAIT;
-    Msg.hdr.cParms      = pCtx->uNumParms;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_MSG_WAIT, pCtx->uNumParms);
     VbglHGCMParmUInt32Set(&Msg.context, 0);
     VbglHGCMParmUInt32Set(&Msg.pid, 0);
@@ -1145,14 +1026,8 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 4;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_OPEN);
     VbglHGCMParmUInt32Set(&Msg.rc, uRc);
-
     VbglHGCMParmUInt32Set(&Msg.u.open.handle, uFileHandle);
 
@@ -1174,10 +1049,5 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 3;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 3);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_CLOSE);
@@ -1200,10 +1070,5 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 3;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 3);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_ERROR);
@@ -1228,14 +1093,8 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 4;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_READ);
     VbglHGCMParmUInt32Set(&Msg.rc, uRc);
-
     VbglHGCMParmPtrSet(&Msg.u.read.data, pvData, cbData);
 
@@ -1257,14 +1116,8 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 4;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_WRITE);
     VbglHGCMParmUInt32Set(&Msg.rc, uRc);
-
     VbglHGCMParmUInt32Set(&Msg.u.write.written, uWritten);
 
@@ -1286,14 +1139,8 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 4;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_SEEK);
     VbglHGCMParmUInt32Set(&Msg.rc, uRc);
-
     VbglHGCMParmUInt64Set(&Msg.u.seek.offset, uOffActual);
 
@@ -1315,14 +1162,8 @@
 
     HGCMReplyFileNotify Msg;
-
-    Msg.hdr.result      = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_FILE_NOTIFY;
-    Msg.hdr.cParms      = 4;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_FILE_NOTIFY, 4);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.type, GUEST_FILE_NOTIFYTYPE_TELL);
     VbglHGCMParmUInt32Set(&Msg.rc, uRc);
-
     VbglHGCMParmUInt64Set(&Msg.u.tell.offset, uOffActual);
 
@@ -1351,10 +1192,5 @@
 
     HGCMMsgProcStatus Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_EXEC_STATUS;
-    Msg.hdr.cParms = 5;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_STATUS, 5);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.pid, uPID);
@@ -1387,10 +1223,5 @@
 
     HGCMMsgProcOutput Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_EXEC_OUTPUT;
-    Msg.hdr.cParms = 5;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_OUTPUT, 5);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.pid, uPID);
@@ -1423,10 +1254,5 @@
 
     HGCMMsgProcStatusInput Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = pCtx->uClientID;
-    Msg.hdr.u32Function = GUEST_EXEC_INPUT_STATUS;
-    Msg.hdr.cParms = 5;
-
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, pCtx->uClientID, GUEST_EXEC_INPUT_STATUS, 5);
     VbglHGCMParmUInt32Set(&Msg.context, pCtx->uContextID);
     VbglHGCMParmUInt32Set(&Msg.pid, uPID);
Index: trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibGuestProp.cpp	(revision 68458)
@@ -185,9 +185,5 @@
     {
         SetProperty Msg;
-
-        Msg.hdr.result = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = idClient;
-        Msg.hdr.u32Function = SET_PROP_VALUE;
-        Msg.hdr.cParms = 3;
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, SET_PROP_VALUE, 3);
         VbglHGCMParmPtrSetString(&Msg.name,  pszName);
         VbglHGCMParmPtrSetString(&Msg.value, pszValue);
@@ -200,9 +196,5 @@
     {
         DelProperty Msg;
-
-        Msg.hdr.result = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = idClient;
-        Msg.hdr.u32Function = DEL_PROP;
-        Msg.hdr.cParms = 1;
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, DEL_PROP, 1);
         VbglHGCMParmPtrSetString(&Msg.name, pszName);
         rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
@@ -234,9 +226,5 @@
     {
         SetPropertyValue Msg;
-
-        Msg.hdr.result = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = idClient;
-        Msg.hdr.u32Function = SET_PROP_VALUE;
-        Msg.hdr.cParms = 2;
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, SET_PROP_VALUE, 2);
         VbglHGCMParmPtrSetString(&Msg.name, pszName);
         VbglHGCMParmPtrSetString(&Msg.value, pszValue);
@@ -248,9 +236,5 @@
     {
         DelProperty Msg;
-
-        Msg.hdr.result = VERR_WRONG_ORDER;
-        Msg.hdr.u32ClientID = idClient;
-        Msg.hdr.u32Function = DEL_PROP;
-        Msg.hdr.cParms = 1;
+        VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, DEL_PROP, 1);
         VbglHGCMParmPtrSetString(&Msg.name, pszName);
         rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
@@ -342,9 +326,5 @@
      */
     GetProperty Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = GET_PROP;
-    Msg.hdr.cParms = 4;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, GET_PROP, 4);
     VbglHGCMParmPtrSetString(&Msg.name, pszName);
     VbglHGCMParmPtrSet(&Msg.buffer, pvBuf, cbBuf);
@@ -544,9 +524,6 @@
 {
     EnumProperties Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = ENUM_PROPS;
-    Msg.hdr.cParms = 3;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, ENUM_PROPS, 3);
+
     /* Get the length of the patterns array... */
     size_t cchPatterns = 0;
@@ -814,9 +791,5 @@
 
     DelProperty Msg;
-
-    Msg.hdr.result = VERR_WRONG_ORDER;
-    Msg.hdr.u32ClientID = idClient;
-    Msg.hdr.u32Function = DEL_PROP;
-    Msg.hdr.cParms = 1;
+    VBGL_HGCM_HDR_INIT(&Msg.hdr, idClient, DEL_PROP, 1);
     VbglHGCMParmPtrSetString(&Msg.name, pszName);
     int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(Msg)), &Msg, sizeof(Msg));
@@ -924,11 +897,6 @@
      */
     GetNotification Msg;
-
-    Msg.hdr.u32Timeout = cMillies;
-    Msg.hdr.fInterruptible = true;
-    Msg.hdr.info.result = VERR_WRONG_ORDER;
-    Msg.hdr.info.u32ClientID = idClient;
-    Msg.hdr.info.u32Function = GET_NOTIFICATION;
-    Msg.hdr.info.cParms = 4;
+    VBGL_HGCM_HDR_INIT_TIMED(&Msg.hdr, idClient, GET_NOTIFICATION, 4, cMillies);
+
     VbglHGCMParmPtrSetString(&Msg.patterns, pszPatterns);
     Msg.buffer.SetPtr(pvBuf, cbBuf);
Index: trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostChannel.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostChannel.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibHostChannel.cpp	(revision 68458)
@@ -83,10 +83,5 @@
 
     VBoxHostChannelAttach parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_ATTACH;
-    parms.hdr.cParms = 3;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_ATTACH, 3);
     VbglHGCMParmPtrSet(&parms.name, pszCopy, (uint32_t)cbName);
     VbglHGCMParmUInt32Set(&parms.flags, u32Flags);
@@ -113,10 +108,5 @@
 {
     VBoxHostChannelDetach parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_DETACH;
-    parms.hdr.cParms = 1;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_DETACH, 1);
     VbglHGCMParmUInt32Set(&parms.handle, u32ChannelHandle);
 
@@ -130,10 +120,5 @@
 {
     VBoxHostChannelSend parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_SEND;
-    parms.hdr.cParms = 2;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_SEND, 2);
     VbglHGCMParmUInt32Set(&parms.handle, u32ChannelHandle);
     VbglHGCMParmPtrSet(&parms.data, pvData, cbData);
@@ -157,10 +142,5 @@
 {
     VBoxHostChannelRecv parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_RECV;
-    parms.hdr.cParms = 4;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_RECV, 4);
     VbglHGCMParmUInt32Set(&parms.handle, u32ChannelHandle);
     VbglHGCMParmPtrSet(&parms.data, pvData, cbData);
@@ -194,10 +174,5 @@
 {
     VBoxHostChannelControl parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_CONTROL;
-    parms.hdr.cParms = 5;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_CONTROL, 5);
     VbglHGCMParmUInt32Set(&parms.handle, u32ChannelHandle);
     VbglHGCMParmUInt32Set(&parms.code, u32Code);
@@ -229,10 +204,5 @@
 {
     VBoxHostChannelEventWait parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_EVENT_WAIT;
-    parms.hdr.cParms = 4;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_EVENT_WAIT, 4);
     VbglHGCMParmUInt32Set(&parms.handle, 0);
     VbglHGCMParmUInt32Set(&parms.id, 0);
@@ -260,11 +230,8 @@
                                              uint32_t u32HGCMClientId)
 {
+    RT_NOREF1(u32ChannelHandle);
+
     VBoxHostChannelEventCancel parms;
-    RT_NOREF1(u32ChannelHandle);
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_EVENT_CANCEL;
-    parms.hdr.cParms = 0;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_EVENT_CANCEL, 0);
 
     int rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_HGCM_CALL(sizeof(parms)), &parms, sizeof(parms));
@@ -298,10 +265,5 @@
 
     VBoxHostChannelQuery parms;
-
-    parms.hdr.result = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = u32HGCMClientId;
-    parms.hdr.u32Function = VBOX_HOST_CHANNEL_FN_QUERY;
-    parms.hdr.cParms = 5;
-
+    VBGL_HGCM_HDR_INIT(&parms.hdr, u32HGCMClientId, VBOX_HOST_CHANNEL_FN_QUERY, 5);
     VbglHGCMParmPtrSet(&parms.name, pszCopy, (uint32_t)cbName);
     VbglHGCMParmUInt32Set(&parms.code, u32Code);
Index: trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp
===================================================================
--- trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibSharedFolders.cpp	(revision 68458)
@@ -144,9 +144,5 @@
 
     VBoxSFQueryMappings Msg;
-
-    Msg.callInfo.result = VERR_WRONG_ORDER;
-    Msg.callInfo.u32ClientID = idClient;
-    Msg.callInfo.u32Function = SHFL_FN_QUERY_MAPPINGS;
-    Msg.callInfo.cParms = 3;
+    VBGL_HGCM_HDR_INIT(&Msg.callInfo, idClient, SHFL_FN_QUERY_MAPPINGS, 3);
 
     /* Set the mapping flags. */
@@ -237,9 +233,5 @@
 
     VBoxSFQueryMapName Msg;
-
-    Msg.callInfo.result = VERR_WRONG_ORDER;
-    Msg.callInfo.u32ClientID = idClient;
-    Msg.callInfo.u32Function = SHFL_FN_QUERY_MAP_NAME;
-    Msg.callInfo.cParms = 2;
+    VBGL_HGCM_HDR_INIT(&Msg.callInfo, idClient, SHFL_FN_QUERY_MAP_NAME, 2);
 
     int         rc;
Index: trunk/src/VBox/Additions/x11/VBoxClient/check3d.cpp
===================================================================
--- trunk/src/VBox/Additions/x11/VBoxClient/check3d.cpp	(revision 68457)
+++ trunk/src/VBox/Additions/x11/VBoxClient/check3d.cpp	(revision 68458)
@@ -30,5 +30,5 @@
 {
     int rc;
-    HGCMCLIENTID cClientID;
+    HGCMCLIENTID idClient;
     CRVBOXHGCMGETCAPS caps;
     LogFlowFunc(("\n"));
@@ -40,12 +40,9 @@
     if (RT_FAILURE(rc))
         exit(1);
-    rc = VbglR3HGCMConnect("VBoxSharedCrOpenGL", &cClientID);
+    rc = VbglR3HGCMConnect("VBoxSharedCrOpenGL", &idClient);
     if (RT_FAILURE(rc))
         exit(1);
-    caps.hdr.result      = VERR_WRONG_ORDER;
-    caps.hdr.u32ClientID = cClientID;
-    caps.hdr.u32Function = SHCRGL_GUEST_FN_GET_CAPS_LEGACY;
-    caps.hdr.cParms      = SHCRGL_CPARMS_GET_CAPS_LEGACY;
 
+    VBGL_HGCM_HDR_INIT(&caps.hdr, idClient, SHCRGL_GUEST_FN_GET_CAPS_LEGACY, SHCRGL_CPARMS_GET_CAPS_LEGACY);
     caps.Caps.type       = VMMDevHGCMParmType_32bit;
     caps.Caps.u.value32  = 0;
@@ -56,5 +53,5 @@
     if (caps.Caps.u.value32 & CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT)
         exit(1);
-    VbglR3HGCMDisconnect(cClientID);
+    VbglR3HGCMDisconnect(idClient);
     VbglR3Term();
     LogFlowFunc(("returning %Rrc\n", rc));
Index: trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c	(revision 68457)
+++ trunk/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c	(revision 68458)
@@ -757,8 +757,5 @@
         CRVBOXHGCMINJECT parms;
 
-        parms.hdr.result      = VERR_WRONG_ORDER;
-        parms.hdr.u32ClientID = conn->u32ClientID;
-        parms.hdr.u32Function = SHCRGL_GUEST_FN_INJECT;
-        parms.hdr.cParms      = SHCRGL_CPARMS_INJECT;
+        VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_INJECT, SHCRGL_CPARMS_INJECT);
 
         parms.u32ClientID.type       = VMMDevHGCMParmType_32bit;
@@ -777,8 +774,5 @@
         CRVBOXHGCMWRITE parms;
 
-        parms.hdr.result      = VERR_WRONG_ORDER;
-        parms.hdr.u32ClientID = conn->u32ClientID;
-        parms.hdr.u32Function = SHCRGL_GUEST_FN_WRITE;
-        parms.hdr.cParms      = SHCRGL_CPARMS_WRITE;
+        VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE, SHCRGL_CPARMS_WRITE);
 
         parms.pBuffer.type                   = VMMDevHGCMParmType_LinAddr_In;
@@ -815,8 +809,5 @@
     RT_NOREF(buf, len);
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_READ;
-    parms.hdr.cParms      = SHCRGL_CPARMS_READ;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_READ, SHCRGL_CPARMS_READ);
 
     CRASSERT(!conn->pBuffer); /* make sure there's no data to process */
@@ -858,8 +849,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_WRITE_READ;
-    parms.hdr.cParms      = SHCRGL_CPARMS_WRITE_READ;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE_READ, SHCRGL_CPARMS_WRITE_READ);
 
     parms.pBuffer.type                   = VMMDevHGCMParmType_LinAddr_In;
@@ -883,8 +871,5 @@
         CRVBOXHGCMWRITEBUFFER wbParms;
 
-        wbParms.hdr.result = VERR_WRONG_ORDER;
-        wbParms.hdr.u32ClientID = conn->u32ClientID;
-        wbParms.hdr.u32Function = SHCRGL_GUEST_FN_WRITE_BUFFER;
-        wbParms.hdr.cParms = SHCRGL_CPARMS_WRITE_BUFFER;
+        VBGL_HGCM_HDR_INIT(&wbParms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE_BUFFER, SHCRGL_CPARMS_WRITE_BUFFER);
 
         wbParms.iBufferID.type = VMMDevHGCMParmType_32bit;
@@ -927,8 +912,5 @@
             CRVBOXHGCMWRITEREADBUFFERED wrbParms;
 
-            wrbParms.hdr.result = VERR_WRONG_ORDER;
-            wrbParms.hdr.u32ClientID = conn->u32ClientID;
-            wrbParms.hdr.u32Function = SHCRGL_GUEST_FN_WRITE_READ_BUFFERED;
-            wrbParms.hdr.cParms = SHCRGL_CPARMS_WRITE_READ_BUFFERED;
+            VBGL_HGCM_HDR_INIT(&wrbParms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE_READ_BUFFERED, SHCRGL_CPARMS_WRITE_READ_BUFFERED);
 
             crMemcpy(&wrbParms.iBufferID, &wbParms.iBufferID, sizeof(HGCMFunctionParameter));
@@ -1060,8 +1042,5 @@
     CRASSERT(!conn->pBuffer);
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_READ;
-    parms.hdr.cParms      = SHCRGL_CPARMS_READ;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_READ, SHCRGL_CPARMS_READ);
 
     parms.pBuffer.type                   = VMMDevHGCMParmType_LinAddr_Out;
@@ -1266,8 +1245,5 @@
     RT_NOREF(vMajor, vMinor);
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_SET_VERSION;
-    parms.hdr.cParms      = SHCRGL_CPARMS_SET_VERSION;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_SET_VERSION, SHCRGL_CPARMS_SET_VERSION);
 
     parms.vMajor.type      = VMMDevHGCMParmType_32bit;
@@ -1303,8 +1279,5 @@
     int rc;
 
-    caps.hdr.result      = VERR_WRONG_ORDER;
-    caps.hdr.u32ClientID = conn->u32ClientID;
-    caps.hdr.u32Function = SHCRGL_GUEST_FN_GET_CAPS_LEGACY;
-    caps.hdr.cParms      = SHCRGL_CPARMS_GET_CAPS_LEGACY;
+    VBGL_HGCM_HDR_INIT(&caps.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_GET_CAPS_LEGACY, SHCRGL_CPARMS_GET_CAPS_LEGACY);
 
     caps.Caps.type       = VMMDevHGCMParmType_32bit;
@@ -1338,8 +1311,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_SET_PID;
-    parms.hdr.cParms      = SHCRGL_CPARMS_SET_PID;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_SET_PID, SHCRGL_CPARMS_SET_PID);
 
     parms.u64PID.type     = VMMDevHGCMParmType_64bit;
Index: trunk/src/VBox/GuestHost/OpenGL/util/vboxhgsmi.c
===================================================================
--- trunk/src/VBox/GuestHost/OpenGL/util/vboxhgsmi.c	(revision 68457)
+++ trunk/src/VBox/GuestHost/OpenGL/util/vboxhgsmi.c	(revision 68458)
@@ -1146,8 +1146,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_SET_VERSION;
-    parms.hdr.cParms      = SHCRGL_CPARMS_SET_VERSION;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_SET_VERSION, SHCRGL_CPARMS_SET_VERSION);
 
     parms.vMajor.type      = VMMDevHGCMParmType_32bit;
@@ -1178,8 +1175,5 @@
     int rc;
 
-    parms.hdr.result      = VERR_WRONG_ORDER;
-    parms.hdr.u32ClientID = conn->u32ClientID;
-    parms.hdr.u32Function = SHCRGL_GUEST_FN_SET_PID;
-    parms.hdr.cParms      = SHCRGL_CPARMS_SET_PID;
+    VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_SET_PID, SHCRGL_CPARMS_SET_PID);
 
     parms.u64PID.type     = VMMDevHGCMParmType_64bit;
