Index: /trunk/include/VBox/vd-image-backend.h
===================================================================
--- /trunk/include/VBox/vd-image-backend.h	(revision 79964)
+++ /trunk/include/VBox/vd-image-backend.h	(revision 79965)
@@ -96,8 +96,9 @@
      * @param   pVDIfsDisk      Pointer to the per-disk VD interface list.
      * @param   pVDIfsImage     Pointer to the per-image VD interface list.
+     * @param   enmDesiredType  The desired image type, VDTYPE_INVALID if anything goes.
      * @param   penmType        Returns the supported device type on success.
      */
     DECLR3CALLBACKMEMBER(int, pfnProbe, (const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                         PVDINTERFACE pVDIfsImage, VDTYPE *penmType));
+                                         PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType));
 
     /**
Index: /trunk/include/VBox/vd.h
===================================================================
--- /trunk/include/VBox/vd.h	(revision 79964)
+++ /trunk/include/VBox/vd.h	(revision 79965)
@@ -592,4 +592,5 @@
  * @param   pVDIfsImage     Pointer to the per-image VD interface list.
  * @param   pszFilename     Name of the image file for which the backend is queried.
+ * @param   enmDesiredType  The desired image type, VDTYPE_INVALID if anything goes.
  * @param   ppszFormat      Receives pointer of the UTF-8 string which contains the format name.
  *                          The returned pointer must be freed using RTStrFree().
@@ -597,5 +598,6 @@
  */
 VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                              const char *pszFilename, char **ppszFormat, VDTYPE *penmType);
+                              const char *pszFilename, VDTYPE enmDesiredType,
+                              char **ppszFormat, VDTYPE *penmType);
 
 /**
Index: /trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
===================================================================
--- /trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp	(revision 79964)
+++ /trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp	(revision 79965)
@@ -656,5 +656,5 @@
     VDTYPE enmType = VDTYPE_INVALID;
     int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                         argv[1], &pszFormat, &enmType);
+                         argv[1], VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return RTMsgErrorExit(RTEXITCODE_FAILURE, "Format autodetect failed: %Rrc", rc);
@@ -709,5 +709,5 @@
     VDTYPE enmType = VDTYPE_INVALID;
     int rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                         argv[0], &pszFormat, &enmType);
+                         argv[0], VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return RTMsgErrorExit(RTEXITCODE_FAILURE, "Format autodetect failed: %Rrc", rc);
@@ -2016,5 +2016,5 @@
         VDTYPE enmType = VDTYPE_INVALID;
         vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                          src.c_str(), &pszFormat, &enmType);
+                          src.c_str(), VDTYPE_INVALID, &pszFormat, &enmType);
         if (RT_FAILURE(vrc) || enmType != VDTYPE_HDD)
         {
@@ -2164,5 +2164,5 @@
             char *pszFormat = NULL;
             vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                              src.c_str(), &pszFormat, &enmSrcType);
+                              src.c_str(), VDTYPE_HDD, &pszFormat, &enmSrcType);
             if (RT_FAILURE(vrc))
             {
@@ -2282,5 +2282,5 @@
 
             vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                              image.c_str(), &pszFormat, &enmSrcType);
+                              image.c_str(), VDTYPE_HDD, &pszFormat, &enmSrcType);
             if (RT_FAILURE(vrc) && (vrc != VERR_VD_IMAGE_CORRUPTED))
             {
Index: /trunk/src/VBox/ImageMounter/VBoxFUSE/VBoxFUSE.cpp
===================================================================
--- /trunk/src/VBox/ImageMounter/VBoxFUSE/VBoxFUSE.cpp	(revision 79964)
+++ /trunk/src/VBox/ImageMounter/VBoxFUSE/VBoxFUSE.cpp	(revision 79965)
@@ -521,5 +521,5 @@
     char *pszFormat;
     VDTYPE enmType;
-    rc = VDGetFormat(NULL /* pVDIIfsDisk */, NULL /* pVDIIfsImage*/, pszImage, &pszFormat, &enmType);
+    rc = VDGetFormat(NULL /* pVDIIfsDisk */, NULL /* pVDIIfsImage*/, pszImage,  VDTYPE_INVALID,&pszFormat, &enmType);
     if (RT_FAILURE(rc))
     {
Index: /trunk/src/VBox/ImageMounter/vboximg-mount/vboximg-mount.cpp
===================================================================
--- /trunk/src/VBox/ImageMounter/vboximg-mount/vboximg-mount.cpp	(revision 79964)
+++ /trunk/src/VBox/ImageMounter/vboximg-mount/vboximg-mount.cpp	(revision 79965)
@@ -1372,5 +1372,5 @@
      * Create HDD container to open base image and differencing images into
      */
-    rc = VDGetFormat(NULL /* pVDIIfsDisk */, NULL /* pVDIIfsImage*/,
+    rc = VDGetFormat(NULL /* pVDIIfsDisk */, NULL /* pVDIIfsImage*/, VDTYPE_INVALID,
             CSTR(pVDiskBaseImagePath), &pszFormat, &enmType);
 
Index: /trunk/src/VBox/Main/src-server/MediumImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 79964)
+++ /trunk/src/VBox/Main/src-server/MediumImpl.cpp	(revision 79965)
@@ -7619,4 +7619,7 @@
         if (isImport)
         {
+            VDTYPE const enmDesiredType = m->devType == DeviceType_Floppy   ? VDTYPE_FLOPPY
+                                        : m->devType == DeviceType_DVD      ? VDTYPE_OPTICAL_DISC
+                                        : m->devType == DeviceType_HardDisk ? VDTYPE_HDD : VDTYPE_INVALID;
             VDTYPE enmType = VDTYPE_INVALID;
             char *backendName = NULL;
@@ -7634,5 +7637,5 @@
             {
                 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                                  locationFull.c_str(), &backendName, &enmType);
+                                  locationFull.c_str(), enmDesiredType, &backendName, &enmType);
             }
             else if (   vrc != VERR_FILE_NOT_FOUND
@@ -7644,5 +7647,5 @@
                 locationFull = aLocation;
                 vrc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                                  locationFull.c_str(), &backendName, &enmType);
+                                  locationFull.c_str(), enmDesiredType, &backendName, &enmType);
             }
 
Index: /trunk/src/VBox/Storage/CUE.cpp
===================================================================
--- /trunk/src/VBox/Storage/CUE.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/CUE.cpp	(revision 79965)
@@ -1432,7 +1432,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) cueProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                  PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                  PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
     int rc = VINF_SUCCESS;
Index: /trunk/src/VBox/Storage/DMG.cpp
===================================================================
--- /trunk/src/VBox/Storage/DMG.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/DMG.cpp	(revision 79965)
@@ -1742,7 +1742,7 @@
 /** @interface_method_impl{VDIMAGEBACKEND,pfnProbe} */
 static DECLCALLBACK(int) dmgProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                  PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                  PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n",
                  pszFilename, pVDIfsDisk, pVDIfsImage, penmType));
Index: /trunk/src/VBox/Storage/ISCSI.cpp
===================================================================
--- /trunk/src/VBox/Storage/ISCSI.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/ISCSI.cpp	(revision 79965)
@@ -4767,7 +4767,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) iscsiProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                    PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF4(pszFilename, pVDIfsDisk, pVDIfsImage, penmType);
+                                    PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pszFilename, pVDIfsDisk, pVDIfsImage, enmDesiredType, penmType);
     LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
 
Index: /trunk/src/VBox/Storage/Parallels.cpp
===================================================================
--- /trunk/src/VBox/Storage/Parallels.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/Parallels.cpp	(revision 79965)
@@ -376,7 +376,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) parallelsProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                        PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                        PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     int rc;
     PVDIOSTORAGE pStorage;
Index: /trunk/src/VBox/Storage/QCOW.cpp
===================================================================
--- /trunk/src/VBox/Storage/QCOW.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/QCOW.cpp	(revision 79965)
@@ -1577,7 +1577,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) qcowProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                   PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                   PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
     PVDIOSTORAGE pStorage = NULL;
Index: /trunk/src/VBox/Storage/QED.cpp
===================================================================
--- /trunk/src/VBox/Storage/QED.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/QED.cpp	(revision 79965)
@@ -1503,7 +1503,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) qedProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                  PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                  PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
     PVDIOSTORAGE pStorage = NULL;
Index: /trunk/src/VBox/Storage/RAW.cpp
===================================================================
--- /trunk/src/VBox/Storage/RAW.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/RAW.cpp	(revision 79965)
@@ -28,4 +28,6 @@
 #include <iprt/alloc.h>
 #include <iprt/path.h>
+#include <iprt/formats/iso9660.h>
+#include <iprt/formats/udf.h>
 
 #include "VDBackends.h"
@@ -320,10 +322,203 @@
 }
 
+/**
+ * Worker for rawProbe that checks if the file looks like it contains an ISO
+ * 9660 or UDF descriptor sequence at the expected offset.
+ *
+ * Caller already checked if the size is suitable for ISOs.
+ *
+ * @returns IPRT status code.  Success if detected ISO 9660 or UDF, failure if
+ *          not.
+ *
+ * @note Code is a modified version of rtFsIsoVolTryInit() IPRT (isovfs.cpp).
+ */
+static int rawProbeIsIso9660OrUdf(PVDINTERFACEIOINT pIfIo, PVDIOSTORAGE pStorage)
+{
+    PRTERRINFO                  pErrInfo = NULL;
+    const uint32_t              cbSector = _2K;
+
+    union
+    {
+        uint8_t                 ab[_2K];
+        ISO9660VOLDESCHDR       VolDescHdr;
+    } Buf;
+    Assert(cbSector <= sizeof(Buf));
+    RT_ZERO(Buf);
+
+    uint8_t         uUdfLevel               = 0;
+    uint64_t        offUdfBootVolDesc       = UINT64_MAX;
+
+    uint32_t        cPrimaryVolDescs        = 0;
+    uint32_t        cSupplementaryVolDescs  = 0;
+    uint32_t        cBootRecordVolDescs     = 0;
+    uint32_t        offVolDesc              = 16 * cbSector;
+    enum
+    {
+        kStateStart = 0,
+        kStateNoSeq,
+        kStateCdSeq,
+        kStateUdfSeq
+    }               enmState = kStateStart;
+    for (uint32_t iVolDesc = 0; ; iVolDesc++, offVolDesc += cbSector)
+    {
+        if (iVolDesc > 32)
+            return RTERRINFO_LOG_SET(pErrInfo, VERR_VFS_BOGUS_FORMAT, "More than 32 volume descriptors, doesn't seem right...");
+
+        /* Read the next one and check the signature. */
+        int rc = vdIfIoIntFileReadSync(pIfIo, pStorage, offVolDesc, &Buf, cbSector);
+        if (RT_FAILURE(rc))
+            return RTERRINFO_LOG_SET_F(pErrInfo, rc, "Unable to read volume descriptor #%u", iVolDesc);
+
+#define MATCH_STD_ID(a_achStdId1, a_szStdId2) \
+            (   (a_achStdId1)[0] == (a_szStdId2)[0] \
+             && (a_achStdId1)[1] == (a_szStdId2)[1] \
+             && (a_achStdId1)[2] == (a_szStdId2)[2] \
+             && (a_achStdId1)[3] == (a_szStdId2)[3] \
+             && (a_achStdId1)[4] == (a_szStdId2)[4] )
+#define MATCH_HDR(a_pStd, a_bType2, a_szStdId2, a_bVer2) \
+            (    MATCH_STD_ID((a_pStd)->achStdId, a_szStdId2) \
+             && (a_pStd)->bDescType    == (a_bType2) \
+             && (a_pStd)->bDescVersion == (a_bVer2) )
+
+        /*
+         * ISO 9660 ("CD001").
+         */
+        if (   (   enmState == kStateStart
+                || enmState == kStateCdSeq
+                || enmState == kStateNoSeq)
+            && MATCH_STD_ID(Buf.VolDescHdr.achStdId, ISO9660VOLDESC_STD_ID) )
+        {
+            enmState = kStateCdSeq;
+
+            /* Do type specific handling. */
+            Log(("RAW/ISO9660: volume desc #%u: type=%#x\n", iVolDesc, Buf.VolDescHdr.bDescType));
+            if (Buf.VolDescHdr.bDescType == ISO9660VOLDESC_TYPE_PRIMARY)
+            {
+                cPrimaryVolDescs++;
+                if (Buf.VolDescHdr.bDescVersion != ISO9660PRIMARYVOLDESC_VERSION)
+                    return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_UNSUPPORTED_FORMAT,
+                                               "Unsupported primary volume descriptor version: %#x", Buf.VolDescHdr.bDescVersion);
+                if (cPrimaryVolDescs == 1)
+                { /*rc = rtFsIsoVolHandlePrimaryVolDesc(pThis, &Buf.PrimaryVolDesc, offVolDesc, &RootDir, &offRootDirRec, pErrInfo);*/ }
+                else if (cPrimaryVolDescs == 2)
+                    Log(("RAW/ISO9660: ignoring 2nd primary descriptor\n")); /* so we can read the w2k3 ifs kit */
+                else
+                    return RTERRINFO_LOG_SET(pErrInfo, VERR_VFS_UNSUPPORTED_FORMAT, "More than one primary volume descriptor");
+            }
+            else if (Buf.VolDescHdr.bDescType == ISO9660VOLDESC_TYPE_SUPPLEMENTARY)
+            {
+                cSupplementaryVolDescs++;
+                if (Buf.VolDescHdr.bDescVersion != ISO9660SUPVOLDESC_VERSION)
+                    return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_UNSUPPORTED_FORMAT,
+                                               "Unsupported supplemental volume descriptor version: %#x", Buf.VolDescHdr.bDescVersion);
+                /*rc = rtFsIsoVolHandleSupplementaryVolDesc(pThis, &Buf.SupVolDesc, offVolDesc, &bJolietUcs2Level, &JolietRootDir,
+                                                          &offJolietRootDirRec, pErrInfo);*/
+            }
+            else if (Buf.VolDescHdr.bDescType == ISO9660VOLDESC_TYPE_BOOT_RECORD)
+            {
+                cBootRecordVolDescs++;
+            }
+            else if (Buf.VolDescHdr.bDescType == ISO9660VOLDESC_TYPE_TERMINATOR)
+            {
+                if (!cPrimaryVolDescs)
+                    return RTERRINFO_LOG_SET(pErrInfo, VERR_VFS_BOGUS_FORMAT, "No primary volume descriptor");
+                enmState = kStateNoSeq;
+            }
+            else
+                return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_UNSUPPORTED_FORMAT,
+                                           "Unknown volume descriptor: %#x", Buf.VolDescHdr.bDescType);
+        }
+        /*
+         * UDF volume recognition sequence (VRS).
+         */
+        else if (   (   enmState == kStateNoSeq
+                     || enmState == kStateStart)
+                 && MATCH_HDR(&Buf.VolDescHdr, UDF_EXT_VOL_DESC_TYPE, UDF_EXT_VOL_DESC_STD_ID_BEGIN, UDF_EXT_VOL_DESC_VERSION) )
+        {
+            if (uUdfLevel == 0)
+                enmState = kStateUdfSeq;
+            else
+                return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT, "Only one BEA01 sequence is supported");
+        }
+        else if (   enmState == kStateUdfSeq
+                 && MATCH_HDR(&Buf.VolDescHdr, UDF_EXT_VOL_DESC_TYPE, UDF_EXT_VOL_DESC_STD_ID_NSR_02, UDF_EXT_VOL_DESC_VERSION) )
+            uUdfLevel = 2;
+        else if (   enmState == kStateUdfSeq
+                 && MATCH_HDR(&Buf.VolDescHdr, UDF_EXT_VOL_DESC_TYPE, UDF_EXT_VOL_DESC_STD_ID_NSR_03, UDF_EXT_VOL_DESC_VERSION) )
+            uUdfLevel = 3;
+        else if (   enmState == kStateUdfSeq
+                 && MATCH_HDR(&Buf.VolDescHdr, UDF_EXT_VOL_DESC_TYPE, UDF_EXT_VOL_DESC_STD_ID_BOOT, UDF_EXT_VOL_DESC_VERSION) )
+        {
+            if (offUdfBootVolDesc == UINT64_MAX)
+                offUdfBootVolDesc = iVolDesc * cbSector;
+            else
+                return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT, "Only one BOOT2 descriptor is supported");
+        }
+        else if (   enmState == kStateUdfSeq
+                 && MATCH_HDR(&Buf.VolDescHdr, UDF_EXT_VOL_DESC_TYPE, UDF_EXT_VOL_DESC_STD_ID_TERM, UDF_EXT_VOL_DESC_VERSION) )
+        {
+            if (uUdfLevel != 0)
+                enmState = kStateNoSeq;
+            else
+                return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT, "Found BEA01 & TEA01, but no NSR02 or NSR03 descriptors");
+        }
+        /*
+         * Unknown, probably the end.
+         */
+        else if (enmState == kStateNoSeq)
+            break;
+        else if (enmState == kStateStart)
+                return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_UNKNOWN_FORMAT,
+                                           "Not ISO? Unable to recognize volume descriptor signature: %.5Rhxs", Buf.VolDescHdr.achStdId);
+        else if (enmState == kStateCdSeq)
+            return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT,
+                                       "Missing ISO 9660 terminator volume descriptor? (Found %.5Rhxs)", Buf.VolDescHdr.achStdId);
+        else if (enmState == kStateUdfSeq)
+            return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_BOGUS_FORMAT,
+                                       "Missing UDF terminator volume descriptor? (Found %.5Rhxs)", Buf.VolDescHdr.achStdId);
+        else
+            return RTERRINFO_LOG_SET_F(pErrInfo, VERR_VFS_UNKNOWN_FORMAT,
+                                       "Unknown volume descriptor signature found at sector %u: %.5Rhxs",
+                                       16 + iVolDesc, Buf.VolDescHdr.achStdId);
+    }
+
+    return VINF_SUCCESS;
+}
+
+/**
+ * Checks the given extension array for the given suffix and type.
+ *
+ * @returns true if found in the list, false if not.
+ * @param   paExtensions        The extension array to check against.
+ * @param   pszSuffix           The suffix to look for.  Can be NULL.
+ * @param   enmType             The image type to look for.
+ */
+static bool rawProbeContainsExtension(const VDFILEEXTENSION *paExtensions, const char *pszSuffix, VDTYPE enmType)
+{
+    if (pszSuffix)
+    {
+        if (*pszSuffix == '.')
+            pszSuffix++;
+        if (*pszSuffix != '\0')
+        {
+            for (size_t i = 0;; i++)
+            {
+                if (!paExtensions[i].pszExtension)
+                    break;
+                if (   paExtensions[i].enmType == enmType
+                    && RTStrICmpAscii(paExtensions[i].pszExtension, pszSuffix) == 0)
+                    return true;
+            }
+        }
+    }
+    return false;
+}
+
 
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) rawProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                  PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                  PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
     PVDIOSTORAGE pStorage = NULL;
@@ -343,47 +538,118 @@
     {
         uint64_t cbFile;
-        const char *pszSuffix = RTPathSuffix(pszFilename);
         rc = vdIfIoIntFileGetSize(pIfIo, pStorage, &cbFile);
-
-        /* Try to guess the image type based on the extension. */
-        if (   RT_SUCCESS(rc)
-            && pszSuffix)
+        if (RT_SUCCESS(rc))
         {
-            if (   !RTStrICmp(pszSuffix, ".iso")
-                || !RTStrICmp(pszSuffix, ".cdr")) /* DVD images. */
+            /*
+             * Detecting raw ISO and floppy images and keeping them apart isn't all
+             * that simple.
+             *
+             * - Both must be a multiple of their sector sizes, though
+             *   that means that any ISO can also be a floppy, since 2048 is 512 * 4.
+             * - The ISO images must be 32KB and floppies are generally not larger
+             *   than 2.88MB, but that leaves quite a bit of size overlap,
+             *
+             * So, the size cannot conclusively say whether something is one or the other.
+             *
+             * - The content of a normal ISO image is detectable, but not all ISO
+             *   images need to follow that spec to work in a DVD ROM drive.
+             * - It is common for ISO images to start like a floppy with a boot sector
+             *   at the very start of the image.
+             * - Floppies doesn't need to contain a DOS-style boot sector, it depends
+             *   on the system it is formatted and/or intended for.
+             *
+             * So, the content cannot conclusively determine the type either.
+             *
+             * However, there are a number of cases, especially for ISOs, where we can
+             * say we a deal of confidence that something is an ISO image.
+             */
+            const char * const pszSuffix = RTPathSuffix(pszFilename);
+
+            /*
+             * Start by checking for sure signs of an ISO 9660 / UDF image.
+             */
+            rc = VERR_VD_RAW_INVALID_HEADER;
+            if (   (enmDesiredType == VDTYPE_INVALID || enmDesiredType == VDTYPE_OPTICAL_DISC)
+                && (cbFile % 2048) == 0
+                &&  cbFile > 32768)
             {
-                /* Note that there are ISO images smaller than 1 MB; it is impossible to distinguish
-                 * between raw floppy and CD images based on their size (and cannot be reliably done
-                 * based on contents, either).
-                 * bird: Not sure what this comment is mumbling about, the test below is 32KB not 1MB.
-                 */
-                if (cbFile % 2048)
-                    rc = VERR_VD_RAW_SIZE_MODULO_2048;
-                else if (cbFile <= 32768)
-                    rc = VERR_VD_RAW_SIZE_OPTICAL_TOO_SMALL;
-                else
+                int rc2 = rawProbeIsIso9660OrUdf(pIfIo, pStorage);
+                if (RT_SUCCESS(rc2))
                 {
+                    /* *puScore = VDPROBE_SCORE_HIGH; */
+                    *penmType = VDTYPE_OPTICAL_DISC;
+                    rc = VINF_SUCCESS;
+                }
+                /* If that didn't work out, check by extension (the old way): */
+                else if (rawProbeContainsExtension(s_aRawFileExtensions, pszSuffix, VDTYPE_OPTICAL_DISC))
+                {
+                    /* *puScore = VDPROBE_SCORE_LOW; */
                     *penmType = VDTYPE_OPTICAL_DISC;
                     rc = VINF_SUCCESS;
                 }
             }
-            else if (   !RTStrICmp(pszSuffix, ".img")
-                     || !RTStrICmp(pszSuffix, ".ima")
-                     || !RTStrICmp(pszSuffix, ".dsk")
-                     || !RTStrICmp(pszSuffix, ".flp")
-                     || !RTStrICmp(pszSuffix, ".vfd")) /* Floppy images */
+
+            /*
+             * We could do something similar for floppies, i.e. check for a
+             * DOS'ish boot sector and thereby get a good match on most of the
+             * relevant floppy images out there.
+             */
+            if (   RT_FAILURE(rc)
+                && (enmDesiredType == VDTYPE_INVALID || enmDesiredType == VDTYPE_FLOPPY)
+                && (cbFile % 512) == 0
+                && cbFile > 512
+                && cbFile <= RAW_MAX_FLOPPY_IMG_SIZE)
             {
-                if (cbFile % 512)
-                    rc = VERR_VD_RAW_SIZE_MODULO_512;
-                else if (cbFile > RAW_MAX_FLOPPY_IMG_SIZE)
-                    rc = VERR_VD_RAW_SIZE_FLOPPY_TOO_BIG;
-                else
+                /** @todo check if the content is DOSish.  */
+                if (false)
                 {
+                    /* *puScore = VDPROBE_SCORE_HIGH; */
+                    *penmType = VDTYPE_FLOPPY;
+                    rc = VINF_SUCCESS;
+                }
+                else if (rawProbeContainsExtension(s_aRawFileExtensions, pszSuffix, VDTYPE_FLOPPY))
+                {
+                    /* *puScore = VDPROBE_SCORE_LOW; */
                     *penmType = VDTYPE_FLOPPY;
                     rc = VINF_SUCCESS;
                 }
             }
-            else
-                rc = VERR_VD_RAW_INVALID_HEADER;
+
+            /*
+             * No luck?  Go exclusively by extension like we've done since
+             * for ever and complain about the size if it doesn't fit expectations.
+             * We can get here if the desired type doesn't match the extension and such.
+             */
+            if (RT_FAILURE(rc))
+            {
+                if (rawProbeContainsExtension(s_aRawFileExtensions, pszSuffix, VDTYPE_OPTICAL_DISC))
+                {
+                    if (cbFile % 2048)
+                        rc = VERR_VD_RAW_SIZE_MODULO_2048;
+                    else if (cbFile <= 32768)
+                        rc = VERR_VD_RAW_SIZE_OPTICAL_TOO_SMALL;
+                    else
+                    {
+                        Assert(enmDesiredType != VDTYPE_OPTICAL_DISC);
+                        *penmType = VDTYPE_OPTICAL_DISC;
+                        rc = VINF_SUCCESS;
+                    }
+                }
+                else if (rawProbeContainsExtension(s_aRawFileExtensions, pszSuffix, VDTYPE_FLOPPY))
+                {
+                    if (cbFile % 512)
+                        rc = VERR_VD_RAW_SIZE_MODULO_512;
+                    else if (cbFile > RAW_MAX_FLOPPY_IMG_SIZE)
+                        rc = VERR_VD_RAW_SIZE_FLOPPY_TOO_BIG;
+                    else
+                    {
+                        Assert(cbFile == 0 || enmDesiredType != VDTYPE_FLOPPY);
+                        *penmType = VDTYPE_FLOPPY;
+                        rc = VINF_SUCCESS;
+                    }
+                }
+                else
+                    rc = VERR_VD_RAW_INVALID_HEADER;
+            }
         }
         else
Index: /trunk/src/VBox/Storage/VD.cpp
===================================================================
--- /trunk/src/VBox/Storage/VD.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VD.cpp	(revision 79965)
@@ -5408,9 +5408,12 @@
  * @param   pVDIfsImage     Pointer to the per-image VD interface list.
  * @param   pszFilename     Name of the image file for which the backend is queried.
+ * @param   enmDesiredType  The desired image type, VDTYPE_INVALID if anything goes.
  * @param   ppszFormat      Receives pointer of the UTF-8 string which contains the format name.
  *                          The returned pointer must be freed using RTStrFree().
+ * @param   penmType        Where to store the type of the image.
  */
 VBOXDDU_DECL(int) VDGetFormat(PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
-                              const char *pszFilename, char **ppszFormat, VDTYPE *penmType)
+                              const char *pszFilename, VDTYPE enmDesiredType,
+                              char **ppszFormat, VDTYPE *penmType)
 {
     int rc = VERR_NOT_SUPPORTED;
@@ -5430,4 +5433,5 @@
                     ("penmType=%#p\n", penmType),
                     VERR_INVALID_PARAMETER);
+    AssertReturn(enmDesiredType >= VDTYPE_INVALID && enmDesiredType <= VDTYPE_FLOPPY, VERR_INVALID_PARAMETER);
 
     if (!vdPluginIsInitialized())
@@ -5464,4 +5468,11 @@
     AssertRC(rc);
 
+    /** @todo r=bird: Would be better to do a scoring approach here, where the
+     * backend that scores the highest is choosen.  That way we don't have to depend
+     * on registration order and filename suffixes to figure out what RAW should
+     * handle and not.   Besides, the registration order won't cut it for plug-ins
+     * anyway, as they end up after the builtin ones.
+     */
+
     /* Find the backend supporting this file format. */
     for (unsigned i = 0; i < vdGetImageBackendCount(); i++)
@@ -5473,5 +5484,5 @@
         if (pBackend->pfnProbe)
         {
-            rc = pBackend->pfnProbe(pszFilename, pVDIfsDisk, pVDIfsImage, penmType);
+            rc = pBackend->pfnProbe(pszFilename, pVDIfsDisk, pVDIfsImage, enmDesiredType, penmType);
             if (    RT_SUCCESS(rc)
                 /* The correct backend has been found, but there is a small
Index: /trunk/src/VBox/Storage/VDI.cpp
===================================================================
--- /trunk/src/VBox/Storage/VDI.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VDI.cpp	(revision 79965)
@@ -1410,6 +1410,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) vdiProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                  PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
+                                  PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\"\n", pszFilename));
     int rc = VINF_SUCCESS;
Index: /trunk/src/VBox/Storage/VDPlugin.cpp
===================================================================
--- /trunk/src/VBox/Storage/VDPlugin.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VDPlugin.cpp	(revision 79965)
@@ -77,5 +77,11 @@
 static RTLDRMOD *g_ahBackendPlugins = NULL;
 #endif
-/** Builtin image backends. */
+/**
+ * Builtin image backends.
+ *
+ * @note As long as the pfnProb() calls aren't scored, the ordering influences
+ *       which backend take precedence.  In particular, the RAW backend should
+ *       be thowards the end of the list.
+ */
 static PCVDIMAGEBACKEND aStaticBackends[] =
 {
@@ -88,7 +94,7 @@
     &g_QCowBackend,
     &g_VhdxBackend,
-    &g_RawBackend,
     &g_CueBackend,
     &g_VBoxIsoMakerBackend,
+    &g_RawBackend,
     &g_ISCSIBackend
 };
Index: /trunk/src/VBox/Storage/VDVfs.cpp
===================================================================
--- /trunk/src/VBox/Storage/VDVfs.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VDVfs.cpp	(revision 79965)
@@ -714,5 +714,5 @@
     char  *pszFormat = NULL;
     VDTYPE enmType   = VDTYPE_INVALID;
-    int rc = VDGetFormat(NULL, NULL, pElement->paArgs[0].psz, &pszFormat, &enmType);
+    int rc = VDGetFormat(NULL, NULL, pElement->paArgs[0].psz, VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_SUCCESS(rc))
     {
Index: /trunk/src/VBox/Storage/VHD.cpp
===================================================================
--- /trunk/src/VBox/Storage/VHD.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VHD.cpp	(revision 79965)
@@ -1296,7 +1296,7 @@
 /** @interface_method_impl{VDIMAGEBACKEND,pfnProbe} */
 static DECLCALLBACK(int) vhdProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                  PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                  PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
     PVDIOSTORAGE pStorage;
Index: /trunk/src/VBox/Storage/VHDX.cpp
===================================================================
--- /trunk/src/VBox/Storage/VHDX.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VHDX.cpp	(revision 79965)
@@ -1770,7 +1770,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) vhdxProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                   PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
-    RT_NOREF1(pVDIfsDisk);
+                                   PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(pVDIfsDisk, enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p\n", pszFilename, pVDIfsDisk, pVDIfsImage));
     PVDIOSTORAGE pStorage = NULL;
Index: /trunk/src/VBox/Storage/VISO.cpp
===================================================================
--- /trunk/src/VBox/Storage/VISO.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VISO.cpp	(revision 79965)
@@ -209,5 +209,6 @@
  * @interface_method_impl{VDIMAGEBACKEND,pfnProbe}
  */
-static DECLCALLBACK(int) visoProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
+static DECLCALLBACK(int) visoProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk, PVDINTERFACE pVDIfsImage,
+                                   VDTYPE enmDesiredType, VDTYPE *penmType)
 {
     /*
@@ -224,4 +225,10 @@
 
     RT_NOREF(pVDIfsDisk);
+
+    /*
+     * We can only fake DVD stuff, so fail if the desired type doesn't match up
+     */
+    if (enmDesiredType != VDTYPE_OPTICAL_DISC && enmDesiredType != VDTYPE_INVALID)
+        return VERR_VD_GEN_INVALID_HEADER; /* Caller has strict, though undocument, status code expectations. */
 
     /*
Index: /trunk/src/VBox/Storage/VMDK.cpp
===================================================================
--- /trunk/src/VBox/Storage/VMDK.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/VMDK.cpp	(revision 79965)
@@ -5233,6 +5233,7 @@
 /** @copydoc VDIMAGEBACKEND::pfnProbe */
 static DECLCALLBACK(int) vmdkProbe(const char *pszFilename, PVDINTERFACE pVDIfsDisk,
-                                   PVDINTERFACE pVDIfsImage, VDTYPE *penmType)
-{
+                                   PVDINTERFACE pVDIfsImage, VDTYPE enmDesiredType, VDTYPE *penmType)
+{
+    RT_NOREF(enmDesiredType);
     LogFlowFunc(("pszFilename=\"%s\" pVDIfsDisk=%#p pVDIfsImage=%#p penmType=%#p\n",
                  pszFilename, pVDIfsDisk, pVDIfsImage, penmType));
Index: /trunk/src/VBox/Storage/testcase/tstVD.cpp
===================================================================
--- /trunk/src/VBox/Storage/testcase/tstVD.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/testcase/tstVD.cpp	(revision 79965)
@@ -544,5 +544,5 @@
         RTFileClose(File);
         rc = VDGetFormat(NULL /* pVDIfsDisk */, NULL /* pVDIfsImage */,
-                         pszBaseFilename, &pszFormat, &enmType);
+                         pszBaseFilename, VDTYPE_INVALID, &pszFormat, &enmType);
         RTPrintf("VDGetFormat() pszFormat=%s rc=%Rrc\n", pszFormat, rc);
         if (RT_SUCCESS(rc) && strcmp(pszFormat, pszBackend))
Index: /trunk/src/VBox/Storage/testcase/vbox-img.cpp
===================================================================
--- /trunk/src/VBox/Storage/testcase/vbox-img.cpp	(revision 79964)
+++ /trunk/src/VBox/Storage/testcase/vbox-img.cpp	(revision 79965)
@@ -283,5 +283,5 @@
         /* Don't pass error interface, as that would triggers error messages
          * because some backends fail to open the image. */
-        rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
+        rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszFormat, &enmType);
         if (RT_FAILURE(rc))
             return errorRuntime("Format autodetect failed: %Rrc\n", rc);
@@ -419,5 +419,5 @@
         /* Don't pass error interface, as that would triggers error messages
          * because some backends fail to open the image. */
-        rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
+        rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszFormat, &enmType);
         if (RT_FAILURE(rc))
             return errorRuntime("Format autodetect failed: %Rrc\n", rc);
@@ -1215,5 +1215,5 @@
             char *pszFormat = NULL;
             VDTYPE enmType = VDTYPE_INVALID;
-            rc = VDGetFormat(NULL, NULL, pszSrcFilename, &pszFormat, &enmType);
+            rc = VDGetFormat(NULL, NULL, pszSrcFilename, VDTYPE_INVALID, &pszFormat, &enmType);
             if (RT_FAILURE(rc))
             {
@@ -1311,5 +1311,5 @@
     char *pszFormat = NULL;
     VDTYPE enmType = VDTYPE_INVALID;
-    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
+    rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return errorSyntax("Format autodetect failed: %Rrc\n", rc);
@@ -1407,5 +1407,5 @@
     char *pszFormat = NULL;
     VDTYPE enmType = VDTYPE_INVALID;
-    int rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
+    int rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return errorSyntax("Format autodetect failed: %Rrc\n", rc);
@@ -1812,5 +1812,5 @@
     if (!pszFormat)
     {
-        rc = VDGetFormat(NULL, NULL, pszFilename, &pszBackend, &enmType);
+        rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszBackend, &enmType);
         if (RT_FAILURE(rc))
             return errorSyntax("Format autodetect failed: %Rrc\n", rc);
@@ -1865,5 +1865,5 @@
     char *pszFormat = NULL;
     VDTYPE enmType = VDTYPE_INVALID;
-    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
+    rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return errorSyntax("Format autodetect failed: %Rrc\n", rc);
@@ -2022,5 +2022,5 @@
     char *pszFormat = NULL;
     VDTYPE enmType = VDTYPE_INVALID;
-    rc = VDGetFormat(NULL, NULL, pszFilename, &pszFormat, &enmType);
+    rc = VDGetFormat(NULL, NULL, pszFilename, VDTYPE_INVALID, &pszFormat, &enmType);
     if (RT_FAILURE(rc))
         return errorSyntax("Format autodetect failed: %Rrc\n", rc);
