Index: /trunk/src/VBox/Disassembler/DisasmCore.cpp
===================================================================
--- /trunk/src/VBox/Disassembler/DisasmCore.cpp	(revision 41821)
+++ /trunk/src/VBox/Disassembler/DisasmCore.cpp	(revision 41822)
@@ -35,6 +35,7 @@
 *   Defined Constants And Macros                                               *
 *******************************************************************************/
-/** This must be less or equal to DISSTATE::abInstr. */
-#define DIS_MAX_INSTR_LENGTH 16
+/** This must be less or equal to DISSTATE::abInstr.
+ * See Vol3A/Table 6-2 and Vol3B/Section22.25 for instance.  */
+#define DIS_MAX_INSTR_LENGTH    15
 
 /** Whether we can do unaligned access. */
@@ -311,4 +312,7 @@
         Log(("disReadByte: too long instruction...\n"));
         pDis->rc = VERR_DIS_TOO_LONG_INSTR;
+        RTINTPTR cbLeft = sizeof(pDis->abInstr) - offInstr;
+        if (cbLeft > 0)
+            return pDis->abInstr[offInstr];
         return 0;
     }
@@ -349,7 +353,14 @@
         Log(("disReadWord: too long instruction...\n"));
         pDis->rc = VERR_DIS_TOO_LONG_INSTR;
-        if (offInstr < DIS_MAX_INSTR_LENGTH)
-            return pDis->abInstr[offInstr];
-        return 0;
+        RTINTPTR cbLeft = sizeof(pDis->abInstr) - offInstr;
+        switch (cbLeft)
+        {
+            case 1:
+                return pDis->abInstr[offInstr];
+            default:
+                if (cbLeft >= 2)
+                    return RT_MAKE_U16(pDis->abInstr[offInstr], pDis->abInstr[offInstr + 1]);
+                return 0;
+        }
     }
 
@@ -398,5 +409,6 @@
         Log(("disReadDWord: too long instruction...\n"));
         pDis->rc = VERR_DIS_TOO_LONG_INSTR;
-        switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - offInstr)
+        RTINTPTR cbLeft = sizeof(pDis->abInstr) - offInstr;
+        switch (cbLeft)
         {
             case 1:
@@ -406,6 +418,10 @@
             case 3:
                 return RT_MAKE_U32_FROM_U8(pDis->abInstr[offInstr], pDis->abInstr[offInstr + 1], pDis->abInstr[offInstr + 2], 0);
-        }
-        return 0;
+            default:
+                if (cbLeft >= 4)
+                    return RT_MAKE_U32_FROM_U8(pDis->abInstr[offInstr    ], pDis->abInstr[offInstr + 1],
+                                               pDis->abInstr[offInstr + 2], pDis->abInstr[offInstr + 3]);
+                return 0;
+        }
     }
 
@@ -456,5 +472,6 @@
         Log(("disReadQWord: too long instruction...\n"));
         pDis->rc = VERR_DIS_TOO_LONG_INSTR;
-        switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - offInstr)
+        RTINTPTR cbLeft = sizeof(pDis->abInstr) - offInstr;
+        switch (cbLeft)
         {
             case 1:
@@ -468,16 +485,27 @@
                 return RT_MAKE_U64_FROM_U8(pDis->abInstr[offInstr    ], pDis->abInstr[offInstr + 1],
                                            pDis->abInstr[offInstr + 2], pDis->abInstr[offInstr + 3],
-                                           pDis->abInstr[offInstr + 4], 0, 0, 0);
+                                           0, 0, 0, 0);
             case 5:
                 return RT_MAKE_U64_FROM_U8(pDis->abInstr[offInstr    ], pDis->abInstr[offInstr + 1],
                                            pDis->abInstr[offInstr + 2], pDis->abInstr[offInstr + 3],
-                                           pDis->abInstr[offInstr + 4], pDis->abInstr[offInstr + 5], 0, 0);
+                                           pDis->abInstr[offInstr + 4], 0, 0, 0);
             case 6:
                 return RT_MAKE_U64_FROM_U8(pDis->abInstr[offInstr    ], pDis->abInstr[offInstr + 1],
                                            pDis->abInstr[offInstr + 2], pDis->abInstr[offInstr + 3],
                                            pDis->abInstr[offInstr + 4], pDis->abInstr[offInstr + 5],
+                                           0, 0);
+            case 7:
+                return RT_MAKE_U64_FROM_U8(pDis->abInstr[offInstr    ], pDis->abInstr[offInstr + 1],
+                                           pDis->abInstr[offInstr + 2], pDis->abInstr[offInstr + 3],
+                                           pDis->abInstr[offInstr + 4], pDis->abInstr[offInstr + 5],
                                            pDis->abInstr[offInstr + 6], 0);
-        }
-        return 0;
+            default:
+                if (cbLeft >= 8)
+                    return RT_MAKE_U64_FROM_U8(pDis->abInstr[offInstr    ], pDis->abInstr[offInstr + 1],
+                                               pDis->abInstr[offInstr + 2], pDis->abInstr[offInstr + 3],
+                                               pDis->abInstr[offInstr + 4], pDis->abInstr[offInstr + 5],
+                                               pDis->abInstr[offInstr + 6], pDis->abInstr[offInstr + 7]);
+                return 0;
+        }
     }
 
