 Fido Pascal Conference  PASCAL 
Msg  : 404 of 417                                                               
From : Rob Perelman                        1:202/1308.0         06 Jul 93  07:33 
To   : All                                                                       
Subj : Modifying EXE code                                                     

With all this talk about self modifying EXE code, I decided to try it
for myself.  I found a file that is supposed to change an EXE, but it
was too complicated for me.  For those of you people who want to try out
self-modifying EXE code, check out this program I wrote.  I call it
FINDBOOL, because guess what it does?  It finds a boolean!  See, you
make a CONST at the top of your program called REGISTERED or something,
and set it to FALSE.  Then compile it.  Then edit it and change it to
TRUE.  Then compile it under a different name.  Then run my program
(FINDBOOL) with the names of the two EXE files as parameters
(ie FINDBOOL FILE1.EXE FILE2.EXE).  It will search through the two and
find the boolean value.  Then it will write to a file called
REGISTER.PAS, which, when applied to either EXE, it will go to the
location of the boolean (found from both the EXEs) and toggle the
boolean (if it was FALSE, make it TRUE...or vice versa).  You can
compile REGISTER.PAS and give it an EXE as a file name and it will
toggle the boolean!  Pretty neat, eh?  Sorry about this gibberish I call
an explanation, but it's 7am and I haven't gone to bed yet...ain't it
great to be a programmer??  Well, anyway...the code is in the next
message, but here is code to test my FINDBOOL.  Compile this, rename it,
change the boolean, compile it again, and then run FINDBOOL.  Oh, by the
way, FINDBOOL works with OVRs, too...so you overlay users, don't fret :)

Program Test;

Const Registered=False;

Begin
  If Registered then Writeln('Thank you for registering!')
                Else Writeln('Please register!');
End.