Checking for Presence of Mouse Device Driver
PSS ID Number: Q19990
Article last modified on 05-14-1993
PSS database name: H_Mouse

2.x 3.x 4.x 5.x 6.0

MS-DOS


--------------------------------------------------------------------
The information in this article applies to:

 - Microsoft MS-DOS operating system versions 2.x 3.x, 4.x, 5.x, 
   and 6.0
--------------------------------------------------------------------

Summary:

Before doing a software interrupt to the mouse device driver, you can
determine if the mouse driver is loaded by checking the INT 33h vector
information.

More Information:

When checking to see if the Microsoft Mouse device driver is present,
you should study the following INT 33h vector information to be sure 
that the driver is present before attempting any mouse driver function
calls.

During the initial design of MS-DOS, INT 33h was reserved. Therefore,
Microsoft was able to take advantage of this reserved interrupt for
its mouse. Because of this reserved status and the fact that Microsoft
has used this vector for the mouse for almost 8 years, no other
developers should be using this vector. The exception would be other
mouse manufacturers writing Microsoft Mouse driver emulators.

As a general rule, you must check for uninitialized software
interrupts differently in MS-DOS 2.x than you would in later versions
of MS-DOS. In MS-DOS 2.x, all uninitialized software interrupts should
be zeroed out. In MS-DOS 3.x and later, some are zeroed out while
others (including INT 33h) point to IRET instructions. Be certain that
the driver is installed, then check to see if the vector for INT 33h
is zeroed out. If it is, the mouse driver has not been loaded.

If the vector is not zeroed out, check to see if the vector points to
an IRET instruction. If there is an immediate IRET, the driver is not
loaded. However, if these tests are successful, you can assume that
the mouse driver is loaded. It should not be necessary to check for
mouse device driver code.

Because no other manufacturer should use INT 33h, and BIOS on
compatibles should be handling uninitialized software interrupts as
indicated above, compatibility and transportability of code should not
be a problem.

Below is a C example of checking the existence of a mouse driver under
DOS versions 2.0 and later, using MS-DOS interrupt 21 hex with
function 35 hex:

void chkdrv(void)
{
	union REGS inregs, outregs;
	struct SREGS segregs;
	long address;
	unsigned char first_byte;

	inregs.x.ax = 0x3533;
	intdosx ( &inregs, &outregs, &segregs );

	address = (((long) segregs.es) << 16) + (long) outregs.x.bx;
	first_byte = (unsigned char) * (long far *) address;

	if ((address == 0L) || (first_byte == 0xcf))
		 {
		 printf("Mouse driver NOT installed");
		 exit(0);
		 }
}

Additional reference words: 3.00 3.10 3.20 3.30 3.30a 3.0 3.1 3.2 3.3
3.3a 4.00 5.00 6.00

Copyright Microsoft Corporation 1993.