Search code examples
assemblyx86code-injectionpatchmemory-address

Writing assembly code for a non-static location in memory (need absolute addresses)


I have some assembly code that I want to assemble for injection into a running process, but it's not always going to be in the same location in memory. It contains references to addresses within the program that don't change, however. I tried using jmp far and call far, but it's giving me the error "value referenced by FAR is not relocatable". How can I set it up to use absolute addresses in the binary code, so it will jump to and call the correct addresses regardless of where exactly the code is in memory?


Solution

  • How about:

             mov    reg, <fixed_address>
             call   reg