Author Topic: How do I set compiling location?  (Read 5448 times)

Offline ben321

  • Full Member
  • **
  • Posts: 182
How do I set compiling location?
« on: March 21, 2015, 02:43:50 AM »
Is there a compiler directive for doing this?
For example
Code: [Select]
jmp 0x12345678
set compiling location 0x12345678
mov eax,0x12121212

What this would do is write a jump for the executing program to go to a certain addres, then it would move the compiler's own pointer for compiling opcodes to that new location, then it would compile some more code at this new location.

Is there a way to do this?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: How do I set compiling location?
« Reply #1 on: March 21, 2015, 06:59:21 AM »
I'm not aware of any easy way to do it. In "-f bin" mode, with arbitrary section names, and the judicious use of "start=" (if you want it padded to the new location) and "vstart=" (if you just want to start using new numbers), you might be able to accomplish something like what you describe.

What do you have in mind? You're gonna do this in Windows? What would be the ummm... "object" of this?

Best,
Frank


Offline ben321

  • Full Member
  • **
  • Posts: 182
Re: How do I set compiling location?
« Reply #2 on: March 21, 2015, 01:58:08 PM »
I'm not aware of any easy way to do it. In "-f bin" mode, with arbitrary section names, and the judicious use of "start=" (if you want it padded to the new location) and "vstart=" (if you just want to start using new numbers), you might be able to accomplish something like what you describe.

What do you have in mind? You're gonna do this in Windows? What would be the ummm... "object" of this?

Best,
Frank

I was thinking of possibly a obfuscation/copyprotection scheme where I would set the location of the compiler to compile some code in a location well after the location (possibly like a few kilobytes after) the end of where most of my code would be, then place a few key lines of code there, then jump back to where I left off, and finish placing my code there. Then when my program needs to run a specific piece of code (the code that I placed in this special location) I could easily place a "jmp" command there in my main code. By so placing key pieces of code many kilobytes away from the main code, my plan is to make it so as to confuse decompiler programs, to make reverse engineering my software more difficult. Not all decompilers/disassemblers follow jmps. Some of them simply read from the first line of code up to the apparant end of the program (where there's a "ret" with no matching "call", or there's a call to "ExitProcess"), or else they read from the first line of code up to where there's a huge number of consecutive 0x00 bytes and assume that's the end. As a result, placing parts of your code WELL PAST the end of your main code can confuse some disassemblers.