Newsgroups: comp.sys.atari.st.tech
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!gaak!jpexg
From: jpexg@gaak.lcs.mit.edu (John Purbrick)
Subject: Re: How store extra data at the end of an executable?
Message-ID: <1991Apr8.042056.12877@mintaka.lcs.mit.edu>
Sender: news@mintaka.lcs.mit.edu
Organization: MIT Laboratory for Computer Science
References: <5796@mcrware.UUCP> <615@uqcspe.cs.uq.oz.au>
Date: Mon, 8 Apr 91 04:20:56 GMT
Lines: 37

>In <5796@mcrware.UUCP> erik@mcrware.UUCP (Erik Johnson) writes:
>
>Here is what I would like to do.  I would like to append a picture file to the
>end of my executable file. In this case, the extra data is a picture file that
>is the menu for my program. Once a program is loaded into memory, is it closed
>and all file offset information lost, or is there a way I can start reading
>data from the file where the program data left off.

I've done this successfully storing a SMALL amount of data holding default
settings for a printer-driver program. It could probably be expanded though.
The main point is that an executable file is like any other; it gets loaded
into memory to run, but if you can find it on disk or wherever you can modify
it at will, as long as you don't damage it.

What I did was to start the program with a function which is never called.
This contains any "password" you want, encoded into an ASM block.
So:

my_data(){
	asm{	DC.B "The password"
		DC.B "Enough space to store what you need"
}	}

The program opens its own file (the_prog.prg or whatever) and searches for 
the string "The password"; since function my_data is near the start, this 
doesn't take long. Then the subsequent data can be read or written. The data
and password, which obviously aren't executable themselves, never screw
anything up because the function is never called as a function. It's a kludge
but it's fairly simple and it works.

ONe problem for the stated application is that the program would have to know
how to find itself and what its name is, in order to do the searching. Perhaps
you could use the principle of a non-executed block to store your file as data,
and give the program a pointer into it?

John Purbrick
jpexg@lcs.mit.edu
