(OT) Adding data to exe files

Two simple questions. (Thought this was a good place of knowledge even
though it might nog be SDL specific, but can be used by SDL programmers to
store imagedata etc)

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back, will
    the exe still run as normal?

  2. This is really OT, but prehaps someone can give me a guiding finger. Is
    it possible to place, for example, a PDF file in memory and starting Adobe
    Acrobat and having it load the pdf from memory? (In Windows)

Best regards
Daniel Liljeberg

p.s.
Plz, don’t flame me… I have already punished myself for this OT post_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail

Two simple questions. (Thought this was a good place of knowledge
even though it might nog be SDL specific, but can be used by SDL
programmers to store imagedata etc)

  1. If I add imagedata to the end of an exe file, by just opening it
    in binary format and putting the imagefile in binaryformat in the
    back, will the exe still run as normal?

That’s probably OS dependent, but AFAIK, most executable loaders
consider only what’s explicitly referenced - any other data is
silently ignored.

  1. This is really OT, but prehaps someone can give me a guiding
    finger. Is it possible to place, for example, a PDF file in memory
    and starting Adobe Acrobat and having it load the pdf from memory?
    (In Windows)

Well, that would depend on Acrobat, I think. Dunno if you can do this
on Win32, but to pass memory data as a file to another application, I
think you’d have to make it a shared memory block, and then you’d
need some OS feature that lets fopen() (or equivalent) do I/O to/from
shared memory blocks as if they were files.

It would probably be a lot easier and a lot more portable to just
write your data to a file in the temp directory and have Acrobat read
it from there…

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Wednesday 17 March 2004 12.50, Damien Damien wrote:

Damien Damien wrote:

Two simple questions. (Thought this was a good place of knowledge even
though it might nog be SDL specific, but can be used by SDL programmers
to store imagedata etc)

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back,
    will the exe still run as normal?

Most executable formats (including the PE format used on Windows, and
the ELF format used by most UNIXy systems) let you embed “other” data
inside an executable in a standard way, and most operating systems have
support for accessing it. Look up “resources” or something similar on
http://msdn.microsoft.com/ and you’ll probably find lots of details.

On the other hand, there’s something to be said for leaving your data
outside the executable… it’s much easier to tweak and refine (and
update, once it’s out in the wild) your data without rebuilding the
executable.

  1. This is really OT, but prehaps someone can give me a guiding finger.
    Is it possible to place, for example, a PDF file in memory and starting
    Adobe Acrobat and having it load the pdf from memory? (In Windows)

I don’t know, but the Acrobat SDKs can probably answer this:

http://partners.adobe.com/asn/tech/pdf/acrobatsdks.jsp

Plz, don’t flame me… I have already punished myself for this OT post

Note that both of your questions result in non-portable code; one of
SDL’s greatest features is how it makes it easier for you to write
portable media applications…

Also, there’s probably a USENET newsgroup for self-punishment fans. :-)–
Chris Herborth (@Chris_Herborth)
Potestatem Obscuri Lateris nescitis

To clearify a bit. I want do do this AFTER the exe is compiled. So I have a
working exe file and then adding data later… Let me give an example to
show you the use. I could take a exe file, put it in another exe file that
is alreade programmed to Open a specific URL in a browser and then writing
the other exe to file and running it.

Best regards
Daniel Liljeberg>From: Chris Herborth

Reply-To: sdl at libsdl.org
To: sdl at libsdl.org
Subject: Re: [sdl-lists] [SDL] (OT) Adding data to exe files
Date: Wed, 17 Mar 2004 07:31:27 -0500

Damien Damien wrote:

Two simple questions. (Thought this was a good place of knowledge even
though it might nog be SDL specific, but can be used by SDL programmers to
store imagedata etc)

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back, will
    the exe still run as normal?

Most executable formats (including the PE format used on Windows, and the
ELF format used by most UNIXy systems) let you embed “other” data inside an
executable in a standard way, and most operating systems have support for
accessing it. Look up “resources” or something similar on
http://msdn.microsoft.com/ and you’ll probably find lots of details.

On the other hand, there’s something to be said for leaving your data
outside the executable… it’s much easier to tweak and refine (and update,
once it’s out in the wild) your data without rebuilding the executable.

  1. This is really OT, but prehaps someone can give me a guiding finger. Is
    it possible to place, for example, a PDF file in memory and starting Adobe
    Acrobat and having it load the pdf from memory? (In Windows)

I don’t know, but the Acrobat SDKs can probably answer this:

http://partners.adobe.com/asn/tech/pdf/acrobatsdks.jsp

Plz, don’t flame me… I have already punished myself for this OT post

Note that both of your questions result in non-portable code; one of SDL’s
greatest features is how it makes it easier for you to write portable media
applications…

Also, there’s probably a USENET newsgroup for self-punishment fans. :slight_smile:


Chris Herborth (chrish at pobox.com)
Potestatem Obscuri Lateris nescitis


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Mvh
Daniel Liljeberg

Daniel Liljeberg
Vaniljgatan 14
424 45 Angered
031-3308167 / 0708-809893
"Welcome To Yesterdays Future"


MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus

  1. If I add imagedata to the end of an exe file, by just opening it
    in binary format and putting the imagefile in binaryformat in the
    back, will the exe still run as normal?

That’s probably OS dependent, but AFAIK, most executable loaders
consider only what’s explicitly referenced - any other data is
silently ignored.

oh yes, in linux and windows it works fine!

Damien Damien wrote:

Two simple questions. (Thought this was a good place of knowledge even
though it might nog be SDL specific, but can be used by SDL
programmers to store imagedata etc)

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back,
    will the exe still run as normal?

Yes. This is how many 4k/64k demos work. The data is compressed and
placed at the end of the file and loaded when required.

Just look at the following sites, there are some tutorials there if I’m not
wrong. Just look into the diskmags.

http://pain.scene.org/
http://www.hugi.de/

Hugi seems offline at the moment, just try this links in the meantime.
They aren’t updated but they may provide the examples you’re after.

http://www.hugi.scene.org
http://www.pouet.net/prod.php?which=10807

  1. This is really OT, but prehaps someone can give me a guiding
    finger. Is it possible to place, for example, a PDF file in memory and
    starting Adobe Acrobat and having it load the pdf from memory? (In
    Windows)

Not sure, but the Acrobat OCX control might allow it.

Cheers,
Paulo

That’s probably OS dependent, but AFAIK, most executable loaders
consider only what’s explicitly referenced - any other data is
silently ignored.

Hmmm, but what about antivirus software? These concern me…

Ing. Gabriel Gambetta
ARTech - GeneXus Development Team
ggambett at artech.com.uy

Damien Damien wrote:

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back,
    will the exe still run as normal?

You can also include the images in the executable as C sources doing a
dump of the image source or using an ASCII image format like XPM that is
pratically a C header.

Bye,
Gabry

No there isnt’!

Yes there is!

No there ISN’T!

Yes there IS!

NO THERE ISN’T!

… wait… I thought you were talking about an argument newsgroup

:wink:

To get semi-back-on-topic, I think a good mix of the two worlds
(easy-to-tweak data, plus putting-data-on-your-EXE) would be to use
some kind of Makefile to build the /final/ product.

In the meantime, for development, read the data from the files directly.

I suppose that’d require having two ways of ‘getting at the data’
(either via filesystem, or ‘check the end of my EXE’), but that’s when
you go and write your own “open_file()” function :slight_smile:

-bill!On Wed, Mar 17, 2004 at 07:31:27AM -0500, Chris Herborth wrote:

Also, there’s probably a USENET newsgroup for self-punishment fans. :slight_smile:

Serious antivirus software should indeed complain about executables
containing code to mess with binary files - but you might get away
with it if you only open for reading…

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Wednesday 17 March 2004 14.38, Gabriel Gambetta wrote:

That’s probably OS dependent, but AFAIK, most executable loaders
consider only what’s explicitly referenced - any other data is
silently ignored.

Hmmm, but what about antivirus software? These concern me…

Chris Herborth wrote:

Damien Damien wrote:

Two simple questions. (Thought this was a good place of knowledge even
though it might nog be SDL specific, but can be used by SDL
programmers to store imagedata etc)

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back,
    will the exe still run as normal?

Most executable formats (including the PE format used on Windows, and
the ELF format used by most UNIXy systems) let you embed “other” data
inside an executable in a standard way, and most operating systems have
support for accessing it. Look up “resources” or something similar on
http://msdn.microsoft.com/ and you’ll probably find lots of details.

On the other hand, there’s something to be said for leaving your data
outside the executable… it’s much easier to tweak and refine (and
update, once it’s out in the wild) your data without rebuilding the
executable.

http://zziplib.sf.net has some pointers to build an sfx-type zip archive
with an exe part at offset zero. The data in the zip archive can be
openend transparently, the magic open/read functions will overlay an
outside data tree with the internal data tree of the zip archive. That
makes it easy to modify data during development and ship out a
single binary. And all the access is done in a way of normal stdio,
and the “binary format” can be easily handled with lots of tools, where
the exe header is simply at the head and the zip trailer at the end.

cheers,
– guido http://google.de/search?q=guidod
GCS/E/S/P C++/++++$ ULHS L++w- N++@ s+:a d(±) r+@>+++ y++

  1. If I add imagedata to the end of an exe file, by just opening it in
    binary format and putting the imagefile in binaryformat in the back, will
    the exe still run as normal?

Yes in Windows. (I don’t know in other platforms)
With this way, runs all self-extract programs in Windows.
You must add a 4-byte reference ( fseek(XXXX, SEEK_END) ) in the
end of executable file.

But it is very stupid, because you must copy the image in the end of file at
every linking

I add data to exe in my setup program. I just add data to the end of
file and last 4 bytes is offset so the code is “somehow” portable and i
it’s not necessary to look in exe header.

mao

nbs at sonic.net 17.3.2004 15:53 >>>
Also, there’s probably a USENET newsgroup for self-punishment fans.
:slight_smile:

No there isnt’!

Yes there is!

No there ISN’T!

Yes there IS!

NO THERE ISN’T!

… wait… I thought you were talking about an argument newsgroup

:wink:

To get semi-back-on-topic, I think a good mix of the two worlds
(easy-to-tweak data, plus putting-data-on-your-EXE) would be to use
some kind of Makefile to build the /final/ product.

In the meantime, for development, read the data from the files directly.

I suppose that’d require having two ways of ‘getting at the data’
(either via filesystem, or ‘check the end of my EXE’), but that’s when
you go and write your own “open_file()” function :slight_smile:

-bill!On Wed, Mar 17, 2004 at 07:31:27AM -0500, Chris Herborth wrote:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl