Sets the values of the registers. @see: L{get_context} @type context: dict( str S{->} int ) @param context: Dictionary mapping register names to their values. @type bSuspend: bool @param bSuspend: C{True} to automatically suspend the thread befo
(self, context, bSuspend=False)
| 552 | return ctx |
| 553 | |
| 554 | def set_context(self, context, bSuspend=False): |
| 555 | """ |
| 556 | Sets the values of the registers. |
| 557 | |
| 558 | @see: L{get_context} |
| 559 | |
| 560 | @type context: dict( str S{->} int ) |
| 561 | @param context: Dictionary mapping register names to their values. |
| 562 | |
| 563 | @type bSuspend: bool |
| 564 | @param bSuspend: C{True} to automatically suspend the thread before |
| 565 | setting its context, C{False} otherwise. |
| 566 | |
| 567 | Defaults to C{False} because suspending the thread during some |
| 568 | debug events (like thread creation or destruction) may lead to |
| 569 | strange errors. |
| 570 | |
| 571 | Note that WinAppDbg 1.4 used to suspend the thread automatically |
| 572 | always. This behavior was changed in version 1.5. |
| 573 | """ |
| 574 | |
| 575 | # Get the thread handle. |
| 576 | dwAccess = win32.THREAD_SET_CONTEXT |
| 577 | if bSuspend: |
| 578 | dwAccess = dwAccess | win32.THREAD_SUSPEND_RESUME |
| 579 | hThread = self.get_handle(dwAccess) |
| 580 | |
| 581 | # Suspend the thread if requested. |
| 582 | if bSuspend: |
| 583 | self.suspend() |
| 584 | # No fix for the exit process event bug. |
| 585 | # Setting the context of a dead thread is pointless anyway. |
| 586 | |
| 587 | # Set the thread context. |
| 588 | try: |
| 589 | if win32.bits == 64 and self.is_wow64(): |
| 590 | win32.Wow64SetThreadContext(hThread, context) |
| 591 | else: |
| 592 | win32.SetThreadContext(hThread, context) |
| 593 | |
| 594 | # Resume the thread if we suspended it. |
| 595 | finally: |
| 596 | if bSuspend: |
| 597 | self.resume() |
| 598 | |
| 599 | def get_register(self, register): |
| 600 | """ |
no test coverage detected