ANTIC VOL. 2, NO. 2 / MAY 1983 / PAGE 28
Suppose someone stole your disks, or copied them without permission. Could you prove it? It is possible to create a permanent, secret label on your disks, and I'm not talking about invisible ink.
This label, residing on the disk itself, could hold your name, the date, a serial number, or any other important data‹without using any space on the disk! It would be invisible, yet readily available to you, the owner. Sound exotic, intriguing, impossible? The fact is, it's easy, straightforward, and possible because of a quirk in Atari DOS. But first, you'll need to understand how the disk is organized.
When you save a file onto disk, the File Management System (FMS) writes the data to certain sectors. Along with writing in the sector, the FMS marks the sector "used" in the VTOC, simply by placing a zero in the VTOC bit position corresponding to the written sector. This prevents the FMS from using that sector for another file (unless you delete this file, in which case the sectors are marked as "free").
So far, so good. Now for the bad news ‹ at least from the system's point of view. From our point of view this is the good news! The FMS interprets all 720 bits as corresponding to sectors 0 to 719. This in itself is no problem, except that the disk drive will not accept commands for sector zero. This means that not only will sector zero in the bit map never be marked (because of the drive's limitation), but that sector 720 will not be used by the FMS, since there is no bit to represent it. Since it can't be represensed in the VTOC, the FMS can never store information there!
Here's where we step in. Just because the FMS will not access this sector doesn't mean that we shouldn't (or can't). That sector is exactly where we will write our "invisible" data. Since the FMS doesn't count this sector in the first place, we will lose nothing by using it, but we will gain 128 bytes to store anything we want. For a more detailed expalanation of the VTOC and its interaction with the FMS, see Bill Wilkinson's Inside Atari DOS.
X = USR(1536,CODE,ADR(BUFR$))
where CODE is 82 (decimal) for read, and 87 for write. BUFR$ must be at least 128 bytes long, and depending on the operation, contains the data to be written or the data just read. The routine itself is not complicated; it merely sets the following parameters:
Next, it jumps to the DOS diskhandler routine (whose starting address is $E453), which does all of the work. These disk commands are fully explained in the Atari Operating System User's Manual (Chapter 5), which gives detailed examples of the necessary values for all parameters when using different disk commands.
When the program is run, it first POKEs the Assembly routine into memory on Page Six. It then asks whether you want to read or write. For a write, it asks you for the information it wants. Then the Assembly routine is executed. One valuable location to check after performing these operations is location 771 (decimal). This contains the disk status. After the read or write, the program checks the status to make sure the operation was successful. If the value contains a 1, the operation went as planned. If the value is not a 1, the value gives the error code for the operation. Then, if the operation was a read, the program prints out what it found.
Listing 3 is an even shorter BASIC program that provides a directory of files on a disk. This is a fairly standard technique of reading the directory as a file, so I won't explain it too much. However, before listing the files on the disk, this program first reads and prints out the data from sector 720. This shows how this sector could be used to: indicate ownership, or date of creation, or anything else you want. After reading the label, the directory is opened as a file, and the files in the directory are read out of this file. When you read the "FREE SECTORS" message, you know you are done, so you close the file and end.
mnemonic location (hex) explanation --------------------------------------- DUNIT $301 the disk unit (usually 1) DCOMND $302 the command (82=read;87=write with verify) DBUF $304-30S address of buffer (low byte, then high) DAUX1 $30A for these commands, sector number (low byte, DAUX2 $30B then high)[CODE]