
                                  DISCLAIMER

This software is provided 'as-is', without any express or implied     
warranty.  In no event will the author be held liable for any damages 
arising from the use of this software.                                


Introduction
------------

DLOCK is a small TSR i wrote to debug my device drivers and *own* file system.
It hooks at the top of INT13h and checks if any program tries to access a
protected cylinder. DLOCK can protect up to 10 cylinder areas on independant
drives.

Mostly DLOCK is for developers/coders and not for the "vanilla user" ;) like
somebody said ;) Oh and of course you can create lot trouble with it through
protecting a cylinder of the FAT so i guess its also of use for the kind of
destructive babyhackers that think they are sooo 3!33+3 and of course dont
know how to code something like this - bah.

DLOCK is freeware and can be used by anybody including commercial developers
and companies but it *CANT* be sold with commercial software without written
permission of the author.

What is captured ?
--------------------------------

Captured are functions 2,3 and 4 which are the standard sector read/write and
verify calls. Additionally the functions 0a/0b (read/write) long sector are
filtered, these functions are officially for diagnostic uses only on a PS/2.
They are also checked for multi-sector read/write requests though documentation
states that these calls only accept 1 sector at a time. The routines
precalculates the last accessed sector of a multisector request to detect if
it touches a protected area. The disk status function (int13h/ah=1) is
updated for floppydisk/harddisk denied accesses (040:041/040:074 status bytes).

What isnt captured ?
--------------------

Function 5/6/7 which allow to format cylinders arent filtered. Also for ESDI
drives the low-level format function 1A isnt captured.
Basically you can still format protected data areas.

DLOCK can guard any drive which is controlled by INT13h and hasnt number 0xFFh.
I dont know of any drive which uses 0xFFh (it would be harddisk number 128 ;)
so it should be not a problem for anyone.

Usage
-----

DLOCK recognizes four parameters and only accepts one parameter at a time.
The parameters are:

        /?      - displays a short parameter summary
        /AON    - switches alert popup mode on
        /AOFF   - switches alert popup mode off
        [+-]a[drive],[startcylinder]-[endcylinder]
                - adds or removes a drive/cylinderrange to DLOCK

[+-]            - a "+" says you add a area to the protectionlist and "-"
                  means you want to remove it

[drive]         - is the hexadecimal drivenumber
                  (00 = disk A / 01 = disk B / 80 = harddisk 1 / 
                   81 = harddisk 2)

[startcylinder] and [endcylinder] are the cylinder numbers inclusive you want
protected.

example: to protect cylinder 0 of harddisk 1 do "dlock +a80,0-0"
         to remove the protection do "dlock -a80,0-0"
         protect cylinders 50 to 100 on harddisk 2 with "dlock +a81,50-100"

The "a" means "access" - if people want it i will implement "r" and "w" too so
you can say only read or only write protect. Currently only "a" is allowed
as i only need that.

The alert popup mode writes directly to 0b800h and assumes you have a color
display so it skips every second byte (the attributes).
Sadly without the alert popup mode you sometimes dont know if applications
try to access protected areas since especially C coder seem to think errorcodes
dont exist ;) so the applications continues with corrupt data and later will
likely show strange behaviour ;)

WARNINGS !!!
------------

Never protect cylinder 0 and start fdisk !!! (explanation see below)
Never protect a cylinder which is allready in use by DOS !!! (this can really
screw DOS up - and therefore maybe also your harddisk !!)
In general you can really screw your harddisk up if you protect the wrong
areas which are in use by DOS allready - the protected areas arent screwed as
DOS cant write to them but it still can screw the next/remaining cylinder :)

Also remember that DLOCK has to be the last chained program into INT13 (or the
first one which will be called from INT13) otherwise it is possible that it
cant protect your harddisk. If you start other INT13 handlers after DLOCK,
like the adaptec aspi4dos driver, this will disable DLOCK for the drives
which are handled through aspi4dos. So dont forget to start DLOCK *after* 
every other INT13 handler (most other INT13h handlers are anyway device driver
and since DLOCK is a TSR it will anyway come after them).

After the program was debugged and worked well, I played a bit with it and of
cause i tried to protect cylinder 0 of HD 1 and started fdisk ;) with
using MS-D*S 6.2 .
(one of the biggest mistakes i ever did - upgrading from D*S 5.1 to 6.2 :(

Well i have two hd's and fdisk reported a error on HD1 and switched to HD2,
I was able to switch back to HD1 manually and "create" partitions on the
cylinder. When i left fdisk it destroyed sector 0 of cylinder *1* !!!!!
It didnt even try to save the partitiontable - it just filled the sector with
0F6h  :( and killed the bootsector of my primary DOS partition - guess if i
had a backup ;)

In the process of repairing this - i managed to create a DOS bootsector
which hung DOS after reading it ;)

So obviously it is possible to hang DOS with a defect bootsector (and the BPB
was correct !!)

To do
-----

 - release PSP from memory
 - make program graphics mode aware
 - more error messages and better parameter handling
 - hypertext popup online manual with graphic ;)


You can reach me through email at "haberdit@server.et-inf.fho-emden.de" or
talk to "bitblazer" on IRC (greets faker alte nase ;)

                Have fun,

                        Frank.

btw. the first working function was a 251 bytes COM program and needed about
20 minutes to write.
