VirtualBox

Changeset 41784 in vbox for trunk/src/VBox/Disassembler


Ignore:
Timestamp:
Jun 16, 2012 7:37:11 PM (12 years ago)
Author:
vboxsync
Message:

DIS: Work with a instruction offset instead of address. Only the byte reader implementation cares about addresses.

File:
1 edited

Legend:

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

    r41782 r41784  
    253253 *
    254254 * @param   pCpu                The disassembler state.
    255  * @param   off                 The offset of the read request.
     255 * @param   offInstr            The offset of the read request.
    256256 * @param   cbMin               The size of the read request that needs to be
    257257 *                              satisfied.
    258258 */
    259 DECL_NO_INLINE(static, void) disReadMore(PDISCPUSTATE pCpu, uint8_t off, uint8_t cbMin)
    260 {
    261     Assert(cbMin + off <= sizeof(pCpu->abInstr));
     259DECL_NO_INLINE(static, void) disReadMore(PDISCPUSTATE pCpu, uint8_t offInstr, uint8_t cbMin)
     260{
     261    Assert(cbMin + offInstr <= sizeof(pCpu->abInstr));
    262262
    263263    /*
     
    265265     * been read and to make sure we don't leave unread gaps.
    266266     */
    267     if (off < pCpu->cbCachedInstr)
    268     {
    269         Assert(off + cbMin > pCpu->cbCachedInstr);
    270         cbMin -= pCpu->cbCachedInstr - off;
    271         off = pCpu->cbCachedInstr;
    272     }
    273     else if (off > pCpu->cbCachedInstr)
    274     {
    275         cbMin += off - pCpu->cbCachedInstr;
    276         off = pCpu->cbCachedInstr;
     267    if (offInstr < pCpu->cbCachedInstr)
     268    {
     269        Assert(offInstr + cbMin > pCpu->cbCachedInstr);
     270        cbMin -= pCpu->cbCachedInstr - offInstr;
     271        offInstr = pCpu->cbCachedInstr;
     272    }
     273    else if (offInstr > pCpu->cbCachedInstr)
     274    {
     275        cbMin += offInstr - pCpu->cbCachedInstr;
     276        offInstr = pCpu->cbCachedInstr;
    277277    }
    278278
     
    282282     * DISInstrEx API.)
    283283     */
    284     int rc = pCpu->pfnReadBytes(pCpu, off, cbMin, sizeof(pCpu->abInstr) - off);
     284    int rc = pCpu->pfnReadBytes(pCpu, offInstr, cbMin, sizeof(pCpu->abInstr) - offInstr);
    285285    if (RT_SUCCESS(rc))
    286286    {
    287         Assert(pCpu->cbCachedInstr >= off + cbMin);
     287        Assert(pCpu->cbCachedInstr >= offInstr + cbMin);
    288288        Assert(pCpu->cbCachedInstr <= sizeof(pCpu->abInstr));
    289289    }
     
    301301 * @returns The requested byte.
    302302 * @param   pCpu                The disassembler state.
    303  * @param   off                 The offset of the byte relative to the
     303 * @param   offInstr            The offset of the byte relative to the
    304304 *                              instruction.
    305305 */
    306 DECL_NO_INLINE(static, uint8_t) disReadByteSlow(PDISCPUSTATE pCpu, RTUINTPTR off)
    307 {
    308     if (RT_UNLIKELY(off >= DIS_MAX_INSTR_LENGTH))
     306DECL_NO_INLINE(static, uint8_t) disReadByteSlow(PDISCPUSTATE pCpu, size_t offInstr)
     307{
     308    if (RT_UNLIKELY(offInstr >= DIS_MAX_INSTR_LENGTH))
    309309    {
    310310        Log(("disReadByte: too long instruction...\n"));
     
    313313    }
    314314
    315     disReadMore(pCpu, off, 1);
    316     return pCpu->abInstr[off];
     315    disReadMore(pCpu, offInstr, 1);
     316    return pCpu->abInstr[offInstr];
    317317}
    318318
    319319
    320320/**
    321  * Read a byte (8-bit) instruction byte by offset.
     321 * Read a byte (8-bit) instruction.
    322322 *
    323323 * @returns The requested byte.
     
    325325 * @param   uAddress            The address.
    326326 */
    327 DECLINLINE(uint8_t) disReadByteByOff(PDISCPUSTATE pCpu, RTUINTPTR off)
    328 {
    329     if (RT_UNLIKELY(off >= pCpu->cbCachedInstr))
    330         return disReadByteSlow(pCpu, off);
    331 
    332     return pCpu->abInstr[off];
    333 }
    334 
    335 
    336 /**
    337  * Read a byte (8-bit) instruction byte.
    338  *
    339  * @returns The requested byte.
    340  * @param   pCpu                The disassembler state.
    341  * @param   uAddress            The address.
    342  */
    343 DECL_FORCE_INLINE(uint8_t) disReadByte(PDISCPUSTATE pCpu, RTUINTPTR uAddress)
    344 {
    345     return disReadByteByOff(pCpu, uAddress - pCpu->uInstrAddr);
     327DECLINLINE(uint8_t) disReadByte(PDISCPUSTATE pCpu, size_t offInstr)
     328{
     329    if (RT_UNLIKELY(offInstr >= pCpu->cbCachedInstr))
     330        return disReadByteSlow(pCpu, offInstr);
     331
     332    return pCpu->abInstr[offInstr];
    346333}
    347334
     
    352339 * @returns The requested word.
    353340 * @param   pCpu                The disassembler state.
    354  * @param   off                 The offset of the word relative to the
     341 * @param   offInstr            The offset of the word relative to the
    355342 *                              instruction.
    356343 */
    357 DECL_NO_INLINE(static, uint16_t) disReadWordSlow(PDISCPUSTATE pCpu, RTUINTPTR off)
    358 {
    359     if (RT_UNLIKELY(off + 2 > DIS_MAX_INSTR_LENGTH))
     344DECL_NO_INLINE(static, uint16_t) disReadWordSlow(PDISCPUSTATE pCpu, size_t offInstr)
     345{
     346    if (RT_UNLIKELY(offInstr + 2 > DIS_MAX_INSTR_LENGTH))
    360347    {
    361348        Log(("disReadWord: too long instruction...\n"));
    362349        pCpu->rc = VERR_DIS_TOO_LONG_INSTR;
    363         if (off < DIS_MAX_INSTR_LENGTH)
    364             return pCpu->abInstr[off];
     350        if (offInstr < DIS_MAX_INSTR_LENGTH)
     351            return pCpu->abInstr[offInstr];
    365352        return 0;
    366353    }
    367354
    368     disReadMore(pCpu, off, 2);
     355    disReadMore(pCpu, offInstr, 2);
    369356#ifdef DIS_HOST_UNALIGNED_ACCESS_OK
    370     return *(uint16_t const *)&pCpu->abInstr[off];
     357    return *(uint16_t const *)&pCpu->abInstr[offInstr];
    371358#else
    372     return RT_MAKE_U16(pCpu->abInstr[off], pCpu->abInstr[off + 1]);
     359    return RT_MAKE_U16(pCpu->abInstr[offInstr], pCpu->abInstr[offInstr + 1]);
    373360#endif
    374361}
     
    376363
    377364/**
    378  * Read a word (16-bit) instruction byte by offset.
     365 * Read a word (16-bit) instruction.
    379366 *
    380367 * @returns The requested word.
    381368 * @param   pCpu                The disassembler state.
    382  * @param   uAddress            The address.
     369 * @param   offInstr            The offset of the qword relative to the
     370 *                              instruction.
    383371 */
    384 DECLINLINE(uint16_t) disReadWordByOff(PDISCPUSTATE pCpu, RTUINTPTR off)
    385 {
    386     if (RT_UNLIKELY(off + 2 > pCpu->cbCachedInstr))
    387         return disReadWordSlow(pCpu, off);
     372DECLINLINE(uint16_t) disReadWord(PDISCPUSTATE pCpu, size_t offInstr)
     373{
     374    if (RT_UNLIKELY(offInstr + 2 > pCpu->cbCachedInstr))
     375        return disReadWordSlow(pCpu, offInstr);
    388376
    389377#ifdef DIS_HOST_UNALIGNED_ACCESS_OK
    390     return *(uint16_t const *)&pCpu->abInstr[off];
     378    return *(uint16_t const *)&pCpu->abInstr[offInstr];
    391379#else
    392     return RT_MAKE_U16(pCpu->abInstr[off], pCpu->abInstr[off + 1]);
     380    return RT_MAKE_U16(pCpu->abInstr[offInstr], pCpu->abInstr[offInstr + 1]);
    393381#endif
    394 }
    395 
    396 
    397 /**
    398  * Read a word (16-bit) instruction byte.
    399  *
    400  * @returns The requested word.
    401  * @param   pCpu                The disassembler state.
    402  * @param   uAddress            The address.
    403  */
    404 DECL_FORCE_INLINE(uint16_t) disReadWord(PDISCPUSTATE pCpu, RTUINTPTR uAddress)
    405 {
    406     return disReadWordByOff(pCpu, uAddress - pCpu->uInstrAddr);
    407382}
    408383
     
    413388 * @returns The requested dword.
    414389 * @param   pCpu                The disassembler state.
    415  * @param   off                 The offset of the dword relative to the
     390 * @param   offInstr            The offset of the dword relative to the
    416391 *                              instruction.
    417392 */
    418 DECL_NO_INLINE(static, uint32_t) disReadDWordSlow(PDISCPUSTATE pCpu, RTUINTPTR off)
    419 {
    420     if (RT_UNLIKELY(off + 4 > DIS_MAX_INSTR_LENGTH))
     393DECL_NO_INLINE(static, uint32_t) disReadDWordSlow(PDISCPUSTATE pCpu, size_t offInstr)
     394{
     395    if (RT_UNLIKELY(offInstr + 4 > DIS_MAX_INSTR_LENGTH))
    421396    {
    422397        Log(("disReadDWord: too long instruction...\n"));
    423398        pCpu->rc = VERR_DIS_TOO_LONG_INSTR;
    424         switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - off)
     399        switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - offInstr)
    425400        {
    426401            case 1:
    427                 return RT_MAKE_U32_FROM_U8(pCpu->abInstr[off], 0, 0, 0);
     402                return RT_MAKE_U32_FROM_U8(pCpu->abInstr[offInstr], 0, 0, 0);
    428403            case 2:
    429                 return RT_MAKE_U32_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], 0, 0);
     404                return RT_MAKE_U32_FROM_U8(pCpu->abInstr[offInstr], pCpu->abInstr[offInstr + 1], 0, 0);
    430405            case 3:
    431                 return RT_MAKE_U32_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], 0);
     406                return RT_MAKE_U32_FROM_U8(pCpu->abInstr[offInstr], pCpu->abInstr[offInstr + 1], pCpu->abInstr[offInstr + 2], 0);
    432407        }
    433408        return 0;
    434409    }
    435410
    436     disReadMore(pCpu, off, 4);
     411    disReadMore(pCpu, offInstr, 4);
    437412#ifdef DIS_HOST_UNALIGNED_ACCESS_OK
    438     return *(uint32_t const *)&pCpu->abInstr[off];
     413    return *(uint32_t const *)&pCpu->abInstr[offInstr];
    439414#else
    440     return RT_MAKE_U32_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3]);
     415    return RT_MAKE_U32_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     416                               pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3]);
    441417#endif
    442418}
     
    444420
    445421/**
    446  * Read a dword (32-bit) instruction byte by offset.
     422 * Read a dword (32-bit) instruction.
    447423 *
    448424 * @returns The requested dword.
    449425 * @param   pCpu                The disassembler state.
    450  * @param   uAddress            The address.
     426 * @param   offInstr            The offset of the qword relative to the
     427 *                              instruction.
    451428 */
    452 DECLINLINE(uint32_t) disReadDWordByOff(PDISCPUSTATE pCpu, RTUINTPTR off)
    453 {
    454     if (RT_UNLIKELY(off + 4 > pCpu->cbCachedInstr))
    455         return disReadDWordSlow(pCpu, off);
     429DECLINLINE(uint32_t) disReadDWord(PDISCPUSTATE pCpu, size_t offInstr)
     430{
     431    if (RT_UNLIKELY(offInstr + 4 > pCpu->cbCachedInstr))
     432        return disReadDWordSlow(pCpu, offInstr);
    456433
    457434#ifdef DIS_HOST_UNALIGNED_ACCESS_OK
    458     return *(uint32_t const *)&pCpu->abInstr[off];
     435    return *(uint32_t const *)&pCpu->abInstr[offInstr];
    459436#else
    460     return RT_MAKE_U32_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3]);
     437    return RT_MAKE_U32_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     438                               pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3]);
    461439#endif
    462 }
    463 
    464 
    465 /**
    466  * Read a dword (32-bit) instruction byte.
    467  *
    468  * @returns The requested dword.
    469  * @param   pCpu                The disassembler state.
    470  * @param   uAddress            The address.
    471  */
    472 DECL_FORCE_INLINE(uint32_t) disReadDWord(PDISCPUSTATE pCpu, RTUINTPTR uAddress)
    473 {
    474     return disReadDWordByOff(pCpu, uAddress - pCpu->uInstrAddr);
    475440}
    476441
     
    481446 * @returns The requested qword.
    482447 * @param   pCpu                The disassembler state.
    483  * @param   off                 The offset of the qword relative to the
     448 * @param   offInstr            The offset of the qword relative to the
    484449 *                              instruction.
    485450 */
    486 DECL_NO_INLINE(static, uint64_t) disReadQWordSlow(PDISCPUSTATE pCpu, RTUINTPTR off)
    487 {
    488     if (RT_UNLIKELY(off + 8 > DIS_MAX_INSTR_LENGTH))
     451DECL_NO_INLINE(static, uint64_t) disReadQWordSlow(PDISCPUSTATE pCpu, size_t offInstr)
     452{
     453    if (RT_UNLIKELY(offInstr + 8 > DIS_MAX_INSTR_LENGTH))
    489454    {
    490455        Log(("disReadQWord: too long instruction...\n"));
    491456        pCpu->rc = VERR_DIS_TOO_LONG_INSTR;
    492         switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - off)
     457        switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - offInstr)
    493458        {
    494459            case 1:
    495                 return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off], 0, 0, 0,   0, 0, 0, 0);
     460                return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr], 0, 0, 0,   0, 0, 0, 0);
    496461            case 2:
    497                 return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], 0, 0,   0, 0, 0, 0);
     462                return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr], pCpu->abInstr[offInstr + 1], 0, 0,   0, 0, 0, 0);
    498463            case 3:
    499                 return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], 0,   0, 0, 0, 0);
     464                return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     465                                           pCpu->abInstr[offInstr + 2], 0,   0, 0, 0, 0);
    500466            case 4:
    501                 return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3],
    502                                            pCpu->abInstr[off + 4], 0, 0, 0);
     467                return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     468                                           pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3],
     469                                           pCpu->abInstr[offInstr + 4], 0, 0, 0);
    503470            case 5:
    504                 return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3],
    505                                            pCpu->abInstr[off + 4], pCpu->abInstr[off + 5], 0, 0);
     471                return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     472                                           pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3],
     473                                           pCpu->abInstr[offInstr + 4], pCpu->abInstr[offInstr + 5], 0, 0);
    506474            case 6:
    507                 return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3],
    508                                            pCpu->abInstr[off + 4], pCpu->abInstr[off + 5], pCpu->abInstr[off + 6], 0);
     475                return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     476                                           pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3],
     477                                           pCpu->abInstr[offInstr + 4], pCpu->abInstr[offInstr + 5],
     478                                           pCpu->abInstr[offInstr + 6], 0);
    509479        }
    510480        return 0;
    511481    }
    512482
    513     disReadMore(pCpu, off, 8);
     483    disReadMore(pCpu, offInstr, 8);
    514484#ifdef DIS_HOST_UNALIGNED_ACCESS_OK
    515     return *(uint64_t const *)&pCpu->abInstr[off];
     485    return *(uint64_t const *)&pCpu->abInstr[offInstr];
    516486#else
    517     return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off    ], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3],
    518                                pCpu->abInstr[off + 4], pCpu->abInstr[off + 5], pCpu->abInstr[off + 6], pCpu->abInstr[off + 7]);
     487    return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     488                               pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3],
     489                               pCpu->abInstr[offInstr + 4], pCpu->abInstr[offInstr + 5],
     490                               pCpu->abInstr[offInstr + 6], pCpu->abInstr[offInstr + 7]);
    519491#endif
    520492}
     
    522494
    523495/**
    524  * Read a qword (64-bit) instruction byte by offset.
     496 * Read a qword (64-bit) instruction.
    525497 *
    526498 * @returns The requested qword.
     
    528500 * @param   uAddress            The address.
    529501 */
    530 DECLINLINE(uint64_t) disReadQWordByOff(PDISCPUSTATE pCpu, RTUINTPTR off)
    531 {
    532     if (RT_UNLIKELY(off + 8 > pCpu->cbCachedInstr))
    533         return disReadQWordSlow(pCpu, off);
     502DECLINLINE(uint64_t) disReadQWord(PDISCPUSTATE pCpu, size_t offInstr)
     503{
     504    if (RT_UNLIKELY(offInstr + 8 > pCpu->cbCachedInstr))
     505        return disReadQWordSlow(pCpu, offInstr);
    534506
    535507#ifdef DIS_HOST_UNALIGNED_ACCESS_OK
    536     return *(uint64_t const *)&pCpu->abInstr[off];
     508    return *(uint64_t const *)&pCpu->abInstr[offInstr];
    537509#else
    538     return RT_MAKE_U64_FROM_U8(pCpu->abInstr[off    ], pCpu->abInstr[off + 1], pCpu->abInstr[off + 2], pCpu->abInstr[off + 3],
    539                                pCpu->abInstr[off + 4], pCpu->abInstr[off + 5], pCpu->abInstr[off + 6], pCpu->abInstr[off + 7]);
     510    return RT_MAKE_U64_FROM_U8(pCpu->abInstr[offInstr    ], pCpu->abInstr[offInstr + 1],
     511                               pCpu->abInstr[offInstr + 2], pCpu->abInstr[offInstr + 3],
     512                               pCpu->abInstr[offInstr + 4], pCpu->abInstr[offInstr + 5],
     513                               pCpu->abInstr[offInstr + 6], pCpu->abInstr[offInstr + 7]);
    540514#endif
    541515}
    542516
    543517
    544 /**
    545  * Read a qword (64-bit) instruction byte.
    546  *
    547  * @returns The requested qword.
    548  * @param   pCpu                The disassembler state.
    549  * @param   uAddress            The address.
    550  */
    551 DECL_FORCE_INLINE(uint64_t) disReadQWord(PDISCPUSTATE pCpu, RTUINTPTR uAddress)
    552 {
    553     return disReadQWordByOff(pCpu, uAddress - pCpu->uInstrAddr);
    554 }
    555 
    556 
    557 
    558 //*****************************************************************************
    559 //*****************************************************************************
    560 static unsigned disParseInstruction(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISCPUSTATE pCpu)
     518
     519//*****************************************************************************
     520//*****************************************************************************
     521static unsigned disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISCPUSTATE pCpu)
    561522{
    562523    int  size = 0;
    563524    bool fFiltered = false;
    564525
    565     Assert(uCodePtr && pOp && pCpu);
     526    Assert(pOp); Assert(pCpu);
    566527
    567528    // Store the opcode format string for disasmPrintf
     
    608569    if (pOp->idxParse1 != IDX_ParseNop)
    609570    {
    610         size += pCpu->pfnDisasmFnTable[pOp->idxParse1](uCodePtr, pOp, &pCpu->Param1, pCpu);
     571        size += pCpu->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, &pCpu->Param1, pCpu);
    611572        if (fFiltered == false) pCpu->Param1.cb = DISGetParamSize(pCpu, &pCpu->Param1);
    612573    }
     
    614575    if (pOp->idxParse2 != IDX_ParseNop)
    615576    {
    616         size += pCpu->pfnDisasmFnTable[pOp->idxParse2](uCodePtr+size, pOp, &pCpu->Param2, pCpu);
     577        size += pCpu->pfnDisasmFnTable[pOp->idxParse2](offInstr+size, pOp, &pCpu->Param2, pCpu);
    617578        if (fFiltered == false) pCpu->Param2.cb = DISGetParamSize(pCpu, &pCpu->Param2);
    618579    }
     
    620581    if (pOp->idxParse3 != IDX_ParseNop)
    621582    {
    622         size += pCpu->pfnDisasmFnTable[pOp->idxParse3](uCodePtr+size, pOp, &pCpu->Param3, pCpu);
     583        size += pCpu->pfnDisasmFnTable[pOp->idxParse3](offInstr+size, pOp, &pCpu->Param3, pCpu);
    623584        if (fFiltered == false) pCpu->Param3.cb = DISGetParamSize(pCpu, &pCpu->Param3);
    624585    }
     
    630591/* Floating point opcode parsing */
    631592//*****************************************************************************
    632 static unsigned ParseEscFP(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     593static size_t ParseEscFP(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    633594{
    634595    int index;
     
    638599    NOREF(pOp);
    639600
    640     ModRM = disReadByte(pCpu, uCodePtr);
     601    ModRM = disReadByte(pCpu, offInstr);
    641602
    642603    index = pCpu->bOpCode - 0xD8;
     
    683644
    684645    if (fpop->idxParse1 != IDX_ParseNop)
    685         size += pCpu->pfnDisasmFnTable[fpop->idxParse1](uCodePtr+size, (PCDISOPCODE)fpop, pParam, pCpu);
     646        size += pCpu->pfnDisasmFnTable[fpop->idxParse1](offInstr+size, (PCDISOPCODE)fpop, pParam, pCpu);
    686647
    687648    if (fpop->idxParse2 != IDX_ParseNop)
    688         size += pCpu->pfnDisasmFnTable[fpop->idxParse2](uCodePtr+size, (PCDISOPCODE)fpop, pParam, pCpu);
     649        size += pCpu->pfnDisasmFnTable[fpop->idxParse2](offInstr+size, (PCDISOPCODE)fpop, pParam, pCpu);
    689650
    690651    return size;
     
    695656// Scale  Index  Base
    696657//*****************************************************************************
    697 static void UseSIB(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    698 {
    699     unsigned regtype;
    700     NOREF(uCodePtr); NOREF(pOp);
     658static void UseSIB(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     659{
     660    NOREF(offInstr); NOREF(pOp);
    701661
    702662    unsigned scale = pCpu->SIB.Bits.Scale;
     
    704664    unsigned index = pCpu->SIB.Bits.Index;
    705665
     666    unsigned regtype;
    706667    if (pCpu->uAddrMode == DISCPUMODE_32BIT)
    707668        regtype    = DISUSE_REG_GEN32;
     
    744705//*****************************************************************************
    745706//*****************************************************************************
    746 static unsigned ParseSIB(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     707static size_t ParseSIB(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    747708{
    748709    unsigned size = sizeof(uint8_t);
     
    750711    NOREF(pOp); NOREF(pParam);
    751712
    752     SIB = disReadByte(pCpu, uCodePtr);
    753     uCodePtr += size;
     713    SIB = disReadByte(pCpu, offInstr);
     714    offInstr += size;
    754715
    755716    pCpu->SIB.Bits.Base  = SIB_BASE(SIB);
     
    770731    {
    771732        /* Additional 32 bits displacement. No change in long mode. */
    772         pCpu->i32SibDisp = disReadDWord(pCpu, uCodePtr);
     733        pCpu->i32SibDisp = disReadDWord(pCpu, offInstr);
    773734        size += sizeof(int32_t);
    774735    }
     
    777738//*****************************************************************************
    778739//*****************************************************************************
    779 static unsigned ParseSIB_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     740static size_t ParseSIB_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    780741{
    781742    unsigned size = sizeof(uint8_t);
     
    783744    NOREF(pOp); NOREF(pParam);
    784745
    785     SIB = disReadByte(pCpu, uCodePtr);
    786     uCodePtr += size;
     746    SIB = disReadByte(pCpu, offInstr);
    787747
    788748    pCpu->SIB.Bits.Base  = SIB_BASE(SIB);
     
    811771// Mod    Reg/Opcode  R/M
    812772//*****************************************************************************
    813 static unsigned UseModRM(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     773static size_t UseModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    814774{
    815775    unsigned vtype = OP_PARM_VTYPE(pParam->fParam);
     
    894854            if (rm == 4)
    895855            {   /* SIB byte follows ModRM */
    896                 UseSIB(uCodePtr, pOp, pParam, pCpu);
     856                UseSIB(offInstr, pOp, pParam, pCpu);
    897857            }
    898858            else
     
    920880        case 1: //effective address + 8 bits displacement
    921881            if (rm == 4) {//SIB byte follows ModRM
    922                 UseSIB(uCodePtr, pOp, pParam, pCpu);
     882                UseSIB(offInstr, pOp, pParam, pCpu);
    923883            }
    924884            else
     
    933893        case 2: //effective address + 32 bits displacement
    934894            if (rm == 4) {//SIB byte follows ModRM
    935                 UseSIB(uCodePtr, pOp, pParam, pCpu);
     895                UseSIB(offInstr, pOp, pParam, pCpu);
    936896            }
    937897            else
     
    988948// Query the size of the ModRM parameters and fetch the immediate data (if any)
    989949//*****************************************************************************
    990 static unsigned QueryModRM(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
     950static unsigned QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
    991951{
    992952    unsigned sibinc;
     
    1010970        if (mod != 3 && rm == 4)
    1011971        {   /* SIB byte follows ModRM */
    1012             *pSibInc = ParseSIB(uCodePtr, pOp, pParam, pCpu);
    1013             uCodePtr += *pSibInc;
     972            *pSibInc = ParseSIB(offInstr, pOp, pParam, pCpu);
     973            offInstr += *pSibInc;
    1014974            size += *pSibInc;
    1015975        }
     
    1019979        case 0: /* Effective address */
    1020980            if (rm == 5) {  /* 32 bits displacement */
    1021                 pCpu->i32SibDisp = disReadDWord(pCpu, uCodePtr);
     981                pCpu->i32SibDisp = disReadDWord(pCpu, offInstr);
    1022982                size += sizeof(int32_t);
    1023983            }
     
    1026986
    1027987        case 1: /* Effective address + 8 bits displacement */
    1028             pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, uCodePtr);
     988            pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, offInstr);
    1029989            size += sizeof(char);
    1030990            break;
    1031991
    1032992        case 2: /* Effective address + 32 bits displacement */
    1033             pCpu->i32SibDisp = disReadDWord(pCpu, uCodePtr);
     993            pCpu->i32SibDisp = disReadDWord(pCpu, offInstr);
    1034994            size += sizeof(int32_t);
    1035995            break;
     
    10461006        case 0: /* Effective address */
    10471007            if (rm == 6) {
    1048                 pCpu->i32SibDisp = disReadWord(pCpu, uCodePtr);
     1008                pCpu->i32SibDisp = disReadWord(pCpu, offInstr);
    10491009                size += sizeof(uint16_t);
    10501010            }
     
    10531013
    10541014        case 1: /* Effective address + 8 bits displacement */
    1055             pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, uCodePtr);
     1015            pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, offInstr);
    10561016            size += sizeof(char);
    10571017            break;
    10581018
    10591019        case 2: /* Effective address + 32 bits displacement */
    1060             pCpu->i32SibDisp = (int16_t)disReadWord(pCpu, uCodePtr);
     1020            pCpu->i32SibDisp = (int16_t)disReadWord(pCpu, offInstr);
    10611021            size += sizeof(uint16_t);
    10621022            break;
     
    10711031// Query the size of the ModRM parameters and fetch the immediate data (if any)
    10721032//*****************************************************************************
    1073 static unsigned QueryModRM_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
     1033static unsigned QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)
    10741034{
    10751035    unsigned sibinc;
     
    10921052        if (mod != 3 && rm == 4)
    10931053        {   /* SIB byte follows ModRM */
    1094             *pSibInc = ParseSIB_SizeOnly(uCodePtr, pOp, pParam, pCpu);
    1095             uCodePtr += *pSibInc;
     1054            *pSibInc = ParseSIB_SizeOnly(offInstr, pOp, pParam, pCpu);
     1055            offInstr += *pSibInc;
    10961056            size += *pSibInc;
    10971057        }
     
    11461106//*****************************************************************************
    11471107//*****************************************************************************
    1148 static unsigned ParseIllegal(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1149 {
    1150     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1108static size_t ParseIllegal(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1109{
     1110    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    11511111    AssertFailed();
    11521112    return 0;
     
    11541114//*****************************************************************************
    11551115//*****************************************************************************
    1156 static unsigned ParseModRM(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1116static size_t ParseModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    11571117{
    11581118    unsigned size = sizeof(uint8_t);   //ModRM byte
    11591119    unsigned sibinc, ModRM;
    11601120
    1161     ModRM = disReadByte(pCpu, uCodePtr);
    1162     uCodePtr += sizeof(uint8_t);
     1121    ModRM = disReadByte(pCpu, offInstr);
     1122    offInstr += sizeof(uint8_t);
    11631123
    11641124    pCpu->ModRM.Bits.Rm  = MODRM_RM(ModRM);
     
    11921152        }
    11931153    }
    1194     size += QueryModRM(uCodePtr, pOp, pParam, pCpu, &sibinc);
    1195     uCodePtr += sibinc;
    1196 
    1197     UseModRM(uCodePtr, pOp, pParam, pCpu);
     1154    size += QueryModRM(offInstr, pOp, pParam, pCpu, &sibinc);
     1155    offInstr += sibinc;
     1156
     1157    UseModRM(offInstr, pOp, pParam, pCpu);
    11981158    return size;
    11991159}
    12001160//*****************************************************************************
    12011161//*****************************************************************************
    1202 static unsigned ParseModRM_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1162static size_t ParseModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    12031163{
    12041164    unsigned size = sizeof(uint8_t);   //ModRM byte
    12051165    unsigned sibinc, ModRM;
    12061166
    1207     ModRM = disReadByte(pCpu, uCodePtr);
    1208     uCodePtr += sizeof(uint8_t);
     1167    ModRM = disReadByte(pCpu, offInstr);
     1168    offInstr += sizeof(uint8_t);
    12091169
    12101170    pCpu->ModRM.Bits.Rm  = MODRM_RM(ModRM);
     
    12391199    }
    12401200
    1241     size += QueryModRM_SizeOnly(uCodePtr, pOp, pParam, pCpu, &sibinc);
    1242     uCodePtr += sibinc;
     1201    size += QueryModRM_SizeOnly(offInstr, pOp, pParam, pCpu, &sibinc);
     1202    offInstr += sibinc;
    12431203
    12441204    /* UseModRM is not necessary here; we're only interested in the opcode size */
     
    12471207//*****************************************************************************
    12481208//*****************************************************************************
    1249 static unsigned ParseModFence(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1209static size_t ParseModFence(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    12501210{
    12511211    ////AssertMsgFailed(("??\n"));
    12521212    //nothing to do apparently
    1253     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1213    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    12541214    return 0;
    12551215}
    12561216//*****************************************************************************
    12571217//*****************************************************************************
    1258 static unsigned ParseImmByte(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1218static size_t ParseImmByte(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    12591219{
    12601220    NOREF(pOp);
    1261     pParam->uValue = disReadByte(pCpu, uCodePtr);
     1221    pParam->uValue = disReadByte(pCpu, offInstr);
    12621222    pParam->fUse  |= DISUSE_IMMEDIATE8;
    12631223    pParam->cb     = sizeof(uint8_t);
     
    12661226//*****************************************************************************
    12671227//*****************************************************************************
    1268 static unsigned ParseImmByte_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1269 {
    1270     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1228static size_t ParseImmByte_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1229{
     1230    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    12711231    return sizeof(uint8_t);
    12721232}
    12731233//*****************************************************************************
    12741234//*****************************************************************************
    1275 static unsigned ParseImmByteSX(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1235static size_t ParseImmByteSX(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    12761236{
    12771237    NOREF(pOp);
    12781238    if (pCpu->uOpMode == DISCPUMODE_32BIT)
    12791239    {
    1280         pParam->uValue = (uint32_t)(int8_t)disReadByte(pCpu, uCodePtr);
     1240        pParam->uValue = (uint32_t)(int8_t)disReadByte(pCpu, offInstr);
    12811241        pParam->fUse  |= DISUSE_IMMEDIATE32_SX8;
    12821242        pParam->cb     = sizeof(uint32_t);
     
    12851245    if (pCpu->uOpMode == DISCPUMODE_64BIT)
    12861246    {
    1287         pParam->uValue = (uint64_t)(int8_t)disReadByte(pCpu, uCodePtr);
     1247        pParam->uValue = (uint64_t)(int8_t)disReadByte(pCpu, offInstr);
    12881248        pParam->fUse  |= DISUSE_IMMEDIATE64_SX8;
    12891249        pParam->cb     = sizeof(uint64_t);
     
    12911251    else
    12921252    {
    1293         pParam->uValue = (uint16_t)(int8_t)disReadByte(pCpu, uCodePtr);
     1253        pParam->uValue = (uint16_t)(int8_t)disReadByte(pCpu, offInstr);
    12941254        pParam->fUse  |= DISUSE_IMMEDIATE16_SX8;
    12951255        pParam->cb     = sizeof(uint16_t);
     
    12991259//*****************************************************************************
    13001260//*****************************************************************************
    1301 static unsigned ParseImmByteSX_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1302 {
    1303     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1261static size_t ParseImmByteSX_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1262{
     1263    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    13041264    return sizeof(uint8_t);
    13051265}
    13061266//*****************************************************************************
    13071267//*****************************************************************************
    1308 static unsigned ParseImmUshort(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1268static size_t ParseImmUshort(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    13091269{
    13101270    NOREF(pOp);
    1311     pParam->uValue = disReadWord(pCpu, uCodePtr);
     1271    pParam->uValue = disReadWord(pCpu, offInstr);
    13121272    pParam->fUse  |= DISUSE_IMMEDIATE16;
    13131273    pParam->cb     = sizeof(uint16_t);
     
    13161276//*****************************************************************************
    13171277//*****************************************************************************
    1318 static unsigned ParseImmUshort_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1319 {
    1320     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1278static size_t ParseImmUshort_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1279{
     1280    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    13211281    return sizeof(uint16_t);
    13221282}
    13231283//*****************************************************************************
    13241284//*****************************************************************************
    1325 static unsigned ParseImmUlong(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1285static size_t ParseImmUlong(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    13261286{
    13271287    NOREF(pOp);
    1328     pParam->uValue = disReadDWord(pCpu, uCodePtr);
     1288    pParam->uValue = disReadDWord(pCpu, offInstr);
    13291289    pParam->fUse  |= DISUSE_IMMEDIATE32;
    13301290    pParam->cb     = sizeof(uint32_t);
     
    13331293//*****************************************************************************
    13341294//*****************************************************************************
    1335 static unsigned ParseImmUlong_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1336 {
    1337     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1295static size_t ParseImmUlong_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1296{
     1297    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    13381298    return sizeof(uint32_t);
    13391299}
    13401300//*****************************************************************************
    13411301//*****************************************************************************
    1342 static unsigned ParseImmQword(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1302static size_t ParseImmQword(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    13431303{
    13441304    NOREF(pOp);
    1345     pParam->uValue = disReadQWord(pCpu, uCodePtr);
     1305    pParam->uValue = disReadQWord(pCpu, offInstr);
    13461306    pParam->fUse  |= DISUSE_IMMEDIATE64;
    13471307    pParam->cb     = sizeof(uint64_t);
     
    13501310//*****************************************************************************
    13511311//*****************************************************************************
    1352 static unsigned ParseImmQword_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1353 {
    1354     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1312static size_t ParseImmQword_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1313{
     1314    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    13551315    return sizeof(uint64_t);
    13561316}
    13571317//*****************************************************************************
    13581318//*****************************************************************************
    1359 static unsigned ParseImmV(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1319static size_t ParseImmV(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    13601320{
    13611321    NOREF(pOp);
    13621322    if (pCpu->uOpMode == DISCPUMODE_32BIT)
    13631323    {
    1364         pParam->uValue = disReadDWord(pCpu, uCodePtr);
     1324        pParam->uValue = disReadDWord(pCpu, offInstr);
    13651325        pParam->fUse  |= DISUSE_IMMEDIATE32;
    13661326        pParam->cb     = sizeof(uint32_t);
     
    13701330    if (pCpu->uOpMode == DISCPUMODE_64BIT)
    13711331    {
    1372         pParam->uValue = disReadQWord(pCpu, uCodePtr);
     1332        pParam->uValue = disReadQWord(pCpu, offInstr);
    13731333        pParam->fUse  |= DISUSE_IMMEDIATE64;
    13741334        pParam->cb     = sizeof(uint64_t);
     
    13761336    }
    13771337
    1378     pParam->uValue = disReadWord(pCpu, uCodePtr);
     1338    pParam->uValue = disReadWord(pCpu, offInstr);
    13791339    pParam->fUse  |= DISUSE_IMMEDIATE16;
    13801340    pParam->cb     = sizeof(uint16_t);
     
    13831343//*****************************************************************************
    13841344//*****************************************************************************
    1385 static unsigned ParseImmV_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1386 {
    1387     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam);
     1345static size_t ParseImmV_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1346{
     1347    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
    13881348    if (pCpu->uOpMode == DISCPUMODE_32BIT)
    13891349        return sizeof(uint32_t);
     
    13941354//*****************************************************************************
    13951355//*****************************************************************************
    1396 static unsigned ParseImmZ(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1356static size_t ParseImmZ(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    13971357{
    13981358    NOREF(pOp);
     
    14001360    if (pCpu->uOpMode == DISCPUMODE_16BIT)
    14011361    {
    1402         pParam->uValue = disReadWord(pCpu, uCodePtr);
     1362        pParam->uValue = disReadWord(pCpu, offInstr);
    14031363        pParam->fUse  |= DISUSE_IMMEDIATE16;
    14041364        pParam->cb     = sizeof(uint16_t);
     
    14091369    if (pCpu->uOpMode == DISCPUMODE_64BIT)
    14101370    {
    1411         pParam->uValue = (uint64_t)(int32_t)disReadDWord(pCpu, uCodePtr);
     1371        pParam->uValue = (uint64_t)(int32_t)disReadDWord(pCpu, offInstr);
    14121372        pParam->fUse  |= DISUSE_IMMEDIATE64;
    14131373        pParam->cb     = sizeof(uint64_t);
     
    14151375    else
    14161376    {
    1417         pParam->uValue = disReadDWord(pCpu, uCodePtr);
     1377        pParam->uValue = disReadDWord(pCpu, offInstr);
    14181378        pParam->fUse  |= DISUSE_IMMEDIATE32;
    14191379        pParam->cb     = sizeof(uint32_t);
     
    14231383//*****************************************************************************
    14241384//*****************************************************************************
    1425 static unsigned ParseImmZ_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1426 {
    1427     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam);
     1385static size_t ParseImmZ_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1386{
     1387    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
    14281388    /* Word for 16-bit operand-size or doubleword for 32 or 64-bit operand-size. */
    14291389    if (pCpu->uOpMode == DISCPUMODE_16BIT)
     
    14351395// Relative displacement for branches (rel. to next instruction)
    14361396//*****************************************************************************
    1437 static unsigned ParseImmBRel(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1397static size_t ParseImmBRel(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    14381398{
    14391399    NOREF(pOp);
    1440     pParam->uValue = disReadByte(pCpu, uCodePtr);
     1400    pParam->uValue = disReadByte(pCpu, offInstr);
    14411401    pParam->fUse  |= DISUSE_IMMEDIATE8_REL;
    14421402    pParam->cb     = sizeof(uint8_t);
     
    14461406// Relative displacement for branches (rel. to next instruction)
    14471407//*****************************************************************************
    1448 static unsigned ParseImmBRel_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1449 {
    1450     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
     1408static size_t ParseImmBRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1409{
     1410    NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);
    14511411    return sizeof(char);
    14521412}
     
    14541414// Relative displacement for branches (rel. to next instruction)
    14551415//*****************************************************************************
    1456 static unsigned ParseImmVRel(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1416static size_t ParseImmVRel(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    14571417{
    14581418    NOREF(pOp);
    14591419    if (pCpu->uOpMode == DISCPUMODE_32BIT)
    14601420    {
    1461         pParam->uValue = disReadDWord(pCpu, uCodePtr);
     1421        pParam->uValue = disReadDWord(pCpu, offInstr);
    14621422        pParam->fUse  |= DISUSE_IMMEDIATE32_REL;
    14631423        pParam->cb     = sizeof(int32_t);
     
    14681428    {
    14691429        /* 32 bits relative immediate sign extended to 64 bits. */
    1470         pParam->uValue = (uint64_t)(int32_t)disReadDWord(pCpu, uCodePtr);
     1430        pParam->uValue = (uint64_t)(int32_t)disReadDWord(pCpu, offInstr);
    14711431        pParam->fUse  |= DISUSE_IMMEDIATE64_REL;
    14721432        pParam->cb     = sizeof(int64_t);
     
    14741434    }
    14751435
    1476     pParam->uValue = disReadWord(pCpu, uCodePtr);
     1436    pParam->uValue = disReadWord(pCpu, offInstr);
    14771437    pParam->fUse  |= DISUSE_IMMEDIATE16_REL;
    14781438    pParam->cb     = sizeof(int16_t);
     
    14821442// Relative displacement for branches (rel. to next instruction)
    14831443//*****************************************************************************
    1484 static unsigned ParseImmVRel_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1485 {
    1486     NOREF(uCodePtr); NOREF(pOp); NOREF(pParam);
     1444static size_t ParseImmVRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1445{
     1446    NOREF(offInstr); NOREF(pOp); NOREF(pParam);
    14871447    if (pCpu->uOpMode == DISCPUMODE_16BIT)
    14881448        return sizeof(int16_t);
     
    14921452//*****************************************************************************
    14931453//*****************************************************************************
    1494 static unsigned ParseImmAddr(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1454static size_t ParseImmAddr(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    14951455{
    14961456    if (pCpu->uAddrMode == DISCPUMODE_32BIT)
     
    14991459        {
    15001460            /* far 16:32 pointer */
    1501             pParam->uValue = disReadDWord(pCpu, uCodePtr);
    1502             *((uint32_t*)&pParam->uValue+1) = disReadWord(pCpu, uCodePtr+sizeof(uint32_t));
     1461            pParam->uValue = disReadDWord(pCpu, offInstr);
     1462            *((uint32_t*)&pParam->uValue+1) = disReadWord(pCpu, offInstr+sizeof(uint32_t));
    15031463            pParam->fUse   |= DISUSE_IMMEDIATE_ADDR_16_32;
    15041464            pParam->cb     = sizeof(uint16_t) + sizeof(uint32_t);
     
    15121472         * so we treat it like displacement.
    15131473         */
    1514         pParam->uDisp.i32 = disReadDWord(pCpu, uCodePtr);
     1474        pParam->uDisp.i32 = disReadDWord(pCpu, offInstr);
    15151475        pParam->fUse  |= DISUSE_DISPLACEMENT32;
    15161476        pParam->cb     = sizeof(uint32_t);
     
    15271487         * so we treat it like displacement.
    15281488         */
    1529         pParam->uDisp.i64 = disReadQWord(pCpu, uCodePtr);
     1489        pParam->uDisp.i64 = disReadQWord(pCpu, offInstr);
    15301490        pParam->fUse  |= DISUSE_DISPLACEMENT64;
    15311491        pParam->cb     = sizeof(uint64_t);
     
    15351495    {
    15361496        /* far 16:16 pointer */
    1537         pParam->uValue = disReadDWord(pCpu, uCodePtr);
     1497        pParam->uValue = disReadDWord(pCpu, offInstr);
    15381498        pParam->fUse  |= DISUSE_IMMEDIATE_ADDR_16_16;
    15391499        pParam->cb     = 2*sizeof(uint16_t);
     
    15471507     * so we treat it like displacement.
    15481508     */
    1549     pParam->uDisp.i16 = disReadWord(pCpu, uCodePtr);
     1509    pParam->uDisp.i16 = disReadWord(pCpu, offInstr);
    15501510    pParam->fUse  |= DISUSE_DISPLACEMENT16;
    15511511    pParam->cb     = sizeof(uint16_t);
     
    15541514//*****************************************************************************
    15551515//*****************************************************************************
    1556 static unsigned ParseImmAddr_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1557 {
    1558     NOREF(uCodePtr); NOREF(pOp);
     1516static size_t ParseImmAddr_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1517{
     1518    NOREF(offInstr); NOREF(pOp);
    15591519    if (pCpu->uAddrMode == DISCPUMODE_32BIT)
    15601520    {
     
    15871547//*****************************************************************************
    15881548//*****************************************************************************
    1589 static unsigned ParseImmAddrF(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1549static size_t ParseImmAddrF(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    15901550{
    15911551    // immediate far pointers - only 16:16 or 16:32; determined by operand, *not* address size!
     
    15951555    {
    15961556        // far 16:32 pointer
    1597         pParam->uValue = disReadDWord(pCpu, uCodePtr);
    1598         *((uint32_t*)&pParam->uValue+1) = disReadWord(pCpu, uCodePtr+sizeof(uint32_t));
     1557        pParam->uValue = disReadDWord(pCpu, offInstr);
     1558        *((uint32_t*)&pParam->uValue+1) = disReadWord(pCpu, offInstr+sizeof(uint32_t));
    15991559        pParam->fUse   |= DISUSE_IMMEDIATE_ADDR_16_32;
    16001560        pParam->cb     = sizeof(uint16_t) + sizeof(uint32_t);
     
    16031563
    16041564    // far 16:16 pointer
    1605     pParam->uValue = disReadDWord(pCpu, uCodePtr);
     1565    pParam->uValue = disReadDWord(pCpu, offInstr);
    16061566    pParam->fUse  |= DISUSE_IMMEDIATE_ADDR_16_16;
    16071567    pParam->cb     = 2*sizeof(uint16_t);
     
    16101570//*****************************************************************************
    16111571//*****************************************************************************
    1612 static unsigned ParseImmAddrF_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1613 {
    1614     NOREF(uCodePtr); NOREF(pOp);
     1572static size_t ParseImmAddrF_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1573{
     1574    NOREF(offInstr); NOREF(pOp);
    16151575    // immediate far pointers - only 16:16 or 16:32
    16161576    Assert(pCpu->uOpMode == DISCPUMODE_16BIT || pCpu->uOpMode == DISCPUMODE_32BIT);
     
    16291589//*****************************************************************************
    16301590//*****************************************************************************
    1631 static unsigned ParseFixedReg(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1632 {
    1633     NOREF(uCodePtr);
     1591static size_t ParseFixedReg(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1592{
     1593    NOREF(offInstr);
    16341594
    16351595    /*
     
    17301690//*****************************************************************************
    17311691//*****************************************************************************
    1732 static unsigned ParseXv(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1733 {
    1734     NOREF(uCodePtr);
     1692static size_t ParseXv(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1693{
     1694    NOREF(offInstr);
    17351695
    17361696    pParam->fUse |= DISUSE_POINTER_DS_BASED;
     
    17551715//*****************************************************************************
    17561716//*****************************************************************************
    1757 static unsigned ParseXb(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1758 {
    1759     NOREF(uCodePtr); NOREF(pOp);
     1717static size_t ParseXb(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1718{
     1719    NOREF(offInstr); NOREF(pOp);
    17601720
    17611721    pParam->fUse |= DISUSE_POINTER_DS_BASED;
     
    17801740//*****************************************************************************
    17811741//*****************************************************************************
    1782 static unsigned ParseYv(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1783 {
    1784     NOREF(uCodePtr);
     1742static size_t ParseYv(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1743{
     1744    NOREF(offInstr);
    17851745
    17861746    pParam->fUse |= DISUSE_POINTER_ES_BASED;
     
    18051765//*****************************************************************************
    18061766//*****************************************************************************
    1807 static unsigned ParseYb(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    1808 {
    1809     NOREF(uCodePtr); NOREF(pOp);
     1767static size_t ParseYb(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1768{
     1769    NOREF(offInstr); NOREF(pOp);
    18101770
    18111771    pParam->fUse |= DISUSE_POINTER_ES_BASED;
     
    18301790//*****************************************************************************
    18311791//*****************************************************************************
    1832 static unsigned ParseTwoByteEsc(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1792static size_t ParseTwoByteEsc(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    18331793{
    18341794    PCDISOPCODE   pOpcode;
     
    18371797
    18381798    /* 2nd byte */
    1839     pCpu->bOpCode = disReadByte(pCpu, uCodePtr);
     1799    pCpu->bOpCode = disReadByte(pCpu, offInstr);
    18401800
    18411801    /* default to the non-prefixed table. */
     
    18841844    }
    18851845
    1886     size += disParseInstruction(uCodePtr+size, pOpcode, pCpu);
     1846    size += disParseInstruction(offInstr+size, pOpcode, pCpu);
    18871847    return size;
    18881848}
    18891849//*****************************************************************************
    18901850//*****************************************************************************
    1891 static unsigned ParseThreeByteEsc4(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1851static size_t ParseThreeByteEsc4(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    18921852{
    18931853    PCDISOPCODE   pOpcode;
     
    18961856
    18971857    /* 3rd byte */
    1898     pCpu->bOpCode = disReadByte(pCpu, uCodePtr);
     1858    pCpu->bOpCode = disReadByte(pCpu, offInstr);
    18991859
    19001860    /* default to the non-prefixed table. */
     
    19451905    }
    19461906
    1947     size += disParseInstruction(uCodePtr+size, pOpcode, pCpu);
     1907    size += disParseInstruction(offInstr+size, pOpcode, pCpu);
    19481908    return size;
    19491909}
    19501910//*****************************************************************************
    19511911//*****************************************************************************
    1952 static unsigned ParseThreeByteEsc5(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1912static size_t ParseThreeByteEsc5(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    19531913{
    19541914    PCDISOPCODE   pOpcode;
     
    19571917
    19581918    /* 3rd byte */
    1959     pCpu->bOpCode = disReadByte(pCpu, uCodePtr);
     1919    pCpu->bOpCode = disReadByte(pCpu, offInstr);
    19601920
    19611921    /** @todo Should we take the first or last prefix byte in case of multiple prefix bytes??? */
     
    19801940        pOpcode = &g_InvalidOpcode[0];
    19811941
    1982     size += disParseInstruction(uCodePtr+size, pOpcode, pCpu);
     1942    size += disParseInstruction(offInstr+size, pOpcode, pCpu);
    19831943    return size;
    19841944}
    19851945//*****************************************************************************
    19861946//*****************************************************************************
    1987 static unsigned ParseNopPause(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1947static size_t ParseNopPause(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    19881948{
    19891949    unsigned size = 0;
     
    19981958        pOp = &g_aMapX86_NopPause[0]; /* NOP */
    19991959
    2000     size += disParseInstruction(uCodePtr, pOp, pCpu);
     1960    size += disParseInstruction(offInstr, pOp, pCpu);
    20011961    return size;
    20021962}
    20031963//*****************************************************************************
    20041964//*****************************************************************************
    2005 static unsigned ParseImmGrpl(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1965static size_t ParseImmGrpl(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    20061966{
    20071967    int idx = (pCpu->bOpCode - 0x80) * 8;
     
    20091969    NOREF(pParam);
    20101970
    2011     modrm = disReadByte(pCpu, uCodePtr);
     1971    modrm = disReadByte(pCpu, offInstr);
    20121972    reg   = MODRM_REG(modrm);
    20131973
     
    20171977        size = sizeof(uint8_t); //ModRM byte
    20181978
    2019     size += disParseInstruction(uCodePtr, pOp, pCpu);
     1979    size += disParseInstruction(offInstr, pOp, pCpu);
    20201980
    20211981    return size;
     
    20231983//*****************************************************************************
    20241984//*****************************************************************************
    2025 static unsigned ParseShiftGrp2(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     1985static size_t ParseShiftGrp2(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    20261986{
    20271987    int idx;
     
    20482008    }
    20492009
    2050     modrm = disReadByte(pCpu, uCodePtr);
     2010    modrm = disReadByte(pCpu, offInstr);
    20512011    reg   = MODRM_REG(modrm);
    20522012
     
    20572017        size = sizeof(uint8_t); //ModRM byte
    20582018
    2059     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2019    size += disParseInstruction(offInstr, pOp, pCpu);
    20602020
    20612021    return size;
     
    20632023//*****************************************************************************
    20642024//*****************************************************************************
    2065 static unsigned ParseGrp3(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2025static size_t ParseGrp3(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    20662026{
    20672027    int idx = (pCpu->bOpCode - 0xF6) * 8;
     
    20692029    NOREF(pParam);
    20702030
    2071     modrm = disReadByte(pCpu, uCodePtr);
     2031    modrm = disReadByte(pCpu, offInstr);
    20722032    reg   = MODRM_REG(modrm);
    20732033
     
    20782038        size = sizeof(uint8_t); //ModRM byte
    20792039
    2080     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2040    size += disParseInstruction(offInstr, pOp, pCpu);
    20812041
    20822042    return size;
     
    20842044//*****************************************************************************
    20852045//*****************************************************************************
    2086 static unsigned ParseGrp4(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2046static size_t ParseGrp4(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    20872047{
    20882048    unsigned size = 0, modrm, reg;
    20892049    NOREF(pParam);
    20902050
    2091     modrm = disReadByte(pCpu, uCodePtr);
     2051    modrm = disReadByte(pCpu, offInstr);
    20922052    reg   = MODRM_REG(modrm);
    20932053
     
    20982058        size = sizeof(uint8_t); //ModRM byte
    20992059
    2100     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2060    size += disParseInstruction(offInstr, pOp, pCpu);
    21012061
    21022062    return size;
     
    21042064//*****************************************************************************
    21052065//*****************************************************************************
    2106 static unsigned ParseGrp5(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2066static size_t ParseGrp5(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    21072067{
    21082068    unsigned size = 0, modrm, reg;
    21092069    NOREF(pParam);
    21102070
    2111     modrm = disReadByte(pCpu, uCodePtr);
     2071    modrm = disReadByte(pCpu, offInstr);
    21122072    reg   = MODRM_REG(modrm);
    21132073
     
    21182078        size = sizeof(uint8_t); //ModRM byte
    21192079
    2120     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2080    size += disParseInstruction(offInstr, pOp, pCpu);
    21212081
    21222082    return size;
     
    21282088//
    21292089//*****************************************************************************
    2130 static unsigned Parse3DNow(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2090static size_t Parse3DNow(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    21312091{
    21322092    unsigned size = 0, modrmsize;
     
    21372097#endif
    21382098
    2139     unsigned ModRM = disReadByte(pCpu, uCodePtr);
     2099    unsigned ModRM = disReadByte(pCpu, offInstr);
    21402100    pCpu->ModRM.Bits.Rm  = MODRM_RM(ModRM);
    21412101    pCpu->ModRM.Bits.Mod = MODRM_MOD(ModRM);
    21422102    pCpu->ModRM.Bits.Reg = MODRM_REG(ModRM);
    21432103
    2144     modrmsize = QueryModRM(uCodePtr+sizeof(uint8_t), pOp, pParam, pCpu, NULL);
    2145 
    2146     uint8_t opcode = disReadByte(pCpu, uCodePtr+sizeof(uint8_t)+modrmsize);
     2104    modrmsize = QueryModRM(offInstr+sizeof(uint8_t), pOp, pParam, pCpu, NULL);
     2105
     2106    uint8_t opcode = disReadByte(pCpu, offInstr+sizeof(uint8_t)+modrmsize);
    21472107
    21482108    pOp = (PCDISOPCODE)&g_aTwoByteMapX86_3DNow[opcode];
     
    21572117    }
    21582118
    2159     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2119    size += disParseInstruction(offInstr, pOp, pCpu);
    21602120    size += sizeof(uint8_t);   //imm8_opcode uint8_t
    21612121
     
    21642124//*****************************************************************************
    21652125//*****************************************************************************
    2166 static unsigned ParseGrp6(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2126static size_t ParseGrp6(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    21672127{
    21682128    unsigned size = 0, modrm, reg;
    21692129    NOREF(pParam);
    21702130
    2171     modrm = disReadByte(pCpu, uCodePtr);
     2131    modrm = disReadByte(pCpu, offInstr);
    21722132    reg   = MODRM_REG(modrm);
    21732133
     
    21782138        size = sizeof(uint8_t); //ModRM byte
    21792139
    2180     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2140    size += disParseInstruction(offInstr, pOp, pCpu);
    21812141
    21822142    return size;
     
    21842144//*****************************************************************************
    21852145//*****************************************************************************
    2186 static unsigned ParseGrp7(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2146static size_t ParseGrp7(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    21872147{
    21882148    unsigned size = 0, modrm, reg, rm, mod;
    21892149    NOREF(pParam);
    21902150
    2191     modrm = disReadByte(pCpu, uCodePtr);
     2151    modrm = disReadByte(pCpu, offInstr);
    21922152    mod   = MODRM_MOD(modrm);
    21932153    reg   = MODRM_REG(modrm);
     
    22062166        size = sizeof(uint8_t); //ModRM byte
    22072167
    2208     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2168    size += disParseInstruction(offInstr, pOp, pCpu);
    22092169
    22102170    return size;
     
    22122172//*****************************************************************************
    22132173//*****************************************************************************
    2214 static unsigned ParseGrp8(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2174static size_t ParseGrp8(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    22152175{
    22162176    unsigned size = 0, modrm, reg;
    22172177    NOREF(pParam);
    22182178
    2219     modrm = disReadByte(pCpu, uCodePtr);
     2179    modrm = disReadByte(pCpu, offInstr);
    22202180    reg   = MODRM_REG(modrm);
    22212181
     
    22262186        size = sizeof(uint8_t); //ModRM byte
    22272187
    2228     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2188    size += disParseInstruction(offInstr, pOp, pCpu);
    22292189
    22302190    return size;
     
    22322192//*****************************************************************************
    22332193//*****************************************************************************
    2234 static unsigned ParseGrp9(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2194static size_t ParseGrp9(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    22352195{
    22362196    unsigned size = 0, modrm, reg;
    22372197    NOREF(pParam);
    22382198
    2239     modrm = disReadByte(pCpu, uCodePtr);
     2199    modrm = disReadByte(pCpu, offInstr);
    22402200    reg   = MODRM_REG(modrm);
    22412201
     
    22462206        size = sizeof(uint8_t); //ModRM byte
    22472207
    2248     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2208    size += disParseInstruction(offInstr, pOp, pCpu);
    22492209
    22502210    return size;
     
    22522212//*****************************************************************************
    22532213//*****************************************************************************
    2254 static unsigned ParseGrp10(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2214static size_t ParseGrp10(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    22552215{
    22562216    unsigned size = 0, modrm, reg;
    22572217    NOREF(pParam);
    22582218
    2259     modrm = disReadByte(pCpu, uCodePtr);
     2219    modrm = disReadByte(pCpu, offInstr);
    22602220    reg   = MODRM_REG(modrm);
    22612221
     
    22662226        size = sizeof(uint8_t); //ModRM byte
    22672227
    2268     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2228    size += disParseInstruction(offInstr, pOp, pCpu);
    22692229
    22702230    return size;
     
    22722232//*****************************************************************************
    22732233//*****************************************************************************
    2274 static unsigned ParseGrp12(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2234static size_t ParseGrp12(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    22752235{
    22762236    unsigned size = 0, modrm, reg;
    22772237    NOREF(pParam);
    22782238
    2279     modrm = disReadByte(pCpu, uCodePtr);
     2239    modrm = disReadByte(pCpu, offInstr);
    22802240    reg   = MODRM_REG(modrm);
    22812241
     
    22892249        size = sizeof(uint8_t); //ModRM byte
    22902250
    2291     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2251    size += disParseInstruction(offInstr, pOp, pCpu);
    22922252    return size;
    22932253}
    22942254//*****************************************************************************
    22952255//*****************************************************************************
    2296 static unsigned ParseGrp13(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2256static size_t ParseGrp13(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    22972257{
    22982258    unsigned size = 0, modrm, reg;
    22992259    NOREF(pParam);
    23002260
    2301     modrm = disReadByte(pCpu, uCodePtr);
     2261    modrm = disReadByte(pCpu, offInstr);
    23022262    reg   = MODRM_REG(modrm);
    23032263    if (pCpu->fPrefix & DISPREFIX_OPSIZE)
     
    23102270        size = sizeof(uint8_t); //ModRM byte
    23112271
    2312     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2272    size += disParseInstruction(offInstr, pOp, pCpu);
    23132273
    23142274    return size;
     
    23162276//*****************************************************************************
    23172277//*****************************************************************************
    2318 static unsigned ParseGrp14(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2278static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    23192279{
    23202280    unsigned size = 0, modrm, reg;
    23212281    NOREF(pParam);
    23222282
    2323     modrm = disReadByte(pCpu, uCodePtr);
     2283    modrm = disReadByte(pCpu, offInstr);
    23242284    reg   = MODRM_REG(modrm);
    23252285    if (pCpu->fPrefix & DISPREFIX_OPSIZE)
     
    23322292        size = sizeof(uint8_t); //ModRM byte
    23332293
    2334     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2294    size += disParseInstruction(offInstr, pOp, pCpu);
    23352295
    23362296    return size;
     
    23382298//*****************************************************************************
    23392299//*****************************************************************************
    2340 static unsigned ParseGrp15(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2300static size_t ParseGrp15(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    23412301{
    23422302    unsigned size = 0, modrm, reg, mod, rm;
    23432303    NOREF(pParam);
    23442304
    2345     modrm = disReadByte(pCpu, uCodePtr);
     2305    modrm = disReadByte(pCpu, offInstr);
    23462306    mod   = MODRM_MOD(modrm);
    23472307    reg   = MODRM_REG(modrm);
     
    23572317        size = sizeof(uint8_t); //ModRM byte
    23582318
    2359     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2319    size += disParseInstruction(offInstr, pOp, pCpu);
    23602320    return size;
    23612321}
    23622322//*****************************************************************************
    23632323//*****************************************************************************
    2364 static unsigned ParseGrp16(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
     2324static size_t ParseGrp16(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)
    23652325{
    23662326    unsigned size = 0, modrm, reg;
    23672327    NOREF(pParam);
    23682328
    2369     modrm = disReadByte(pCpu, uCodePtr);
     2329    modrm = disReadByte(pCpu, offInstr);
    23702330    reg   = MODRM_REG(modrm);
    23712331
     
    23762336        size = sizeof(uint8_t); //ModRM byte
    23772337
    2378     size += disParseInstruction(uCodePtr, pOp, pCpu);
     2338    size += disParseInstruction(offInstr, pOp, pCpu);
    23792339    return size;
    23802340}
     
    25762536 * @param   pCpu            Initialized cpu state.
    25772537 * @param   paOneByteMap    The one byte opcode map to use.
    2578  * @param   uInstrAddr      Instruction address.
    25792538 * @param   pcbInstr        Where to store the instruction size. Can be NULL.
    25802539 */
    2581 static int disInstrWorker(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, PCDISOPCODE paOneByteMap, uint32_t *pcbInstr)
     2540static int disInstrWorker(PDISCPUSTATE pCpu, PCDISOPCODE paOneByteMap, uint32_t *pcbInstr)
    25822541{
    25832542    /*
    25842543     * Parse byte by byte.
    25852544     */
    2586     size_t offByte = 0;
     2545    size_t offInstr = 0;
    25872546    for (;;)
    25882547    {
    2589         uint8_t codebyte = disReadByteByOff(pCpu, offByte++);
     2548        uint8_t codebyte = disReadByte(pCpu, offInstr++);
    25902549        uint8_t opcode   = paOneByteMap[codebyte].uOpcode;
    25912550
     
    26052564            case OP_INVALID:
    26062565                if (pcbInstr)
    2607                     *pcbInstr = (uint32_t)offByte;
     2566                    *pcbInstr = (uint32_t)offInstr;
    26082567                return pCpu->rc = VERR_DIS_INVALID_OPCODE;
    26092568
     
    26672626        /* first opcode byte. */
    26682627        pCpu->bOpCode = codebyte;
    2669         offByte += disParseInstruction(uInstrAddr + offByte, &paOneByteMap[pCpu->bOpCode], pCpu);
     2628        offInstr += disParseInstruction(offInstr, &paOneByteMap[pCpu->bOpCode], pCpu);
    26702629        break;
    26712630    }
    26722631
    2673     pCpu->cbInstr = offByte;
     2632    pCpu->cbInstr = offInstr;
    26742633    if (pcbInstr)
    2675         *pcbInstr = offByte;
     2634        *pcbInstr = offInstr;
    26762635
    26772636    if (pCpu->fPrefix & DISPREFIX_LOCK)
     
    27682727    }
    27692728
    2770     return disInstrWorker(pCpu, uInstrAddr, paOneByteMap, pcbInstr);
     2729    return disInstrWorker(pCpu, paOneByteMap, pcbInstr);
    27712730}
    27722731
Note: See TracChangeset for help on using the changeset viewer.

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