Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The "64Bit" field is defined in the IOCTL or FSCTL control code. This field contains a bit flag that is always set for 64-bit callers, but is always clear for 32-bit. Which bit in the control code is chosen as the "64Bit" field is driver-specific, but it must be a bit that is never set for 32-bit callers. A good choice for most drivers is the most significant bit (MSB) in the Function field.
For example, the IOCTL (FSCTL) control codes used in 32-bit drivers contain four bitfields:
| Device type | Access | Function | Method |
|---|---|---|---|
16 bits |
2 bits |
12 bits |
2 bits |
As long as none of the existing driver-defined control codes set the MSB in the Function field, these control codes can continue to be used by 32-bit user-mode applications.
To accommodate 64-bit callers, the driver defines a Function field that is shorter by one bit. This bit is redefined as a "64Bit" field:
| Device type | Access | 64Bit | Function | Method |
|---|---|---|---|---|
16 bits |
2 bits |
1 bit |
11 bits |
2 bits |
The following code example shows how to define a "64Bit" field in a driver header file:
#define REGISTER_FUNCTION 0 // Define the IOCTL function code
#ifdef _WIN64
#define CLIENT_64BIT 0x800
#define REGISTER_FUNCTION 0
#define IOCTL_REGISTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
CLIENT_64BIT|REGISTER_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)
#else
#define IOCTL_REGISTER CTL_CODE(FILE_DEVICE_UNKNOWN, \
REGISTER_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)
#endif
typedef struct _IOCTL_PARAMETERS {
PVOID Addr;
SIZE_T Length;
HANDLE Handle;
} IOCTL_PARAMETERS, *PIOCTL_PARAMETERS;