-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I use content.replac_at to replace the instruction? Can you provide some concrete examples? #13
Comments
Hey, any update on this? |
This is the test program I'm using to replace a instruction at an address with
But this keeps giving me the said error:
I'm not sure what this error is trying to say, the |
I think the problem is that you're passing a string instead of a This version should work, though I haven't tested it: from gtirb_rewriting import *
import gtirb_rewriting.driver
from gtirb_capstone.instructions import GtirbInstructionDecoder
import logging
import gtirb
class ReplaceInstructionPass(Pass):
def __init__(self):
self.target_address = 0x118b
def begin_module(self, module, functions, context):
decoder = GtirbInstructionDecoder(module.isa)
for function in functions:
for block in function.get_all_blocks():
offset = 0
for instruction in decoder.get_instructions(block):
if instruction.address == self.target_address:
context.replace_at(block, offset, instruction.size, Patch.from_function(self.nop_patch))
logging.debug(f"Inserted at {hex(instruction.address)}")
return
offset += instruction.size
@patch_constraints
def nop_patch(self, context):
return "nop"
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
gtirb_rewriting.driver.main(ReplaceInstructionPass) |
Thanks! this did work, Is there a better way to communicate about such issues instead of creating multiple github issues? Perhaps a dedicated space where people can ask questions or share doubts related to this tool? |
No description provided.
The text was updated successfully, but these errors were encountered: