How do i encode an instruction #367
-
Continuation of #363 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi, the register shouldn't make a difference here. I don't see any issue in encoding your instruction (if you can control at which place in memory the instruction is emitted). What you see in the disassembly here is the absolute address while the 32-bit displacement of a RIP-rel instruction is relative to the position of the instruction itself (to the end of the instruction to be precise). Being able to address memory > +/-2^31 was basically the reason for inventing the RIP-rel addressing mode. You need to convert your absolute address to a relative one based on the emitted instruction position and it's length. Sadly Zydis currently does not provide a way to help you with that (but @mappzor is working on it), so you will need to patch the displacement by your own after the instruction has been encoded. Feel free to ask again, if you are not sure how to do it. |
Beta Was this translation helpful? Give feedback.
-
That depends where you want to put your new code. There are two solutions:
|
Beta Was this translation helpful? Give feedback.
That depends where you want to put your new code. There are two solutions: