VisualStudio Predefined Macros
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5
Other versions are also available for the following:
- Microsoft Visual Studio 2003/.NET Framework 1.1
- Microsoft Visual Studio 2005/.NET Framework 2.0
- .NET Framework 3.0
C/C++ Preprocessor Reference
Predefined Macros
Names the predefined ANSI C and Microsoft C++ implementation macros.
The compiler recognizes predefined ANSI C macros and the Microsoft C++ implementation provides several more. These macros take no arguments and cannot be redefined. Some of the predefined macros listed below are defined with multiple values. See the following tables for more information.
ANSI-Compliant Predefined Macros
Microsoft-Specific Predefined Macros
As shown in following table, the compiler generates a value for the preprocessor identifiers that reflect the processor option specified.
Values for _M_IX86
Option in Development Environment |
Command-Line Option |
Resulting Value |
Blend |
/GB |
_M_IX86 = 600 (Default. Future compilers will emit a different value to reflect the dominant processor.) |
Pentium |
/G5 |
_M_IX86 = 500 |
Pentium Pro, Pentium II, and Pentium III |
/G6 |
_M_IX86 = 600 |
80386 |
/G3 |
_M_IX86 = 300 |
80486 |
/G4 |
_M_IX86 = 400 |
See Also
How the IME System Works
Glossary
- Input Method Profiler (IMP): The module on Windows NT 3.5 that keeps track of IMEs installed on the system.
- Input Method Manager (IMM): The module on Windows that handles communication between IMEs and applications.
The IME module on Windows fits into a larger mechanism for passing user input to applications, and this section briefly describes this overall framework. Unless you are writing an IME package or customizing your IME user interface, you don't need to worry about the details behind the other components.
On Windows NT, the Input Method Profiler (IMP) stores information about each IME, such as whether it is currently active. Control Panel calls the IMP API to add, delete, or activate an individual IME. To get an idea of what kind of information the IMP handles, click the IME icon in the Windows NT 3.5 Control Panel. When the user changes the active IME via Control Panel, the IMP sends a WM_IME_REPORT message to all applications, with wParam set to IR_IMESELECT. More than one IME can be installed on the system, although on Windows NT 3.5 only one can be active at a time.
On Windows 95, multiple IMEs are handled by the multilingual API instead of by an Input Method Profiler. (See Chapter 6 for a description of the multilingual API.) Windows stores information about each IME installed on the system in the system registry (in the H_KEY_CURRENT_USER\Control Panel\Input Method section). The user switches IMEs the same way the user switches Western keyboard layoutsby clicking the input language menu on the taskbar or by entering a shortcut-key combination. The change is reflected on the taskbar indicator:
Switching IMEs generates the same messages as switching other keyboard layouts: WM_INPUTLANGCHANGEREQUEST and WM_INPUTLANGCHANGE. Applications can activate specific IMEs by calling ActivateKeyboardLayout.
The IMM manages communication between IMEs and applications, serving as the go-between. On Windows NT 3.5, the IMM API is called almost exclusively by the system. Applications can call two IMM functions: WINNLSEnableIME, which enables or disables an IME, and WINNLSGetEnableStatus, which returns the enabled or disabled status set by WINNLSEnableIME. On Windows 95, applications can call a number of IMM API functions in order to customize the IME user interface, as described in the section titled "Customized IME Support on Windows 95".
In concept, Input Method Editors are the same as keyboard drivers, but IMEs handle more characters, and Far East systems require some extra code to handle them. On Windows 95, the Input Method Manager is an extension of USER.EXE. Figure 7-17 below illustrates the way in which the IME, the application, and the rest of the system on Windows 95 communicate.
Figure 7-17 Communication between the IME, the application, and the rest of the Windows 95 system.
When the IME program is active, it traps all keyboard events, including the virtual keys listed in Figure 7-18 below. You can see how some of these virtual-key codes correspond to the IME states listed in Figure 7-6 and Figure 7-10. Unless you are writing an IME package or bypassing the IME module to create your own application-specific input mechanism (definitely not recommended!), you don't need to worry about adding code to respond to these virtual keys.
Virtual Key | Description |
VK_DBE_ALPHANUMERIC | Changes the mode to alphanumeric |
VK_DBE_KATAKANA | Changes the mode to katakana |
VK_DBE_HIRAGANA | Changes the mode to hiragana |
VK_DBE_SBCSCHAR | Changes the mode to single-byte characters |
VK_DBE_DBCSCHAR | Changes the mode to double-byte characters |
VK_DBE_ROMAN | Changes the mode to Roman characters |
VK_DBE_NOROMAN | Changes the mode to non-Roman characters |
VK_DBE_CODEINPUT | Changes the mode to code input |
VK_DBE_NOCODEINPUT | Changes the mode to non-code input |
VK_DBE_ENTERIMECONFIGMODE | Activates a dialog box for setting up an IME environment |
VK_DBE_ENTERWORDREGISTERMODE | Activates the word registration dialog box |
VK_DBE_FLUSHSTRING | Deletes the undetermined string without determining it |
VK_HANGEUL | Changes the mode to hangul |
VK_HANJA | Changes the mode to hanja |
VK_JUNJA | Changes the mode to junja |
VK_PROCESSKEY (Windows 95) | Tells the application that the IME has processed a virtual key; to retrieve the value of the virtual key, applications can call ImmGetVirtualKey |
Figure 7-18 IME virtual keys.
The WM_CHAR message is posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function. The WM_CHAR message contains the character code of the key that was pressed.
Syntax
WM_CHAR WPARAM wParam LPARAM lParam;
Parameters
- wParam
- Specifies the character code of the key.
- lParam
- Specifies the repeat count, scan code, extended-key flag, context code, previous key-state flag, and transition-state flag, as shown in the following table.
0-15
- Specifies the repeat count for the current message. The value is the number of times the keystroke is autorepeated as a result of the user holding down the key. If the keystroke is held long enough, multiple messages are sent. However, the repeat count is not cumulative.
16-23
- Specifies the scan code. The value depends on the OEM.
24
- Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0.
25-28
- Reserved; do not use.
29
- Specifies the context code. The value is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0.
30
- Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up.
31
- Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed.
Return Value
An application should return zero if it processes this message.
Remarks
The WM_CHAR message uses Unicode Transformation Format (UTF)-16.
Because there is not necessarily a one-to-one correspondence between keys pressed and character messages generated, the information in the high-order word of the lParam parameter is generally not useful to applications. The information in the high-order word applies only to the most recent WM_KEYDOWN message that precedes the posting of the WM_CHAR message.
For enhanced 101- and 102-key keyboards, extended keys are the right ALT and the right CTRL keys on the main section of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN and arrow keys in the clusters to the left of the numeric keypad; and the divide (/) and ENTER keys in the numeric keypad. Some other keyboards may support the extended-key bit in the lParam parameter.
Windows XP: The WM_UNICHAR message is the same as WM_CHAR, except it uses UTF-32. It is designed to send or post Unicode characters to ANSI windows, and it can handle Unicode Supplementary Plane characters.
Notification Requirements
Minimum DLL Version None Header Declared in Winuser.h, include Windows.h Minimum operating systems Windows 95, Windows NT 3.1
See Also
Keyboard Input Overview, TranslateMessage, WM_KEYDOWN, WM_UNICHAR
IRP Major Function Codes
Windows Driver Kit: Kernel-Mode Driver Architecture
IRP Major Function Codes
Each driver-specific I/O stack location (IO_STACK_LOCATION) for every IRP contains a major function code (IRP_MJ_XXX), which tells the driver what operation it or the underlying device driver should carry out to satisfy the I/O request. Each kernel-mode driver must provide dispatch routines for the major function codes that it must support.
The specific operations a driver carries out for a given IRP_MJ_XXX code depend somewhat on the underlying device, particularly for IRP_MJ_DEVICE_CONTROL and IRP_MJ_INTERNAL_DEVICE_CONTROL requests. For example, the requests sent to a keyboard driver are necessarily somewhat different from those sent to a disk driver. However, the I/O manager defines the parameters and I/O stack location contents for each system-defined major function code.
Every higher-level driver must set up the appropriate I/O stack location in IRPs for the next-lower-level driver and call IoCallDriver, either with each input IRP, or with a driver-created IRP (if the higher-level driver holds on to the input IRP). Consequently, every intermediate driver must supply a dispatch routine for each major function code that the underlying device driver handles. Otherwise, a new intermediate driver will "break the chain" whenever an application or still higher-level driver attempts to send an I/O request down to the underlying device driver.
File system drivers also handle a required subset of system-defined IRP_MJ_XXX function codes, some with subordinate IRP_MN_XXX function codes.
Drivers handle IRPs set with some or all of the following major function codes:
IRP_MJ_INTERNAL_DEVICE_CONTROL
The input and output parameters described in this section are the function-specific parameters in the IRP.
IRP_MJ_CREATE
Every kernel-mode driver must handle IRP_MJ_CREATE requests in a DispatchCreate or DispatchCreateClose routine.
When Sent
The operating system sends an IRP_MJ_CREATE request to open a handle to a file object or device object. For example, when a driver calls ZwCreateFile, the operating system sends an IRP_MJ_CREATE request to perform the actual open operation.
Input Parameters
The Parameters.Create.SecurityContext member points to an IO_SECURITY_CONTEXT structure that describes the security context for the request.
The Parameters.Create.Options member is a ULONG value that describes the options that are used when opening the handle. The high 8 bits correspond to the value of the CreateDisposition parameter of ZwCreateFile, and the low 24 bits correspond to the value of the CreateOptions parameter of ZwCreateFile.
The Parameters.Create.ShareAccess member is a USHORT value that describes the type of share access. This value corresponds to the value of the ShareAccess parameter of ZwCreateFile.
The Parameters.Create.FileAttributes and Parameters.Create.EaLength members are reserved for use by file systems and file system filter drivers. For more information, see the IRP_MJ_CREATE topic in the Installable File System (IFS) documentation.
Output Parameters
None
Operation
Most device and intermediate drivers set STATUS_SUCESS in the I/O status block of the IRP and complete the create request, but drivers can optionally use their DispatchCreate routine to reserve resources for any subsequent I/O requests for that handle. For example, the system serial driver maps its paged-out code and allocates any resources that are necessary to handle subsequent I/O requests for the user-mode thread that is attempting to open the device for input and output.
IRP_MJ_PNP
All drivers must be prepared to service IRP_MJ_PNP requests in a DispatchPnP routine.
When Sent
The PnP manager sends IRP_MJ_PNP requests during enumeration, resource rebalancing, and any other time Plug and Play activity occurs on the system. Drivers can also send certain IRP_MJ_PNP requests, depending on the minor function code.
Input Parameters
Depends on the value at MinorFunction in the current I/O stack location of the IRP. Every IRP_MJ_PNP request specifies a minor function code that identifies the requested PnP action.
Output Parameters
Depends on the value at MinorFunction in the current I/O stack location of the IRP.
Operation
See Plug and Play Minor IRPs for detailed information about IRP_MJ_PNP requests.
IRP_MJ_POWER
All drivers must be prepared to service IRP_MJ_POWER requests in a DispatchPower routine.
When Sent
The power manager or a driver can send IRP_MJ_POWER requests at any time the operating system is running.
Input Parameters
Depends on the value at MinorFunction in the current I/O stack location of the IRP. Every IRP_MJ_POWER request specifies a minor function code that identifies the requested power action.
Output Parameters
Depends on the value at MinorFunction in the current I/O stack location of the IRP.
Operation
See Power Management Minor IRPs for detailed information about IRP_MJ_POWER requests.
IRP_MJ_READ
Every device driver that transfers data from its device to the system must handle read requests in a DispatchRead or DispatchReadWrite routine, as must any higher-level driver layered over such a device driver.
When Sent
Any time following the successful completion of a create request.
Possibly, a user-mode application or Win32 component with a handle for the file object representing the target device object has requested a data transfer from the device. Possibly, a higher-level driver has created and set up the read IRP.
Input Parameters
The driver's I/O stack location in the IRP indicates how many bytes to transfer at Parameters.Read.Length.
Some drivers use the value at Parameters.Read.Key to sort incoming read requests into a driver-determined order in the device queue or in a driver-managed internal queue of IRPs. Certain types of drivers also use the value at Parameters.Read.ByteOffset, which indicates the starting offset for the transfer operation.
Output Parameters
Depending on whether the underlying device driver sets up the target device object's Flags with DO_BUFFERED_IO or with DO_DIRECT_IO, data is transferred into one of the following:
- The buffer at Irp->AssociatedIrp.SystemBuffer if the driver uses buffered I/O
- The buffer described by the MDL at Irp->MdlAddress if the underlying device driver uses direct I/O (DMA or PIO)
Operation
On receipt of a read request, a higher-level driver sets up the I/O stack location in the IRP for the next-lower driver, or it creates and sets up additional IRPs for one or more lower drivers. It can set up its IoCompletion routine, which is optional for the input IRP but required for driver-created IRPs, by calling IoSetCompletionRoutine. Then, the driver passes the request on to the next-lower driver with IoCallDriver.
On receipt of a read request, a device driver transfers data from its device to system memory. The device driver sets the Information field of the I/O status block to the number of bytes transferred when it completes the IRP.
IRP_MJ_WRITE
Every device driver that transfers data from the system to its device must handle write requests in a DispatchWrite or DispatchReadWrite routine, as must any higher-level driver layered over such a device driver.
When Sent
Any time following the successful completion of a create request.
Possibly, a user-mode application or Win32 component with a handle for the file object representing the target device object has requested a data transfer to the device. Possibly, a higher-level driver has created and set up the write IRP.
Input Parameters
The driver's I/O stack location in the IRP indicates how many bytes to transfer at Parameters.Write.Length.
Some drivers use the value at Parameters.Write.Key to sort incoming write requests into a driver-determined order in the device queue or in a driver-managed internal queue of IRPs. Certain types of drivers also use the value at Parameters.Write.ByteOffset, which indicates the starting offset for the transfer operation.
Depending on whether the underlying device driver sets up the target device object's Flags with DO_BUFFERED_IO or with DO_DIRECT_IO, data is transferred from one of the following:
- The buffer at Irp->AssociatedIrp.SystemBuffer, if the driver uses buffered I/O
- The buffer described by the MDL at Irp->MdlAddress, if the underlying device driver uses direct I/O (DMA or PIO)
Output Parameters
None
Operation
On receipt of a write request, a higher-level driver sets up the I/O stack location in the IRP for the next-lower driver, or it creates and sets up additional IRPs for one or more lower drivers. It can set up its IoCompletion routine, which is optional for the input IRP but required for driver-created IRPs, by calling IoSetCompletionRoutine. Then, the driver passes the request on to the next-lower driver with IoCallDriver.
On receipt of a write request, a device driver transfers data from system memory to its device. The device driver sets the Information field of the I/O status block to the number of bytes transferred when it completes the IRP.
IRP_MJ_FLUSH_BUFFERS
Drivers of devices with internal caches for data and drivers that maintain internal buffers for data must handle this request in a DispatchFlushBuffers routine.
When Sent
Receipt of a flush request indicates that the driver should flush the device's cache or its internal buffer, or, possibly, should discard the data in its internal buffer.
Input Parameters
None
Output Parameters
None
Operation
The driver transfers any data currently cached in the device or held in the driver's internal buffers before completing the flush request. The driver of an input-only device that buffers data internally might simply discard the currently buffered device data before completing the flush IRP, depending on the nature of its device.
IRP_MJ_QUERY_INFORMATION
Drivers can optionally handle an IRP_MJ_QUERY_INFORMATION request.
When Sent
The operating system sends an IRP_MJ_QUERY_INFORMATION request to obtain metadata about a file or file handle. For example, when a driver calls ZwQueryInformationFile, the operating system sends an IRP_MJ_QUERY_INFORMATION request.
Input Parameters
The Parameters.QueryFile.FileInformationClass member is a FILE_INFORMATION_CLASS constant that specifies the type of metadata to provide. For more information about the types of metadata, see the FileInformationClass parameter of the ZwQueryInformationFile routine.
The Parameters.QueryFile.Length member specifies the length of the buffer that the AssociatedIrp.SystemBuffer member points to.
Output Parameters
The AssociatedIrp.SystemBuffer member points to the buffer where the driver supplies the requested information. The value of Parameters.QueryFile.FileInformationClass determines the format of the metadata (a FILE_XXX_INFORMATION structure) to return. For more information about the formats of metadata, see the FileInformation parameter of ZwQueryInformationFile.
Operation
Drivers are not required to handle this request, and drivers that do are not required to handle every possible value of Parameters.QueryFile.FileInformationClass. The driver's dispatch routine should return an error code such as STATUS_INVALID_DEVICE_REQUEST for any values that it does not handle.
Not all of the possible values of FILE_INFORMATION_CLASS can occur. For a complete list of the possible values, see the IRP_MJ_QUERY_INFORMATION topic in the Installable File System (IFS) documentation.
IRP_MJ_SET_INFORMATION
Device drivers can optionally handle an IRP_MJ_SET_INFORMATION request.
When Sent
The operating system sends an IRP_MJ_SET_INFORMATION request to set metadata about a file or file handle. For example, when a driver calls ZwSetInformationFile, the operating system sends an IRP_MJ_SET_INFORMATION request.
Input Parameters
The Parameters.SetFile.FileInformationClass member is a FILE_INFORMATION_CLASS constant that specifies the type of metadata to set. For more information about the types of metadata, see the FileInformationClass parameter of ZwSetInformationFile.
The Parameters.SetFile.Length member specifies the length of the buffer that the AssociatedIrp.SystemBuffer member points to.
AssociatedIrp.SystemBuffer points to the buffer that contains the new information setting. The value of Parameters.SetFile.FileInformationClass determines the format of the data (a FILE_XXX_INFORMATION structure) to return. For more information about the formats of metadata, see the FileInformation parameter of ZwSetInformationFile.
Output Parameters
None
Operation
Drivers are not required to handle this request, and drivers that do are not required to handle every possible value of Parameters.SetFile.FileInformationClass. The driver's dispatch routine should return an error code such as STATUS_INVALID_DEVICE_REQUEST for any values that it does not handle.
Not all of the possible values of FILE_INFORMATION_CLASS can occur. For a complete list of the possible values, see the IRP_MJ_SET_INFORMATION topic in the Installable File System (IFS) documentation.
IRP_MJ_DEVICE_CONTROL
Every driver whose device objects belong to a particular device type (see Specifying Device Types) is required to support this request in a DispatchDeviceControl routine, if a set of system-defined I/O control codes (IOCTLs) exists for the type.
Higher-level drivers usually pass these requests on to an underlying device driver. Each device driver in a driver stack is assumed to support this request, along with a set of device type-specific, public or private IOCTLs. For more information about IOCTLs for specific device types, see device type-specific documentation in the Microsoft Windows Driver Kit (WDK).
When Sent
Any time following the successful completion of a create request.
Input Parameters
The I/O control code is contained at Parameters.DeviceIoControl.IoControlCode in the driver's I/O stack location of the IRP.
Other input parameters depend on the I/O control code's value. For more information, see Buffer Descriptions for I/O Control Codes.
Output Parameters
Output parameters depend on the I/O control code's value. For more information, see Buffer Descriptions for I/O Control Codes.
Operation
A driver receives this I/O control code because user-mode thread has called the Microsoft Win32 DeviceIoControl function, or a higher-level kernel-mode driver has set up the request. Possibly, a user-mode driver has called DeviceIoControl, passing in a driver-defined (also called private) I/O control code, to request device- or driver-specific support from a closely coupled, kernel-mode device driver.
On receipt of a device I/O control request, a higher-level driver usually passes the IRP on to the next-lower driver. However, there are some exceptions to this practice. For example, a class driver that has stored configuration information obtained from the underlying port driver might complete certain IOCTL_XXX requests without passing the IRP down to the corresponding port driver.
On receipt of a device I/O control request, a device driver examines the I/O control code to determine how to satisfy the request. For most public I/O control codes, device drivers transfer a small amount of data to or from the buffer at Irp->AssociatedIrp.SystemBuffer.
For general information about I/O control codes for IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL requests, see Using I/O Control Codes. See also Device Type-specific I/O Requests.
IRP_MJ_INTERNAL_DEVICE_CONTROL
In general, any replacement for an existing driver that supports internal device control requests should handle this request in a DispatchInternalDeviceControl routine. Such a driver must support at least the same set of internal I/O control codes as the driver it replaces. Otherwise, existing higher-level drivers might not work with the new driver.
Drivers that replace certain lower-level system drivers are required to handle this request. For example, a replacement for the system parallel port driver must continue to support existing parallel class drivers. Note that certain system drivers that handle this request cannot be replaced, in particular, the system-supplied SCSI and video port drivers.
When Sent
Any time after the successful completion of a create request.
Input Parameters
The I/O control code is contained at Parameters.DeviceIoControl.IoControlCode in the I/O stack location of the IRP.
Other input parameters depend on the I/O control code's value. For more information, see Buffer Descriptions for I/O Control Codes.
Output Parameters
Output parameters depend on the I/O control code's value. For more information, see Buffer Descriptions for I/O Control Codes.
Operation
Drivers receive IRP_MJ_INTERNAL_DEVICE_CONTROL requests when another driver calls either IoBuildDeviceIoControlRequest or IoAllocateIrp to create a request.
This I/O control code has been defined for communication between paired and layered kernel-mode drivers, such as one or more class drivers layered over a port driver. The higher-level driver sets up IRPs with device- or driver-specific I/O control codes, requesting support from the next-lower driver.
The requested operation is device- or driver-specific.
For general information about I/O control codes for IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL requests, see Using I/O Control Codes. See also Device Type-specific I/O Requests.
IRP_MJ_SYSTEM_CONTROL
All drivers must provide a DispatchSystemControl routine that handles IRP_MJ_SYSTEM_CONTROL requests, which are sent by the kernel-mode component of Windows Management Instrumentation (WMI).
When Sent
The WMI kernel-mode component can send an IRP_MJ_SYSTEM_CONTROL request any time following a driver's successful registration as a supplier of WMI data. WMI IRPs typically are sent when a user-mode data consumer has requested WMI data.
Input Parameters
Depends on the value at MinorFunction in the current I/O stack location of the IRP. Every IRP_MJ_SYSTEM_CONTROL request specifies a minor function code that identifies the requested WMI action.
Output Parameters
Depends on the value at MinorFunction in the current I/O stack location of the IRP.
Operation
All drivers must support IRP_MJ_SYSTEM_CONTROL requests by supplying a DispatchSystemControl routine.
Drivers that support Windows Management Instrumentation (WMI) must handle IRP_MJ_SYSTEM_CONTROL requests by processing the minor function codes associated with this major function code. For information about the WMI minor function codes, see WMI Minor IRPs.
Drivers that do not support WMI by registering as a WMI data provider must pass IRP_MJ_SYSTEM_CONTROL requests to the next lower driver.
IRP_MJ_CLEANUP
Drivers that maintain process-specific context information must handle cleanup requests in DispatchCleanup routines.
When Sent
Receipt of this request indicates that the last handle for a file object that is associated with the target device object has been closed (but, due to outstanding I/O requests, might not have been released).
Input Parameters
None
Output Parameters
None
Operation
This IRP is sent in the context of the process that closed the file object handle. Therefore, the driver should release process-specific resources, such as user memory, that the driver previously locked or mapped.
If the driver's device objects were set up as exclusive, so that only a single thread can use the device at a time, the driver must complete every IRP that is currently queued to the target device object and set STATUS_CANCELLED in each IRP's I/O status block.
Otherwise, the driver must cancel and complete only the currently queued IRPs that are associated with the file object handle that is being released. (A pointer to the file object is located in the FileObject member of the driver's IO_STACK_LOCATION of the IRP.) After canceling these queued IRPs, the driver completes the cleanup IRP and sets STATUS_SUCCESS in its I/O status block.
For more information about handling this request, see DispatchCleanup Routines.
IRP_MJ_CLOSE
Every driver must handle close requests in a DispatchClose routine, with the possible exception of a driver whose device cannot be disabled or removed from the machine without bringing down the system. A disk driver whose device holds the system page file is an example of such a driver. Note that the driver of such a device also cannot be unloaded dynamically.
When Sent
Receipt of this request indicates that the last handle of the file object that is associated with the target device object has been closed and released. All outstanding I/O requests have been completed or canceled.
Input Parameters
None
Output Parameters
None
Operation
Many device and intermediate drivers merely set STATUS_SUCCESS in the I/O status block of the IRP and complete the close request. However, what a given driver does on receipt of a close request depends on the driver's design. In general, a driver should undo whatever actions it takes on receipt of the IRP_MJ_CREATE request. Device drivers whose device objects are exclusive, such as a serial driver, also can reset the hardware on receipt of a close request.
The IRP_MJ_CLOSE request is not necessarily sent in the context of the process that closed the file object handle. If the driver must release process-specific resources, such as user memory, that the driver previously locked or mapped, it must do so in response to an IRP_MJ_CLEANUP request.
The IRP_MJ_CLOSE request will always be sent at PASSIVE_LEVEL.
IRP_MJ_SHUTDOWN
Drivers of mass-storage devices that have internal caches for data must handle this request in a DispatchShutdown routine. Drivers of mass-storage devices and intermediate drivers layered over them also must handle this request if an underlying driver maintains internal buffers for data.
When Sent
Receipt of a shutdown request indicates that a file system driver is sending notice that the system is being shut down.
One or more file system drivers can send such a lower-level driver more than one shutdown request when a user logs off or when the system is being shut down for some other reason.
Input Parameters
None
Output Parameters
None
Operation
The driver must complete the transfer of any data currently cached in the device or held in the driver's internal buffers before completing the shutdown request.
A driver does not receive an IRP_MJ_SHUTDOWN request for a device object unless it registers to do so with either IoRegisterShutdownNotification or IoRegisterLastChanceShutdownNotification.