6.3.1.2 Points to Consider in Implementing DispatchCreateClose

Keep the following points in mind when implementing a DispatchCreateClose routine:

·At a minimum, these Dispatch routines must do the following:

1.Set the Status field of the input IRP's I/O status block with an appropriate NTSTATUS, usually STATUS_SUCCESS.

2.Set the Information field of the input IRP's I/O status block to zero.

3.Call IoCompleteRequest with the IRP and a PriorityBoost of IO_NO_INCREMENT.

4.Return the NTSTATUS that it set in the Status field of the IRP's I/O status block.

·In a highest-level or intermediate NT driver, this routine might need to do additional work to process a create and/or close request, depending on the nature of its device or of the underlying device, and on the design of the driver.

·For a create request to open a file object that represents a logical or physical device, a highest-level driver should check the FileObject.FileName in the I/O stack location and complete the IRP with STATUS_SUCCESS if the Unicode string at FileName has a zero length. Otherwise, it should complete the IRP with STATUS_INVALID_PARAMETER.

·The DispatchCreateClose routine(s) of lowest-level NT drivers are called only during the system initialization process when the next-higher-level driver calls IoGetDeviceObjectPointer, IoAttachDevice, or IoDetachDevice. Such a lowest-level driver in a chain of layered drivers frequently does only the minimum required processing of a create or close request.