Sample function to show registering a plugin menu item for a range of bytes. Also possible: register register_for_address register_for_function
(view, start, length)
| 23 | |
| 24 | |
| 25 | def write_breakpoint(view, start, length): |
| 26 | """Sample function to show registering a plugin menu item for a range of bytes. Also possible: |
| 27 | register |
| 28 | register_for_address |
| 29 | register_for_function |
| 30 | """ |
| 31 | bkpt_str = {"x86": "int3", "x86_64": "int3", "armv7": "bkpt", "aarch64": "brk #0", "mips32": "break"} |
| 32 | |
| 33 | if view.arch.name not in bkpt_str: |
| 34 | log_error("Architecture %s not supported" % view.arch.name) |
| 35 | return |
| 36 | |
| 37 | bkpt, err = view.arch.assemble(bkpt_str[view.arch.name]) |
| 38 | if bkpt is None: |
| 39 | log_error(err) |
| 40 | return |
| 41 | view.write(start, bkpt * length // len(bkpt)) |
| 42 | |
| 43 | |
| 44 | PluginCommand.register_for_range("Convert to breakpoint", "Fill region with breakpoint instructions.", write_breakpoint) |