Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi: Set ImageBase bigger than 32-bit (for 64-bit Windows application)

I have been playing with the {$IMAGEBASE} directive in Delphi but I can see that I can only put a value lower than $FFFFFFFF (32-bit).

I'm compiling as x64 and I need to set an image base bigger than 32-bit but Delphi ignores the higher 32-bit DWORD in my 64-bit ImageBase.

Has anyone managed to set a value higher than $FFFFFFFF as ImageBase for Delphi?

I need it because I need to test my application in "high" ImageBase (due to some hook tests, etc)

Thanks!

like image 385
raff Avatar asked Feb 05 '23 06:02

raff


1 Answers

The Delphi linker does not support large image base, although there are new PE optional headers that allow large image base values to be specified.

So I think that until Embarcadero introduce any such functionality, you would need to use a third party tool to rebase the executable file after it has been built. For instance EDITBIN with the /REBASE option from the MS toolchain.

I took a simple 64 bit VCL program, built with XE7, and rebased it like this:

editbin /rebase:base=0xffffff0000 Project1.exe

I confirmed using Process Hacker that the image base was indeed as specified.

enter image description here

like image 80
David Heffernan Avatar answered Feb 13 '23 13:02

David Heffernan