Changeset 41770 in vbox
- Timestamp:
- Jun 15, 2012 7:34:43 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PATM.cpp
r41768 r41770 549 549 if (pDisInfo->fReadFlags & PATMREAD_ORGCODE) 550 550 { 551 for (;;) 552 { 553 int rc = PATMR3QueryOpcode(pDisInfo->pVM, (RTGCPTR32)pDis->uInstrAddr + offInstr, &pDis->abInstr[offInstr]); 554 if (RT_FAILURE(rc)) 555 break; /* VERR_PATCH_NOT_FOUND */ 556 offInstr++; 557 cbMinRead--; 558 if (cbMinRead == 0) 551 size_t cbRead = cbMaxRead; 552 RTUINTPTR uSrcAddr = pDis->uInstrAddr + offInstr; 553 int rc = PATMR3ReadOrgInstr(pDisInfo->pVM, pDis->uInstrAddr + offInstr, &pDis->abInstr[offInstr], cbRead, &cbRead); 554 if (RT_SUCCESS(rc)) 555 { 556 if (cbRead >= cbMinRead) 559 557 { 560 pDis->cbCachedInstr = offInstr ;558 pDis->cbCachedInstr = offInstr + cbRead; 561 559 return VINF_SUCCESS; 562 560 } 563 cbMaxRead--; 561 562 cbMinRead -= cbRead; 563 cbMaxRead -= cbRead; 564 offInstr += cbRead; 565 uSrcAddr += cbRead; 564 566 } 565 567 … … 586 588 else 587 589 { 588 /* pbInstrHC is the base address; adjust according to the GC pointer. */ 590 /* 591 * pbInstrHC is the base address; adjust according to the GC pointer. 592 * 593 * Try read the max number of bytes here. Since the disassembler only 594 * ever uses these bytes for the current instruction, it doesn't matter 595 * much if we accidentally read the start of the next instruction even 596 * if it happens to be a patch jump or int3. 597 */ 589 598 uint8_t const *pbInstrHC = pDisInfo->pbInstrHC; AssertPtr(pbInstrHC); 590 599 pbInstrHC += uSrcAddr - pDisInfo->pInstrGC; 591 600 592 memcpy(&pDis->abInstr[offInstr], pbInstrHC, cbMinRead); 593 offInstr += cbMinRead; 601 size_t cbMaxRead1 = PAGE_SIZE - (uSrcAddr & PAGE_OFFSET_MASK); 602 size_t cbMaxRead2 = PAGE_SIZE - ((uintptr_t)pbInstrHC & PAGE_OFFSET_MASK); 603 size_t cbToRead = RT_MIN(cbMaxRead1, RT_MAX(cbMaxRead2, cbMinRead)); 604 if (cbToRead > cbMaxRead) 605 cbToRead = cbMaxRead; 606 607 memcpy(&pDis->abInstr[offInstr], pbInstrHC, cbToRead); 608 offInstr += (uint8_t)cbToRead; 594 609 } 595 610
Note:
See TracChangeset
for help on using the changeset viewer.