🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #238

Re: changes to exe (binary) file

#238
From: Walter Bright
Date: Tue, 04 Aug 1992 21:05
21 lines
1639 bytes
In article <1992Jul30.152020.8261@menudo.uh.edu> cosc16to@menudo.uh.edu (Andy Hakim) writes:
/I had written a shareware program that writes changes directly to the
/program file.  Here's how:  create a data structure holding all
/information you wish to change ( D in example), this allows all pertinent
/data to be stored in one place, and it can easily be read/written to disk.
/To figure out the offset:  (DEFAULT_OFFSET in example)  compile the
/program, then use a program such as LIST to scan for a sequence of
/matching bytes ( 100 118 138 )  The HEX DUMP mode of LIST is handy.

This is doing it the hard way. The easy way is to simply get the far
pointer to the static data, i.e.:
	void _far *pdata = &data_structure;
Now, subtract the value of _psp from the segment of pdata. Convert
pdata to an offset by the usual (seg<<16)+offset rule. Open the
EXE file, and read the header. There will be an offset to the start of
the load image. Add that to your computed offset, and you have the
offset into the EXE file of data_structure!

For segmented executables, it is a little more complex, but the technique
is the same, and you don't need to fiddle with .MAP files or search the
file for signatures.
Technical Details
Message-ID: <872@nazgul.UUCP>
Path: arc1-ca.pugleaf.net!sparky!uunet!pilchuck!fnx!nazgul!bright
References: <1992Jul29.125540.7401@hou.amoco.com> <1992Jul30.152020.8261@menudo.uh.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!pilchuck!fnx!nazgul!bright
From: bright@nazgul.UUCP (Walter Bright)
Newsgroups: comp.os.msdos.programmer
Subject: Re: changes to exe (binary) file
Message-ID: <872@nazgul.UUCP>
Date: 4 Aug 92 21:05:23 GMT
References: <1992Jul29.125540.7401@hou.amoco.com> <1992Jul30.152020.8261@menudo.uh.edu>
Reply-To: bright@nazgul.UUCP (Walter Bright)
Organization: Zortech, Seattle
Lines: 21