From: johan.nilsson@esrange.ssc.se Sent: Wednesday, January 03, 2001 4:48 AM To: NT Developers Interest List 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 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: GlennEverhart@FirstUSA.com To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com