Recent

Author Topic: /STUB compiler argument?  (Read 2451 times)

_Tom_

  • Newbie
  • Posts: 1
/STUB compiler argument?
« on: October 03, 2015, 07:38:44 pm »
Is it currently possible to use this function in Freepascal compiler/linker? https://msdn.microsoft.com/en-us/library/7z0585h5.aspx
Basically it gives you the ability to customize the file header and create double EXEs with both PE and MZ parts in 1 EXE.  Currently I'm doing it via hex editing but its very time consuming to do it every release.
I'm using win32 compiler and running Lazarus in win32.
If it isn't possible are there any other programs that you can use as linkers to link your .o files or any way to use microsoft's linker together with your objects?

Jonas Maebe

  • Hero Member
  • *****
  • Posts: 1058
Re: /STUB compiler argument?
« Reply #1 on: October 04, 2015, 11:15:12 am »
There's an open feature request for this at http://bugs.freepascal.org/view.php?id=9429 , but as you can see we don't have plans to add support for this ourselves.

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: /STUB compiler argument?
« Reply #2 on: October 05, 2015, 04:32:08 am »
The task itself isn't complicated.

The input Dos executable needs to be prepared for PE header.
Thus the Dos header must be extended up to $40 bytes (the last four bytes must point to the valid PE header)
The relocation table must start from $40, but copied as is (no changes)
If needed the code section must be moved to satisfy paragraph (16-bytes) boundary.

 

TinyPortal © 2005-2018