-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Conversation
when the patched function address is the tail of memory page, the patched code touches two pages. so we must make the two pages writable.
Thanks, that sounds logical. Same change is necessary for xposedtest.cpp as well, but I will take care of this while merging. Just one question: Is size_t better for address calculations than int? |
I have looked through the native Android code a bit.. int and size_t seem to be wildly mixed here. I also found uintptr_t, which seems to match best. What do you think? Also, isn't the check off by one? For simplicitly, let's assume PAGESIZE=10. If function=7 and len=3, the replacement code would go into bytes 7,8 and 9. However, the check would be: |
|
I afraid that if the next page is a writable data segment, we mprotect both of them with out PRO_WRITE at the end. it will crash later, when program write data to the address which is in the next page. |
as the code style, I think the uint_ptr is better :D |
For simplicitly, let's assume PAGESIZE=10. If function=7 and len=3, the replacement code would go into bytes 7,8 and 9. However, the check would be: if (0+10 <= 7+3)
I have used the opportunity to change a few more things. Instead of casting back and forth all the time, uintptr_t is now used for arithmetics and only for the actual memory operations it's casted to void*. Also change the size parameters to size_t. |
Great! |
when the patched function address is the tail of memory page, the
patched code touches two pages. so we must make the two pages writable.