Hardware Reference
In-Depth Information
It is, however, possible to overcome the limitations of Windows Protected Mode
by taking the following steps that will ensure that our program is run within a
pure DOS environment:
1
Develop the program within the IDE in the normal way (but note that attempts
to test the program from within the IDE will have unpredictable results)
2
Compile the program and save a copy to a floppy disk
3
Use the Windows disk formatting utility to format a DOS boot disk
4
Shut down the system and then boot it directly into DOS using the boot disk
5
Insert the program disk and run the program from the DOS prompt.
Despite the fact that a program that accesses low-level hardware will run quite
happily on a Windows XP system provided that it is first booted directly into
DOS, this is hardly an elegant solution for long-term software development. It
therefore becomes necessary to find a way that will allow us to access hardware
from a program that runs under Windows NT/2000/XP without falling foul
of the limitations of Protected Mode. To do this we need to make use of a
kernel mode driver that runs at the highest privileged level and that does allow
I/O instructions. Writing a kernel mode is not an easy task but fortunately a
number of such drivers are currently available for downloading from the Web.
They include:
inpout32.dll from logix4u (http://www.logix4u.net)
io.dll from Fred Bulback (http://www.geekhideout.com/iodll.shtml)
NTPort Library 2.5 from Zeal SoftStudio (http://www.zealsoft.com)
WinIo v2.0 from Yariv Kaplan (http://www.internals.com)
DriverLINX
Port
I/O
Driver
(DLPortIO.DLL)
from
Scientific
Software
Tools, Inc. (http://www.sstnet.com).
Inpout32.dll
In order to provide readers with an example of using a kernel mode driver
we shall describe the use of inpout.dll from logix4u. The functions in the
inpout.dll kernel mode driver are defined in two source files, osversion.cpp
and inpout32drv.cpp. The first routine checks the version of operating system
(it is highly desirable for a kernel mode driver to be able to operate with all
Windows versions) whilst the second routine installs the kernel mode driver
(where required) and then performs the required port I/O routines.
The two functions available from inpout32.dll are:
Inp32 which reads data from the specified parallel port register,
and
Out32 which writes data to the specified parallel port register.
Various other functions are implemented within Inpout32.dll including those
that check the operating system, load and unload the hardware interface, and
create the service.
Search WWH ::




Custom Search