Index: trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp
===================================================================
--- trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp	(revision 78683)
+++ trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp	(revision 78698)
@@ -40,5 +40,6 @@
 #define SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16       2
 #define SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT   3
-#define SHFL_SAVED_STATE_VERSION                        4
+#define SHFL_SAVED_STATE_VERSION_PRE_ERROR_STYLE        4
+#define SHFL_SAVED_STATE_VERSION                        5
 
 
@@ -92,4 +93,5 @@
 static STAMPROFILE g_StatFlush;
 static STAMPROFILE g_StatFlushFail;
+static STAMPROFILE g_StatSetErrorStyle;
 static STAMPROFILE g_StatSetUtf8;
 static STAMPROFILE g_StatSetFileSize;
@@ -170,4 +172,5 @@
 
     pClient->fHasMappingCounts = true;
+    pClient->enmErrorStyle = SHFLERRORSTYLE_NATIVE;
     return VINF_SUCCESS;
 }
@@ -257,14 +260,16 @@
     uint32_t        nrMappings;
     SHFLCLIENTDATA *pClient = (SHFLCLIENTDATA *)pvClient;
-    uint32_t        len, version;
+    uint32_t        len;
 
     Log(("SharedFolders host service: loading state, u32ClientID = %u\n", u32ClientID));
 
-    int rc = SSMR3GetU32(pSSM, &version);
+    uint32_t uShfVersion = 0;
+    int rc = SSMR3GetU32(pSSM, &uShfVersion);
     AssertRCReturn(rc, rc);
 
-    if (   version > SHFL_SAVED_STATE_VERSION
-        || version < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
-        return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
+    if (   uShfVersion > SHFL_SAVED_STATE_VERSION
+        || uShfVersion < SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
+        return SSMR3SetLoadError(pSSM, VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION, RT_SRC_POS,
+                                 "Unknown shared folders state version %u!", uShfVersion);
 
     rc = SSMR3GetU32(pSSM, &nrMappings);
@@ -281,11 +286,20 @@
     else if (len != sizeof(*pClient))
         return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
-                                 "Saved SHFLCLIENTDATA size %u differs from current %u!\n", len, sizeof(*pClient));
+                                 "Saved SHFLCLIENTDATA size %u differs from current %u!", len, sizeof(*pClient));
 
     rc = SSMR3GetMem(pSSM, pClient, len);
     AssertRCReturn(rc, rc);
 
+    /* For older saved state, use the default native error style, otherwise
+       check that the restored value makes sense to us. */
+    if (uShfVersion <= SHFL_SAVED_STATE_VERSION_PRE_ERROR_STYLE)
+        pClient->enmErrorStyle = SHFLERRORSTYLE_NATIVE;
+    else if (   pClient->enmErrorStyle <= kShflErrorStyle_Invalid
+             || pClient->enmErrorStyle >= kShflErrorStyle_End)
+        return SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
+                                 "Saved SHFLCLIENTDATA enmErrorStyle value %d is not known/valid!", pClient->enmErrorStyle);
+
     /* We don't actually (fully) restore the state; we simply check if the current state is as we it expect it to be. */
-    for (int i=0;i<SHFL_MAX_MAPPINGS;i++)
+    for (size_t i = 0; i < SHFL_MAX_MAPPINGS; i++)
     {
         /* Load the saved mapping description and try to find it in the mappings. */
@@ -302,15 +316,14 @@
         if (mapping.fValid)
         {
+            /* Load the host path name. */
             uint32_t cb;
-
-            /* Load the host path name. */
             rc = SSMR3GetU32(pSSM, &cb);
             AssertRCReturn(rc, rc);
 
             char *pszFolderName;
-            if (version == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16)
+            if (uShfVersion == SHFL_SAVED_STATE_VERSION_FOLDERNAME_UTF16) /* (See version range check above.) */
             {
                 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
-                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x\n", cb));
+                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad folder name size: %#x", cb));
                 PSHFLSTRING pFolderName = (PSHFLSTRING)RTMemAlloc(cb);
                 AssertReturn(pFolderName != NULL, VERR_NO_MEMORY);
@@ -320,5 +333,5 @@
                 AssertReturn(pFolderName->u16Size < cb && pFolderName->u16Length < pFolderName->u16Size,
                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
-                                               "Bad folder name string: %#x/%#x cb=%#x\n",
+                                               "Bad folder name string: %#x/%#x cb=%#x",
                                                pFolderName->u16Size, pFolderName->u16Length, cb));
 
@@ -341,5 +354,5 @@
             AssertRCReturn(rc, rc);
             AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
-                         SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x\n", cb));
+                         SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad map name size: %#x", cb));
 
             PSHFLSTRING pMapName = (PSHFLSTRING)RTMemAlloc(cb);
@@ -350,5 +363,5 @@
             AssertReturn(pMapName->u16Size < cb && pMapName->u16Length < pMapName->u16Size,
                          SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
-                                           "Bad map name string: %#x/%#x cb=%#x\n",
+                                           "Bad map name string: %#x/%#x cb=%#x",
                                            pMapName->u16Size, pMapName->u16Length, cb));
 
@@ -362,10 +375,10 @@
             /* Load the auto mount point. */
             PSHFLSTRING pAutoMountPoint;
-            if (version > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
+            if (uShfVersion > SHFL_SAVED_STATE_VERSION_PRE_AUTO_MOUNT_POINT)
             {
                 rc = SSMR3GetU32(pSSM, &cb);
                 AssertRCReturn(rc, rc);
                 AssertReturn(cb > SHFLSTRING_HEADER_SIZE && cb <= UINT16_MAX + SHFLSTRING_HEADER_SIZE && !(cb & 1),
-                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x\n", cb));
+                             SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS, "Bad auto mount point size: %#x", cb));
 
                 pAutoMountPoint = (PSHFLSTRING)RTMemAlloc(cb);
@@ -376,5 +389,5 @@
                 AssertReturn(pAutoMountPoint->u16Size < cb && pAutoMountPoint->u16Length < pAutoMountPoint->u16Size,
                              SSMR3SetLoadError(pSSM, VERR_SSM_DATA_UNIT_FORMAT_CHANGED, RT_SRC_POS,
-                                               "Bad auto mount point string: %#x/%#x cb=%#x\n",
+                                               "Bad auto mount point string: %#x/%#x cb=%#x",
                                                pAutoMountPoint->u16Size, pAutoMountPoint->u16Length, cb));
 
@@ -1566,4 +1579,22 @@
                                   paParms[3].u.uint32, paParms[4].u.uint64, paParms[5].u.uint64,
                                   &paParms[6].u.uint64, paParms[7].u.uint64);
+            break;
+        }
+
+        case SHFL_FN_SET_ERROR_STYLE:
+        {
+            pStatFail = pStat = &g_StatSetErrorStyle;
+
+            /* Validate input: */
+            ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_SET_ERROR_STYLE, rc = VERR_WRONG_PARAMETER_COUNT);
+            ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* enm32Style  */
+            ASSERT_GUEST_STMT_BREAK(   paParms[0].u.uint32 > (uint32_t)kShflErrorStyle_Invalid
+                                    && paParms[0].u.uint32 < (uint32_t)kShflErrorStyle_End, rc = VERR_WRONG_PARAMETER_TYPE);
+            ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* u32Reserved */
+            ASSERT_GUEST_STMT_BREAK(paParms[1].u.uint32 == 0, rc = VERR_WRONG_PARAMETER_TYPE);
+
+            /* Do the work: */
+            pClient->enmErrorStyle = (uint8_t)paParms[0].u.uint32;
+            rc = VINF_SUCCESS;
             break;
         }
@@ -1873,4 +1904,5 @@
              HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlush,                     STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH successes",                   "/HGCM/VBoxSharedFolders/FnFlush");
              HGCMSvcHlpStamRegister(g_pHelpers, &g_StatFlushFail,                 STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_FLUSH failures",                    "/HGCM/VBoxSharedFolders/FnFlushFail");
+             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetErrorStyle,             STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_ERROR_STYLE",                   "/HGCM/VBoxSharedFolders/FnSetErrorStyle");
              HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSetUtf8,                   STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SET_UTF8",                          "/HGCM/VBoxSharedFolders/FnSetUtf8");
              HGCMSvcHlpStamRegister(g_pHelpers, &g_StatSymlink,                   STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_SYMLINK successes",                 "/HGCM/VBoxSharedFolders/FnSymlink");
Index: trunk/src/VBox/HostServices/SharedFolders/shfl.h
===================================================================
--- trunk/src/VBox/HostServices/SharedFolders/shfl.h	(revision 78683)
+++ trunk/src/VBox/HostServices/SharedFolders/shfl.h	(revision 78698)
@@ -27,30 +27,26 @@
 #include <VBox/log.h>
 
-/**
- * Shared Folders client flags.
+/** Shared Folders client flags.
  * @{
  */
-
-/** Client has queried mappings at least once and, therefore,
- *  the service can process its other requests too.
- */
+/** Client has queried mappings at least once and, therefore, the service can
+ * process its other requests too. */
 #define SHFL_CF_MAPPINGS_QUERIED (0x00000001)
-
 /** Mappings have been changed since last query. */
 #define SHFL_CF_MAPPINGS_CHANGED (0x00000002)
-
 /** Client uses UTF8 encoding, if not set then unicode 16 bit (UCS2) is used. */
 #define SHFL_CF_UTF8             (0x00000004)
-
 /** Client both supports and wants to use symlinks. */
 #define SHFL_CF_SYMLINKS         (0x00000008)
-
 /** The call to SHFL_FN_WAIT_FOR_MAPPINGS_CHANGES will return immediately
  *  because of a SHFL_FN_CANCEL_MAPPINGS_CHANGES_WAITS call. */
 #define SHFL_CF_CANCEL_NEXT_WAIT (0x00000010)
-
 /** @} */
 
-typedef struct _SHFLCLIENTDATA
+/**
+ * @note This structure is dumped directly into the saved state, so care must be
+ *       taken when extending it!
+ */
+typedef struct SHFLCLIENTDATA
 {
     /** Client flags */
@@ -58,6 +54,6 @@
     /** Path delimiter. */
     RTUTF16  PathDelimiter;
-    /** Currently unused.   */
-    uint8_t  bPadding;
+    /** The error style, SHFLERRORSTYLE. */
+    uint8_t  enmErrorStyle;
     /** Set if the client has mapping usage counts.
      * This is for helping with saved state. */
