Jump-start your project by learning from devs who
write Windows drivers and file systems every day.
Take an OSR seminar!

Upcoming OSR Seminars:
WDM Lab, Seattle, WA 16 August 2010
WDF Lab, Santa Clara, CA 27 September 2010
Debug Lab, Portland, OR 18 October 2010
Windows Internals & Software Drivers Lab, Santa Clara, CA 15 November 2010


Go Back   OSR Online Lists > ntdev
Welcome, Guest
You must login to post to this list
  Message 1 of 3  
03 Jan 01 04:51
ntdev member 3851
xxxxxx@esrange.ssc.se
Join Date: 08 Nov 2000
Posts To This List: 26
Modify drivers dispatch table

Hi, would it be legal (and possible) to modify the dispatch table of a running driver? To be more specific, what I'd like to do is to have one function called the very first time IRP_MJ_CREATE is dispatched, and another for all subsequent ones. This is to have specific initialization the first time any app opens the device, and avoid having a synchronization mechanism combined with a test for initialization for each following create irp. The driver will have one device object only, which is created during driver load, so I'm considering using an executive spinlock inside the device extension for synchronization, something along the following lines: ***************** struct MY_DEVICE_EXTENSION { ... KSPIN_LOCK CreateDispatchSpinLock; // Initialized during creation of device BOOLEAN CreateInitiallyCalled; // Initialized during creation of device to FALSE ... }; NTSTATUS DriverEntry(...) { ... pDriverObject->MajorFunction[IRP_MJ_CREATE] = InitialCreate; ... }; NTSTATUS InitialCreate(...) { ... get device extension ... ... get spinlock from extension ... ... acquire spinlock ... if (FALSE == pDeviceExtension->CreateInitiallyCalled) { ... do one time initialization ... pDeviceExtension->CreateInitiallyCalled = TRUE; ... get driver object ... pDriverObject->MajorFunction[IRP_MJ_CREATE] = NormalCreate; } ... release spinlock ... complete IRP return NT_SUCCESS; } NTSTATUS NormalCreate(...) { ... complete IRP return NT_SUCCESS; } ************************************** // Johan Nilsson --- You are currently subscribed to ntdev as: $subst('Recip.EmailAddr') To unsubscribe send a blank email to leave-ntdev-$subst('Recip.MemberIDChar')@lists.osr.com
  Message 2 of 3  
03 Jan 01 05:21
ntdev member 3954
xxxxxx@aalayance.com
Join Date:
Posts To This List: 101
Re: Modify drivers dispatch table

Hi, NT Maintains only one Linked list ( I mean DEVICE_OBJECT ) with all information related to Device Driver. If u Aquare Spin lock and Change this structure it should Work. This is just like changing a Global Variable in ur Driver. This is what i Feel ................. Regards, Satish K.S ----- Original Message ----- From: <xxxxx@esrange.ssc.se> To: "NT Developers Interest List" <xxxxx@lists.osr.com> Sent: Wednesday, January 03, 2001 3:17 PM Subject: [ntdev] Modify drivers dispatch table > Hi, > > would it be legal (and possible) to modify the dispatch table of a running > driver? To be more specific, what I'd like to do is to have one function > called the very first time IRP_MJ_CREATE is dispatched, and another for all > subsequent ones. This is to have specific initialization the first time any > app opens the device, and avoid having a synchronization mechanism combined > with a test for initialization for each following create irp. > > The driver will have one device object only, which is created during driver > load, so I'm considering using an executive spinlock inside the device > extension for synchronization, something along the following lines: > > ***************** > > struct MY_DEVICE_EXTENSION > { > ... > KSPIN_LOCK CreateDispatchSpinLock; // Initialized during > creation of device <...excess quoted lines suppressed...> --- You are currently subscribed to ntdev as: $subst('Recip.EmailAddr') To unsubscribe send a blank email to leave-ntdev-$subst('Recip.MemberIDChar')@lists.osr.com
  Message 3 of 3  
03 Jan 01 08:37
ntdev member 2092
xxxxxx@stratus.com
Join Date:
Posts To This List: 1798
Re: Modify drivers dispatch table

It would be much simpler to have a static local LONG in your dispatch routine that is Interlock test and set and if zero when tested you call function x else you call function y. There are reasons why you might want to modify the dispatch table of a driver 'on the fly' but this is not one of them. Mark Roddy xxxxx@hollistech.com www.hollistech.com WindowsNT Windows 2000 Consulting Services > -----Original Message----- > From: Satish [mailto:xxxxx@aalayance.com] > Sent: Wednesday, January 03, 2001 5:15 AM > To: NT Developers Interest List > Subject: [ntdev] Re: Modify drivers dispatch table > > <...excess quoted lines suppressed...> --- You are currently subscribed to ntdev as: $subst('Recip.EmailAddr') To unsubscribe send a blank email to leave-ntdev-$subst('Recip.MemberIDChar')@lists.osr.com
Posting Rules  
You may not post new threads
You may not post replies
You may not post attachments
You must login to OSR Online AND be a member of the ntdev list to be able to post.

All times are GMT -5. The time now is 13:57.


Copyright ©2005, OSR Open Systems Resourcs, Inc.
Based on vBulletin Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Modified under license