Index: trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp
===================================================================
--- trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp	(revision 41501)
+++ trunk/src/VBox/Disassembler/testcase/tstDisasm-2.cpp	(revision 41658)
@@ -171,14 +171,14 @@
  *       however the current doesn't do this and is just complicated...
  */
-static DECLCALLBACK(int) MyDisasInstrRead(RTUINTPTR uSrcAddr, uint8_t *pbDst, uint32_t cbRead, void *pvDisCpu)
-{
-    PMYDISSTATE pState = (PMYDISSTATE)pvDisCpu;
+static DECLCALLBACK(int) MyDisasInstrRead(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead)
+{
+    PMYDISSTATE pState = (PMYDISSTATE)pDisState;
     if (RT_LIKELY(   pState->uNextAddr == uSrcAddr
-                  && pState->cbLeft >= cbRead))
+                  && pState->cbLeft >= cbToRead))
     {
         /*
          * Straight forward reading.
          */
-        if (cbRead == 1)
+        if (cbToRead == 1)
         {
             pState->cbLeft--;
@@ -188,8 +188,8 @@
         else
         {
-            memcpy(pbDst, pState->pbNext, cbRead);
-            pState->pbNext += cbRead;
-            pState->cbLeft -= cbRead;
-            pState->uNextAddr += cbRead;
+            memcpy(pbDst, pState->pbNext, cbToRead);
+            pState->pbNext += cbToRead;
+            pState->cbLeft -= cbToRead;
+            pState->uNextAddr += cbToRead;
         }
     }
@@ -211,5 +211,5 @@
                 pState->cbLeft = 0;
 
-                memset(pbDst, 0xcc, cbRead);
+                memset(pbDst, 0xcc, cbToRead);
                 pState->rc = VERR_EOF;
                 return VERR_EOF;
@@ -227,10 +227,10 @@
 
             /* do the reading. */
-            if (pState->cbLeft >= cbRead)
-            {
-                memcpy(pbDst, pState->pbNext, cbRead);
-                pState->cbLeft -= cbRead;
-                pState->pbNext += cbRead;
-                pState->uNextAddr += cbRead;
+            if (pState->cbLeft >= cbToRead)
+            {
+                memcpy(pbDst, pState->pbNext, cbToRead);
+                pState->cbLeft -= cbToRead;
+                pState->pbNext += cbToRead;
+                pState->uNextAddr += cbToRead;
             }
             else
@@ -240,10 +240,10 @@
                     memcpy(pbDst, pState->pbNext, pState->cbLeft);
                     pbDst += pState->cbLeft;
-                    cbRead -= (uint32_t)pState->cbLeft;
+                    cbToRead -= (uint32_t)pState->cbLeft;
                     pState->pbNext += pState->cbLeft;
                     pState->uNextAddr += pState->cbLeft;
                     pState->cbLeft = 0;
                 }
-                memset(pbDst, 0xcc, cbRead);
+                memset(pbDst, 0xcc, cbToRead);
                 pState->rc = VERR_EOF;
                 return VERR_EOF;
@@ -253,5 +253,5 @@
         {
             RTStrmPrintf(g_pStdErr, "Reading before current instruction!\n");
-            memset(pbDst, 0x90, cbRead);
+            memset(pbDst, 0x90, cbToRead);
             pState->rc = VERR_INTERNAL_ERROR;
             return VERR_INTERNAL_ERROR;
@@ -286,6 +286,4 @@
      */
     MYDISSTATE State;
-    State.Cpu.mode = enmCpuMode;
-    State.Cpu.pfnReadBytes = MyDisasInstrRead;
     State.uAddress = uAddress;
     State.pbInstr = pbFile;
@@ -331,5 +329,7 @@
         State.pbNext = State.pbInstr;
 
-        int rc = DISInstr(&State.Cpu, State.uAddress, 0, &State.cbInstr, State.szLine);
+
+        int rc = DISInstrWithReader(State.uAddress, enmCpuMode, MyDisasInstrRead, &State,
+                                    &State.Cpu, &State.cbInstr, State.szLine);
         if (    RT_SUCCESS(rc)
             ||  (   (   rc == VERR_DIS_INVALID_OPCODE
@@ -345,13 +345,13 @@
             if (State.fUndefOp && State.enmUndefOp == kUndefOp_DefineByte)
             {
+                if (!State.cbInstr)
+                {
+                    State.Cpu.abInstr[0] = 0;
+                    State.Cpu.pfnReadBytes(&State.Cpu, &State.Cpu.abInstr[0], State.uAddress, 1);
+                    State.cbInstr = 1;
+                }
                 RTPrintf("    db");
-                if (!State.cbInstr)
-                    State.cbInstr = 1;
                 for (unsigned off = 0; off < State.cbInstr; off++)
-                {
-                    uint8_t b;
-                    State.Cpu.pfnReadBytes(State.uAddress + off, &b, 1, &State.Cpu);
-                    RTPrintf(off ? ", %03xh" : " %03xh", b);
-                }
+                    RTPrintf(off ? ", %03xh" : " %03xh", State.Cpu.abInstr[off]);
                 RTPrintf("    ; %s\n", State.szLine);
             }
@@ -376,9 +376,5 @@
                     RTPrintf("    db");
                     for (unsigned off = 0; off < State.cbInstr; off++)
-                    {
-                        uint8_t b;
-                        State.Cpu.pfnReadBytes(State.uAddress + off, &b, 1, &State.Cpu);
-                        RTPrintf(off ? ", %03xh" : " %03xh", b);
-                    }
+                        RTPrintf(off ? ", %03xh" : " %03xh", State.Cpu.abInstr[off]);
                     RTPrintf(" ; ");
                 }
