Start binary emulation. Args: begin : emulation starting address end : emulation ending address timeout : limit emulation to a specific amount of time (microseconds); unlimited by default count : limit emulation to a specific amount of
(self, begin: Optional[int] = None, end: Optional[int] = None, timeout: int = 0, count: int = 0)
| 559 | ############### |
| 560 | |
| 561 | def run(self, begin: Optional[int] = None, end: Optional[int] = None, timeout: int = 0, count: int = 0): |
| 562 | """Start binary emulation. |
| 563 | |
| 564 | Args: |
| 565 | begin : emulation starting address |
| 566 | end : emulation ending address |
| 567 | timeout : limit emulation to a specific amount of time (microseconds); unlimited by default |
| 568 | count : limit emulation to a specific amount of instructions; unlimited by default |
| 569 | """ |
| 570 | |
| 571 | # replace the original entry point, exit point, timeout and count |
| 572 | self.entry_point = begin |
| 573 | self.exit_point = end |
| 574 | self.timeout = timeout |
| 575 | self.count = count |
| 576 | |
| 577 | # init debugger (if set) |
| 578 | debugger = select_debugger(self._debugger) |
| 579 | |
| 580 | if debugger: |
| 581 | debugger = debugger(self) |
| 582 | |
| 583 | # patch binary |
| 584 | self.do_bin_patch() |
| 585 | |
| 586 | self.write_exit_trap() |
| 587 | # emulate the binary |
| 588 | self.os.run() |
| 589 | |
| 590 | # run debugger |
| 591 | if debugger and self.debugger: |
| 592 | debugger.run() |
| 593 | |
| 594 | def patch(self, offset: int, data: bytes, target: Optional[str] = None) -> None: |
| 595 | """Volatilely patch binary and libraries with arbitrary content. |