Wednesday, February 17, 2016

Steps To Write Device Driver In Windows Operating System

********* Steps To Write  Device Driver In Windows Operating System********

Step 1: First To install WDK(Window Driver Kit) in Our Computer.



Step 2: Create a  .c file which is use write a Device Driver program.


Step 3: Write a Simple Device Driver Program.

////////////////////////////////////////////////////////////////////////////////////////////////////
Program Name : First_Driver.c
////////////////////////////////////////////////////////////////////////////////////////////////////

//Include header file.

#include<wdm.h>

// call DriverEntry Routine.

NTSTATUS DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath)
{  
     //           
     // Display The Message In Kernel Log
     //      
     DbgPrint("Hello World \n");           
     return STATUS_SUCCESS;           
    //
    //  Processing completed.                
    //
}


////////////////////////////////////////////////////////////////////////////////////////////////////

Step 4: To Write a MakeFile name as "makefile".

////////////////////////////////////////////////////////////////////////////////////////////////////
File Name : makefile
////////////////////////////////////////////////////////////////////////////////////////////////////

!INCLUDE $(NTMAKEENV)\makefile.def

////////////////////////////////////////////////////////////////////////////////////////////////////



Step 5
: To Write a Source File named as "sources".


////////////////////////////////////////////////////////////////////////////////////////////////////

File Name : Sources

////////////////////////////////////////////////////////////////////////////////////////////////////
TARGETNAME = First_Driver
TARGETPATH = obj
TARGETTYPE = DRIVER
SOURCES = First_Driver.c

////////////////////////////////////////////////////////////////////////////////////////////////////



Step 6: After this Start Checked Build Environment. 
For this  go to wdk kit . 

Start -> All Programs -> Window Driver Kit -> Help -> Build Environment -> choose Operating System -> Checked Build Environment.

There are two option free build environment and checked build environment. For Fresher level we have to choose checked build environment because in this environment we have to see the error code in program while free build environment is not see the error code. 
After successful build program we have to create the .sys file in processor directory.



Step 7: To build our Device Driver Use "build" Or "build -cZ" command on checked build command prompt.

build- To build our Device Driver.
c - Specifies that all intermediate object files are deleted.
Z - Specifies that no dependency checking should be performed. i.e all files would have to be compiled.

////////////////////////////////////////////////////////////////////////////////////////////////////

Step 8: To Start Service we have to copy that .sys file in to Windows\System32\drivers folder. and open command prompt then type a command " sc query Drivername" to display the Information about your driver.
" sc create drivername" is use to create service in service manager. " sc delete drivername " is use to delete service from service manager.

////////////////////////////////////////////////////////////////////////////////////////////////////
  

No comments:

Post a Comment

SYBSc (CS) Sem III : Data Structure Slip 14 Que - 2

  SAVITIBAI PHULE UNIVERSITY OF PUNE S. Y. B.Sc. (Computer Science) Semester III Practical Examination       SUBJECT: CS-233 Practical cours...