Skip to content
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

Some question for “thumb2” instruction #4

Closed
rockman1949 opened this issue Oct 26, 2015 · 3 comments
Closed

Some question for “thumb2” instruction #4

rockman1949 opened this issue Oct 26, 2015 · 3 comments

Comments

@rockman1949
Copy link

This is amazing work!
I have some question for you after I dig into the code.

  1. https://github.com/mar-v-in/ArtHook/blob/master/lib/src/main/java/de/larma/arthook/instrs/Thumb2.java#45. why you use "ip" register for cmp?
  2. https://github.com/mar-v-in/ArtHook/blob/master/lib/src/main/java/de/larma/arthook/instrs/Thumb2.java#47. You annotation “bne next”, but I decode the “0x40, (byte) 0xf0, 0x09, (byte) 0x80,” it was mean "bne Included method name on 'Method not found exception' #9". But 9 wasn't an instruction. Maybe I was made a mistake, Could you explain it more detail for me. I know this “bne” shouldn't happen, but I still confused with this code!
    Thank you very much!
@rockman1949
Copy link
Author

As questtion 2, There was a mistake, “0x40, (byte) 0xf0, 0x09, (byte) 0x80" it was mean "bne #18", so it will jump to next "TargetJump", am I right?

@mar-v-in
Copy link
Owner

Question 1: We need to store the value to compare in a register. ip ("intra-procedural scratch register") is the only register that can be destroyed between method calls. Using ip means we don't need to backup the register, which is very fortunate as we can't guarantee that we can write to stack at this position without causing a stack corruption/overflow.

Question 2: Yes, your second comment is right about this statement. "next" is probably not perfect as comment.

@rockman1949
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants