jagomart
digital resources
picture1_Windows Kernel Programming Pdf 188005 | Windows Kernel   Excerpt


 174x       Filetype PDF       File size 0.36 MB       Source: technologeeks.com


File: Windows Kernel Programming Pdf 188005 | Windows Kernel Excerpt
lecture notes on windows kernel programming i o in device drivers creating a driver that actually does something this section extends the sample driver by introducing i o processing via ...

icon picture PDF Filetype PDF | Posted on 02 Feb 2023 | 2 years ago
Partial capture of text on file.
  Lecture Notes on Windows Kernel Programming
                         I/O in Device Drivers
                    Creating a Driver that actually DOES something
                 This section extends the sample driver by introducing I/O processing via 
                 IRPs, and interacting with the driver from user mode and from other 
                 drivers.
                 Key Concepts:IRP, IRP Dispatching, Buffered I/O, Direct I/O, 
                 IoControlCodes (IOCTLs)
  (C) 2009 JL@HisOwn.com               99
    Lecture Notes on Windows Kernel Programming                                                                                              	
	
                                                                                                                                I/O in Device Drivers
                                                                                                                                I/O in Device Drivers
                                                        Driver Entry Points
                                                                                                             DriverEntry also sets 
                                                                                         DriverUnload        DriverUnload (net stop)
                                                                   DriverEntry
                                             IRP_MJ
                                             IRP_MJ                                                                             StartIo()
                           DriverEntry       IRP_MJ
                           Sets up           IRP_MJ
                           Majorfunction                                           Driver                                          FileSystem
                           Array for         IRP_MJ                                                                                Drivers use 
                           incoming IRPs     IRP_MJ                                                                                StartIo() 
                                                                                                                                   function
                                             IRP_MJ
                                                                        ISR                    DPC
                                                  Driver may register Interrupt       ..which, in turn, may queue
                                                  Service Routines (ISRs)…            Deferred Procedure Calls (DPCs)
                     The Kernel defines two callback interfaces for drivers:
                                Fast I/O
                                           Rapid synchronous I/O only, mostly for File System Drivers
                                           Direct from user buffers to system cache (less copying)
                                I/O Request Packets
                                           Default I/O for most operations:
                                                      Both synchronous and asynchronous I/O
                                                      Page faults implemented by IRPs to file system
                                                      Networking – send/recv implemented as IRPs
                     Driver may define additional entry points/callbacks. Fast I/O is used primarily for File System 
                     Drivers (FSDs), and is left out of the scope of this course.
    (C) 2009 JL@HisOwn.com                                                         100
                                                                                 	
	
                                                                         I/O in Device Drivers
                                                                         I/O in Device Drivers
                                             IRPs
                   •  I/O operations are put into “I/O Request Packets”
                   •  IRPs pass up and down the driver stack
                   •  Every driver owns an “IO_STACK_LOCATION” in IRP
                   •  Top level (creator of IRP) must set up IRP “stack size”
                   •  Structure documented, but remains semi-opaque
                      – Structs of Unions of Structs – very volatile
            A fundamental concept in the Windows I/O architecture is that of an I/O Request Packet, or IRP.
   (C) 2009 JL@HisOwn.com                       101
   Lecture Notes on Windows Kernel Programming                                              	
	
                                                                                   I/O in Device Drivers
                                                                                   I/O in Device Drivers
                           IRPs - I/O Request Packets
                      •  IRP_MJ: “Major” Requests
                      •  IRP_MN: “Minor” (sub) Requests (e.g. for IRP_MJ_PNP)
                      •  Common Major request types:
                                         IRP_MJ_                    Use
                                   CREATE                File/Socket/Dir creation open
                                   CLOSE                 File/Socket/Dir close
                                   DEVICE_CONTROL        Ioctl/DeviceIoControl
                                   FILESYSTEM_CONTROL Various FSD operations
                                   READ                  Read operation
                                   QUERY_INFORMATION     Get information on descriptor
                                   SET_INFORMATION       Set information of descriptor
                                   WRITE                 Write operation
              Kernel drivers (with the exception of   typedef struct _IRP {
              NDIS and FSD) generally communicate        …
              through I/O Request Packets. These         PMDL   MdlAddress;
              “packets” are semi opaque objects.         ULONG Flags;
                                                         union {
              The Kernel defines IRP_MJ_ types,            …
              corresponding to “Major” codes, and          PVOID   SystemBuffer;
              IRP_MN_ types, corresponding to            } AssociatedIrp;
              “Minor” codes.                             …
                                                         IO_STATUS_BLOCK     IoStatus;
              The Major codes are for the various        KPROCESSOR_MODE     RequestorMode;
              request operations, the important ones of   …
              which are shown above. The Minor           BOOLEAN   Cancel;   // The cancel bit
              codes are sub codes for a particular       …
              Major – for example, Plug and Play         PDRIVER_CANCEL     CancelRoutine;
              operations all have the same Major code,   PVOID UserBuffer;
              IRP_MJ_PNP, but specific minor codes       union {
              for starting/stopping devices, etc.          struct { ..
                                                            union {
                                                              KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
                                                              struct {
                                                                PVOID   DriverContext[4];
                                                              };
                                                           };
                                                           …
                                                           PETHREAD    Thread;
                                                           LIST_ENTRY    ListEntry;
                                                           ..     } Overlay;
                                                           } Tail;
                                                      } IRP, *PIRP; 
   (C) 2009 JL@HisOwn.com                             102
The words contained in this file might help you see if this file matches what you are looking for:

...Lecture notes on windows kernel programming i o in device drivers creating a driver that actually does something this section extends the sample by introducing processing via irps and interacting with from user mode other key concepts irp dispatching buffered direct iocontrolcodes ioctls c jl hisown com entry points driverentry also sets driverunload net stop mj startio up majorfunction filesystem array for use incoming function isr dpc may register interrupt which turn queue service routines isrs deferred procedure calls dpcs defines two callback interfaces fast rapid synchronous only mostly file system buffers to cache less copying request packets default most operations both asynchronous page faults implemented networking send recv as define additional callbacks is used primarily fsds left out of scope course are put into pass down stack every owns an io location top level creator must set size structure documented but remains semi opaque structs unions very volatile fundamental con...

no reviews yet
Please Login to review.