[comp.sys.ibm.pc] help needed with device driver chai

awylie@pyr1.cs.ucl.ac.uk (06/16/88)

can someone out there tell me how to find the beginning of the DOS device
driver chain? I have been looking in memory and can see the external drivers
loaded after the first memory control block. However the chain pointers in
the driver headers point backwards! I can find my external drivers (NANSI
etc) by eye, and chain back into the DOS area, but what I cant do is find
a pointer to the head of the chain. Any help is appreciated.

------------------------------------------------------------
Andrew Wylie, University of London Computer Centre,
20 Guilford Street, London WC1N 1DZ, England.

JANET:      andrew@uk.ac.ulcc.ncdlab          "I can't complain,
UUCP:       ..!mcvax!ukc!cs.ucl.ac.uk!awylie   but sometimes I still do."
ARPA:       awylie@cs.ucl.ac.uk
BITNET:     andrew%uk.ac.ulcc.ncdlab@ac.uk

if you wish a reply, please give a UUCP path from mcvax to your site.

nelson@sun.soe.clarkson.edu (Russ Nelson) (06/18/88)

In article <39500014@pyr1.cs.ucl.ac.uk> awylie@pyr1.cs.ucl.ac.uk writes:
>
>can someone out there tell me how to find the beginning of the DOS device
>driver chain? I have been looking in memory and can see the external drivers
>loaded after the first memory control block. However the chain pointers in
>the driver headers point backwards! I can find my external drivers (NANSI
>etc) by eye, and chain back into the DOS area, but what I cant do is find
>a pointer to the head of the chain. Any help is appreciated.

I suggest that you don't fiddle with the device chain.  Freemacs used to
fiddle with it, and I could never get it to work correctly under the
various and sundary versions of MS-DOS used around the world.

Fiddling with the device chain is best left to a program like pmap.  You
should certainly never build it into a user program...
-- 
Despise Ronald Reagan now--avoid the rush.

aronoff@garfield (Avram Aronoff) (06/19/88)

In article <39500014@pyr1.cs.ucl.ac.uk> awylie@pyr1.cs.ucl.ac.uk writes:
>Can someone out there tell me how to find the beginning of the DOS device
>driver chain?

The following information is from _MS-DOS Papers_ by The Waite Group.
DOS has an undocumented system call, 52H, which returns a pointer to the
"list-of-lists," an array of far pointers to assorted structures. Do
		mov	ah,52h
		int	21h
A far pointer is returned in es:bx. The information contained there is:

typedef struct ListOfLists {
	void far	*DeviceControlBlockHead;
	void far	*SystemFileTableHandlesHead;
	void far	*ClockDriver;
	void far	*ConsoleDriver;
	short		MaximumSectorSize;
	void far	*CacheBufferHead;
	void far	*CurrentDirectoryStructure;
	void far	*SystemFileTableFCBsHead;
	short		SystemFileTableFCBsSize;
	char		DriveCount;
	char		LastDrive;
} LOL;
The NUL device driver begins immediately after the ListOfLists, and the
segment of the first Memory Control Block sits immediately before it.

							Hymie

Ralf.Brown@B.GP.CS.CMU.EDU (06/19/88)

In article <5717@columbia.edu>, aronoff@garfield (Avram Aronoff) writes:
}The following information is from _MS-DOS Papers_ by The Waite Group.
}DOS has an undocumented system call, 52H, which returns a pointer to the
}"list-of-lists," an array of far pointers to assorted structures. Do
}                mov     ah,52h
}                int     21h
}A far pointer is returned in es:bx. The information contained there is:
[...]

Please note that the given structure is only valid in DOS 3.x.  Under DOS 2.x,
the NUL device driver is at offset 17h from ES:BX, not offset 22h.
--
UUCP: {ucbvax,harvard}!cs.cmu.edu!ralf -=-=-=- Voice: (412) 268-3053 (school)
ARPA: ralf@cs.cmu.edu  BIT: ralf%cs.cmu.edu@CMUCCVMA  FIDO: Ralf Brown 1:129/31
Disclaimer? I     |
claimed something?|            Insert your favorite quote here

dixon@zephyrus.steinmetz (Walter V. Dixon) (06/21/88)

Newsgroups: comp.sys.ibm.pc
Subject: Re: help needed with device driver chai
Summary: Locating device drivers
Expires: 
References: <39500014@pyr1.cs.ucl.ac.uk> <5717@columbia.edu>
Sender: 
Reply-To: dixon@zephyrus.UUCP (Walter V. Dixon)
Followup-To: 
Distribution:world
Organization: General Electric CRD, Schenectady, NY
Keywords: _MS DOS Papers_,Device Drivers, Driver Chain

Although there are two chapters which make reference to int 21h ah=52h,
the level of detail associated with this reply leads me to belive it
comes from one of the two chapters which I wrote.  Under DOS 3.0 and
above this method is indeed the correct way to locate a character device.
An alternative approach is to open the nul device with a FCB.  One
of the undocumented fields in the FCB is the address of the device
header.

Locating a block device is a bit more complicated.  Another field
in this list of list points to a structure known as the current directory
structure (CDS),  which in turn points to a linked list of device
control blocks (DCB).  The DCB contains the address of the device
header.

I have written a program which prints out extensive information about
the device driver chain (as well as info on cache and memory) usage.
I also have a "self-loading" ram disk driver which plugs into the
necessary DOS data structures and then does a terminate and stay
resident.

I have offered to make copies (sources included) of these programs.
Since some of the files on this disk appear in the manuscript,  it
is not clear that I can post them.  The agreement which I have with
the Waite Group lets me provide this disk for $10.00. (Lest someone
accuse me of commercialism,  this fee barely covers my costs).
Anyone who is interested can contact me by email.

I hope this helps.

Walt Dixon		(ARPA: Dixon@GE-CRD.ARPA)