VirtualBox

Changeset 41795 in vbox


Ignore:
Timestamp:
Jun 17, 2012 1:15:06 AM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78613
Message:

DIS: Changed the parsers from returning size to the offset of the next opcode byte, i.e. offInstr+size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r41794 r41795  
    517517//*****************************************************************************
    518518//*****************************************************************************
    519 static size_t disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, size_t cbExtra)
    520 {
    521     size_t size = 0;
    522 
     519static size_t disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis)
     520{
    523521    Assert(pOp); Assert(pDis);
    524522
     
    568566    if (pOp->idxParse1 != IDX_ParseNop)
    569567    {
    570         size += pDis->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, pDis, &pDis->Param1);
     568        offInstr = pDis->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, pDis, &pDis->Param1);
    571569        if (fFiltered == false) pDis->Param1.cb = DISGetParamSize(pDis, &pDis->Param1);
    572570    }
     
    574572    if (pOp->idxParse2 != IDX_ParseNop)
    575573    {
    576         size += pDis->pfnDisasmFnTable[pOp->idxParse2](offInstr+size, pOp, pDis, &pDis->Param2);
     574        offInstr = pDis->pfnDisasmFnTable[pOp->idxParse2](offInstr, pOp, pDis, &pDis->Param2);
    577575        if (fFiltered == false) pDis->Param2.cb = DISGetParamSize(pDis, &pDis->Param2);
    578576    }
     
    580578    if (pOp->idxParse3 != IDX_ParseNop)
    581579    {
    582         size += pDis->pfnDisasmFnTable[pOp->idxParse3](offInstr+size, pOp, pDis, &pDis->Param3);
     580        offInstr = pDis->pfnDisasmFnTable[pOp->idxParse3](offInstr, pOp, pDis, &pDis->Param3);
    583581        if (fFiltered == false) pDis->Param3.cb = DISGetParamSize(pDis, &pDis->Param3);
    584582    }
    585583    // else simple one byte instruction
    586584
    587     return size + cbExtra;
     585    return offInstr;
    588586}
    589587//*****************************************************************************
     
    635633
    636634    // Little hack to make sure the ModRM byte is included in the returned size
    637     size_t      size = 0;
    638635    if (fpop->idxParse1 != IDX_ParseModRM && fpop->idxParse2 != IDX_ParseModRM)
    639         size = sizeof(uint8_t); //ModRM byte
     636        offInstr++; //ModRM byte
    640637
    641638    if (fpop->idxParse1 != IDX_ParseNop)
    642         size += pDis->pfnDisasmFnTable[fpop->idxParse1](offInstr+size, fpop, pDis, pParam);
     639        offInstr = pDis->pfnDisasmFnTable[fpop->idxParse1](offInstr, fpop, pDis, pParam);
    643640
    644641    if (fpop->idxParse2 != IDX_ParseNop)
    645         size += pDis->pfnDisasmFnTable[fpop->idxParse2](offInstr+size, fpop, pDis, pParam);
    646 
    647     return size;
     642        offInstr = pDis->pfnDisasmFnTable[fpop->idxParse2](offInstr, fpop, pDis, pParam);
     643
     644    return offInstr;
    648645}
    649646
     
    707704static size_t ParseSIB(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    708705{
    709     unsigned size = sizeof(uint8_t);
    710706    NOREF(pOp); NOREF(pParam);
    711707
    712     unsigned SIB = disReadByte(pDis, offInstr);
    713     offInstr += size;
     708    uint8_t SIB = disReadByte(pDis, offInstr);
     709    offInstr++;
    714710
    715711    pDis->SIB.Bits.Base  = SIB_BASE(SIB);
     
    731727        /* Additional 32 bits displacement. No change in long mode. */
    732728        pDis->i32SibDisp = disReadDWord(pDis, offInstr);
    733         size += sizeof(int32_t);
    734     }
    735     return size;
     729        offInstr += 4;
     730    }
     731    return offInstr;
    736732}
    737733
     
    739735static size_t ParseSIB_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    740736{
    741     unsigned size = sizeof(uint8_t);
    742737    NOREF(pOp); NOREF(pParam);
    743738
    744     unsigned SIB = disReadByte(pDis, offInstr);
     739    uint8_t SIB = disReadByte(pDis, offInstr);
     740    offInstr++;
    745741
    746742    pDis->SIB.Bits.Base  = SIB_BASE(SIB);
     
    760756    {
    761757        /* Additional 32 bits displacement. No change in long mode. */
    762         size += sizeof(int32_t);
    763     }
    764     return size;
     758        offInstr += 4;
     759    }
     760    return offInstr;
    765761}
    766762
     
    886882{
    887883    unsigned vtype = OP_PARM_VTYPE(pParam->fParam);
    888     unsigned reg = pDis->ModRM.Bits.Reg;
    889     unsigned mod = pDis->ModRM.Bits.Mod;
    890     unsigned rm  = pDis->ModRM.Bits.Rm;
     884    uint8_t reg = pDis->ModRM.Bits.Reg;
     885    uint8_t mod = pDis->ModRM.Bits.Mod;
     886    uint8_t rm  = pDis->ModRM.Bits.Rm;
    891887
    892888    switch (vtype)
     
    894890    case OP_PARM_G: //general purpose register
    895891        disasmModRMReg(reg, pOp, pDis, pParam, 0);
    896         return 0;
     892        return offInstr;
    897893
    898894    default:
     
    913909                else
    914910                    pParam->Base.idxCtrlReg = reg;
    915                 return 0;
     911                return offInstr;
    916912
    917913            case OP_PARM_D: //debug register
    918914                pParam->fUse |= DISUSE_REG_DBG;
    919915                pParam->Base.idxDbgReg = reg;
    920                 return 0;
     916                return offInstr;
    921917
    922918            case OP_PARM_P: //MMX register
     
    924920                pParam->fUse |= DISUSE_REG_MMX;
    925921                pParam->Base.idxMmxReg = reg;
    926                 return 0;
     922                return offInstr;
    927923
    928924            case OP_PARM_S: //segment register
     
    930926                disasmModRMSReg(reg, pOp, pDis, pParam);
    931927                pParam->fUse |= DISUSE_REG_SEG;
    932                 return 0;
     928                return offInstr;
    933929
    934930            case OP_PARM_T: //test register
     
    936932                pParam->fUse |= DISUSE_REG_TEST;
    937933                pParam->Base.idxTestReg = reg;
    938                 return 0;
     934                return offInstr;
    939935
    940936            case OP_PARM_W: //XMM register or memory operand
     
    947943                pParam->fUse |= DISUSE_REG_XMM;
    948944                pParam->Base.idxXmmReg = reg;
    949                 return 0;
     945                return offInstr;
    950946            }
    951947        }
    952948    }
    953949
    954     /* @todo bound */
     950    /** @todo bound */
    955951
    956952    if (pDis->uAddrMode != DISCPUMODE_16BIT)
     
    10511047        }
    10521048    }
    1053     return 0;   //everything was already fetched in ParseModRM
     1049    return offInstr;
    10541050}
    10551051//*****************************************************************************
    10561052// Query the size of the ModRM parameters and fetch the immediate data (if any)
    10571053//*****************************************************************************
    1058 static size_t QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam, size_t *pSibInc)
    1059 {
    1060     size_t sibinc;
    1061     size_t size = 0;
    1062     // unsigned reg = pDis->ModRM.Bits.Reg;
    1063     unsigned mod = pDis->ModRM.Bits.Mod;
    1064     unsigned rm  = pDis->ModRM.Bits.Rm;
    1065 
    1066     if (!pSibInc)
    1067         pSibInc = &sibinc;
    1068 
    1069     *pSibInc = 0;
     1054static size_t QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     1055{
     1056    uint8_t mod = pDis->ModRM.Bits.Mod;
     1057    uint8_t rm  = pDis->ModRM.Bits.Rm;
    10701058
    10711059    if (pDis->uAddrMode != DISCPUMODE_16BIT)
     
    10761064         * Note: displacements in long mode are 8 or 32 bits and sign-extended to 64 bits
    10771065         */
    1078         if (mod != 3 && rm == 4)
    1079         {   /* SIB byte follows ModRM */
    1080             *pSibInc = ParseSIB(offInstr, pOp, pDis, pParam);
    1081             offInstr += *pSibInc;
    1082             size += *pSibInc;
    1083         }
     1066        if (mod != 3 && rm == 4) /* SIB byte follows ModRM */
     1067            offInstr = ParseSIB(offInstr, pOp, pDis, pParam);
    10841068
    10851069        switch (mod)
    10861070        {
    10871071        case 0: /* Effective address */
    1088             if (rm == 5) {  /* 32 bits displacement */
     1072            if (rm == 5)    /* 32 bits displacement */
     1073            {
    10891074                pDis->i32SibDisp = disReadDWord(pDis, offInstr);
    1090                 size += sizeof(int32_t);
     1075                offInstr += 4;
    10911076            }
    10921077            /* else register address */
     
    10951080        case 1: /* Effective address + 8 bits displacement */
    10961081            pDis->i32SibDisp = (int8_t)disReadByte(pDis, offInstr);
    1097             size += sizeof(char);
     1082            offInstr++;
    10981083            break;
    10991084
    11001085        case 2: /* Effective address + 32 bits displacement */
    11011086            pDis->i32SibDisp = disReadDWord(pDis, offInstr);
    1102             size += sizeof(int32_t);
     1087            offInstr += 4;
    11031088            break;
    11041089
     
    11131098        {
    11141099        case 0: /* Effective address */
    1115             if (rm == 6) {
     1100            if (rm == 6)
     1101            {
    11161102                pDis->i32SibDisp = disReadWord(pDis, offInstr);
    1117                 size += sizeof(uint16_t);
     1103                offInstr += 2;
    11181104            }
    11191105            /* else register address */
     
    11221108        case 1: /* Effective address + 8 bits displacement */
    11231109            pDis->i32SibDisp = (int8_t)disReadByte(pDis, offInstr);
    1124             size += sizeof(char);
     1110            offInstr++;
    11251111            break;
    11261112
    11271113        case 2: /* Effective address + 32 bits displacement */
    11281114            pDis->i32SibDisp = (int16_t)disReadWord(pDis, offInstr);
    1129             size += sizeof(uint16_t);
     1115            offInstr += 2;
    11301116            break;
    11311117
     
    11341120        }
    11351121    }
    1136     return size;
    1137 }
    1138 //*****************************************************************************
    1139 // Query the size of the ModRM parameters and fetch the immediate data (if any)
    1140 //*****************************************************************************
    1141 static size_t QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam, size_t *pSibInc)
    1142 {
    1143     size_t sibinc;
    1144     size_t size = 0;
    1145     // unsigned reg = pDis->ModRM.Bits.Reg;
    1146     unsigned mod = pDis->ModRM.Bits.Mod;
    1147     unsigned rm  = pDis->ModRM.Bits.Rm;
    1148 
    1149     if (!pSibInc)
    1150         pSibInc = &sibinc;
    1151 
    1152     *pSibInc = 0;
     1122    return offInstr;
     1123}
     1124//*****************************************************************************
     1125// Parse the ModRM parameters and fetch the immediate data (if any)
     1126//*****************************************************************************
     1127static size_t QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     1128{
     1129    uint8_t mod = pDis->ModRM.Bits.Mod;
     1130    uint8_t rm  = pDis->ModRM.Bits.Rm;
    11531131
    11541132    if (pDis->uAddrMode != DISCPUMODE_16BIT)
     
    11601138        if (mod != 3 && rm == 4)
    11611139        {   /* SIB byte follows ModRM */
    1162             *pSibInc = ParseSIB_SizeOnly(offInstr, pOp, pDis, pParam);
    1163             offInstr += *pSibInc;
    1164             size += *pSibInc;
     1140            offInstr = ParseSIB_SizeOnly(offInstr, pOp, pDis, pParam);
    11651141        }
    11661142
     
    11681144        {
    11691145        case 0: //effective address
    1170             if (rm == 5) {  /* 32 bits displacement */
    1171                 size += sizeof(int32_t);
    1172             }
     1146            if (rm == 5)   /* 32 bits displacement */
     1147                offInstr += 4;
    11731148            /* else register address */
    11741149            break;
    11751150
    11761151        case 1: /* Effective address + 8 bits displacement */
    1177             size += sizeof(char);
     1152            offInstr += 1;
    11781153            break;
    11791154
    11801155        case 2: /* Effective address + 32 bits displacement */
    1181             size += sizeof(int32_t);
     1156            offInstr += 4;
    11821157            break;
    11831158
     
    11921167        {
    11931168        case 0: //effective address
    1194             if (rm == 6) {
    1195                 size += sizeof(uint16_t);
    1196             }
     1169            if (rm == 6)
     1170                offInstr += 2;
    11971171            /* else register address */
    11981172            break;
    11991173
    12001174        case 1: /* Effective address + 8 bits displacement */
    1201             size += sizeof(char);
     1175            offInstr++;
    12021176            break;
    12031177
    12041178        case 2: /* Effective address + 32 bits displacement */
    1205             size += sizeof(uint16_t);
     1179            offInstr += 2;
    12061180            break;
    12071181
     
    12101184        }
    12111185    }
    1212     return size;
     1186    return offInstr;
    12131187}
    12141188//*****************************************************************************
     
    12161190static size_t ParseIllegal(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    12171191{
    1218     NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
     1192    NOREF(pOp); NOREF(pParam); NOREF(pDis);
    12191193    AssertFailed();
    1220     return 0;
     1194    return offInstr;
    12211195}
    12221196//*****************************************************************************
     
    12241198static size_t ParseModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    12251199{
    1226     size_t size = sizeof(uint8_t);   //ModRM byte
    1227     size_t sibinc;
    1228 
    1229     unsigned ModRM = disReadByte(pDis, offInstr);
    1230     offInstr += sizeof(uint8_t);
     1200    uint8_t ModRM = disReadByte(pDis, offInstr);
     1201    offInstr++;
    12311202
    12321203    pDis->ModRM.Bits.Rm  = MODRM_RM(ModRM);
     
    12601231        }
    12611232    }
    1262     size += QueryModRM(offInstr, pOp, pDis, pParam, &sibinc);
    1263     offInstr += sibinc;
    1264 
    1265     UseModRM(offInstr, pOp, pDis, pParam);
    1266     return size;
     1233    offInstr = QueryModRM(offInstr, pOp, pDis, pParam);
     1234
     1235    return UseModRM(offInstr, pOp, pDis, pParam);
    12671236}
    12681237//*****************************************************************************
     
    12701239static size_t ParseModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    12711240{
    1272     size_t size = sizeof(uint8_t);   //ModRM byte
    1273     size_t sibinc;
    1274 
    1275     unsigned ModRM = disReadByte(pDis, offInstr);
    1276     offInstr += sizeof(uint8_t);
     1241    uint8_t ModRM = disReadByte(pDis, offInstr);
     1242    offInstr++;
    12771243
    12781244    pDis->ModRM.Bits.Rm  = MODRM_RM(ModRM);
     
    13071273    }
    13081274
    1309     size += QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam, &sibinc);
    1310     offInstr += sibinc;
     1275    offInstr += QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam);
    13111276
    13121277    /* UseModRM is not necessary here; we're only interested in the opcode size */
    1313     return size;
     1278    return offInstr;
    13141279}
    13151280//*****************************************************************************
     
    13191284    ////AssertMsgFailed(("??\n"));
    13201285    //nothing to do apparently
    1321     NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1322     return 0;
     1286    NOREF(pOp); NOREF(pParam); NOREF(pDis);
     1287    return offInstr;
    13231288}
    13241289//*****************************************************************************
     
    13301295    pParam->fUse  |= DISUSE_IMMEDIATE8;
    13311296    pParam->cb     = sizeof(uint8_t);
    1332     return sizeof(uint8_t);
     1297    return offInstr + 1;
    13331298}
    13341299//*****************************************************************************
     
    13361301static size_t ParseImmByte_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13371302{
    1338     NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1339     return sizeof(uint8_t);
     1303    NOREF(pOp); NOREF(pParam); NOREF(pDis);
     1304    return offInstr + 1;
    13401305}
    13411306//*****************************************************************************
     
    13631328        pParam->cb     = sizeof(uint16_t);
    13641329    }
    1365     return sizeof(uint8_t);
     1330    return offInstr + 1;
    13661331}
    13671332//*****************************************************************************
     
    13691334static size_t ParseImmByteSX_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13701335{
    1371     NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1372     return sizeof(uint8_t);
     1336    NOREF(pOp); NOREF(pParam); NOREF(pDis);
     1337    return offInstr + 1;
    13731338}
    13741339//*****************************************************************************
     
    13801345    pParam->fUse  |= DISUSE_IMMEDIATE16;
    13811346    pParam->cb     = sizeof(uint16_t);
    1382     return sizeof(uint16_t);
     1347    return offInstr + 2;
    13831348}
    13841349//*****************************************************************************
     
    13861351static size_t ParseImmUshort_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    13871352{
    1388     NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1389     return sizeof(uint16_t);
     1353    NOREF(pOp); NOREF(pParam); NOREF(pDis);
     1354    return offInstr + 2;
    13901355}
    13911356//*****************************************************************************
     
    13971362    pParam->fUse  |= DISUSE_IMMEDIATE32;
    13981363    pParam->cb     = sizeof(uint32_t);
    1399     return sizeof(uint32_t);
     1364    return offInstr + 4;
    14001365}
    14011366//*****************************************************************************
     
    14031368static size_t ParseImmUlong_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    14041369{
    1405     NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1406     return sizeof(uint32_t);
     1370    NOREF(pOp); NOREF(pParam); NOREF(pDis);
     1371    return offInstr + 4;
    14071372}
    14081373//*****************************************************************************
     
    14141379    pParam->fUse  |= DISUSE_IMMEDIATE64;
    14151380    pParam->cb     = sizeof(uint64_t);
    1416     return sizeof(uint64_t);
     1381    return offInstr + 8;
    14171382}
    14181383//*****************************************************************************
     
    14211386{
    14221387    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1423     return sizeof(uint64_t);
     1388    return offInstr + 8;
    14241389}
    14251390//*****************************************************************************
     
    14331398        pParam->fUse  |= DISUSE_IMMEDIATE32;
    14341399        pParam->cb     = sizeof(uint32_t);
    1435         return sizeof(uint32_t);
     1400        return offInstr + 4;
    14361401    }
    14371402
     
    14411406        pParam->fUse  |= DISUSE_IMMEDIATE64;
    14421407        pParam->cb     = sizeof(uint64_t);
    1443         return sizeof(uint64_t);
     1408        return offInstr + 8;
    14441409    }
    14451410
     
    14471412    pParam->fUse  |= DISUSE_IMMEDIATE16;
    14481413    pParam->cb     = sizeof(uint16_t);
    1449     return sizeof(uint16_t);
     1414    return offInstr + 2;
    14501415}
    14511416//*****************************************************************************
     
    14551420    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
    14561421    if (pDis->uOpMode == DISCPUMODE_32BIT)
    1457         return sizeof(uint32_t);
     1422        return offInstr + 4;
    14581423    if (pDis->uOpMode == DISCPUMODE_64BIT)
    1459         return sizeof(uint64_t);
    1460     return sizeof(uint16_t);
     1424        return offInstr + 8;
     1425    return offInstr + 2;
    14611426}
    14621427//*****************************************************************************
     
    14711436        pParam->fUse  |= DISUSE_IMMEDIATE16;
    14721437        pParam->cb     = sizeof(uint16_t);
    1473         return sizeof(uint16_t);
     1438        return offInstr + 2;
    14741439    }
    14751440
     
    14871452        pParam->cb     = sizeof(uint32_t);
    14881453    }
    1489     return sizeof(uint32_t);
     1454    return offInstr + 4;
    14901455}
    14911456//*****************************************************************************
     
    14971462    if (pDis->uOpMode == DISCPUMODE_16BIT)
    14981463        return sizeof(uint16_t);
    1499     return sizeof(uint32_t);
     1464    return offInstr + 4;
    15001465}
    15011466
     
    15091474    pParam->fUse  |= DISUSE_IMMEDIATE8_REL;
    15101475    pParam->cb     = sizeof(uint8_t);
    1511     return sizeof(char);
     1476    return offInstr + 1;
    15121477}
    15131478//*****************************************************************************
     
    15171482{
    15181483    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);
    1519     return sizeof(char);
     1484    return offInstr + 1;
    15201485}
    15211486//*****************************************************************************
     
    15301495        pParam->fUse  |= DISUSE_IMMEDIATE32_REL;
    15311496        pParam->cb     = sizeof(int32_t);
    1532         return sizeof(int32_t);
     1497        return offInstr + 4;
    15331498    }
    15341499
     
    15391504        pParam->fUse  |= DISUSE_IMMEDIATE64_REL;
    15401505        pParam->cb     = sizeof(int64_t);
    1541         return sizeof(int32_t);
     1506        return offInstr + 4;
    15421507    }
    15431508
     
    15451510    pParam->fUse  |= DISUSE_IMMEDIATE16_REL;
    15461511    pParam->cb     = sizeof(int16_t);
    1547     return sizeof(int16_t);
     1512    return offInstr + 2;
    15481513}
    15491514//*****************************************************************************
     
    15541519    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
    15551520    if (pDis->uOpMode == DISCPUMODE_16BIT)
    1556         return sizeof(int16_t);
     1521        return offInstr + 2;
    15571522    /* Both 32 & 64 bits mode use 32 bits relative immediates. */
    1558     return sizeof(int32_t);
     1523    return offInstr + 4;
    15591524}
    15601525//*****************************************************************************
     
    15711536            pParam->fUse   |= DISUSE_IMMEDIATE_ADDR_16_32;
    15721537            pParam->cb     = sizeof(uint16_t) + sizeof(uint32_t);
    1573             return sizeof(uint32_t) + sizeof(uint16_t);
     1538            return offInstr + 4 + 2;
    15741539        }
    15751540
     
    15831548        pParam->fUse  |= DISUSE_DISPLACEMENT32;
    15841549        pParam->cb     = sizeof(uint32_t);
    1585         return sizeof(uint32_t);
     1550        return offInstr + 4;
    15861551    }
    15871552
    15881553    if (pDis->uAddrMode == DISCPUMODE_64BIT)
    15891554    {
    1590         Assert(OP_PARM_VSUBTYPE(pParam->fParam) != OP_PARM_p);
    15911555        /*
    15921556         * near 64 bits pointer
     
    15951559         * so we treat it like displacement.
    15961560         */
     1561        Assert(OP_PARM_VSUBTYPE(pParam->fParam) != OP_PARM_p);
    15971562        pParam->uDisp.i64 = disReadQWord(pDis, offInstr);
    15981563        pParam->fUse  |= DISUSE_DISPLACEMENT64;
    15991564        pParam->cb     = sizeof(uint64_t);
    1600         return sizeof(uint64_t);
     1565        return offInstr + 8;
    16011566    }
    16021567    if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p)
     
    16061571        pParam->fUse  |= DISUSE_IMMEDIATE_ADDR_16_16;
    16071572        pParam->cb     = 2*sizeof(uint16_t);
    1608         return sizeof(uint32_t);
     1573        return offInstr + 4;
    16091574    }
    16101575
     
    16181583    pParam->fUse  |= DISUSE_DISPLACEMENT16;
    16191584    pParam->cb     = sizeof(uint16_t);
    1620     return sizeof(uint16_t);
     1585    return offInstr + 2;
    16211586}
    16221587//*****************************************************************************
     
    16281593    {
    16291594        if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p)
    1630         {// far 16:32 pointer
    1631             return sizeof(uint32_t) + sizeof(uint16_t);
    1632         }
    1633         else
    1634         {// near 32 bits pointer
    1635             return sizeof(uint32_t);
    1636         }
     1595            return offInstr + 4 + 2; /* far 16:32 pointer */
     1596        return offInstr + 4;         /* near 32 bits pointer */
    16371597    }
    16381598    if (pDis->uAddrMode == DISCPUMODE_64BIT)
    16391599    {
    16401600        Assert(OP_PARM_VSUBTYPE(pParam->fParam) != OP_PARM_p);
    1641         return sizeof(uint64_t);
    1642     }
    1643     else
    1644     {
    1645         if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p)
    1646         {// far 16:16 pointer
    1647             return sizeof(uint32_t);
    1648         }
    1649         else
    1650         {// near 16 bits pointer
    1651             return sizeof(uint16_t);
    1652         }
    1653     }
     1601        return offInstr + 8;
     1602    }
     1603    if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p)
     1604        return offInstr + 4;        /* far 16:16 pointer */
     1605    return offInstr + 2;            /* near 16 bits pointer */
    16541606}
    16551607//*****************************************************************************
     
    16671619        pParam->fUse   |= DISUSE_IMMEDIATE_ADDR_16_32;
    16681620        pParam->cb     = sizeof(uint16_t) + sizeof(uint32_t);
    1669         return sizeof(uint32_t) + sizeof(uint16_t);
     1621        return offInstr + 4 + 2;
    16701622    }
    16711623
     
    16741626    pParam->fUse  |= DISUSE_IMMEDIATE_ADDR_16_16;
    16751627    pParam->cb     = 2*sizeof(uint16_t);
    1676     return sizeof(uint32_t);
     1628    return offInstr + 2 + 2;
    16771629}
    16781630//*****************************************************************************
     
    16851637    Assert(OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p);
    16861638    if (pDis->uOpMode == DISCPUMODE_32BIT)
    1687     {
    1688         // far 16:32 pointer
    1689         return sizeof(uint32_t) + sizeof(uint16_t);
    1690     }
    1691     else
    1692     {
    1693         // far 16:16 pointer
    1694         return sizeof(uint32_t);
    1695     }
     1639        return offInstr + 4 + 2;    /* far 16:32 pointer */
     1640    return offInstr + 2 + 2;        /* far 16:16 pointer */
    16961641}
    16971642//*****************************************************************************
     
    17081653    {
    17091654        /* No parameter at all. */
    1710         return 0;
     1655        return offInstr;
    17111656    }
    17121657
     
    17941739    /* else - not supported for now registers. */
    17951740
    1796     return 0;
     1741    return offInstr;
    17971742}
    17981743//*****************************************************************************
     
    18001745static size_t ParseXv(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18011746{
    1802     NOREF(offInstr);
     1747    NOREF(pOp);
    18031748
    18041749    pParam->fUse |= DISUSE_POINTER_DS_BASED;
     
    18191764        pParam->fUse |= DISUSE_REG_GEN16;
    18201765    }
    1821     return 0;   //no additional opcode bytes
     1766    return offInstr;
    18221767}
    18231768//*****************************************************************************
     
    18251770static size_t ParseXb(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18261771{
    1827     NOREF(offInstr); NOREF(pOp);
     1772    NOREF(pOp);
    18281773
    18291774    pParam->fUse |= DISUSE_POINTER_DS_BASED;
     
    18441789        pParam->fUse |= DISUSE_REG_GEN16;
    18451790    }
    1846     return 0;   //no additional opcode bytes
     1791    return offInstr;
    18471792}
    18481793//*****************************************************************************
     
    18501795static size_t ParseYv(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18511796{
    1852     NOREF(offInstr);
     1797    NOREF(pOp);
    18531798
    18541799    pParam->fUse |= DISUSE_POINTER_ES_BASED;
     
    18691814        pParam->fUse |= DISUSE_REG_GEN16;
    18701815    }
    1871     return 0;   //no additional opcode bytes
     1816    return offInstr;
    18721817}
    18731818//*****************************************************************************
     
    18751820static size_t ParseYb(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    18761821{
    1877     NOREF(offInstr); NOREF(pOp);
     1822    NOREF(pOp);
    18781823
    18791824    pParam->fUse |= DISUSE_POINTER_ES_BASED;
     
    18941839        pParam->fUse |= DISUSE_REG_GEN16;
    18951840    }
    1896     return 0;   //no additional opcode bytes
     1841    return offInstr;
    18971842}
    18981843//*****************************************************************************
     
    19001845static size_t ParseTwoByteEsc(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    19011846{
    1902     PCDISOPCODE   pOpcode;
    1903     size_t        size    = sizeof(uint8_t);
    19041847    NOREF(pOp); NOREF(pParam);
    19051848
    19061849    /* 2nd byte */
    19071850    pDis->bOpCode = disReadByte(pDis, offInstr);
     1851    offInstr++;
    19081852
    19091853    /* default to the non-prefixed table. */
    1910     pOpcode      = &g_aTwoByteMapX86[pDis->bOpCode];
     1854    PCDISOPCODE pOpcode = &g_aTwoByteMapX86[pDis->bOpCode];
    19111855
    19121856    /* Handle opcode table extensions that rely on the address, repe or repne prefix byte.  */
     
    19521896    }
    19531897
    1954     return disParseInstruction(offInstr+size, pOpcode, pDis, size);
     1898    return disParseInstruction(offInstr, pOpcode, pDis);
    19551899}
    19561900//*****************************************************************************
     
    19581902static size_t ParseThreeByteEsc4(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    19591903{
    1960     PCDISOPCODE   pOpcode;
    1961     size_t        size    = sizeof(uint8_t);
    19621904    NOREF(pOp); NOREF(pParam);
    19631905
    19641906    /* 3rd byte */
    19651907    pDis->bOpCode = disReadByte(pDis, offInstr);
     1908    offInstr++;
    19661909
    19671910    /* default to the non-prefixed table. */
     1911    PCDISOPCODE pOpcode;
    19681912    if (g_apThreeByteMapX86_0F38[pDis->bOpCode >> 4])
    19691913    {
     
    20121956    }
    20131957
    2014     return disParseInstruction(offInstr+size, pOpcode, pDis, size);
     1958    return disParseInstruction(offInstr, pOpcode, pDis);
    20151959}
    20161960//*****************************************************************************
     
    20181962static size_t ParseThreeByteEsc5(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20191963{
    2020     PCDISOPCODE   pOpcode;
    2021     size_t        size    = sizeof(uint8_t);
    20221964    NOREF(pOp); NOREF(pParam);
    20231965
    20241966    /* 3rd byte */
    20251967    pDis->bOpCode = disReadByte(pDis, offInstr);
     1968    offInstr++;
    20261969
    20271970    /** @todo Should we take the first or last prefix byte in case of multiple prefix bytes??? */
     
    20291972
    20301973    /* default to the non-prefixed table. */
     1974    PCDISOPCODE pOpcode;
    20311975    if (g_apThreeByteMapX86_660F3A[pDis->bOpCode >> 4])
    20321976    {
     
    20461990        pOpcode = &g_InvalidOpcode[0];
    20471991
    2048     return disParseInstruction(offInstr+size, pOpcode, pDis, size);
     1992    return disParseInstruction(offInstr, pOpcode, pDis);
    20491993}
    20501994//*****************************************************************************
     
    20521996static size_t ParseNopPause(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20531997{
    2054     size_t size = 0;
    20551998    NOREF(pParam);
    20561999
     
    20632006        pOp = &g_aMapX86_NopPause[0]; /* NOP */
    20642007
    2065     return disParseInstruction(offInstr, pOp, pDis, size);
     2008    return disParseInstruction(offInstr, pOp, pDis);
    20662009}
    20672010//*****************************************************************************
     
    20692012static size_t ParseImmGrpl(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20702013{
    2071     int idx = (pDis->bOpCode - 0x80) * 8;
    2072     size_t size = 0;
    20732014    NOREF(pParam);
    20742015
    2075     unsigned modrm = disReadByte(pDis, offInstr);
    2076     unsigned reg   = MODRM_REG(modrm);
     2016    uint8_t  modrm = disReadByte(pDis, offInstr);
     2017    uint8_t  reg   = MODRM_REG(modrm);
     2018    unsigned idx   = (pDis->bOpCode - 0x80) * 8;
    20772019
    20782020    pOp = &g_aMapX86_Group1[idx+reg];
    20792021    //little hack to make sure the ModRM byte is included in the returned size
    20802022    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2081         size = sizeof(uint8_t); //ModRM byte
    2082 
    2083     return disParseInstruction(offInstr, pOp, pDis, size);
     2023        offInstr++;
     2024
     2025    return disParseInstruction(offInstr, pOp, pDis);
    20842026}
    20852027//*****************************************************************************
     
    20872029static size_t ParseShiftGrp2(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    20882030{
    2089     int idx;
    2090     size_t size = 0;
    20912031    NOREF(pParam);
    20922032
     2033    unsigned idx;
    20932034    switch (pDis->bOpCode)
    20942035    {
     
    21062047
    21072048    default:
    2108         AssertMsgFailed(("Oops\n"));
    2109         return sizeof(uint8_t);
    2110     }
    2111 
    2112     unsigned modrm = disReadByte(pDis, offInstr);
    2113     unsigned reg   = MODRM_REG(modrm);
     2049        Log(("ParseShiftGrp2: bOpCode=%#x\n", pDis->bOpCode));
     2050        pDis->rc = VERR_DIS_INVALID_OPCODE;
     2051        return offInstr;
     2052    }
     2053
     2054    uint8_t modrm = disReadByte(pDis, offInstr);
     2055    uint8_t reg   = MODRM_REG(modrm);
    21142056
    21152057    pOp = &g_aMapX86_Group2[idx+reg];
     
    21172059    //little hack to make sure the ModRM byte is included in the returned size
    21182060    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2119         size = sizeof(uint8_t); //ModRM byte
    2120 
    2121     return disParseInstruction(offInstr, pOp, pDis, size);
     2061        offInstr++;
     2062
     2063    return disParseInstruction(offInstr, pOp, pDis);
    21222064}
    21232065//*****************************************************************************
     
    21252067static size_t ParseGrp3(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21262068{
    2127     int idx = (pDis->bOpCode - 0xF6) * 8;
    2128     size_t size = 0;
     2069    unsigned idx = (pDis->bOpCode - 0xF6) * 8;
    21292070    NOREF(pParam);
    21302071
    2131     unsigned modrm = disReadByte(pDis, offInstr);
    2132     unsigned reg   = MODRM_REG(modrm);
     2072    uint8_t modrm = disReadByte(pDis, offInstr);
     2073    uint8_t reg   = MODRM_REG(modrm);
    21332074
    21342075    pOp = &g_aMapX86_Group3[idx+reg];
     
    21362077    //little hack to make sure the ModRM byte is included in the returned size
    21372078    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2138         size = sizeof(uint8_t); //ModRM byte
    2139 
    2140     return disParseInstruction(offInstr, pOp, pDis, size);
     2079        offInstr++;
     2080
     2081    return disParseInstruction(offInstr, pOp, pDis);
    21412082}
    21422083//*****************************************************************************
     
    21442085static size_t ParseGrp4(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21452086{
    2146     size_t size = 0;
    21472087    NOREF(pParam);
    21482088
    2149     unsigned modrm = disReadByte(pDis, offInstr);
    2150     unsigned reg   = MODRM_REG(modrm);
     2089    uint8_t modrm = disReadByte(pDis, offInstr);
     2090    uint8_t reg   = MODRM_REG(modrm);
    21512091
    21522092    pOp = &g_aMapX86_Group4[reg];
     
    21542094    //little hack to make sure the ModRM byte is included in the returned size
    21552095    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2156         size = sizeof(uint8_t); //ModRM byte
    2157 
    2158     return disParseInstruction(offInstr, pOp, pDis, size);
     2096        offInstr++;
     2097
     2098    return disParseInstruction(offInstr, pOp, pDis);
    21592099}
    21602100//*****************************************************************************
     
    21622102static size_t ParseGrp5(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21632103{
    2164     size_t size = 0;
    21652104    NOREF(pParam);
    21662105
    2167     unsigned modrm = disReadByte(pDis, offInstr);
    2168     unsigned reg   = MODRM_REG(modrm);
     2106    uint8_t modrm = disReadByte(pDis, offInstr);
     2107    uint8_t reg   = MODRM_REG(modrm);
    21692108
    21702109    pOp = &g_aMapX86_Group5[reg];
     
    21722111    //little hack to make sure the ModRM byte is included in the returned size
    21732112    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2174         size = sizeof(uint8_t); //ModRM byte
    2175 
    2176     return disParseInstruction(offInstr, pOp, pDis, size);
     2113        offInstr++;
     2114
     2115    return disParseInstruction(offInstr, pOp, pDis);
    21772116}
    21782117//*****************************************************************************
     
    21842123static size_t Parse3DNow(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    21852124{
    2186     size_t size = 0;
    2187 
    21882125#ifdef DEBUG_Sander
    21892126    //needs testing
     
    21912128#endif
    21922129
    2193     unsigned ModRM = disReadByte(pDis, offInstr);
     2130    uint8_t ModRM = disReadByte(pDis, offInstr);
    21942131    pDis->ModRM.Bits.Rm  = MODRM_RM(ModRM);
    21952132    pDis->ModRM.Bits.Mod = MODRM_MOD(ModRM);
    21962133    pDis->ModRM.Bits.Reg = MODRM_REG(ModRM);
    21972134
    2198     size_t modrmsize = QueryModRM(offInstr+sizeof(uint8_t), pOp, pDis, pParam, NULL);
    2199 
    2200     uint8_t opcode = disReadByte(pDis, offInstr+sizeof(uint8_t)+modrmsize);
    2201 
     2135    size_t offRet = QueryModRM(offInstr + 1, pOp, pDis, pParam);
     2136
     2137    uint8_t opcode = disReadByte(pDis, offRet);
     2138    offRet++;
    22022139    pOp = &g_aTwoByteMapX86_3DNow[opcode];
    22032140
    22042141    //little hack to make sure the ModRM byte is included in the returned size
    22052142    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2206     {
    2207 #ifdef DEBUG_Sander /* bird, 2005-06-28: Alex is getting this during full installation of win2ksp4. */
    2208         AssertMsgFailed(("Oops!\n")); //shouldn't happen!
    2209 #endif
    2210         size = sizeof(uint8_t); //ModRM byte
    2211     }
    2212 
    2213     size += sizeof(uint8_t);   //imm8_opcode uint8_t
    2214     return disParseInstruction(offInstr, pOp, pDis, size);
     2143        offInstr++;                 /* for illegal opcodes */
     2144
     2145    size_t offStrict = disParseInstruction(offInstr, pOp, pDis);
     2146    Assert(offStrict == offRet - 1);  NOREF(offStrict);   /* the imm8_opcode */
     2147    return offRet;
    22152148}
    22162149//*****************************************************************************
     
    22182151static size_t ParseGrp6(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22192152{
    2220     size_t size = 0;
    22212153    NOREF(pParam);
    22222154
    2223     unsigned modrm = disReadByte(pDis, offInstr);
    2224     unsigned reg   = MODRM_REG(modrm);
     2155    uint8_t modrm = disReadByte(pDis, offInstr);
     2156    uint8_t reg   = MODRM_REG(modrm);
    22252157
    22262158    pOp = &g_aMapX86_Group6[reg];
     
    22282160    //little hack to make sure the ModRM byte is included in the returned size
    22292161    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2230         size = sizeof(uint8_t); //ModRM byte
    2231 
    2232     return disParseInstruction(offInstr, pOp, pDis, size);
     2162        offInstr++;
     2163
     2164    return disParseInstruction(offInstr, pOp, pDis);
    22332165}
    22342166//*****************************************************************************
     
    22362168static size_t ParseGrp7(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22372169{
    2238     size_t size = 0;
    22392170    NOREF(pParam);
    22402171
    2241     unsigned modrm = disReadByte(pDis, offInstr);
    2242     unsigned mod   = MODRM_MOD(modrm);
    2243     unsigned reg   = MODRM_REG(modrm);
    2244     unsigned rm    = MODRM_RM(modrm);
     2172    uint8_t modrm = disReadByte(pDis, offInstr);
     2173    uint8_t mod   = MODRM_MOD(modrm);
     2174    uint8_t reg   = MODRM_REG(modrm);
     2175    uint8_t rm    = MODRM_RM(modrm);
    22452176
    22462177    if (mod == 3 && rm == 0)
     
    22542185    //little hack to make sure the ModRM byte is included in the returned size
    22552186    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2256         size = sizeof(uint8_t); //ModRM byte
    2257 
    2258     return disParseInstruction(offInstr, pOp, pDis, size);
     2187        offInstr++;
     2188
     2189    return disParseInstruction(offInstr, pOp, pDis);
    22592190}
    22602191//*****************************************************************************
     
    22622193static size_t ParseGrp8(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22632194{
    2264     size_t size = 0;
    22652195    NOREF(pParam);
    22662196
    2267     unsigned modrm = disReadByte(pDis, offInstr);
    2268     unsigned reg   = MODRM_REG(modrm);
     2197    uint8_t modrm = disReadByte(pDis, offInstr);
     2198    uint8_t reg   = MODRM_REG(modrm);
    22692199
    22702200    pOp = &g_aMapX86_Group8[reg];
     
    22722202    //little hack to make sure the ModRM byte is included in the returned size
    22732203    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2274         size = sizeof(uint8_t); //ModRM byte
    2275 
    2276     return disParseInstruction(offInstr, pOp, pDis, size);
     2204        offInstr++;
     2205
     2206    return disParseInstruction(offInstr, pOp, pDis);
    22772207}
    22782208//*****************************************************************************
     
    22802210static size_t ParseGrp9(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22812211{
    2282     size_t size = 0;
    22832212    NOREF(pParam);
    22842213
    2285     unsigned modrm = disReadByte(pDis, offInstr);
    2286     unsigned reg   = MODRM_REG(modrm);
     2214    uint8_t modrm = disReadByte(pDis, offInstr);
     2215    uint8_t reg   = MODRM_REG(modrm);
    22872216
    22882217    pOp = &g_aMapX86_Group9[reg];
     
    22902219    //little hack to make sure the ModRM byte is included in the returned size
    22912220    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2292         size = sizeof(uint8_t); //ModRM byte
    2293 
    2294     return disParseInstruction(offInstr, pOp, pDis, size);
     2221        offInstr++;
     2222
     2223    return disParseInstruction(offInstr, pOp, pDis);
    22952224}
    22962225//*****************************************************************************
     
    22982227static size_t ParseGrp10(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    22992228{
    2300     size_t size = 0;
    23012229    NOREF(pParam);
    23022230
    2303     unsigned modrm = disReadByte(pDis, offInstr);
    2304     unsigned reg   = MODRM_REG(modrm);
     2231    uint8_t modrm = disReadByte(pDis, offInstr);
     2232    uint8_t reg   = MODRM_REG(modrm);
    23052233
    23062234    pOp = &g_aMapX86_Group10[reg];
     
    23082236    //little hack to make sure the ModRM byte is included in the returned size
    23092237    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2310         size = sizeof(uint8_t); //ModRM byte
    2311 
    2312     return disParseInstruction(offInstr, pOp, pDis, size);
     2238        offInstr++;
     2239
     2240    return disParseInstruction(offInstr, pOp, pDis);
    23132241}
    23142242//*****************************************************************************
     
    23162244static size_t ParseGrp12(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    23172245{
    2318     size_t size = 0;
    23192246    NOREF(pParam);
    23202247
    2321     unsigned modrm = disReadByte(pDis, offInstr);
    2322     unsigned reg   = MODRM_REG(modrm);
     2248    uint8_t modrm = disReadByte(pDis, offInstr);
     2249    uint8_t reg   = MODRM_REG(modrm);
    23232250
    23242251    if (pDis->fPrefix & DISPREFIX_OPSIZE)
     
    23292256    //little hack to make sure the ModRM byte is included in the returned size
    23302257    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2331         size = sizeof(uint8_t); //ModRM byte
    2332 
    2333     return disParseInstruction(offInstr, pOp, pDis, size);
     2258        offInstr++;
     2259
     2260    return disParseInstruction(offInstr, pOp, pDis);
    23342261}
    23352262//*****************************************************************************
    23362263//*****************************************************************************
    23372264static size_t ParseGrp13(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    2338 {
    2339     size_t size = 0;
    2340     NOREF(pParam);
    2341 
    2342     unsigned modrm = disReadByte(pDis, offInstr);
    2343     unsigned reg   = MODRM_REG(modrm);
    2344     if (pDis->fPrefix & DISPREFIX_OPSIZE)
    2345         reg += 8;   //2nd table
    2346 
    2347     pOp = &g_aMapX86_Group13[reg];
    2348 
    2349     //little hack to make sure the ModRM byte is included in the returned size
    2350     if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2351         size = sizeof(uint8_t); //ModRM byte
    2352 
    2353     return disParseInstruction(offInstr, pOp, pDis, size);
    2354 }
    2355 //*****************************************************************************
    2356 //*****************************************************************************
    2357 static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
    23582265{
    23592266    NOREF(pParam);
     
    23642271        reg += 8;   //2nd table
    23652272
     2273    pOp = &g_aMapX86_Group13[reg];
     2274
     2275    //little hack to make sure the ModRM byte is included in the returned size
     2276    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     2277        offInstr++;
     2278
     2279    return disParseInstruction(offInstr, pOp, pDis);
     2280}
     2281//*****************************************************************************
     2282//*****************************************************************************
     2283static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)
     2284{
     2285    NOREF(pParam);
     2286
     2287    uint8_t modrm = disReadByte(pDis, offInstr);
     2288    uint8_t reg   = MODRM_REG(modrm);
     2289    if (pDis->fPrefix & DISPREFIX_OPSIZE)
     2290        reg += 8;   //2nd table
     2291
    23662292    pOp = &g_aMapX86_Group14[reg];
    23672293
     
    23692295    size_t size = 0;
    23702296    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2371         size = sizeof(uint8_t); //ModRM byte
    2372 
    2373     return disParseInstruction(offInstr, pOp, pDis, size);
     2297        offInstr++;
     2298
     2299    return disParseInstruction(offInstr, pOp, pDis);
    23742300}
    23752301//*****************************************************************************
     
    23922318    size_t size = 0;
    23932319    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2394         size = sizeof(uint8_t); //ModRM byte
    2395 
    2396     return disParseInstruction(offInstr, pOp, pDis, size);
     2320        offInstr++;
     2321
     2322    return disParseInstruction(offInstr, pOp, pDis);
    23972323}
    23982324//*****************************************************************************
     
    24062332
    24072333    //little hack to make sure the ModRM byte is included in the returned size
    2408     size_t size = 0;
    24092334    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    2410         size = sizeof(uint8_t); //ModRM byte
    2411 
    2412     return disParseInstruction(offInstr, pOp, pDis, size);
     2335        offInstr++;
     2336
     2337    return disParseInstruction(offInstr, pOp, pDis);
    24132338}
    24142339
     
    25942519        pDis->bOpCode  = codebyte;
    25952520        pDis->cbPrefix = (uint8_t)offInstr - 1;
    2596         offInstr = disParseInstruction(offInstr, &paOneByteMap[pDis->bOpCode], pDis, offInstr);
     2521        offInstr = disParseInstruction(offInstr, &paOneByteMap[pDis->bOpCode], pDis);
    25972522        break;
    25982523    }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette