[fpc-pascal] Editing resource of executable

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Thu Aug 30 10:07:22 CEST 2012

Krzysztof wrote:
> Hi,
> I have some problem. Example:
> I created some exec using free pascal and lazarus. It is placed on
> http server. User in webbrowser click download, and server should
> attach link from where it is clicked into this exec. So when user run
> downloaded exec, this exec can read this link. The idea is that
> everything is in one file (and must be). My question is, exists any
> commandline tool which can edit executable file for edit some resource
> (like ResEdit or Restorator for Windows) which can be used by http
> server? By resource I mean some const (or resourcestring section, free
> pascal binary can replace it in runtime, can some tool do this same
> outside?). So main problem is in server side. Finally we can use free
> pascal compiler and compile modified source by server, but this
> solution we use when everything fails (admins, restrictions etc.). I
> need this only for windows (for now), so I'm considering some
> commandline installer makers like InnoSetup or something. Any idea?

Let's see if we can get this straight. What you're basically looking for 
is something which can take one or more of the environment variables (or 
equivalent) that the web server knows about, and use it to "brand" the 

This is probably going to be very much specific to the version of 
Windows that the client is running: it used to be possible to simply 
append data to an executable since there was an unambiguous file length 
in the header, but this obviously won't work if the file is checksummed 
or signed.

Unless you're doing it by re-linking the program when sending it to the 
client, this is probably outside the remit of FPC and you'd be better 
off looking for non-specific tools.

In any case, you've obviously got the problem of copying the unbranded 
binary to a working area before manipulating it, unless you can 
serialise the CGI or whatever you're using.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list