Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c++ visual studio 2010 exe in resource get Rebased?

Has anyone noticed that if you import an exe as resource it gets rebased and also seems that its PE header gets rebuilt?

There are times that this is irritating. Does anybody knows how to disable the rebasing!?

steps to reproduce in c++:

1) compile a hello world and manually set its base address (in properties) to lets say 0x1000000

2) make a second project and include the hello world into resources. Also manually set its base address as above.

3) build second project

4) extract the exe from resources and check it with a Pe editor! it gets set back to 0x400000. Why?!

like image 939
Ray Avatar asked Sep 27 '11 05:09

Ray


1 Answers

How are you including the EXE as a resource into the second project?

Using these defines:

#define BINFILE 222
#define IDR_MYFILE 101

If I reference the executable in my .rc file as pointing to the original file, e.g.:

IDR_MYFILE BINFILE "S:\\mysource\\t1\\Release\\t1.exe"

Then, upon extraction, my embedded EXE resource is not rebased, but maintains what I had built it with.

like image 197
Joe Avatar answered Nov 08 '22 21:11

Joe