Date: Sun, 20 Jul 1997 07:50:51 -0700 (PDT) Message-Id: <199707201450.HAA05609@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: csantill AT lausd DOT k12 DOT ca DOT us From: Nate Eldredge Subject: Re: Self Modifying EXE's Cc: djgpp AT delorie DOT com Precedence: bulk You wrote: >I would like to know if it is possible to write a self-modifying EXE? >I just want my game to keep track of a high score table w/names,pts >scored, date accomplished, that sort of thing but w/o the use of a >external file. Any & all help would be highly appreciated! First of all: This question is off topic for this group. Now that that's out of the way... ;-) Yes, technically it's possible. The `standard' way to do it is like this: struct self_modifying_area { char signature[20]; /* or whatever */ char buffer[1000]; /* or however much space you need to store stuff */ }; struct self_modifying_area high_scores = { "SELF MODIFY HERE--->" , "" }; /* Note exactly 20 characters! ^^^^^^^^^^^^^^^^^^^^ */ Then find the name of your executable with argv[0], search through it for the signature string, and write your data after that point.\* Now here's why not to do it. - This will fail horribly if your program is compressed with DJP or such. - If the user runs your program via a DJGPP-style symlink, this won't work either (you'll read the stub part only). - You will probably trigger the user's virus protection software if they have any. This will make people rather suspicious... - If your program has been set read-only (and many people do this!), guess what? IT WON'T WORK. - Your program will be very non-portable. I'd like to suggest you use an external file. I would recommend that your program be able to create it if it doesn't exist. You can keep people from reading it with an encryption algorithm, or keep them from changing it with a CRC. Nate Eldredge eldredge AT ap DOT net