🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #5304

Self Modifying code

#5304
From: Richard E. Covert
Date: Thu, 26 Oct 1989 19:21
41 lines
1625 bytes
I have a friend who has written some shareware programs
(ARCIT, ARCIT Shell, UNARCIT etc ) and he would like to
make his code self-modifying. IN particular he would like
to save the state of various buttons that he uses.

1) Write the data to an external file (*.CFG), but now
you have to maintain a PRG, a RSC and a CFG file. Clumsy.

2) Write to the RSC file, but my friend wants to incorporate
the RSC into the PRG (using RSCTOC or equivalent). So, there
may not be a RSC to write to.

3) Write to the PRG file. Best of all since you need it to
run his program!!




But how do you modify a PRG file on the run?? One idea is
to store some unique string of characters indicating the
start of a buffer region. Then the PRG could do a binary
search of itself to locate the string in the disk file,
and then overwrite the next XX bytes with the new config
data. But you would have to make certain that the search
string is unique.

Another idea is to reserve XX bytes at the end of the
PRG file. If you read in the PRG as a binary file you
could LSEEK to the end of the PRG and then LSEEK back
XX bytes.

Well, does anyone have any C code that could be used??

I am interested in this whole idea.

Rich Covert


How can one go about do this in C??

I have several ideas.
Technical Details
Message-ID: <46768dca.14a1f@force.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!asuvax!hrc!force!covertr

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!asuvax!hrc!force!covertr
From: covertr@force.UUCP (Richard E. Covert)
Newsgroups: comp.sys.atari.st
Subject: Self Modifying code
Keywords: C, atari st
Message-ID: <46768dca.14a1f@force.UUCP>
Date: 26 Oct 89 19:21:01 GMT
Organization: gte
Lines: 41