home *** CD-ROM | disk | FTP | other *** search
- PROGRAM modify4;
- { Version B, 12/23/87. Minor bug fixes, additional comments added
- regarding how to deal with headers which fall across the boundaries
- of your search buffer.}
-
- { This is an update of Modify 1.00, which is designed to
- allowing quick cloning under Turbo version 3. This now
- works under version 4. Address questions and bug reports
- to Bob Tolz, Compuserve ID #70475,1071. Original comments for
- the modify version 1.00 follow. Please read them with a grain
- of salt, given the changes required for upgrading to 4.0}
-
- {---------- Begin Modify 1.00 Comments ------------}
- { PROGRAM Modify_Turbo_COM_File; }
- { For DOS versions of Turbo only }
-
- (*
- Purpose of Modify:
- Like the popular CLONE.PAS and CLOVER.PAS, Modify provides a method
- by which Turbo programmers can allow users to create customized versions
- of their programs without recompiling the source.
-
- How it works:
- Modify takes advantage of the fact that Turbo stores typed constants
- in the code segment. This means that the location of a given typed
- constant in a .COM file will always correspond to its offset from CSeg, less
- the size of the Program Segment Prefix ($100 bytes). An integer variable
- (typed constant) located at CSeg:$0500 while a program is in memory, for
- example, can be found by Seek-ing to the 1024th byte (1024 = $400) in the
- .COM file. If you were then to write the current value of the integer
- variable to disk, the current value would become the default or initial
- value. This is what Modify does, essentially, except that it can change
- multiple variables in one swoop.
-
- How to use the Modify function:
- The demonstration program included here shows how to use Modify, but
- I'll explain the procedure briefly anyway:
- First, declare all the variables that you want to be able to modify
- as typed constants (global) in a single cluster. The cluster should
- begin with a "header string", probably the name of the program and perhaps
- a version number as well. This will help Modify insure that the .COM
- file being modified is the right one. (Be sure that the header string is
- unique--if you release an updated version of your Modify-able program,
- you should change the header string.) The end of the cluster should be
- marked by a one-byte dummy variable, such as "Tail" in the demo program.
- In between you can put as many variables as you wish.
- Modifying your program is then simple: just call the Modify function
- with three parameters: the name of the .COM file, the header string, and
- the dummy variable used to mark the end of the cluster. Modify takes
- care of everything else, and returns an error code to indicate what
- happened. (See the list of return codes, below.)
-
- Modify lacks some of the features of CLONE and CLOVER--it can't make
- backup versions of programs, for example--and it is slightly riskier
- (in my own programs, I ask the user to confirm that he has a backup
- copy of the program before calling Modify). But it is the smallest,
- fastest, and simplest routine to clone COM files that I've seen, and
- I think that many people will find that its advantages more than
- compensate for its disadvantages. (I almost forgot: Modify, like
- Clover, works fine for programs with overlays. It will not, however,
- work with EXE files created by Turbo Extender. Randy Forgaard is
- reportedly working on a simlar routine that will.)
-
- Special thanks to Randy Forgaard for his suggestions, as well as to Bob
- Tolz, Bela Lubkin, and James Troutman. Please address all comments,
- suggestions, etc. to:
- Brian Foley, CompuServe ID #76317,3247.
- *)
- {---------- End Modify 1.00 Comments ------------}