Changeset 41784 in vbox for trunk/src/VBox/Disassembler
- Timestamp:
- Jun 16, 2012 7:37:11 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Disassembler/DisasmCore.cpp
r41782 r41784 253 253 * 254 254 * @param pCpu The disassembler state. 255 * @param off 255 * @param offInstr The offset of the read request. 256 256 * @param cbMin The size of the read request that needs to be 257 257 * satisfied. 258 258 */ 259 DECL_NO_INLINE(static, void) disReadMore(PDISCPUSTATE pCpu, uint8_t off , uint8_t cbMin)260 { 261 Assert(cbMin + off <= sizeof(pCpu->abInstr));259 DECL_NO_INLINE(static, void) disReadMore(PDISCPUSTATE pCpu, uint8_t offInstr, uint8_t cbMin) 260 { 261 Assert(cbMin + offInstr <= sizeof(pCpu->abInstr)); 262 262 263 263 /* … … 265 265 * been read and to make sure we don't leave unread gaps. 266 266 */ 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; 277 277 } 278 278 … … 282 282 * DISInstrEx API.) 283 283 */ 284 int rc = pCpu->pfnReadBytes(pCpu, off , cbMin, sizeof(pCpu->abInstr) - off);284 int rc = pCpu->pfnReadBytes(pCpu, offInstr, cbMin, sizeof(pCpu->abInstr) - offInstr); 285 285 if (RT_SUCCESS(rc)) 286 286 { 287 Assert(pCpu->cbCachedInstr >= off + cbMin);287 Assert(pCpu->cbCachedInstr >= offInstr + cbMin); 288 288 Assert(pCpu->cbCachedInstr <= sizeof(pCpu->abInstr)); 289 289 } … … 301 301 * @returns The requested byte. 302 302 * @param pCpu The disassembler state. 303 * @param off 303 * @param offInstr The offset of the byte relative to the 304 304 * instruction. 305 305 */ 306 DECL_NO_INLINE(static, uint8_t) disReadByteSlow(PDISCPUSTATE pCpu, RTUINTPTR off)307 { 308 if (RT_UNLIKELY(off >= DIS_MAX_INSTR_LENGTH))306 DECL_NO_INLINE(static, uint8_t) disReadByteSlow(PDISCPUSTATE pCpu, size_t offInstr) 307 { 308 if (RT_UNLIKELY(offInstr >= DIS_MAX_INSTR_LENGTH)) 309 309 { 310 310 Log(("disReadByte: too long instruction...\n")); … … 313 313 } 314 314 315 disReadMore(pCpu, off , 1);316 return pCpu->abInstr[off ];315 disReadMore(pCpu, offInstr, 1); 316 return pCpu->abInstr[offInstr]; 317 317 } 318 318 319 319 320 320 /** 321 * Read a byte (8-bit) instruction byte by offset.321 * Read a byte (8-bit) instruction. 322 322 * 323 323 * @returns The requested byte. … … 325 325 * @param uAddress The address. 326 326 */ 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); 327 DECLINLINE(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]; 346 333 } 347 334 … … 352 339 * @returns The requested word. 353 340 * @param pCpu The disassembler state. 354 * @param off 341 * @param offInstr The offset of the word relative to the 355 342 * instruction. 356 343 */ 357 DECL_NO_INLINE(static, uint16_t) disReadWordSlow(PDISCPUSTATE pCpu, RTUINTPTR off)358 { 359 if (RT_UNLIKELY(off + 2 > DIS_MAX_INSTR_LENGTH))344 DECL_NO_INLINE(static, uint16_t) disReadWordSlow(PDISCPUSTATE pCpu, size_t offInstr) 345 { 346 if (RT_UNLIKELY(offInstr + 2 > DIS_MAX_INSTR_LENGTH)) 360 347 { 361 348 Log(("disReadWord: too long instruction...\n")); 362 349 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]; 365 352 return 0; 366 353 } 367 354 368 disReadMore(pCpu, off , 2);355 disReadMore(pCpu, offInstr, 2); 369 356 #ifdef DIS_HOST_UNALIGNED_ACCESS_OK 370 return *(uint16_t const *)&pCpu->abInstr[off ];357 return *(uint16_t const *)&pCpu->abInstr[offInstr]; 371 358 #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]); 373 360 #endif 374 361 } … … 376 363 377 364 /** 378 * Read a word (16-bit) instruction byte by offset.365 * Read a word (16-bit) instruction. 379 366 * 380 367 * @returns The requested word. 381 368 * @param pCpu The disassembler state. 382 * @param uAddress The address. 369 * @param offInstr The offset of the qword relative to the 370 * instruction. 383 371 */ 384 DECLINLINE(uint16_t) disReadWord ByOff(PDISCPUSTATE pCpu, RTUINTPTR off)385 { 386 if (RT_UNLIKELY(off + 2 > pCpu->cbCachedInstr))387 return disReadWordSlow(pCpu, off );372 DECLINLINE(uint16_t) disReadWord(PDISCPUSTATE pCpu, size_t offInstr) 373 { 374 if (RT_UNLIKELY(offInstr + 2 > pCpu->cbCachedInstr)) 375 return disReadWordSlow(pCpu, offInstr); 388 376 389 377 #ifdef DIS_HOST_UNALIGNED_ACCESS_OK 390 return *(uint16_t const *)&pCpu->abInstr[off ];378 return *(uint16_t const *)&pCpu->abInstr[offInstr]; 391 379 #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]); 393 381 #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);407 382 } 408 383 … … 413 388 * @returns The requested dword. 414 389 * @param pCpu The disassembler state. 415 * @param off 390 * @param offInstr The offset of the dword relative to the 416 391 * instruction. 417 392 */ 418 DECL_NO_INLINE(static, uint32_t) disReadDWordSlow(PDISCPUSTATE pCpu, RTUINTPTR off)419 { 420 if (RT_UNLIKELY(off + 4 > DIS_MAX_INSTR_LENGTH))393 DECL_NO_INLINE(static, uint32_t) disReadDWordSlow(PDISCPUSTATE pCpu, size_t offInstr) 394 { 395 if (RT_UNLIKELY(offInstr + 4 > DIS_MAX_INSTR_LENGTH)) 421 396 { 422 397 Log(("disReadDWord: too long instruction...\n")); 423 398 pCpu->rc = VERR_DIS_TOO_LONG_INSTR; 424 switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - off )399 switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - offInstr) 425 400 { 426 401 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); 428 403 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); 430 405 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); 432 407 } 433 408 return 0; 434 409 } 435 410 436 disReadMore(pCpu, off , 4);411 disReadMore(pCpu, offInstr, 4); 437 412 #ifdef DIS_HOST_UNALIGNED_ACCESS_OK 438 return *(uint32_t const *)&pCpu->abInstr[off ];413 return *(uint32_t const *)&pCpu->abInstr[offInstr]; 439 414 #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]); 441 417 #endif 442 418 } … … 444 420 445 421 /** 446 * Read a dword (32-bit) instruction byte by offset.422 * Read a dword (32-bit) instruction. 447 423 * 448 424 * @returns The requested dword. 449 425 * @param pCpu The disassembler state. 450 * @param uAddress The address. 426 * @param offInstr The offset of the qword relative to the 427 * instruction. 451 428 */ 452 DECLINLINE(uint32_t) disReadDWord ByOff(PDISCPUSTATE pCpu, RTUINTPTR off)453 { 454 if (RT_UNLIKELY(off + 4 > pCpu->cbCachedInstr))455 return disReadDWordSlow(pCpu, off );429 DECLINLINE(uint32_t) disReadDWord(PDISCPUSTATE pCpu, size_t offInstr) 430 { 431 if (RT_UNLIKELY(offInstr + 4 > pCpu->cbCachedInstr)) 432 return disReadDWordSlow(pCpu, offInstr); 456 433 457 434 #ifdef DIS_HOST_UNALIGNED_ACCESS_OK 458 return *(uint32_t const *)&pCpu->abInstr[off ];435 return *(uint32_t const *)&pCpu->abInstr[offInstr]; 459 436 #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]); 461 439 #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);475 440 } 476 441 … … 481 446 * @returns The requested qword. 482 447 * @param pCpu The disassembler state. 483 * @param off 448 * @param offInstr The offset of the qword relative to the 484 449 * instruction. 485 450 */ 486 DECL_NO_INLINE(static, uint64_t) disReadQWordSlow(PDISCPUSTATE pCpu, RTUINTPTR off)487 { 488 if (RT_UNLIKELY(off + 8 > DIS_MAX_INSTR_LENGTH))451 DECL_NO_INLINE(static, uint64_t) disReadQWordSlow(PDISCPUSTATE pCpu, size_t offInstr) 452 { 453 if (RT_UNLIKELY(offInstr + 8 > DIS_MAX_INSTR_LENGTH)) 489 454 { 490 455 Log(("disReadQWord: too long instruction...\n")); 491 456 pCpu->rc = VERR_DIS_TOO_LONG_INSTR; 492 switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - off )457 switch ((RTUINTPTR)DIS_MAX_INSTR_LENGTH - offInstr) 493 458 { 494 459 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); 496 461 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); 498 463 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); 500 466 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); 503 470 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); 506 474 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); 509 479 } 510 480 return 0; 511 481 } 512 482 513 disReadMore(pCpu, off , 8);483 disReadMore(pCpu, offInstr, 8); 514 484 #ifdef DIS_HOST_UNALIGNED_ACCESS_OK 515 return *(uint64_t const *)&pCpu->abInstr[off ];485 return *(uint64_t const *)&pCpu->abInstr[offInstr]; 516 486 #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]); 519 491 #endif 520 492 } … … 522 494 523 495 /** 524 * Read a qword (64-bit) instruction byte by offset.496 * Read a qword (64-bit) instruction. 525 497 * 526 498 * @returns The requested qword. … … 528 500 * @param uAddress The address. 529 501 */ 530 DECLINLINE(uint64_t) disReadQWord ByOff(PDISCPUSTATE pCpu, RTUINTPTR off)531 { 532 if (RT_UNLIKELY(off + 8 > pCpu->cbCachedInstr))533 return disReadQWordSlow(pCpu, off );502 DECLINLINE(uint64_t) disReadQWord(PDISCPUSTATE pCpu, size_t offInstr) 503 { 504 if (RT_UNLIKELY(offInstr + 8 > pCpu->cbCachedInstr)) 505 return disReadQWordSlow(pCpu, offInstr); 534 506 535 507 #ifdef DIS_HOST_UNALIGNED_ACCESS_OK 536 return *(uint64_t const *)&pCpu->abInstr[off ];508 return *(uint64_t const *)&pCpu->abInstr[offInstr]; 537 509 #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]); 540 514 #endif 541 515 } 542 516 543 517 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 //***************************************************************************** 521 static unsigned disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISCPUSTATE pCpu) 561 522 { 562 523 int size = 0; 563 524 bool fFiltered = false; 564 525 565 Assert( uCodePtr && pOp &&pCpu);526 Assert(pOp); Assert(pCpu); 566 527 567 528 // Store the opcode format string for disasmPrintf … … 608 569 if (pOp->idxParse1 != IDX_ParseNop) 609 570 { 610 size += pCpu->pfnDisasmFnTable[pOp->idxParse1]( uCodePtr, pOp, &pCpu->Param1, pCpu);571 size += pCpu->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, &pCpu->Param1, pCpu); 611 572 if (fFiltered == false) pCpu->Param1.cb = DISGetParamSize(pCpu, &pCpu->Param1); 612 573 } … … 614 575 if (pOp->idxParse2 != IDX_ParseNop) 615 576 { 616 size += pCpu->pfnDisasmFnTable[pOp->idxParse2]( uCodePtr+size, pOp, &pCpu->Param2, pCpu);577 size += pCpu->pfnDisasmFnTable[pOp->idxParse2](offInstr+size, pOp, &pCpu->Param2, pCpu); 617 578 if (fFiltered == false) pCpu->Param2.cb = DISGetParamSize(pCpu, &pCpu->Param2); 618 579 } … … 620 581 if (pOp->idxParse3 != IDX_ParseNop) 621 582 { 622 size += pCpu->pfnDisasmFnTable[pOp->idxParse3]( uCodePtr+size, pOp, &pCpu->Param3, pCpu);583 size += pCpu->pfnDisasmFnTable[pOp->idxParse3](offInstr+size, pOp, &pCpu->Param3, pCpu); 623 584 if (fFiltered == false) pCpu->Param3.cb = DISGetParamSize(pCpu, &pCpu->Param3); 624 585 } … … 630 591 /* Floating point opcode parsing */ 631 592 //***************************************************************************** 632 static unsigned ParseEscFP(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)593 static size_t ParseEscFP(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 633 594 { 634 595 int index; … … 638 599 NOREF(pOp); 639 600 640 ModRM = disReadByte(pCpu, uCodePtr);601 ModRM = disReadByte(pCpu, offInstr); 641 602 642 603 index = pCpu->bOpCode - 0xD8; … … 683 644 684 645 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); 686 647 687 648 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); 689 650 690 651 return size; … … 695 656 // Scale Index Base 696 657 //***************************************************************************** 697 static void UseSIB(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 698 { 699 unsigned regtype; 700 NOREF(uCodePtr); NOREF(pOp); 658 static void UseSIB(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 659 { 660 NOREF(offInstr); NOREF(pOp); 701 661 702 662 unsigned scale = pCpu->SIB.Bits.Scale; … … 704 664 unsigned index = pCpu->SIB.Bits.Index; 705 665 666 unsigned regtype; 706 667 if (pCpu->uAddrMode == DISCPUMODE_32BIT) 707 668 regtype = DISUSE_REG_GEN32; … … 744 705 //***************************************************************************** 745 706 //***************************************************************************** 746 static unsigned ParseSIB(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)707 static size_t ParseSIB(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 747 708 { 748 709 unsigned size = sizeof(uint8_t); … … 750 711 NOREF(pOp); NOREF(pParam); 751 712 752 SIB = disReadByte(pCpu, uCodePtr);753 uCodePtr += size;713 SIB = disReadByte(pCpu, offInstr); 714 offInstr += size; 754 715 755 716 pCpu->SIB.Bits.Base = SIB_BASE(SIB); … … 770 731 { 771 732 /* Additional 32 bits displacement. No change in long mode. */ 772 pCpu->i32SibDisp = disReadDWord(pCpu, uCodePtr);733 pCpu->i32SibDisp = disReadDWord(pCpu, offInstr); 773 734 size += sizeof(int32_t); 774 735 } … … 777 738 //***************************************************************************** 778 739 //***************************************************************************** 779 static unsigned ParseSIB_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)740 static size_t ParseSIB_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 780 741 { 781 742 unsigned size = sizeof(uint8_t); … … 783 744 NOREF(pOp); NOREF(pParam); 784 745 785 SIB = disReadByte(pCpu, uCodePtr); 786 uCodePtr += size; 746 SIB = disReadByte(pCpu, offInstr); 787 747 788 748 pCpu->SIB.Bits.Base = SIB_BASE(SIB); … … 811 771 // Mod Reg/Opcode R/M 812 772 //***************************************************************************** 813 static unsigned UseModRM(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)773 static size_t UseModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 814 774 { 815 775 unsigned vtype = OP_PARM_VTYPE(pParam->fParam); … … 894 854 if (rm == 4) 895 855 { /* SIB byte follows ModRM */ 896 UseSIB( uCodePtr, pOp, pParam, pCpu);856 UseSIB(offInstr, pOp, pParam, pCpu); 897 857 } 898 858 else … … 920 880 case 1: //effective address + 8 bits displacement 921 881 if (rm == 4) {//SIB byte follows ModRM 922 UseSIB( uCodePtr, pOp, pParam, pCpu);882 UseSIB(offInstr, pOp, pParam, pCpu); 923 883 } 924 884 else … … 933 893 case 2: //effective address + 32 bits displacement 934 894 if (rm == 4) {//SIB byte follows ModRM 935 UseSIB( uCodePtr, pOp, pParam, pCpu);895 UseSIB(offInstr, pOp, pParam, pCpu); 936 896 } 937 897 else … … 988 948 // Query the size of the ModRM parameters and fetch the immediate data (if any) 989 949 //***************************************************************************** 990 static unsigned QueryModRM( RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)950 static unsigned QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc) 991 951 { 992 952 unsigned sibinc; … … 1010 970 if (mod != 3 && rm == 4) 1011 971 { /* SIB byte follows ModRM */ 1012 *pSibInc = ParseSIB( uCodePtr, pOp, pParam, pCpu);1013 uCodePtr += *pSibInc;972 *pSibInc = ParseSIB(offInstr, pOp, pParam, pCpu); 973 offInstr += *pSibInc; 1014 974 size += *pSibInc; 1015 975 } … … 1019 979 case 0: /* Effective address */ 1020 980 if (rm == 5) { /* 32 bits displacement */ 1021 pCpu->i32SibDisp = disReadDWord(pCpu, uCodePtr);981 pCpu->i32SibDisp = disReadDWord(pCpu, offInstr); 1022 982 size += sizeof(int32_t); 1023 983 } … … 1026 986 1027 987 case 1: /* Effective address + 8 bits displacement */ 1028 pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, uCodePtr);988 pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, offInstr); 1029 989 size += sizeof(char); 1030 990 break; 1031 991 1032 992 case 2: /* Effective address + 32 bits displacement */ 1033 pCpu->i32SibDisp = disReadDWord(pCpu, uCodePtr);993 pCpu->i32SibDisp = disReadDWord(pCpu, offInstr); 1034 994 size += sizeof(int32_t); 1035 995 break; … … 1046 1006 case 0: /* Effective address */ 1047 1007 if (rm == 6) { 1048 pCpu->i32SibDisp = disReadWord(pCpu, uCodePtr);1008 pCpu->i32SibDisp = disReadWord(pCpu, offInstr); 1049 1009 size += sizeof(uint16_t); 1050 1010 } … … 1053 1013 1054 1014 case 1: /* Effective address + 8 bits displacement */ 1055 pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, uCodePtr);1015 pCpu->i32SibDisp = (int8_t)disReadByte(pCpu, offInstr); 1056 1016 size += sizeof(char); 1057 1017 break; 1058 1018 1059 1019 case 2: /* Effective address + 32 bits displacement */ 1060 pCpu->i32SibDisp = (int16_t)disReadWord(pCpu, uCodePtr);1020 pCpu->i32SibDisp = (int16_t)disReadWord(pCpu, offInstr); 1061 1021 size += sizeof(uint16_t); 1062 1022 break; … … 1071 1031 // Query the size of the ModRM parameters and fetch the immediate data (if any) 1072 1032 //***************************************************************************** 1073 static unsigned QueryModRM_SizeOnly( RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc)1033 static unsigned QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu, unsigned *pSibInc) 1074 1034 { 1075 1035 unsigned sibinc; … … 1092 1052 if (mod != 3 && rm == 4) 1093 1053 { /* 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; 1096 1056 size += *pSibInc; 1097 1057 } … … 1146 1106 //***************************************************************************** 1147 1107 //***************************************************************************** 1148 static unsigned ParseIllegal(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1149 { 1150 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1108 static size_t ParseIllegal(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1109 { 1110 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1151 1111 AssertFailed(); 1152 1112 return 0; … … 1154 1114 //***************************************************************************** 1155 1115 //***************************************************************************** 1156 static unsigned ParseModRM(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1116 static size_t ParseModRM(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1157 1117 { 1158 1118 unsigned size = sizeof(uint8_t); //ModRM byte 1159 1119 unsigned sibinc, ModRM; 1160 1120 1161 ModRM = disReadByte(pCpu, uCodePtr);1162 uCodePtr += sizeof(uint8_t);1121 ModRM = disReadByte(pCpu, offInstr); 1122 offInstr += sizeof(uint8_t); 1163 1123 1164 1124 pCpu->ModRM.Bits.Rm = MODRM_RM(ModRM); … … 1192 1152 } 1193 1153 } 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); 1198 1158 return size; 1199 1159 } 1200 1160 //***************************************************************************** 1201 1161 //***************************************************************************** 1202 static unsigned ParseModRM_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1162 static size_t ParseModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1203 1163 { 1204 1164 unsigned size = sizeof(uint8_t); //ModRM byte 1205 1165 unsigned sibinc, ModRM; 1206 1166 1207 ModRM = disReadByte(pCpu, uCodePtr);1208 uCodePtr += sizeof(uint8_t);1167 ModRM = disReadByte(pCpu, offInstr); 1168 offInstr += sizeof(uint8_t); 1209 1169 1210 1170 pCpu->ModRM.Bits.Rm = MODRM_RM(ModRM); … … 1239 1199 } 1240 1200 1241 size += QueryModRM_SizeOnly( uCodePtr, pOp, pParam, pCpu, &sibinc);1242 uCodePtr += sibinc;1201 size += QueryModRM_SizeOnly(offInstr, pOp, pParam, pCpu, &sibinc); 1202 offInstr += sibinc; 1243 1203 1244 1204 /* UseModRM is not necessary here; we're only interested in the opcode size */ … … 1247 1207 //***************************************************************************** 1248 1208 //***************************************************************************** 1249 static unsigned ParseModFence(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1209 static size_t ParseModFence(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1250 1210 { 1251 1211 ////AssertMsgFailed(("??\n")); 1252 1212 //nothing to do apparently 1253 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1213 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1254 1214 return 0; 1255 1215 } 1256 1216 //***************************************************************************** 1257 1217 //***************************************************************************** 1258 static unsigned ParseImmByte(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1218 static size_t ParseImmByte(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1259 1219 { 1260 1220 NOREF(pOp); 1261 pParam->uValue = disReadByte(pCpu, uCodePtr);1221 pParam->uValue = disReadByte(pCpu, offInstr); 1262 1222 pParam->fUse |= DISUSE_IMMEDIATE8; 1263 1223 pParam->cb = sizeof(uint8_t); … … 1266 1226 //***************************************************************************** 1267 1227 //***************************************************************************** 1268 static unsigned ParseImmByte_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1269 { 1270 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1228 static size_t ParseImmByte_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1229 { 1230 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1271 1231 return sizeof(uint8_t); 1272 1232 } 1273 1233 //***************************************************************************** 1274 1234 //***************************************************************************** 1275 static unsigned ParseImmByteSX(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1235 static size_t ParseImmByteSX(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1276 1236 { 1277 1237 NOREF(pOp); 1278 1238 if (pCpu->uOpMode == DISCPUMODE_32BIT) 1279 1239 { 1280 pParam->uValue = (uint32_t)(int8_t)disReadByte(pCpu, uCodePtr);1240 pParam->uValue = (uint32_t)(int8_t)disReadByte(pCpu, offInstr); 1281 1241 pParam->fUse |= DISUSE_IMMEDIATE32_SX8; 1282 1242 pParam->cb = sizeof(uint32_t); … … 1285 1245 if (pCpu->uOpMode == DISCPUMODE_64BIT) 1286 1246 { 1287 pParam->uValue = (uint64_t)(int8_t)disReadByte(pCpu, uCodePtr);1247 pParam->uValue = (uint64_t)(int8_t)disReadByte(pCpu, offInstr); 1288 1248 pParam->fUse |= DISUSE_IMMEDIATE64_SX8; 1289 1249 pParam->cb = sizeof(uint64_t); … … 1291 1251 else 1292 1252 { 1293 pParam->uValue = (uint16_t)(int8_t)disReadByte(pCpu, uCodePtr);1253 pParam->uValue = (uint16_t)(int8_t)disReadByte(pCpu, offInstr); 1294 1254 pParam->fUse |= DISUSE_IMMEDIATE16_SX8; 1295 1255 pParam->cb = sizeof(uint16_t); … … 1299 1259 //***************************************************************************** 1300 1260 //***************************************************************************** 1301 static unsigned ParseImmByteSX_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1302 { 1303 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1261 static size_t ParseImmByteSX_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1262 { 1263 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1304 1264 return sizeof(uint8_t); 1305 1265 } 1306 1266 //***************************************************************************** 1307 1267 //***************************************************************************** 1308 static unsigned ParseImmUshort(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1268 static size_t ParseImmUshort(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1309 1269 { 1310 1270 NOREF(pOp); 1311 pParam->uValue = disReadWord(pCpu, uCodePtr);1271 pParam->uValue = disReadWord(pCpu, offInstr); 1312 1272 pParam->fUse |= DISUSE_IMMEDIATE16; 1313 1273 pParam->cb = sizeof(uint16_t); … … 1316 1276 //***************************************************************************** 1317 1277 //***************************************************************************** 1318 static unsigned ParseImmUshort_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1319 { 1320 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1278 static size_t ParseImmUshort_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1279 { 1280 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1321 1281 return sizeof(uint16_t); 1322 1282 } 1323 1283 //***************************************************************************** 1324 1284 //***************************************************************************** 1325 static unsigned ParseImmUlong(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1285 static size_t ParseImmUlong(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1326 1286 { 1327 1287 NOREF(pOp); 1328 pParam->uValue = disReadDWord(pCpu, uCodePtr);1288 pParam->uValue = disReadDWord(pCpu, offInstr); 1329 1289 pParam->fUse |= DISUSE_IMMEDIATE32; 1330 1290 pParam->cb = sizeof(uint32_t); … … 1333 1293 //***************************************************************************** 1334 1294 //***************************************************************************** 1335 static unsigned ParseImmUlong_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1336 { 1337 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1295 static size_t ParseImmUlong_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1296 { 1297 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1338 1298 return sizeof(uint32_t); 1339 1299 } 1340 1300 //***************************************************************************** 1341 1301 //***************************************************************************** 1342 static unsigned ParseImmQword(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1302 static size_t ParseImmQword(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1343 1303 { 1344 1304 NOREF(pOp); 1345 pParam->uValue = disReadQWord(pCpu, uCodePtr);1305 pParam->uValue = disReadQWord(pCpu, offInstr); 1346 1306 pParam->fUse |= DISUSE_IMMEDIATE64; 1347 1307 pParam->cb = sizeof(uint64_t); … … 1350 1310 //***************************************************************************** 1351 1311 //***************************************************************************** 1352 static unsigned ParseImmQword_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1353 { 1354 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1312 static size_t ParseImmQword_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1313 { 1314 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1355 1315 return sizeof(uint64_t); 1356 1316 } 1357 1317 //***************************************************************************** 1358 1318 //***************************************************************************** 1359 static unsigned ParseImmV(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1319 static size_t ParseImmV(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1360 1320 { 1361 1321 NOREF(pOp); 1362 1322 if (pCpu->uOpMode == DISCPUMODE_32BIT) 1363 1323 { 1364 pParam->uValue = disReadDWord(pCpu, uCodePtr);1324 pParam->uValue = disReadDWord(pCpu, offInstr); 1365 1325 pParam->fUse |= DISUSE_IMMEDIATE32; 1366 1326 pParam->cb = sizeof(uint32_t); … … 1370 1330 if (pCpu->uOpMode == DISCPUMODE_64BIT) 1371 1331 { 1372 pParam->uValue = disReadQWord(pCpu, uCodePtr);1332 pParam->uValue = disReadQWord(pCpu, offInstr); 1373 1333 pParam->fUse |= DISUSE_IMMEDIATE64; 1374 1334 pParam->cb = sizeof(uint64_t); … … 1376 1336 } 1377 1337 1378 pParam->uValue = disReadWord(pCpu, uCodePtr);1338 pParam->uValue = disReadWord(pCpu, offInstr); 1379 1339 pParam->fUse |= DISUSE_IMMEDIATE16; 1380 1340 pParam->cb = sizeof(uint16_t); … … 1383 1343 //***************************************************************************** 1384 1344 //***************************************************************************** 1385 static unsigned ParseImmV_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1386 { 1387 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam);1345 static size_t ParseImmV_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1346 { 1347 NOREF(offInstr); NOREF(pOp); NOREF(pParam); 1388 1348 if (pCpu->uOpMode == DISCPUMODE_32BIT) 1389 1349 return sizeof(uint32_t); … … 1394 1354 //***************************************************************************** 1395 1355 //***************************************************************************** 1396 static unsigned ParseImmZ(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1356 static size_t ParseImmZ(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1397 1357 { 1398 1358 NOREF(pOp); … … 1400 1360 if (pCpu->uOpMode == DISCPUMODE_16BIT) 1401 1361 { 1402 pParam->uValue = disReadWord(pCpu, uCodePtr);1362 pParam->uValue = disReadWord(pCpu, offInstr); 1403 1363 pParam->fUse |= DISUSE_IMMEDIATE16; 1404 1364 pParam->cb = sizeof(uint16_t); … … 1409 1369 if (pCpu->uOpMode == DISCPUMODE_64BIT) 1410 1370 { 1411 pParam->uValue = (uint64_t)(int32_t)disReadDWord(pCpu, uCodePtr);1371 pParam->uValue = (uint64_t)(int32_t)disReadDWord(pCpu, offInstr); 1412 1372 pParam->fUse |= DISUSE_IMMEDIATE64; 1413 1373 pParam->cb = sizeof(uint64_t); … … 1415 1375 else 1416 1376 { 1417 pParam->uValue = disReadDWord(pCpu, uCodePtr);1377 pParam->uValue = disReadDWord(pCpu, offInstr); 1418 1378 pParam->fUse |= DISUSE_IMMEDIATE32; 1419 1379 pParam->cb = sizeof(uint32_t); … … 1423 1383 //***************************************************************************** 1424 1384 //***************************************************************************** 1425 static unsigned ParseImmZ_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1426 { 1427 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam);1385 static size_t ParseImmZ_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1386 { 1387 NOREF(offInstr); NOREF(pOp); NOREF(pParam); 1428 1388 /* Word for 16-bit operand-size or doubleword for 32 or 64-bit operand-size. */ 1429 1389 if (pCpu->uOpMode == DISCPUMODE_16BIT) … … 1435 1395 // Relative displacement for branches (rel. to next instruction) 1436 1396 //***************************************************************************** 1437 static unsigned ParseImmBRel(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1397 static size_t ParseImmBRel(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1438 1398 { 1439 1399 NOREF(pOp); 1440 pParam->uValue = disReadByte(pCpu, uCodePtr);1400 pParam->uValue = disReadByte(pCpu, offInstr); 1441 1401 pParam->fUse |= DISUSE_IMMEDIATE8_REL; 1442 1402 pParam->cb = sizeof(uint8_t); … … 1446 1406 // Relative displacement for branches (rel. to next instruction) 1447 1407 //***************************************************************************** 1448 static unsigned ParseImmBRel_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1449 { 1450 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam); NOREF(pCpu);1408 static size_t ParseImmBRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1409 { 1410 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pCpu); 1451 1411 return sizeof(char); 1452 1412 } … … 1454 1414 // Relative displacement for branches (rel. to next instruction) 1455 1415 //***************************************************************************** 1456 static unsigned ParseImmVRel(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1416 static size_t ParseImmVRel(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1457 1417 { 1458 1418 NOREF(pOp); 1459 1419 if (pCpu->uOpMode == DISCPUMODE_32BIT) 1460 1420 { 1461 pParam->uValue = disReadDWord(pCpu, uCodePtr);1421 pParam->uValue = disReadDWord(pCpu, offInstr); 1462 1422 pParam->fUse |= DISUSE_IMMEDIATE32_REL; 1463 1423 pParam->cb = sizeof(int32_t); … … 1468 1428 { 1469 1429 /* 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); 1471 1431 pParam->fUse |= DISUSE_IMMEDIATE64_REL; 1472 1432 pParam->cb = sizeof(int64_t); … … 1474 1434 } 1475 1435 1476 pParam->uValue = disReadWord(pCpu, uCodePtr);1436 pParam->uValue = disReadWord(pCpu, offInstr); 1477 1437 pParam->fUse |= DISUSE_IMMEDIATE16_REL; 1478 1438 pParam->cb = sizeof(int16_t); … … 1482 1442 // Relative displacement for branches (rel. to next instruction) 1483 1443 //***************************************************************************** 1484 static unsigned ParseImmVRel_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1485 { 1486 NOREF( uCodePtr); NOREF(pOp); NOREF(pParam);1444 static size_t ParseImmVRel_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1445 { 1446 NOREF(offInstr); NOREF(pOp); NOREF(pParam); 1487 1447 if (pCpu->uOpMode == DISCPUMODE_16BIT) 1488 1448 return sizeof(int16_t); … … 1492 1452 //***************************************************************************** 1493 1453 //***************************************************************************** 1494 static unsigned ParseImmAddr(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1454 static size_t ParseImmAddr(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1495 1455 { 1496 1456 if (pCpu->uAddrMode == DISCPUMODE_32BIT) … … 1499 1459 { 1500 1460 /* 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)); 1503 1463 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_32; 1504 1464 pParam->cb = sizeof(uint16_t) + sizeof(uint32_t); … … 1512 1472 * so we treat it like displacement. 1513 1473 */ 1514 pParam->uDisp.i32 = disReadDWord(pCpu, uCodePtr);1474 pParam->uDisp.i32 = disReadDWord(pCpu, offInstr); 1515 1475 pParam->fUse |= DISUSE_DISPLACEMENT32; 1516 1476 pParam->cb = sizeof(uint32_t); … … 1527 1487 * so we treat it like displacement. 1528 1488 */ 1529 pParam->uDisp.i64 = disReadQWord(pCpu, uCodePtr);1489 pParam->uDisp.i64 = disReadQWord(pCpu, offInstr); 1530 1490 pParam->fUse |= DISUSE_DISPLACEMENT64; 1531 1491 pParam->cb = sizeof(uint64_t); … … 1535 1495 { 1536 1496 /* far 16:16 pointer */ 1537 pParam->uValue = disReadDWord(pCpu, uCodePtr);1497 pParam->uValue = disReadDWord(pCpu, offInstr); 1538 1498 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_16; 1539 1499 pParam->cb = 2*sizeof(uint16_t); … … 1547 1507 * so we treat it like displacement. 1548 1508 */ 1549 pParam->uDisp.i16 = disReadWord(pCpu, uCodePtr);1509 pParam->uDisp.i16 = disReadWord(pCpu, offInstr); 1550 1510 pParam->fUse |= DISUSE_DISPLACEMENT16; 1551 1511 pParam->cb = sizeof(uint16_t); … … 1554 1514 //***************************************************************************** 1555 1515 //***************************************************************************** 1556 static unsigned ParseImmAddr_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1557 { 1558 NOREF( uCodePtr); NOREF(pOp);1516 static size_t ParseImmAddr_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1517 { 1518 NOREF(offInstr); NOREF(pOp); 1559 1519 if (pCpu->uAddrMode == DISCPUMODE_32BIT) 1560 1520 { … … 1587 1547 //***************************************************************************** 1588 1548 //***************************************************************************** 1589 static unsigned ParseImmAddrF(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1549 static size_t ParseImmAddrF(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1590 1550 { 1591 1551 // immediate far pointers - only 16:16 or 16:32; determined by operand, *not* address size! … … 1595 1555 { 1596 1556 // 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)); 1599 1559 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_32; 1600 1560 pParam->cb = sizeof(uint16_t) + sizeof(uint32_t); … … 1603 1563 1604 1564 // far 16:16 pointer 1605 pParam->uValue = disReadDWord(pCpu, uCodePtr);1565 pParam->uValue = disReadDWord(pCpu, offInstr); 1606 1566 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_16; 1607 1567 pParam->cb = 2*sizeof(uint16_t); … … 1610 1570 //***************************************************************************** 1611 1571 //***************************************************************************** 1612 static unsigned ParseImmAddrF_SizeOnly(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1613 { 1614 NOREF( uCodePtr); NOREF(pOp);1572 static size_t ParseImmAddrF_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1573 { 1574 NOREF(offInstr); NOREF(pOp); 1615 1575 // immediate far pointers - only 16:16 or 16:32 1616 1576 Assert(pCpu->uOpMode == DISCPUMODE_16BIT || pCpu->uOpMode == DISCPUMODE_32BIT); … … 1629 1589 //***************************************************************************** 1630 1590 //***************************************************************************** 1631 static unsigned ParseFixedReg(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1632 { 1633 NOREF( uCodePtr);1591 static size_t ParseFixedReg(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1592 { 1593 NOREF(offInstr); 1634 1594 1635 1595 /* … … 1730 1690 //***************************************************************************** 1731 1691 //***************************************************************************** 1732 static unsigned ParseXv(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1733 { 1734 NOREF( uCodePtr);1692 static size_t ParseXv(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1693 { 1694 NOREF(offInstr); 1735 1695 1736 1696 pParam->fUse |= DISUSE_POINTER_DS_BASED; … … 1755 1715 //***************************************************************************** 1756 1716 //***************************************************************************** 1757 static unsigned ParseXb(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1758 { 1759 NOREF( uCodePtr); NOREF(pOp);1717 static size_t ParseXb(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1718 { 1719 NOREF(offInstr); NOREF(pOp); 1760 1720 1761 1721 pParam->fUse |= DISUSE_POINTER_DS_BASED; … … 1780 1740 //***************************************************************************** 1781 1741 //***************************************************************************** 1782 static unsigned ParseYv(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1783 { 1784 NOREF( uCodePtr);1742 static size_t ParseYv(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1743 { 1744 NOREF(offInstr); 1785 1745 1786 1746 pParam->fUse |= DISUSE_POINTER_ES_BASED; … … 1805 1765 //***************************************************************************** 1806 1766 //***************************************************************************** 1807 static unsigned ParseYb(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1808 { 1809 NOREF( uCodePtr); NOREF(pOp);1767 static size_t ParseYb(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1768 { 1769 NOREF(offInstr); NOREF(pOp); 1810 1770 1811 1771 pParam->fUse |= DISUSE_POINTER_ES_BASED; … … 1830 1790 //***************************************************************************** 1831 1791 //***************************************************************************** 1832 static unsigned ParseTwoByteEsc(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1792 static size_t ParseTwoByteEsc(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1833 1793 { 1834 1794 PCDISOPCODE pOpcode; … … 1837 1797 1838 1798 /* 2nd byte */ 1839 pCpu->bOpCode = disReadByte(pCpu, uCodePtr);1799 pCpu->bOpCode = disReadByte(pCpu, offInstr); 1840 1800 1841 1801 /* default to the non-prefixed table. */ … … 1884 1844 } 1885 1845 1886 size += disParseInstruction( uCodePtr+size, pOpcode, pCpu);1846 size += disParseInstruction(offInstr+size, pOpcode, pCpu); 1887 1847 return size; 1888 1848 } 1889 1849 //***************************************************************************** 1890 1850 //***************************************************************************** 1891 static unsigned ParseThreeByteEsc4(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1851 static size_t ParseThreeByteEsc4(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1892 1852 { 1893 1853 PCDISOPCODE pOpcode; … … 1896 1856 1897 1857 /* 3rd byte */ 1898 pCpu->bOpCode = disReadByte(pCpu, uCodePtr);1858 pCpu->bOpCode = disReadByte(pCpu, offInstr); 1899 1859 1900 1860 /* default to the non-prefixed table. */ … … 1945 1905 } 1946 1906 1947 size += disParseInstruction( uCodePtr+size, pOpcode, pCpu);1907 size += disParseInstruction(offInstr+size, pOpcode, pCpu); 1948 1908 return size; 1949 1909 } 1950 1910 //***************************************************************************** 1951 1911 //***************************************************************************** 1952 static unsigned ParseThreeByteEsc5(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1912 static size_t ParseThreeByteEsc5(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1953 1913 { 1954 1914 PCDISOPCODE pOpcode; … … 1957 1917 1958 1918 /* 3rd byte */ 1959 pCpu->bOpCode = disReadByte(pCpu, uCodePtr);1919 pCpu->bOpCode = disReadByte(pCpu, offInstr); 1960 1920 1961 1921 /** @todo Should we take the first or last prefix byte in case of multiple prefix bytes??? */ … … 1980 1940 pOpcode = &g_InvalidOpcode[0]; 1981 1941 1982 size += disParseInstruction( uCodePtr+size, pOpcode, pCpu);1942 size += disParseInstruction(offInstr+size, pOpcode, pCpu); 1983 1943 return size; 1984 1944 } 1985 1945 //***************************************************************************** 1986 1946 //***************************************************************************** 1987 static unsigned ParseNopPause(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1947 static size_t ParseNopPause(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 1988 1948 { 1989 1949 unsigned size = 0; … … 1998 1958 pOp = &g_aMapX86_NopPause[0]; /* NOP */ 1999 1959 2000 size += disParseInstruction( uCodePtr, pOp, pCpu);1960 size += disParseInstruction(offInstr, pOp, pCpu); 2001 1961 return size; 2002 1962 } 2003 1963 //***************************************************************************** 2004 1964 //***************************************************************************** 2005 static unsigned ParseImmGrpl(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1965 static size_t ParseImmGrpl(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2006 1966 { 2007 1967 int idx = (pCpu->bOpCode - 0x80) * 8; … … 2009 1969 NOREF(pParam); 2010 1970 2011 modrm = disReadByte(pCpu, uCodePtr);1971 modrm = disReadByte(pCpu, offInstr); 2012 1972 reg = MODRM_REG(modrm); 2013 1973 … … 2017 1977 size = sizeof(uint8_t); //ModRM byte 2018 1978 2019 size += disParseInstruction( uCodePtr, pOp, pCpu);1979 size += disParseInstruction(offInstr, pOp, pCpu); 2020 1980 2021 1981 return size; … … 2023 1983 //***************************************************************************** 2024 1984 //***************************************************************************** 2025 static unsigned ParseShiftGrp2(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)1985 static size_t ParseShiftGrp2(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2026 1986 { 2027 1987 int idx; … … 2048 2008 } 2049 2009 2050 modrm = disReadByte(pCpu, uCodePtr);2010 modrm = disReadByte(pCpu, offInstr); 2051 2011 reg = MODRM_REG(modrm); 2052 2012 … … 2057 2017 size = sizeof(uint8_t); //ModRM byte 2058 2018 2059 size += disParseInstruction( uCodePtr, pOp, pCpu);2019 size += disParseInstruction(offInstr, pOp, pCpu); 2060 2020 2061 2021 return size; … … 2063 2023 //***************************************************************************** 2064 2024 //***************************************************************************** 2065 static unsigned ParseGrp3(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2025 static size_t ParseGrp3(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2066 2026 { 2067 2027 int idx = (pCpu->bOpCode - 0xF6) * 8; … … 2069 2029 NOREF(pParam); 2070 2030 2071 modrm = disReadByte(pCpu, uCodePtr);2031 modrm = disReadByte(pCpu, offInstr); 2072 2032 reg = MODRM_REG(modrm); 2073 2033 … … 2078 2038 size = sizeof(uint8_t); //ModRM byte 2079 2039 2080 size += disParseInstruction( uCodePtr, pOp, pCpu);2040 size += disParseInstruction(offInstr, pOp, pCpu); 2081 2041 2082 2042 return size; … … 2084 2044 //***************************************************************************** 2085 2045 //***************************************************************************** 2086 static unsigned ParseGrp4(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2046 static size_t ParseGrp4(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2087 2047 { 2088 2048 unsigned size = 0, modrm, reg; 2089 2049 NOREF(pParam); 2090 2050 2091 modrm = disReadByte(pCpu, uCodePtr);2051 modrm = disReadByte(pCpu, offInstr); 2092 2052 reg = MODRM_REG(modrm); 2093 2053 … … 2098 2058 size = sizeof(uint8_t); //ModRM byte 2099 2059 2100 size += disParseInstruction( uCodePtr, pOp, pCpu);2060 size += disParseInstruction(offInstr, pOp, pCpu); 2101 2061 2102 2062 return size; … … 2104 2064 //***************************************************************************** 2105 2065 //***************************************************************************** 2106 static unsigned ParseGrp5(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2066 static size_t ParseGrp5(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2107 2067 { 2108 2068 unsigned size = 0, modrm, reg; 2109 2069 NOREF(pParam); 2110 2070 2111 modrm = disReadByte(pCpu, uCodePtr);2071 modrm = disReadByte(pCpu, offInstr); 2112 2072 reg = MODRM_REG(modrm); 2113 2073 … … 2118 2078 size = sizeof(uint8_t); //ModRM byte 2119 2079 2120 size += disParseInstruction( uCodePtr, pOp, pCpu);2080 size += disParseInstruction(offInstr, pOp, pCpu); 2121 2081 2122 2082 return size; … … 2128 2088 // 2129 2089 //***************************************************************************** 2130 static unsigned Parse3DNow(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2090 static size_t Parse3DNow(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2131 2091 { 2132 2092 unsigned size = 0, modrmsize; … … 2137 2097 #endif 2138 2098 2139 unsigned ModRM = disReadByte(pCpu, uCodePtr);2099 unsigned ModRM = disReadByte(pCpu, offInstr); 2140 2100 pCpu->ModRM.Bits.Rm = MODRM_RM(ModRM); 2141 2101 pCpu->ModRM.Bits.Mod = MODRM_MOD(ModRM); 2142 2102 pCpu->ModRM.Bits.Reg = MODRM_REG(ModRM); 2143 2103 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); 2147 2107 2148 2108 pOp = (PCDISOPCODE)&g_aTwoByteMapX86_3DNow[opcode]; … … 2157 2117 } 2158 2118 2159 size += disParseInstruction( uCodePtr, pOp, pCpu);2119 size += disParseInstruction(offInstr, pOp, pCpu); 2160 2120 size += sizeof(uint8_t); //imm8_opcode uint8_t 2161 2121 … … 2164 2124 //***************************************************************************** 2165 2125 //***************************************************************************** 2166 static unsigned ParseGrp6(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2126 static size_t ParseGrp6(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2167 2127 { 2168 2128 unsigned size = 0, modrm, reg; 2169 2129 NOREF(pParam); 2170 2130 2171 modrm = disReadByte(pCpu, uCodePtr);2131 modrm = disReadByte(pCpu, offInstr); 2172 2132 reg = MODRM_REG(modrm); 2173 2133 … … 2178 2138 size = sizeof(uint8_t); //ModRM byte 2179 2139 2180 size += disParseInstruction( uCodePtr, pOp, pCpu);2140 size += disParseInstruction(offInstr, pOp, pCpu); 2181 2141 2182 2142 return size; … … 2184 2144 //***************************************************************************** 2185 2145 //***************************************************************************** 2186 static unsigned ParseGrp7(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2146 static size_t ParseGrp7(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2187 2147 { 2188 2148 unsigned size = 0, modrm, reg, rm, mod; 2189 2149 NOREF(pParam); 2190 2150 2191 modrm = disReadByte(pCpu, uCodePtr);2151 modrm = disReadByte(pCpu, offInstr); 2192 2152 mod = MODRM_MOD(modrm); 2193 2153 reg = MODRM_REG(modrm); … … 2206 2166 size = sizeof(uint8_t); //ModRM byte 2207 2167 2208 size += disParseInstruction( uCodePtr, pOp, pCpu);2168 size += disParseInstruction(offInstr, pOp, pCpu); 2209 2169 2210 2170 return size; … … 2212 2172 //***************************************************************************** 2213 2173 //***************************************************************************** 2214 static unsigned ParseGrp8(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2174 static size_t ParseGrp8(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2215 2175 { 2216 2176 unsigned size = 0, modrm, reg; 2217 2177 NOREF(pParam); 2218 2178 2219 modrm = disReadByte(pCpu, uCodePtr);2179 modrm = disReadByte(pCpu, offInstr); 2220 2180 reg = MODRM_REG(modrm); 2221 2181 … … 2226 2186 size = sizeof(uint8_t); //ModRM byte 2227 2187 2228 size += disParseInstruction( uCodePtr, pOp, pCpu);2188 size += disParseInstruction(offInstr, pOp, pCpu); 2229 2189 2230 2190 return size; … … 2232 2192 //***************************************************************************** 2233 2193 //***************************************************************************** 2234 static unsigned ParseGrp9(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2194 static size_t ParseGrp9(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2235 2195 { 2236 2196 unsigned size = 0, modrm, reg; 2237 2197 NOREF(pParam); 2238 2198 2239 modrm = disReadByte(pCpu, uCodePtr);2199 modrm = disReadByte(pCpu, offInstr); 2240 2200 reg = MODRM_REG(modrm); 2241 2201 … … 2246 2206 size = sizeof(uint8_t); //ModRM byte 2247 2207 2248 size += disParseInstruction( uCodePtr, pOp, pCpu);2208 size += disParseInstruction(offInstr, pOp, pCpu); 2249 2209 2250 2210 return size; … … 2252 2212 //***************************************************************************** 2253 2213 //***************************************************************************** 2254 static unsigned ParseGrp10(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2214 static size_t ParseGrp10(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2255 2215 { 2256 2216 unsigned size = 0, modrm, reg; 2257 2217 NOREF(pParam); 2258 2218 2259 modrm = disReadByte(pCpu, uCodePtr);2219 modrm = disReadByte(pCpu, offInstr); 2260 2220 reg = MODRM_REG(modrm); 2261 2221 … … 2266 2226 size = sizeof(uint8_t); //ModRM byte 2267 2227 2268 size += disParseInstruction( uCodePtr, pOp, pCpu);2228 size += disParseInstruction(offInstr, pOp, pCpu); 2269 2229 2270 2230 return size; … … 2272 2232 //***************************************************************************** 2273 2233 //***************************************************************************** 2274 static unsigned ParseGrp12(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2234 static size_t ParseGrp12(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2275 2235 { 2276 2236 unsigned size = 0, modrm, reg; 2277 2237 NOREF(pParam); 2278 2238 2279 modrm = disReadByte(pCpu, uCodePtr);2239 modrm = disReadByte(pCpu, offInstr); 2280 2240 reg = MODRM_REG(modrm); 2281 2241 … … 2289 2249 size = sizeof(uint8_t); //ModRM byte 2290 2250 2291 size += disParseInstruction( uCodePtr, pOp, pCpu);2251 size += disParseInstruction(offInstr, pOp, pCpu); 2292 2252 return size; 2293 2253 } 2294 2254 //***************************************************************************** 2295 2255 //***************************************************************************** 2296 static unsigned ParseGrp13(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2256 static size_t ParseGrp13(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2297 2257 { 2298 2258 unsigned size = 0, modrm, reg; 2299 2259 NOREF(pParam); 2300 2260 2301 modrm = disReadByte(pCpu, uCodePtr);2261 modrm = disReadByte(pCpu, offInstr); 2302 2262 reg = MODRM_REG(modrm); 2303 2263 if (pCpu->fPrefix & DISPREFIX_OPSIZE) … … 2310 2270 size = sizeof(uint8_t); //ModRM byte 2311 2271 2312 size += disParseInstruction( uCodePtr, pOp, pCpu);2272 size += disParseInstruction(offInstr, pOp, pCpu); 2313 2273 2314 2274 return size; … … 2316 2276 //***************************************************************************** 2317 2277 //***************************************************************************** 2318 static unsigned ParseGrp14(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2278 static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2319 2279 { 2320 2280 unsigned size = 0, modrm, reg; 2321 2281 NOREF(pParam); 2322 2282 2323 modrm = disReadByte(pCpu, uCodePtr);2283 modrm = disReadByte(pCpu, offInstr); 2324 2284 reg = MODRM_REG(modrm); 2325 2285 if (pCpu->fPrefix & DISPREFIX_OPSIZE) … … 2332 2292 size = sizeof(uint8_t); //ModRM byte 2333 2293 2334 size += disParseInstruction( uCodePtr, pOp, pCpu);2294 size += disParseInstruction(offInstr, pOp, pCpu); 2335 2295 2336 2296 return size; … … 2338 2298 //***************************************************************************** 2339 2299 //***************************************************************************** 2340 static unsigned ParseGrp15(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2300 static size_t ParseGrp15(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2341 2301 { 2342 2302 unsigned size = 0, modrm, reg, mod, rm; 2343 2303 NOREF(pParam); 2344 2304 2345 modrm = disReadByte(pCpu, uCodePtr);2305 modrm = disReadByte(pCpu, offInstr); 2346 2306 mod = MODRM_MOD(modrm); 2347 2307 reg = MODRM_REG(modrm); … … 2357 2317 size = sizeof(uint8_t); //ModRM byte 2358 2318 2359 size += disParseInstruction( uCodePtr, pOp, pCpu);2319 size += disParseInstruction(offInstr, pOp, pCpu); 2360 2320 return size; 2361 2321 } 2362 2322 //***************************************************************************** 2363 2323 //***************************************************************************** 2364 static unsigned ParseGrp16(RTUINTPTR uCodePtr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu)2324 static size_t ParseGrp16(size_t offInstr, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu) 2365 2325 { 2366 2326 unsigned size = 0, modrm, reg; 2367 2327 NOREF(pParam); 2368 2328 2369 modrm = disReadByte(pCpu, uCodePtr);2329 modrm = disReadByte(pCpu, offInstr); 2370 2330 reg = MODRM_REG(modrm); 2371 2331 … … 2376 2336 size = sizeof(uint8_t); //ModRM byte 2377 2337 2378 size += disParseInstruction( uCodePtr, pOp, pCpu);2338 size += disParseInstruction(offInstr, pOp, pCpu); 2379 2339 return size; 2380 2340 } … … 2576 2536 * @param pCpu Initialized cpu state. 2577 2537 * @param paOneByteMap The one byte opcode map to use. 2578 * @param uInstrAddr Instruction address.2579 2538 * @param pcbInstr Where to store the instruction size. Can be NULL. 2580 2539 */ 2581 static int disInstrWorker(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr,PCDISOPCODE paOneByteMap, uint32_t *pcbInstr)2540 static int disInstrWorker(PDISCPUSTATE pCpu, PCDISOPCODE paOneByteMap, uint32_t *pcbInstr) 2582 2541 { 2583 2542 /* 2584 2543 * Parse byte by byte. 2585 2544 */ 2586 size_t off Byte= 0;2545 size_t offInstr = 0; 2587 2546 for (;;) 2588 2547 { 2589 uint8_t codebyte = disReadByte ByOff(pCpu, offByte++);2548 uint8_t codebyte = disReadByte(pCpu, offInstr++); 2590 2549 uint8_t opcode = paOneByteMap[codebyte].uOpcode; 2591 2550 … … 2605 2564 case OP_INVALID: 2606 2565 if (pcbInstr) 2607 *pcbInstr = (uint32_t)off Byte;2566 *pcbInstr = (uint32_t)offInstr; 2608 2567 return pCpu->rc = VERR_DIS_INVALID_OPCODE; 2609 2568 … … 2667 2626 /* first opcode byte. */ 2668 2627 pCpu->bOpCode = codebyte; 2669 off Byte += disParseInstruction(uInstrAddr + offByte, &paOneByteMap[pCpu->bOpCode], pCpu);2628 offInstr += disParseInstruction(offInstr, &paOneByteMap[pCpu->bOpCode], pCpu); 2670 2629 break; 2671 2630 } 2672 2631 2673 pCpu->cbInstr = off Byte;2632 pCpu->cbInstr = offInstr; 2674 2633 if (pcbInstr) 2675 *pcbInstr = off Byte;2634 *pcbInstr = offInstr; 2676 2635 2677 2636 if (pCpu->fPrefix & DISPREFIX_LOCK) … … 2768 2727 } 2769 2728 2770 return disInstrWorker(pCpu, uInstrAddr,paOneByteMap, pcbInstr);2729 return disInstrWorker(pCpu, paOneByteMap, pcbInstr); 2771 2730 } 2772 2731
Note:
See TracChangeset
for help on using the changeset viewer.