-1

I want to compile an independent binary which I'll then byte to byte copy in the context of another binary (probably using Hex Editor). I can specify the base by '/BASE' option but I wasn't able to find a way for me to say something like:

int var@0x30000; //only declare the symbol by its address in the host binary
AnArrayOfFunctions
  • 3,452
  • 2
  • 29
  • 66
  • There is no mechanism for this, the linker decides where stuff is placed and it doesn't have a way to nail anything down to a specific address. You'll have to use an OS function, like VirtualAlloc(), and keep your fingers crossed that the address is not already in use. If two processes need to agree about a memory location then use a memory-mapped file. Beware that you are asking about a solution without describing the real problem, it is a very unusual one. – Hans Passant Sep 13 '18 at 16:24
  • @HansPassant The idea is - I want to compile a part of another executable. I'll manually copy the content. – AnArrayOfFunctions Sep 13 '18 at 16:42

1 Answers1

0

To store part (or all) of one executable (or another arbitrary blob) inside another PE executable, you probably want to look into storing it as a binary resource, which you'll then read with FindResource, LoadResource, LockResource, etc.

This also saves you from using a hex editor to embed the blob into the executable--you can use the normal build tools (resource compiler and linker) to handle embedding the data into the executable.

Jerry Coffin
  • 476,176
  • 80
  • 629
  • 1,111