Index: /trunk/include/VBox/dis.h
===================================================================
--- /trunk/include/VBox/dis.h	(revision 41670)
+++ /trunk/include/VBox/dis.h	(revision 41671)
@@ -552,10 +552,9 @@
 DISDECL(int) DISInstrToStr(void const *pvInstr, DISCPUMODE enmCpuMode,
                            PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput);
-DISDECL(int) DISInstrWithOff(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, uint32_t *pcbInstr, char *pszOutput);
-DISDECL(int) DISInstrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
-                                PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput);
-DISDECL(int) DISInstrEx(RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, DISCPUMODE enmCpuMode,
-                        PFNDISREADBYTES pfnReadBytes, void *pvUser, uint32_t uFilter,
-                        PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput);
+DISDECL(int) DISInstrToStrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
+                                     PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput);
+DISDECL(int) DISInstrToStrEx(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode,
+                             PFNDISREADBYTES pfnReadBytes, void *pvUser, uint32_t uFilter,
+                             PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput);
 
 DISDECL(int) DISCoreOne(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr);
Index: /trunk/src/VBox/Disassembler/Disasm.cpp
===================================================================
--- /trunk/src/VBox/Disassembler/Disasm.cpp	(revision 41670)
+++ /trunk/src/VBox/Disassembler/Disasm.cpp	(revision 41671)
@@ -47,28 +47,6 @@
                            char *pszOutput, size_t cbOutput)
 {
-    return DISInstrEx((uintptr_t)pvInstr, 0, enmCpuMode, NULL, NULL, OPTYPE_ALL,
-                      pCpu, pcbInstr, pszOutput);
-}
-
-/**
- * Disassembles one instruction
- *
- * @returns VBox error code
- * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
- *                          set correctly.
- * @param   uInstrAddr      Pointer to the instruction to disassemble.
- * @param   offRealAddr     Offset to add to instruction address to get the real
- *                          virtual address.
- * @param   pcbInstr        Where to store the size of the instruction. NULL is
- *                          allowed.
- * @param   pszOutput       Storage for disassembled instruction
- *
- * @todo    Define output callback.
- */
-DISDECL(int) DISInstrWithOff(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr,
-                             uint32_t *pcbInstr, char *pszOutput)
-{
-    return DISInstrEx(uInstrAddr, offRealAddr, pCpu->mode, pCpu->pfnReadBytes, pCpu->apvUserData[0], OPTYPE_ALL,
-                      pCpu, pcbInstr, pszOutput);
+    return DISInstrToStrEx((uintptr_t)pvInstr, enmCpuMode, NULL, NULL, OPTYPE_ALL,
+                           pCpu, pcbInstr, pszOutput, cbOutput);
 }
 
@@ -85,14 +63,15 @@
  * @param   pcbInstr        Where to store the size of the instruction. NULL is
  *                          allowed.
- * @param   pszOutput       Storage for disassembled instruction
+ * @param   pszOutput       Storage for disassembled instruction.
+ * @param   cbOutput        Size of the output buffer.
  *
  * @todo    Define output callback.
  */
-DISDECL(int) DISInstrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
-                                PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
+DISDECL(int) DISInstrToStrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
+                                     PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput)
 
 {
-    return DISInstrEx(uInstrAddr, 0, enmCpuMode, pfnReadBytes, pvUser, OPTYPE_ALL,
-                      pCpu, pcbInstr, pszOutput);
+    return DISInstrToStrEx(uInstrAddr, enmCpuMode, pfnReadBytes, pvUser, OPTYPE_ALL,
+                           pCpu, pcbInstr, pszOutput, cbOutput);
 }
 
@@ -101,43 +80,28 @@
  *
  * @returns VBox error code
- * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
- *                          set correctly.
  * @param   uInstrAddr      Pointer to the structure to disassemble.
- * @param   u32EipOffset    Offset to add to instruction address to get the real virtual address
+ * @param   enmCpuMode      The CPU mode.
+ * @param   pfnCallback     The byte fetcher callback.
+ * @param   uFilter         Instruction filter.
+ * @param   pCpu            Where to return the disassembled instruction.
  * @param   pcbInstr        Where to store the size of the instruction. NULL is
  *                          allowed.
- * @param   pszOutput       Storage for disassembled instruction
- * @param   uFilter         Instruction type filter.
+ * @param   pszOutput       Storage for disassembled instruction.
+ * @param   cbOutput        Size of the output buffer.
  *
  * @todo    Define output callback.
  */
-DISDECL(int) DISInstrEx(RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, DISCPUMODE enmCpuMode,
-                        PFNDISREADBYTES pfnReadBytes, void *pvUser, uint32_t uFilter,
-                        PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
+DISDECL(int) DISInstrToStrEx(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode,
+                             PFNDISREADBYTES pfnReadBytes, void *pvUser, uint32_t uFilter,
+                             PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput)
 {
     int rc = DISCoreOneExEx(uInstrAddr, enmCpuMode, uFilter, pfnReadBytes, pvUser, pCpu, pcbInstr);
-    if (RT_SUCCESS(rc) && pszOutput)
+    if (RT_SUCCESS(rc) && pszOutput && cbOutput)
     {
-        size_t      cbOutput = 128;
-        size_t      cch;
-#if 0
-        RTUINTPTR   uRealAddr = uInstrAddr + offRealAddr;
-        if (pCpu->mode == CPUMODE_64BIT || uRealAddr > UINT32_MAX)
-            cch = RTStrPrintf(pszOutput, cbOutput, "%016RTptr:  ", uRealAddr);
-        else
-            cch = RTStrPrintf(pszOutput, cbOutput, "%08RX32:  ", (uint32_t)uRealAddr);
-        rc = DISFormatYasmEx(pCpu, pszOutput + cch, cbOutput - cch,
-                             DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_BYTES_BRACKETS | DIS_FMT_FLAGS_BYTES_SPACED
-                             | DIS_FMT_FLAGS_RELATIVE_BRANCH,
-                             NULL /*pfnGetSymbol*/, NULL /*pvUser*/);
-#else
-        pCpu->uInstrAddr += offRealAddr;
         rc = DISFormatYasmEx(pCpu, pszOutput, cbOutput,
                              DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_BYTES_BRACKETS | DIS_FMT_FLAGS_BYTES_SPACED
                              | DIS_FMT_FLAGS_RELATIVE_BRANCH | DIS_FMT_FLAGS_ADDR_LEFT,
                              NULL /*pfnGetSymbol*/, NULL /*pvUser*/);
-        pCpu->uInstrAddr = uInstrAddr;
-#endif
-        cch = strlen(pszOutput);
+        size_t cch = strlen(pszOutput);
         if (cch < cbOutput)
         {
Index: /trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp
===================================================================
--- /trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp	(revision 41670)
+++ /trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp	(revision 41671)
@@ -329,7 +329,6 @@
         State.pbNext = State.pbInstr;
 
-
-        int rc = DISInstrWithReader(State.uAddress, enmCpuMode, MyDisasInstrRead, &State,
-                                    &State.Cpu, &State.cbInstr, State.szLine);
+        int rc = DISInstrToStrWithReader(State.uAddress, enmCpuMode, MyDisasInstrRead, &State,
+                                         &State.Cpu, &State.cbInstr, State.szLine, sizeof(State.szLine));
         if (    RT_SUCCESS(rc)
             ||  (   (   rc == VERR_DIS_INVALID_OPCODE
Index: /trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp
===================================================================
--- /trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp	(revision 41670)
+++ /trunk/src/VBox/Runtime/testcase/tstLdr-2.cpp	(revision 41671)
@@ -39,6 +39,7 @@
 
 
-bool MyDisBlock(PDISCPUSTATE pCpu, RTHCUINTPTR pvCodeBlock, int32_t cbMax, RTUINTPTR off)
+bool MyDisBlock(uint8_t const *pbCodeBlock, int32_t cbMax)
 {
+    DISCPUSTATE Cpu;
     int32_t i = 0;
     while (i < cbMax)
@@ -46,5 +47,5 @@
         char        szOutput[256];
         uint32_t    cbInstr;
-        if (RT_FAILURE(DISInstrWithOff(pCpu, pvCodeBlock + i, off, &cbInstr, szOutput)))
+        if (RT_FAILURE(DISInstrToStr(pbCodeBlock + i, CPUMODE_32BIT, &Cpu, &cbInstr, szOutput, sizeof(szOutput))))
             return false;
 
@@ -118,9 +119,5 @@
                     if (off < cb)
                     {
-                        DISCPUSTATE Cpu;
-
-                        memset(&Cpu, 0, sizeof(Cpu));
-                        Cpu.mode = CPUMODE_32BIT;
-                        if (MyDisBlock(&Cpu, (uintptr_t)pvBits + off, 200, Addr - (uintptr_t)pvBits))
+                        if (MyDisBlock((uint8_t *)pvBits + off, Addr - (uintptr_t)pvBits))
                         {
                             RTUINTPTR Addr2 = 0xd0000000;
@@ -128,5 +125,5 @@
                             if (RT_SUCCESS(rc))
                             {
-                                if (MyDisBlock(&Cpu, (uintptr_t)pvBits + off, 200, Addr2 - (uintptr_t)pvBits))
+                                if (MyDisBlock((uint8_t *)pvBits + off, Addr2 - (uintptr_t)pvBits))
                                     rcRet = 0;
                                 else
Index: /trunk/src/VBox/VMM/VMMR3/CPUM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/CPUM.cpp	(revision 41670)
+++ /trunk/src/VBox/VMM/VMMR3/CPUM.cpp	(revision 41671)
@@ -3676,10 +3676,11 @@
     uint32_t cbInstr;
 #ifndef LOG_ENABLED
-    rc = DISInstrWithReader(GCPtrPC, enmDisCpuMode, cpumR3DisasInstrRead, &State, pCpu, &cbInstr, NULL);
+    rc = DISCoreOneWithReader(GCPtrPC, enmDisCpuMode, cpumR3DisasInstrRead, &State, pCpu, &cbInstr);
     if (RT_SUCCESS(rc))
     {
 #else
     char szOutput[160];
-    rc = DISInstrWithReader(GCPtrPC, enmDisCpuMode, cpumR3DisasInstrRead, &State, pCpu, &cbInstr, szOutput);
+    rc = DISInstrToStrWithReader(GCPtrPC, enmDisCpuMode, cpumR3DisasInstrRead, &State,
+                                 pCpu, &cbInstr, szOutput, sizeof(szOutput));
     if (RT_SUCCESS(rc))
     {
Index: /trunk/src/VBox/VMM/VMMR3/CSAM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/CSAM.cpp	(revision 41670)
+++ /trunk/src/VBox/VMM/VMMR3/CSAM.cpp	(revision 41671)
@@ -762,15 +762,18 @@
 
 DECLINLINE(int) CSAMR3DISInstr(PVM pVM, RTRCPTR InstrGC, uint8_t *InstrHC, DISCPUMODE enmCpuMode,
-                               PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput)
+                               PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput)
 {
     (pCpu)->apvUserData[1] = InstrHC;
     (pCpu)->apvUserData[2] = (void *)(uintptr_t)InstrGC; Assert(sizeof(InstrGC) <= sizeof(pCpu->apvUserData[0]));
 #ifdef DEBUG
-    return DISInstrEx(InstrGC, 0, enmCpuMode, CSAMR3ReadBytes, pVM, OPTYPE_ALL,
-                      pCpu, pcbInstr, pszOutput);
+    return DISInstrToStrEx(InstrGC, enmCpuMode, CSAMR3ReadBytes, pVM, OPTYPE_ALL,
+                           pCpu, pcbInstr, pszOutput, cbOutput);
 #else
     /* We are interested in everything except harmless stuff */
-    return DISInstrEx(InstrGC, 0, enmCpuMode, CSAMR3ReadBytes, pVM, ~(OPTYPE_INVALID | OPTYPE_HARMLESS | OPTYPE_RRM_MASK),
-                      pCpu, pcbInstr, pszOutput);
+    if (pszOutput)
+        return DISInstrToStrEx(InstrGC, enmCpuMode, CSAMR3ReadBytes, pVM, ~(OPTYPE_INVALID | OPTYPE_HARMLESS | OPTYPE_RRM_MASK),
+                               pCpu, pcbInstr, pszOutput, cbOutput);
+    return DISCoreOneExEx(InstrGC, enmCpuMode, CSAMR3ReadBytes, pVM, ~(OPTYPE_INVALID | OPTYPE_HARMLESS | OPTYPE_RRM_MASK),
+                          pCpu, pcbInstr);
 #endif
 }
@@ -869,5 +872,5 @@
 
                 rc = CSAMR3DISInstr(pVM, pCurInstrGC, pCurInstrHC, (fCode32) ? CPUMODE_32BIT : CPUMODE_16BIT,
-                                    &cpu, &opsize, NULL);
+                                    &cpu, &opsize, NULL, 0);
             }
             AssertRC(rc);
@@ -1052,9 +1055,9 @@
 #ifdef DEBUG
                 rc2 = CSAMR3DISInstr(pVM, pCurInstrGC, pCurInstrHC, (fCode32) ? CPUMODE_32BIT : CPUMODE_16BIT,
-                                     &cpu, &opsize, szOutput);
+                                     &cpu, &opsize, szOutput, sizeof(szOutput));
                 if (RT_SUCCESS(rc2)) Log(("CSAM Call Analysis: %s", szOutput));
 #else
                 rc2 = CSAMR3DISInstr(pVM, pCurInstrGC, pCurInstrHC, (fCode32) ? CPUMODE_32BIT : CPUMODE_16BIT,
-                                     &cpu, &opsize, NULL);
+                                     &cpu, &opsize, NULL, 0);
 #endif
                 STAM_PROFILE_STOP(&pVM->csam.s.StatTimeDisasm, a);
@@ -1265,9 +1268,9 @@
 #ifdef DEBUG
             rc2 = CSAMR3DISInstr(pVM, pCurInstrGC, pCurInstrHC, fCode32 ? CPUMODE_32BIT : CPUMODE_16BIT,
-                                 &cpu, &opsize, szOutput);
+                                 &cpu, &opsize, szOutput, sizeof(szOutput));
             if (RT_SUCCESS(rc2)) Log(("CSAM Analysis: %s", szOutput));
 #else
             rc2 = CSAMR3DISInstr(pVM, pCurInstrGC, pCurInstrHC, fCode32 ? CPUMODE_32BIT : CPUMODE_16BIT,
-                                 &cpu, &opsize, NULL);
+                                 &cpu, &opsize, NULL, 0);
 #endif
             STAM_PROFILE_STOP(&pVM->csam.s.StatTimeDisasm, a);
Index: /trunk/src/VBox/VMM/VMMR3/PATM.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/PATM.cpp	(revision 41670)
+++ /trunk/src/VBox/VMM/VMMR3/PATM.cpp	(revision 41671)
@@ -69,4 +69,21 @@
 
 
+#define PATMREAD_RAWCODE        1  /* read code as-is */
+#define PATMREAD_ORGCODE        2  /* read original guest opcode bytes; not the patched bytes */
+#define PATMREAD_NOCHECK        4  /* don't check for patch conflicts */
+
+/*
+ * Private structure used during disassembly
+ */
+typedef struct
+{
+    PVM                  pVM;
+    PPATCHINFO           pPatchInfo;
+    R3PTRTYPE(uint8_t *) pInstrHC;
+    RTRCPTR              pInstrGC;
+    uint32_t             fReadFlags;
+} PATMDISASM, *PPATMDISASM;
+
+
 /*******************************************************************************
 *   Internal Functions                                                         *
@@ -576,4 +593,87 @@
 }
 
+
+DECLINLINE(bool) patmR3DisInstrToStr(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 InstrGCPtr32, uint8_t *pbInstrHC, uint32_t fReadFlags,
+                                     PDISCPUSTATE pCpu, uint32_t *pcbInstr, char *pszOutput, size_t cbOutput)
+{
+    PATMDISASM disinfo;
+    disinfo.pVM         = pVM;
+    disinfo.pPatchInfo  = pPatch;
+    disinfo.pInstrHC    = pbInstrHC;
+    disinfo.pInstrGC    = InstrGCPtr32;
+    disinfo.fReadFlags  = fReadFlags;
+    (pCpu)->pfnReadBytes = patmReadBytes;
+    (pCpu)->apvUserData[0] = &disinfo;
+    return RT_SUCCESS(DISInstrToStrWithReader(InstrGCPtr32,
+                                              (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT,
+                                              patmReadBytes, &disinfo,
+                                              pCpu, pcbInstr, pszOutput, cbOutput));
+}
+
+
+DECLINLINE(bool) patmR3DisInstr(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 InstrGCPtr32, uint8_t *pbInstrHC, uint32_t fReadFlags,
+                                PDISCPUSTATE pCpu, uint32_t *pcbInstr)
+{
+    PATMDISASM disinfo;
+    disinfo.pVM         = pVM;
+    disinfo.pPatchInfo  = pPatch;
+    disinfo.pInstrHC    = pbInstrHC;
+    disinfo.pInstrGC    = InstrGCPtr32;
+    disinfo.fReadFlags  = fReadFlags;
+    (pCpu)->pfnReadBytes = patmReadBytes;
+    (pCpu)->apvUserData[0] = &disinfo;
+    return RT_SUCCESS(DISCoreOneWithReader(InstrGCPtr32,
+                                           (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT,
+                                           patmReadBytes, &disinfo,
+                                           pCpu, pcbInstr));
+}
+
+
+DECLINLINE(bool) patmR3DisInstrNoStrOpMode(PVM pVM, PPATCHINFO pPatch, RTGCPTR32 InstrGCPtr32, uint8_t *pbInstrHC,
+                                           uint32_t fReadFlags,
+                                           PDISCPUSTATE pCpu, uint32_t *pcbInstr)
+{
+    PATMDISASM disinfo;
+    disinfo.pVM         = pVM;
+    disinfo.pPatchInfo  = pPatch;
+    disinfo.pInstrHC    = pbInstrHC;
+    disinfo.pInstrGC    = InstrGCPtr32;
+    disinfo.fReadFlags  = fReadFlags;
+    (pCpu)->pfnReadBytes = patmReadBytes;
+    (pCpu)->apvUserData[0] = &disinfo;
+    return RT_SUCCESS(DISCoreOneWithReader(InstrGCPtr32, pPatch->uOpMode, patmReadBytes, &disinfo,
+                                           pCpu, pcbInstr));
+}
+
+#ifdef LOG_ENABLED
+# define PATM_LOG_ORG_PATCH_INSTR(a_pVM, a_pPatch, a_szComment) \
+    PATM_LOG_PATCH_INSTR(a_pVM, a_pPatch, PATMREAD_ORGCODE, a_szComment, " patch:")
+# define PATM_LOG_RAW_PATCH_INSTR(a_pVM, a_pPatch, a_szComment) \
+    PATM_LOG_PATCH_INSTR(a_pVM, a_pPatch, PATMREAD_RAWCODE, a_szComment, " patch:")
+
+# define PATM_LOG_PATCH_INSTR(a_pVM, a_pPatch, a_fFlags, a_szComment1, a_szComment2) \
+    do { \
+        if (LogIsEnabled()) \
+            patmLogRawPatchInstr(a_pVM, a_pPatch, a_fFlags, a_szComment1, a_szComment2); \
+    } while (0)
+
+static void patmLogRawPatchInstr(PVM pVM, PPATCHINFO pPatch, uint32_t fFlags,
+                                 const char *pszComment1, const char *pszComment2)
+{
+    DISCPUSTATE DisState;
+    char szOutput[128];
+    szOutput[0] = '\0';
+    patmR3DisInstrToStr(pVM, pPatch, pPatch->pPrivInstrGC, NULL, fFlags,
+                        &DisState, NULL, szOutput, sizeof(szOutput));
+    Log(("%s%s %s", pszComment1, pszComment2, szOutput));
+}
+
+#else
+# define PATM_LOG_ORG_PATCH_INSTR(a_pVM, a_pPatch, a_szComment)                         do { } while (0)
+# define PATM_LOG_RAW_PATCH_INSTR(a_pVM, a_pPatch, a_szComment)                         do { } while (0)
+# define PATM_LOG_PATCH_INSTR(a_pVM, a_pPatch, a_fFlags, a_szComment1, a_szComment2)    do { } while (0)
+#endif
+
+
 /**
  * Callback function for RTAvloU32DoWithAll
@@ -590,10 +690,4 @@
     PVM             pVM = (PVM)pParam;
     RTRCINTPTR      delta;
-#ifdef LOG_ENABLED
-    DISCPUSTATE     cpu;
-    char            szOutput[256];
-    uint32_t        opsize;
-    bool            disret;
-#endif
     int             rc;
 
@@ -602,12 +696,6 @@
         return 0;
 
-#ifdef LOG_ENABLED
     if (pPatch->patch.flags & PATMFL_PATCHED_GUEST_CODE)
-    {
-        cpu.mode = (pPatch->patch.flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, &pPatch->patch, &cpu, pPatch->patch.pPrivInstrGC, NULL, &opsize, szOutput, PATMREAD_RAWCODE);
-        Log(("Org patch jump: %s", szOutput));
-    }
-#endif
+        PATM_LOG_PATCH_INSTR(pVM, &pPatch->patch, PATMREAD_RAWCODE, "Org patch jump:", "");
 
     Log(("Nr of fixups %d\n", pPatch->patch.nrFixups));
@@ -786,12 +874,6 @@
     }
 
-#ifdef LOG_ENABLED
     if (pPatch->patch.flags & PATMFL_PATCHED_GUEST_CODE)
-    {
-        cpu.mode = (pPatch->patch.flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, &pPatch->patch, &cpu, pPatch->patch.pPrivInstrGC, NULL, &opsize, szOutput, PATMREAD_RAWCODE);
-        Log(("Rel patch jump: %s", szOutput));
-    }
-#endif
+        PATM_LOG_PATCH_INSTR(pVM, &pPatch->patch, PATMREAD_RAWCODE, "Rel patch jump:", "");
     return 0;
 }
@@ -1738,5 +1820,5 @@
 
                 // Disassemble the next instruction
-                disret = PATMR3DISInstr(pVM, pPatch, &cpu, pNextInstrGC, pNextInstrHC, &opsize, NULL);
+                disret = patmR3DisInstr(pVM, pPatch, pNextInstrGC, pNextInstrHC, PATMREAD_ORGCODE, &cpu, &opsize);
             }
             if (disret == false)
@@ -2052,5 +2134,4 @@
         uint32_t    dummy;
 
-        cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
         pOrgJumpGC = patmPatchGCPtr2GuestGCPtr(pVM, pPatch, pCurInstrGC);
 
@@ -2058,5 +2139,5 @@
             uint8_t *pOrgJumpHC = PATMGCVirtToHCVirt(pVM, pCacheRec, pOrgJumpGC);
 
-            bool disret = PATMR3DISInstr(pVM, pPatch, &cpu, pOrgJumpGC, pOrgJumpHC, &dummy, NULL);
+            bool disret = patmR3DisInstr(pVM, pPatch, pOrgJumpGC, pOrgJumpHC, PATMREAD_ORGCODE, &cpu, NULL);
             if (!disret || cpu.pCurInstr->opcode != OP_CALL || cpu.param1.cb != 4 /* only near calls */)
                 return VINF_SUCCESS;
@@ -2115,8 +2196,6 @@
     delta = pVM->patm.s.pPatchMemGC - (uintptr_t)pVM->patm.s.pPatchMemHC;
 
-    while(rc == VWRN_CONTINUE_ANALYSIS)
-    {
-        cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-
+    while (rc == VWRN_CONTINUE_ANALYSIS)
+    {
         pCurInstrHC = PATMGCVirtToHCVirt(pVM, pCacheRec, pCurInstrGC);
         if (pCurInstrHC == NULL)
@@ -2126,5 +2205,6 @@
         }
 
-        disret = PATMR3DISInstr(pVM, pPatch, &cpu, pCurInstrGC, pCurInstrHC, &opsize, szOutput, PATMREAD_RAWCODE);
+        disret = patmR3DisInstrToStr(pVM, pPatch, pCurInstrGC, pCurInstrHC, PATMREAD_RAWCODE,
+                                     &cpu, &opsize, szOutput, sizeof(szOutput));
         if (PATMIsPatchGCAddr(pVM, pCurInstrGC))
         {
@@ -2285,6 +2365,4 @@
     while (rc == VWRN_CONTINUE_RECOMPILE)
     {
-        cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-
         pCurInstrHC = PATMGCVirtToHCVirt(pVM, pCacheRec, pCurInstrGC);
         if (pCurInstrHC == NULL)
@@ -2294,8 +2372,9 @@
         }
 #ifdef LOG_ENABLED
-        disret = PATMR3DISInstr(pVM, pPatch, &cpu, pCurInstrGC, pCurInstrHC, &opsize, szOutput);
+        disret = patmR3DisInstrToStr(pVM, pPatch, pCurInstrGC, pCurInstrHC, PATMREAD_ORGCODE,
+                                     &cpu, &opsize, szOutput, sizeof(szOutput));
         Log(("Recompile: %s", szOutput));
 #else
-        disret = PATMR3DISInstr(pVM, pPatch, &cpu, pCurInstrGC, pCurInstrHC, &opsize, NULL);
+        disret = patmR3DisInstr(pVM, pPatch, pCurInstrGC, pCurInstrHC, PATMREAD_ORGCODE, &cpu, &opsize);
 #endif
         if (disret == false)
@@ -2333,6 +2412,5 @@
                     goto end;
                 }
-                cpunext.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-                disret = PATMR3DISInstr(pVM, pPatch, &cpunext, pNextInstrGC, pNextInstrHC, &opsizenext, NULL);
+                disret = patmR3DisInstr(pVM, pPatch, pNextInstrGC, pNextInstrHC, PATMREAD_ORGCODE, &cpunext, &opsizenext);
                 if (disret == false)
                 {
@@ -2565,6 +2643,6 @@
     while (i < pPatch->cbPrivInstr)
     {
-        cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC + i, NULL, &opsize, szOutput);
+        disret = patmR3DisInstrToStr(pVM, pPatch, pPatch->pPrivInstrGC + i, NULL, PATMREAD_ORGCODE,
+                                     &cpu, &opsize, szOutput, sizeof(szOutput));
         if (disret == false)
             break;
@@ -2582,8 +2660,8 @@
     {
         i = 0;
-        while(i < pPatch->cbPrivInstr)
-        {
-            cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-            disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC + i, NULL, &opsize, szOutput);
+        while (i < pPatch->cbPrivInstr)
+        {
+            disret = patmR3DisInstrToStr(pVM, pPatch, pPatch->pPrivInstrGC + i, NULL, PATMREAD_ORGCODE,
+                                         &cpu, &opsize, szOutput, sizeof(szOutput));
             if (disret == false)
                 break;
@@ -2661,13 +2739,7 @@
     PPATCHINFO pPatch = &pPatchRec->patch;
     int rc = VERR_PATCHING_REFUSED;
-    DISCPUSTATE cpu;
     uint32_t orgOffsetPatchMem = ~0;
     RTRCPTR pInstrStart;
     bool fInserted;
-#ifdef LOG_ENABLED
-    uint32_t opsize;
-    char szOutput[256];
-    bool disret;
-#endif
     NOREF(pInstrHC); NOREF(uOpSize);
 
@@ -2720,6 +2792,4 @@
     pPatch->pPatchBlockOffset = pVM->patm.s.offPatchMem;
     pPatch->uCurPatchOffset = 0;
-
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
 
     if ((pPatch->flags & (PATMFL_IDTHANDLER|PATMFL_IDTHANDLER_WITHOUT_ENTRYPOINT|PATMFL_SYSENTER)) == PATMFL_IDTHANDLER)
@@ -2848,9 +2918,5 @@
     }
 
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC, NULL, &opsize, szOutput, PATMREAD_RAWCODE);
-    Log(("%s patch: %s", patmGetInstructionString(pPatch->opcode, pPatch->flags), szOutput));
-#endif
+    PATM_LOG_RAW_PATCH_INSTR(pVM, pPatch, patmGetInstructionString(pPatch->opcode, pPatch->flags));
 
     patmEmptyTree(pVM, &pPatch->pTempInfo->IllegalInstrTree);
@@ -2917,6 +2983,5 @@
      * condition here and only patch the common entypoint once.
      */
-    cpuPush.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpuPush, pCurInstrGC, pCurInstrHC, &opsize, NULL);
+    disret = patmR3DisInstr(pVM, pPatch, pCurInstrGC, pCurInstrHC, PATMREAD_ORGCODE, &cpuPush, &opsize);
     Assert(disret);
     if (disret && cpuPush.pCurInstr->opcode == OP_PUSH)
@@ -2926,6 +2991,5 @@
         pCurInstrGC += opsize;
 
-        cpuJmp.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, pPatch, &cpuJmp, pCurInstrGC, pCurInstrHC, &opsize, NULL);
+        disret = patmR3DisInstr(pVM, pPatch, pCurInstrGC, pCurInstrHC, PATMREAD_ORGCODE, &cpuJmp, &opsize);
         if (   disret
             && cpuJmp.pCurInstr->opcode == OP_JMP
@@ -3034,10 +3098,4 @@
     uint32_t orgOffsetPatchMem = ~0;
     bool fInserted;
-#ifdef LOG_ENABLED
-    bool disret;
-    DISCPUSTATE cpu;
-    uint32_t opsize;
-    char szOutput[256];
-#endif
 
     // save original offset (in case of failures later on)
@@ -3074,10 +3132,5 @@
     Log(("Patch code ends -----------------------------------------------------\n"));
 #endif
-
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC, NULL, &opsize, szOutput);
-    Log(("TRAP handler patch: %s", szOutput));
-#endif
+    PATM_LOG_ORG_PATCH_INSTR(pVM, pPatch, "TRAP handler");
     Log(("Successfully installed Trap Trampoline patch at %RRv\n", pInstrGC));
 
@@ -3561,6 +3614,5 @@
                 break;
 
-            cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-            disret = PATMR3DISInstr(pVM, pPatch, &cpu, pTargetGC, pTmpInstrHC, &opsize, NULL);
+            disret = patmR3DisInstr(pVM, pPatch, pTargetGC, pTmpInstrHC, PATMREAD_ORGCODE, &cpu, &opsize);
             if (disret == false || cpu.pCurInstr->opcode != OP_JMP)
                 break;
@@ -3598,10 +3650,5 @@
     pPatch->pInstrGCLowest  = pInstrGC;
     pPatch->pInstrGCHighest = pInstrGC + pCpu->opsize;
-
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC, NULL, &opsize, szOutput);
-    Log(("Call patch: %s", szOutput));
-#endif
+    PATM_LOG_ORG_PATCH_INSTR(pVM, pPatch, "Call");
 
     Log(("Successfully installed function replacement patch at %RRv\n", pInstrGC));
@@ -3634,10 +3681,4 @@
     uint8_t      *pPB;
     int           rc = VERR_PATCHING_REFUSED;
-#ifdef LOG_ENABLED
-    DISCPUSTATE   cpu;
-    uint32_t      opsize;
-    bool          disret;
-    char          szOutput[256];
-#endif
 
     Assert(pVM->patm.s.mmio.pCachedData);
@@ -3658,9 +3699,5 @@
         return VERR_PATCHING_REFUSED;
     }
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC, NULL, &opsize, szOutput);
-    Log(("MMIO patch old instruction: %s", szOutput));
-#endif
+    PATM_LOG_PATCH_INSTR(pVM, pPatch, PATMREAD_ORGCODE, "MMIO patch old instruction:", "");
 
     /* Save original instruction. */
@@ -3678,9 +3715,5 @@
     }
 
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC, NULL, &opsize, szOutput);
-    Log(("MMIO patch: %s", szOutput));
-#endif
+    PATM_LOG_ORG_PATCH_INSTR(pVM, pPatch, "MMIO");
     pVM->patm.s.mmio.pCachedData = 0;
     pVM->patm.s.mmio.GCPhys = 0;
@@ -3713,7 +3746,4 @@
     bool          disret;
     uint8_t      *pInstrHC;
-#ifdef LOG_ENABLED
-    char          szOutput[256];
-#endif
 
     AssertReturn(pVM->patm.s.mmio.pCachedData, VERR_INVALID_PARAMETER);
@@ -3724,6 +3754,6 @@
 
     /* Disassemble mmio instruction. */
-    cpu.mode = pPatch->uOpMode;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pInstrGC, pInstrHC, &opsize, NULL);
+    disret = patmR3DisInstrNoStrOpMode(pVM, pPatch, pInstrGC, pInstrHC, PATMREAD_ORGCODE,
+                                       &cpu, &opsize);
     if (disret == false)
     {
@@ -3751,10 +3781,5 @@
     pPatch->pInstrGCHighest = pInstrGC + cpu.opsize;
 
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pInstrGC, pInstrHC, &opsize, szOutput);
-    Log(("MMIO patch: %s", szOutput));
-#endif
-
+    PATM_LOG_ORG_PATCH_INSTR(pVM, pPatch, "MMIO");
     pVM->patm.s.mmio.pCachedData = 0;
     pVM->patm.s.mmio.GCPhys = 0;
@@ -3828,14 +3853,5 @@
 
     /* Note: Do not use patch memory here! It might called during patch installation too. */
-
-#ifdef LOG_ENABLED
-    DISCPUSTATE   cpu;
-    char          szOutput[256];
-    uint32_t      opsize;
-
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    PATMR3DISInstr(pVM, pPatch, &cpu, pInstrGC, pInstrHC, &opsize, szOutput);
-    Log(("PATMR3PatchInstrInt3: %s", szOutput));
-#endif
+    PATM_LOG_PATCH_INSTR(pVM, pPatch, PATMREAD_ORGCODE, "PATMR3PatchInstrInt3:", "");
 
     /* Save the original instruction. */
@@ -3881,10 +3897,4 @@
     PPATCHINFO pPatch = &pPatchRec->patch;
     int rc = VERR_PATCHING_REFUSED;
-#ifdef LOG_ENABLED
-    bool disret;
-    DISCPUSTATE cpu;
-    uint32_t opsize;
-    char szOutput[256];
-#endif
 
     pPatch->pPatchBlockOffset = 0;  /* doesn't use patch memory */
@@ -3974,10 +3984,5 @@
     pPatch->flags |= PATMFL_MUST_INSTALL_PATCHJMP;
 
-#ifdef LOG_ENABLED
-    cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC, NULL, &opsize, szOutput);
-    Log(("%s patch: %s", patmGetInstructionString(pPatch->opcode, pPatch->flags), szOutput));
-#endif
-
+    PATM_LOG_ORG_PATCH_INSTR(pVM, pPatch, patmGetInstructionString(pPatch->opcode, pPatch->flags));
     Log(("Successfully installed %s patch at %RRv\n", patmGetInstructionString(pPatch->opcode, pPatch->flags), pInstrGC));
 
@@ -4247,6 +4252,5 @@
     }
 
-    cpu.mode = pPatchRec->patch.uOpMode;
-    disret = PATMR3DISInstr(pVM, &pPatchRec->patch, &cpu, pInstrGC, NULL, &opsize, NULL);
+    disret = patmR3DisInstrNoStrOpMode(pVM, &pPatchRec->patch, pInstrGC, NULL, PATMREAD_ORGCODE, &cpu, &opsize);
     if (disret == false)
     {
@@ -4501,6 +4505,5 @@
         uint32_t    opsize;
 
-        cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, pPatch, &cpu, pInstrGC, pInstrHC, &opsize, NULL, PATMREAD_ORGCODE | PATMREAD_NOCHECK);
+        disret = patmR3DisInstr(pVM, pPatch, pInstrGC, pInstrHC, PATMREAD_ORGCODE | PATMREAD_NOCHECK, &cpu, &opsize);
         PGMPhysReleasePageMappingLock(pVM, &Lock);
         if (disret)
@@ -5200,6 +5203,5 @@
     RT_ZERO(patch);
     pInstrHC = PATMGCVirtToHCVirt(pVM, &patch, pInstrGC);
-    cpu.mode = (pConflictPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-    disret = PATMR3DISInstr(pVM, &patch, &cpu, pInstrGC, pInstrHC, &opsize, NULL);
+    disret = patmR3DisInstr(pVM, &patch, pInstrGC, pInstrHC, PATMREAD_ORGCODE, &cpu, &opsize);
     /*
      * If it's a 5 byte relative jump, then we can work around the problem by replacing the 32 bits relative offset
@@ -5343,11 +5345,11 @@
                         DISCPUSTATE cpu;
                         char szOutput[256];
-                        uint32_t opsize, i = 0;
+                        uint32_t opsize;
+                        uint32_t i = 0;
                         bool disret;
-                        i = 0;
                         while(i < pPatch->cbPatchJump)
                         {
-                            cpu.mode = (pPatch->flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-                            disret = PATMR3DISInstr(pVM, pPatch, &cpu, pPatch->pPrivInstrGC + i, NULL, &opsize, szOutput);
+                            disret = patmR3DisInstrToStr(pVM, pPatch, pPatch->pPrivInstrGC + i, NULL, PATMREAD_ORGCODE,
+                                                         &cpu, &opsize, szOutput, sizeof(szOutput));
                             Log(("Renewed patch instr: %s", szOutput));
                             i += opsize;
@@ -6415,6 +6417,6 @@
         cacheRec.pPatch = &pPatch->patch;
 
-        cpu.mode = (pPatch->patch.flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, &pPatch->patch, &cpu, pNewEip, PATMGCVirtToHCVirt(pVM, &cacheRec, pNewEip), &opsize, NULL, PATMREAD_RAWCODE);
+        disret = patmR3DisInstr(pVM, &pPatch->patch, pNewEip, PATMGCVirtToHCVirt(pVM, &cacheRec, pNewEip), PATMREAD_RAWCODE,
+                                &cpu, &opsize);
         if (cacheRec.Lock.pvMap)
             PGMPhysReleasePageMappingLock(pVM, &cacheRec.Lock);
@@ -6454,6 +6456,6 @@
         cacheRec.pPatch = &pPatch->patch;
 
-        cpu.mode = (pPatch->patch.flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-        disret = PATMR3DISInstr(pVM, &pPatch->patch, &cpu, pNewEip, PATMGCVirtToHCVirt(pVM, &cacheRec, pNewEip), &opsize, NULL, PATMREAD_ORGCODE);
+        disret = patmR3DisInstr(pVM, &pPatch->patch, pNewEip, PATMGCVirtToHCVirt(pVM, &cacheRec, pNewEip), PATMREAD_ORGCODE,
+                                &cpu, &opsize);
         if (cacheRec.Lock.pvMap)
             PGMPhysReleasePageMappingLock(pVM, &cacheRec.Lock);
@@ -6462,5 +6464,6 @@
         {
             cpu.mode = (pPatch->patch.flags & PATMFL_CODE32) ? CPUMODE_32BIT : CPUMODE_16BIT;
-            disret = PATMR3DISInstr(pVM, &pPatch->patch, &cpu, pNewEip, PATMGCVirtToHCVirt(pVM, &cacheRec, pNewEip), &opsize, NULL, PATMREAD_RAWCODE);
+            disret = patmR3DisInstr(pVM, &pPatch->patch, pNewEip, PATMGCVirtToHCVirt(pVM, &cacheRec, pNewEip), PATMREAD_RAWCODE,
+                                    &cpu, &opsize);
             if (cacheRec.Lock.pvMap)
                 PGMPhysReleasePageMappingLock(pVM, &cacheRec.Lock);
Index: /trunk/src/VBox/VMM/VMMR3/VMMSwitcher.cpp
===================================================================
--- /trunk/src/VBox/VMM/VMMR3/VMMSwitcher.cpp	(revision 41670)
+++ /trunk/src/VBox/VMM/VMMR3/VMMSwitcher.cpp	(revision 41671)
@@ -814,8 +814,5 @@
              */
             RTLogPrintf("  %s: offCode=%#x cbCode=%#x\n", pszDesc, offCode, cbCode);
-            DISCPUSTATE Cpu;
-
-            memset(&Cpu, 0, sizeof(Cpu));
-            Cpu.mode = CPUMODE_32BIT;
+
             while (cbCode > 0)
             {
@@ -835,13 +832,22 @@
 
                 /* disas */
-                uint32_t cbInstr = 0;
-                char szDisas[256];
-                if (RT_SUCCESS(DISInstrWithOff(&Cpu, (uintptr_t)pu8CodeR3 + offCode, uBase - (uintptr_t)pu8CodeR3,
-                                               &cbInstr, szDisas)))
-                    RTLogPrintf("  %04x: %s", offCode, szDisas); //for whatever reason szDisas includes '\n'.
+                uint32_t    cbInstr = 0;
+                DISCPUSTATE Cpu;
+                char        szDisas[256];
+                int rc = DISCoreOne((uintptr_t)pu8CodeR3 + offCode, CPUMODE_32BIT, &Cpu, &cbInstr);
+                if (RT_SUCCESS(rc))
+                {
+                    Cpu.uInstrAddr += uBase - (uintptr_t)pu8CodeR3;
+                    rc = DISFormatYasmEx(&Cpu, szDisas, sizeof(szDisas),
+                                         DIS_FMT_FLAGS_ADDR_LEFT | DIS_FMT_FLAGS_BYTES_LEFT | DIS_FMT_FLAGS_BYTES_SPACED
+                                         | DIS_FMT_FLAGS_RELATIVE_BRANCH,
+                                         NULL, NULL);
+                }
+                if (RT_SUCCESS(rc))
+                    RTLogPrintf("  %04x: %s\n", offCode, szDisas);
                 else
                 {
-                    RTLogPrintf("  %04x: %02x '%c'\n",
-                                offCode, pu8CodeR3[offCode], RT_C_IS_PRINT(pu8CodeR3[offCode]) ? pu8CodeR3[offCode] : ' ');
+                    RTLogPrintf("  %04x: %02x '%c' (rc=%Rrc\n",
+                                offCode, pu8CodeR3[offCode], RT_C_IS_PRINT(pu8CodeR3[offCode]) ? pu8CodeR3[offCode] : ' ', rc);
                     cbInstr = 1;
                 }
Index: /trunk/src/VBox/VMM/include/PATMInternal.h
===================================================================
--- /trunk/src/VBox/VMM/include/PATMInternal.h	(revision 41670)
+++ /trunk/src/VBox/VMM/include/PATMInternal.h	(revision 41671)
@@ -678,38 +678,4 @@
 
 
-#ifndef IN_RC
-
-#define PATMREAD_RAWCODE        1  /* read code as-is */
-#define PATMREAD_ORGCODE        2  /* read original guest opcode bytes; not the patched bytes */
-#define PATMREAD_NOCHECK        4  /* don't check for patch conflicts */
-
-/*
- * Private structure used during disassembly
- */
-typedef struct
-{
-    PVM                  pVM;
-    PPATCHINFO           pPatchInfo;
-    R3PTRTYPE(uint8_t *) pInstrHC;
-    RTRCPTR              pInstrGC;
-    uint32_t             fReadFlags;
-} PATMDISASM, *PPATMDISASM;
-
-DECLINLINE(bool) PATMR3DISInstr(PVM pVM, PPATCHINFO pPatch, PDISCPUSTATE pCpu, RTRCPTR InstrGC,
-                                uint8_t *InstrHC, uint32_t *pOpsize, char *pszOutput,
-                                uint32_t fReadFlags = PATMREAD_ORGCODE)
-{
-    PATMDISASM disinfo;
-    disinfo.pVM         = pVM;
-    disinfo.pPatchInfo  = pPatch;
-    disinfo.pInstrHC    = InstrHC;
-    disinfo.pInstrGC    = InstrGC;
-    disinfo.fReadFlags  = fReadFlags;
-    (pCpu)->pfnReadBytes = patmReadBytes;
-    (pCpu)->apvUserData[0] = &disinfo;
-    return RT_SUCCESS(DISInstrWithReader(InstrGC, pCpu->mode, patmReadBytes, &disinfo, pCpu, pOpsize, pszOutput));
-}
-#endif /* !IN_RC */
-
 RT_C_DECLS_BEGIN
 /**
