Thursday, March 8, 2007

How to run a Device Driver in Windows


Creating the code

· First create a separate directory for your driver.

· Then create the driver code in .c files and store it in that directory.

· Then create the following two files

Makefile

!INCLUDE $(NTMAKEENV)\makefile.def

Build

TARGETNAME = test //the name of the .sys file we desire

TARGETPATH = obj

TARGETTYPE = DRIVER

INCLUDES = %BUILD%\inc

LIBS = %BUILD%\lib

SOURCES = test.c // the name of the file that contains the driver code

  • Both these files should be stored in the same directory as of the .c file.
  • Both should be saves without any extensions.

Compiling Your Driver Code

· Then go to the DDK in the start menu and select

_>Development Kit

__>Windows 2000 DDK

___>Check Build Environment

· A command prompt opens.

· Navigate to the directory where your driver code resides.

· Then Type build in the command prompt.

· It compiles your driver code.

· Once the compilation is over the .sys file is created.

Registering your Driver

· Before executing the .sys file it has to be registered with the windows registry.

· To register a .sys file download the OSR Driver Loader from the net and first install it.

· Then open and it and in the Driver Path give your newly created .sys file.

· All device driver can be loaded only once but it can be started or stopped frequently.

· The software itself contains all the options such as registering a driver and unregistering a driver, start and stopping the service.

· You can also start and stop the service from command prompt itself using the commands

· netstart (driver name without extension) and netstop(driver name without extension).

Viewing the Output

· To view the output, use the DebugView for debugging and viewing output. Once again it should be downloaded from net.

· Run this first before starting the service and hence you can view the output.

No comments:

Post a Comment