Index: /trunk/include/VBox/vmm/dbgf.h
===================================================================
--- /trunk/include/VBox/vmm/dbgf.h	(revision 73490)
+++ /trunk/include/VBox/vmm/dbgf.h	(revision 73491)
@@ -1204,5 +1204,6 @@
 /** @} */
 VMMR3DECL(int)          DBGFR3ModInMem(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName,
-                                       RTLDRARCH enmArch, uint32_t cbImage, PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo);
+                                       const char *pszFilename, RTLDRARCH enmArch, uint32_t cbImage,
+                                       PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo);
 
 #endif /* IN_RING3 */
Index: /trunk/src/VBox/Debugger/DBGCCommands.cpp
===================================================================
--- /trunk/src/VBox/Debugger/DBGCCommands.cpp	(revision 73490)
+++ /trunk/src/VBox/Debugger/DBGCCommands.cpp	(revision 73491)
@@ -1397,5 +1397,6 @@
     RTDBGMOD hDbgMod;
     RTERRINFOSTATIC ErrInfo;
-    rc = DBGFR3ModInMem(pUVM, &ModAddress, fFlags, pszModName, enmArch, 0 /*cbImage*/, &hDbgMod, RTErrInfoInitStatic(&ErrInfo));
+    rc = DBGFR3ModInMem(pUVM, &ModAddress, fFlags, pszModName, pszModName, enmArch, 0 /*cbImage*/,
+                        &hDbgMod, RTErrInfoInitStatic(&ErrInfo));
     if (RT_FAILURE(rc))
     {
Index: /trunk/src/VBox/Debugger/DBGPlugInWinNt.cpp
===================================================================
--- /trunk/src/VBox/Debugger/DBGPlugInWinNt.cpp	(revision 73490)
+++ /trunk/src/VBox/Debugger/DBGPlugInWinNt.cpp	(revision 73491)
@@ -27,6 +27,8 @@
 #include <VBox/err.h>
 #include <VBox/param.h>
+#include <iprt/ctype.h>
 #include <iprt/ldr.h>
 #include <iprt/mem.h>
+#include <iprt/path.h>
 #include <iprt/stream.h>
 #include <iprt/string.h>
@@ -300,9 +302,10 @@
  * @param   pThis           The instance data.
  * @param   pUVM            The user mode VM handle.
- * @param   pszName         The image name.
+ * @param   pszName         The module name.
+ * @param   pszFilename     The image filename.
  * @param   pImageAddr      The image address.
  * @param   cbImage         The size of the image.
  */
-static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PUVM pUVM, const char *pszName,
+static void dbgDiggerWinNtProcessImage(PDBGDIGGERWINNT pThis, PUVM pUVM, const char *pszName, const char *pszFilename,
                                        PCDBGFADDRESS pImageAddr, uint32_t cbImage)
 {
@@ -324,5 +327,5 @@
     RTERRINFOSTATIC ErrInfo;
     RTDBGMOD        hDbgMod = NIL_RTDBGMOD;
-    int rc = DBGFR3ModInMem(pUVM, pImageAddr, pThis->fNt31 ? DBGFMODINMEM_F_PE_NT31 : 0, pszName,
+    int rc = DBGFR3ModInMem(pUVM, pImageAddr, pThis->fNt31 ? DBGFMODINMEM_F_PE_NT31 : 0, pszName, pszFilename,
                             pThis->f32Bit ? RTLDRARCH_X86_32 : RTLDRARCH_AMD64, cbImage,
                             &hDbgMod, RTErrInfoInitStatic(&ErrInfo));
@@ -350,4 +353,48 @@
     else
         Log(("DigWinNt: %s: DBGFR3ModInMem failed: %Rrc\n", pszName, rc));
+}
+
+
+/**
+ * Adjust the module name into something that's compatible with the debugger.
+ *
+ * @param   pUVM                The user mode VM handle.
+ * @param   ppszName            Pointer to the image name pointer.
+ * @param   pImageAddr          The image load address.
+ */
+static const char *dbgDiggerWintNtFilenameToModuleName(const char *pszFilename, char *pszName, size_t cbName)
+{
+    /* Skip to the filename part of the filename. :-) */
+    pszFilename = RTPathFilenameEx(pszFilename, RTPATH_STR_F_STYLE_DOS);
+
+    /* We try use 'nt' for the kernel. */
+    if (   RTStrICmpAscii(pszFilename, "ntoskrnl.exe") == 0
+        || RTStrICmpAscii(pszFilename, "ntkrnlmp.exe") == 0)
+        return "nt";
+
+
+    /* Drop the extension if .dll or .sys. */
+    size_t cchFilename = strlen(pszFilename);
+    if (   cchFilename > 4
+        && pszFilename[cchFilename - 4] == '.')
+    {
+        if (   RTStrICmpAscii(&pszFilename[cchFilename - 4], ".sys") == 0
+            || RTStrICmpAscii(&pszFilename[cchFilename - 4], ".dll") == 0)
+            cchFilename -= 4;
+    }
+
+    /* Copy and do replacements. */
+    if (cchFilename >= cbName)
+        cchFilename = cbName - 1;
+    size_t off;
+    for (off = 0; off < cchFilename; off++)
+    {
+        char ch = pszFilename[off];
+        if (!RT_C_IS_ALNUM(ch))
+            ch = '_';
+        pszName[off] = ch;
+    }
+    pszName[off] = '\0';
+    return pszName;
 }
 
@@ -690,13 +737,16 @@
             u.wsz[cbName / 2] = '\0';
 
-            char *pszName;
-            rc = RTUtf16ToUtf8(u.wsz, &pszName);
+            char *pszFilename;
+            rc = RTUtf16ToUtf8(u.wsz, &pszFilename);
             if (RT_SUCCESS(rc))
             {
+                char        szModName[128];
+                const char *pszModName = dbgDiggerWintNtFilenameToModuleName(pszFilename, szModName, sizeof(szModName));
+
                 /* Read the start of the PE image and pass it along to a worker. */
                 DBGFADDRESS ImageAddr;
                 DBGFR3AddrFromFlat(pUVM, &ImageAddr, WINNT_UNION(pThis, &Mte, DllBase));
-                dbgDiggerWinNtProcessImage(pThis, pUVM, pszName, &ImageAddr, cbImageMte);
-                RTStrFree(pszName);
+                dbgDiggerWinNtProcessImage(pThis, pUVM, pszModName, pszFilename, &ImageAddr, cbImageMte);
+                RTStrFree(pszFilename);
             }
         }
Index: /trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp
===================================================================
--- /trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp	(revision 73490)
+++ /trunk/src/VBox/Debugger/testcase/tstDBGCStubs.cpp	(revision 73491)
@@ -198,5 +198,5 @@
     return VERR_INTERNAL_ERROR;
 }
-VMMR3DECL(int) DBGFR3ModInMem(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName,
+VMMR3DECL(int) DBGFR3ModInMem(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName, const char *pszFilename,
                               RTLDRARCH enmArch, uint32_t cbImage, PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo)
 {
Index: /trunk/src/VBox/VMM/VMMR3/DBGFR3ModInMem.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/DBGFR3ModInMem.cpp	(revision 73490)
+++ /trunk/src/VBox/VMM/VMMR3/DBGFR3ModInMem.cpp	(revision 73491)
@@ -24,6 +24,8 @@
 
 #include <VBox/err.h>
+#include <iprt/ctype.h>
 #include <iprt/ldr.h>
 #include <iprt/mem.h>
+#include <iprt/path.h>
 #include <iprt/string.h>
 #include <iprt/formats/pecoff.h>
@@ -85,4 +87,51 @@
 
 /**
+ * Normalizes a debug module name.
+ *
+ * @returns Normalized debug module name.
+ * @param   pszName         The name.
+ * @param   pszBuf          Buffer to use if work is needed.
+ * @param   cbBuf           Size of buffer.
+ */
+const char *dbgfR3ModNormalizeName(const char *pszName, char *pszBuf, size_t cbBuf)
+{
+    /*
+     * Skip to the filename in case someone gave us a full filename path.
+     */
+    pszName = RTPathFilenameEx(pszName, RTPATH_STR_F_STYLE_DOS);
+
+    /*
+     * Is it okay?
+     */
+    size_t cchName = strlen(pszName);
+    size_t off = 0;
+    for (;; off++)
+    {
+        char ch = pszName[off];
+        if (ch == '\0')
+            return pszName;
+        if (!RT_C_IS_ALNUM(ch) && ch != '_')
+            break;
+    }
+
+    /*
+     * It's no okay, so morph it.
+     */
+    if (cchName >= cbBuf)
+        cchName = cbBuf - 1;
+    for (off = 0; off < cchName; off++)
+    {
+        char ch = pszName[off];
+        if (!RT_C_IS_ALNUM(ch))
+            ch = '_';
+        pszBuf[off] = ch;
+    }
+    pszBuf[off] = '\0';
+
+    return pszBuf;
+}
+
+
+/**
  * Handles in-memory ELF images.
  *
@@ -91,5 +140,6 @@
  * @param   pImageAddr      The image address.
  * @param   fFlags          Flags, DBGFMODINMEM_F_XXX.
- * @param   pszName         The image name, optional.
+ * @param   pszName         The module name, optional.
+ * @param   pszFilename     The image filename, optional.
  * @param   enmArch         The image arch if we force it, pass
  *                          RTLDRARCH_WHATEVER if you don't care.
@@ -99,9 +149,9 @@
  * @param   pErrInfo        Where to return extended error info on failure.
  */
-static int dbgfR3ModInMemElf(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName,
+static int dbgfR3ModInMemElf(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName, const char *pszFilename,
                              RTLDRARCH enmArch, uint32_t cbImage, PDBGFMODINMEMBUF puBuf,
                              PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo)
 {
-    RT_NOREF(pUVM, fFlags, pszName, enmArch, cbImage, puBuf, phDbgMod);
+    RT_NOREF(pUVM, fFlags, pszName, pszFilename, enmArch, cbImage, puBuf, phDbgMod);
     return RTERRINFO_LOG_SET_F(pErrInfo, VERR_INVALID_EXE_SIGNATURE, "Found ELF magic at %RGv", pImageAddr->FlatPtr);
 }
@@ -422,5 +472,6 @@
  * @param   pImageAddr      The image address.
  * @param   fFlags          Flags, DBGFMODINMEM_F_XXX.
- * @param   pszName         The image name, optional.
+ * @param   pszName         The module name, optional.
+ * @param   pszFilename     The image filename, optional.
  * @param   enmArch         The image arch if we force it, pass
  *                          RTLDRARCH_WHATEVER if you don't care.
@@ -432,7 +483,7 @@
  * @param   pErrInfo        Where to return extended error info on failure.
  */
-static int dbgfR3ModInMemPe(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName, RTLDRARCH enmArch,
-                            uint32_t cbImage, uint32_t offPeHdrs, uint32_t cbPeHdrsPart1, PDBGFMODINMEMBUF puBuf,
-                            PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo)
+static int dbgfR3ModInMemPe(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName, const char *pszFilename,
+                            RTLDRARCH enmArch, uint32_t cbImage, uint32_t offPeHdrs, uint32_t cbPeHdrsPart1,
+                            PDBGFMODINMEMBUF puBuf, PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo)
 {
     /*
@@ -533,11 +584,15 @@
 
     /*
-     * Guess the image name if not specified.
-     */
-    //char szImageName[64];
+     * Guess the module name if not specified and make sure it conforms to DBGC expectations.
+     */
     if (!pszName)
     {
+        if (pszFilename)
+            pszName = RTPathFilenameEx(pszFilename, RTPATH_STR_F_STYLE_DOS);
         /** @todo */
     }
+
+    char szNormalized[128];
+    pszName = dbgfR3ModNormalizeName(pszName, szNormalized, sizeof(szNormalized));
 
     /*
@@ -552,5 +607,5 @@
 
     RTDBGMOD hMod;
-    rc = RTDbgModCreateFromPeImage(&hMod, pszName, NULL, &hLdrMod, cbImageFromHdr,
+    rc = RTDbgModCreateFromPeImage(&hMod, pszFilename, pszName, &hLdrMod, cbImageFromHdr,
                                    puBuf->Nt32.FileHeader.TimeDateStamp, DBGFR3AsGetConfig(pUVM));
     if (RT_SUCCESS(rc))
@@ -579,5 +634,6 @@
  * @param   pImageAddr      The image address.
  * @param   fFlags          Flags, DBGFMODINMEM_F_XXX.
- * @param   pszName         The image name, optional.
+ * @param   pszName         The module name, optional.
+ * @param   pszFilename     The image filename, optional.
  * @param   enmArch         The image arch if we force it, pass
  *                          RTLDRARCH_WHATEVER if you don't care.
@@ -586,5 +642,5 @@
  * @param   pErrInfo        Where to return extended error info on failure.
  */
-VMMR3DECL(int) DBGFR3ModInMem(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName,
+VMMR3DECL(int) DBGFR3ModInMem(PUVM pUVM, PCDBGFADDRESS pImageAddr, uint32_t fFlags, const char *pszName, const char *pszFilename,
                               RTLDRARCH enmArch, uint32_t cbImage, PRTDBGMOD phDbgMod, PRTERRINFO pErrInfo)
 {
@@ -612,5 +668,5 @@
 
     if (uBuf.ab[0] == ELFMAG0 && uBuf.ab[1] == ELFMAG1 && uBuf.ab[2] == ELFMAG2 && uBuf.ab[3] == ELFMAG3)
-        return dbgfR3ModInMemElf(pUVM, pImageAddr, fFlags, pszName, enmArch, cbImage, &uBuf, phDbgMod, pErrInfo);
+        return dbgfR3ModInMemElf(pUVM, pImageAddr, fFlags, pszName, pszFilename, enmArch, cbImage, &uBuf, phDbgMod, pErrInfo);
 
     uint32_t offNewHdrs;
@@ -642,6 +698,6 @@
 
     if (uBuf.Nt32.Signature == IMAGE_NT_SIGNATURE)
-        return dbgfR3ModInMemPe(pUVM, pImageAddr, fFlags, pszName, enmArch, cbImage, offNewHdrs, cbPeHdrsPart1, &uBuf,
-                                phDbgMod, pErrInfo);
+        return dbgfR3ModInMemPe(pUVM, pImageAddr, fFlags, pszName, pszFilename, enmArch, cbImage, offNewHdrs, cbPeHdrsPart1,
+                                &uBuf, phDbgMod, pErrInfo);
 
     return RTERRINFO_LOG_SET_F(pErrInfo, VERR_INVALID_EXE_SIGNATURE, "No PE/LX/NE header at %RGv (off=%#RX32): %.8Rhxs",
