delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/05/20:46:23

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Appending data to executables?
Date: Sun, 28 Sep 1997 13:41:24 +0100
Organization: None
Distribution: world
Message-ID: <RwLHYBA0BlL0EwBr@talula.demon.co.uk>
References: <342C5B94 AT relay DOT probe DOT co DOT uk> <60ktrj$qv7 AT freenet-news DOT carleton DOT ca>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 24
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Paul Derbyshire writes:
>Just how do you do such appending? Make a C program for editing the data
>that somehow knows where the exe ends and the data begins, to fseek to
>there and read/write? How about when the exe needs to read its own
>attached stuff back, or modify it? Same thing? Won't this cause errors in
>windows and other file sharing environments when the exe will be "in use"?

To add the data, just open up the file, seek to the end, and write out
whatever you want. Then ignore your virus checker when it says there is
some suspicious looking stuff tagged onto the end of the file :-)
Actually most virus checkers these days are smart enough to realise that
the extra data doesn't look like code, but a few years ago they really
got upset about programs that did this!

To read it back in, you need some way of telling where it starts, such
as an index on the very end of the file. But basically it's the same
idea, open the file, seek to the position of your data, and read it in.
Plus in the case of Allegro, some jiggery pokery so that the appended
data can be compressed...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019