12.5 COM file symbiosis
------------------------
12.5.1 What is symbiosis?
~~~~~~~~~~~~~~~~~~~~~~~~~~
The C-- compiler has the option to append the program it is compiling
to the end of an already created COM file. This I call "COM File
Symbiosis". When the program is loaded, execution will start in the
appended C-- code, and when execution passes the end of the main()
function block, execution of the original program will begin.
If a function like EXIT() or ABORT() is called within the C--
program, the program will quit, and the original code from the COM file
will not be executed. This allows the program being appended to the
COM file to determine whether control will be passed to the original
code.
12.5.2 How to do it
~~~~~~~~~~~~~~~~~~~~
To do it, you need to use the /SYM command line option followed by
the full name of the COM file to append to. The original COM file will
not be changed, only copied into the beginning of the outputted run COM
file. For example, to compile the program HELLO.C-- onto the end of a
copy of C:\COMMAND.COM use the following command:
C-- /SYM C:\COMMAND.COM HELLO.C--
An output file HELLO.COM will be created.
12.5.3 Uses
~~~~~~~~~~~~
You can probably think of lots of ways of using this function, such
as:
- Adding password protection to certain special COM files.
- Reducing the memory available to the COM file at startup.
- Initializing a video mode for the COM file.
12.5.4 Abuses
~~~~~~~~~~~~~~
A malicious person can also come up with harmful uses for this
function. The most obvious is the creation of Trojan horses. I would like
to point out that this is a nonconstructive use of C--, and any
destructive use of COM-file symbioses is forbidden.