angr / angrop

BSD 2-Clause "Simplified" License
606 stars 71 forks source link

Moving register values #58

Closed truekonrads closed 9 months ago

truekonrads commented 1 year ago

Question

Hello,

I was wondering if there's an example where I can move register values e.g. rop.set_regs(eax="ecx")

Kyle-Kyle commented 1 year ago

I think the functionality is not supported yet. I'll implement it soon

CinnaTech commented 9 months ago

Will this feature be implemented soon?

Kyle-Kyle commented 9 months ago

It seems that many people want this feature. I'll implement it in a few days. :)

Kyle-Kyle commented 9 months ago

it is implemented in this PR: https://github.com/angr/angrop/pull/71 An example use case is included in CI: test_chainbuilder.py -> test_reg_move

    chain = rop.set_regs(ecx=0x42424242)
    chain += rop.set_regs(ebx=0x41414141, preserve_regs=['ecx'])
    chain += rop.move_regs(edx='ebx', eax='ecx')
    state = chain.exec()
    assert state.regs.eax.concrete_value == 0x42424242
    assert state.regs.edx.concrete_value == 0x41414141
Kyle-Kyle commented 9 months ago

Please let me know if you find cases that break the move_regs API. Thanks!

Kyle-Kyle commented 9 months ago

close this issue as the PR is merged. But please feel free to reopen it if you find any issues in it. Thank you very much!