Disk Sector Editor

By Steve Pedler

 

Issue 26

Mar/Apr 87

Next Article >>

<< Prev Article

 

 

Steve Pedler concludes his article on disks with a sector editor you can use as is or as the basis of your own super utility

As I said in the last issue, I have written a simple sector editor and here it is! One of the best ways to put all that information from issue 24 into perspective is to experiment with some of your own disks. This sector editor will allow you to perform direct sector access. Instructions for use are supplied below.

I suggest you experiment with a test disk you don't mind losing until you know how it works. To be safe, the program will not perform any disk write without double checking with you first. Some suggestions for use include examining and changing directory sectors, the VTOC, file link data and so on. Just refer back to issue 24 for guidance.

Feel free to improve the program and add more features such as file tracing and deleted file recovery. Why not send your improved versions to Page 6?

Instructions for use

Type the program in and check it with TYPO III, then save a copy before running it. The program contains two machine language subroutines and mistakes in these may cause the computer to lock up.

On running the editor, you will first be asked for a number. This should be in the range 1 - 720 for a  single density disk, and 1 - 1040 for an enhanced density disk. If you enter a sector number greater than the maximum limit the program will give you an error message. However, if you enter zero (remember that sector zero doesn't exist) you will be sent to the disk utilities menu. More about this later.

The editor will then read the sector and display it on the screen. If you entered a directory sector (361 - 368) the sector will be printed in eight rows, each row corresponding to one directory entry. The first five bytes of each entry will appear in decimal form, the rest in ATASCII form so you can read the filename. If the sector was not a directory sector, it will be shown as 16 rows of eight bytes in decimal form. Machine language programmers may like to convert this so that the values appear in hexadecimal. Across the top of the 16 by 8 matrix are the numbers 0 -7, and down the left side the numbers 0 to 120 in steps of eight. This is so that you can calculate the position of any byte in the sector by adding the appropriate row number to the column number.

Under the sector display you will see the prompt 'Command?'. At this point you may press one of four Control-key combinations (there is no need to press Return). These are:

CTRL-R - read another sector. It will send you back to the beginning of the program so that you can view a different sector.

CTRL-W - write this sector to disk. Usually used when you have changed something in the sector. The program will first ask if you are sure you want to do this before writing to the disk. Respond with a `Y' to confirm, any other key will simply redisplay the same sector.

CTRL-F - display file link data. For any sector other than a directory, VTOC or boot sector (none of which have link data) this command will extract the sector link data from the last three bytes of the sector and display it on the screen. This saves you having to do it manually.

CTRL-C - change the sector. You will be asked for the number of the byte you wish to change, which can be determined by adding the numbers for the row and column the byte is in. The current value of that byte will then be shown, and you will be asked for a new value. The sector will then be redisplayed complete with new value, but note that the change is only in memory. Nothing will be written to the disk until you specifically instruct it. You may make as many changes as you like to a sector and then do just one disk write, which will make all the changes on the disk at the same time.

In order that you can see the effect of the changes you make without going to DOS, I have included a set of the basic disk utilities (read directory, lock and unlock file, and rename or delete file). To access these utilities, enter zero when you are asked for a sector number to read. A short menu will be shown, and you should press one of the number keys 1 - 6 (without Return) corresponding to your choice. Pressing 6 will return you to the main program. All of these utilities will only work with drive 1 as presently written, but this would be easy to change. When asked for a file name, just type the name plus extender (if any). Do not add D: or D1:, the program will do this automatically.

I hope you find this program useful. It is a very simple editor, and there is ample scope for extension and improvement. With a little work this could form the basis of a very useful disk utility.

AtariLister - requires Java

top