Controlling GPS Intermediate Driver Execution
A version of this page is also available for
4/8/2010
The GPS Intermediate Driver (GPSID) runs in device.exe and supports some of the standard service IOCTLs:
For example, IOCTL_SERVICE_REFRESH causes the GPSID to re-read its configuration information from the registry. The other IOCTLs can be used to query, disable, or re-enable GPSID operation. For example, you might use IOCTL_SERVICE_STOP to turn off the GPSID.
Sending IOCTLs to the GPS Intermediate Driver
The GPSID uses a control channel, "GPD0:", to process this group of IOCTLs. To send IOCTLs to the GPS Intermediate Driver:
- Open a connection to the GPS Intermediate Driver, by calling CreateFile and passing "GPD0:" as the first parameter.
- Send the desired message to the GPS Intermediate Driver, by calling DeviceIoControl with the appropriate IOCTL.
- Close the connection to the GPS Intermediate Driver, by calling CloseHandle.
For example, the following code sends an IOCTL_SERVICE_REFRESH to the GPS Intermediate Driver:
HANDLE hGPS = CreateFile(L"GPD0:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (hGPS != INVALID_HANDLE_VALUE) {
DeviceIoControl(hGPS,IOCTL_SERVICE_REFRESH,0,0,0,0,0,0);
CloseHandle(hGPS);
}
IOCTL_SERVICE_START
This IOCTL causes the GPS Intermediate Driver to enter a state where it accepts calls for data using the parsed API or the raw interface. You might use this IOCTL to restart the GPS Intermediate Driver after turning it off using IOCTL_SERVICE_STOP.
This IOCTL does not open the GPS hardware. Instead, the first parsed API or raw interface call causes GPSID to open the GPS hardware.
IOCTL_SERVICE_STOP
This IOCTL causes the GPS Intermediate Driver to:
- close its connection to the underlying GPS hardware, even if applications are currently using the GPS Intermediate Driver to retrieve GPS data,
- close existing raw interface handles with an error, and
- signal all events passed in the GPSOpenDevice hDeviceStateChange parameter.
Any calls to GPSID using GPSOpenDevice or CreateFile will fail after this IOCTL has been processed. To re-enable the GPSID after using this IOCTL, use IOCTL_SERVICE_START.
IOCTL_SERVICE_STATUS
This IOCTL returns the current state of the GPS Intermediate Driver. For more information, see IOCTL_SERVICE_STATUS.
IOCTL_SERVICE_REFRESH
This IOCTL causes the GPSID to re-read its configuration parameters from the registry. The GPSID does not reflect any registry changes until the IOCTL_SERVICE_REFRESH IOCTL is processed. For more information, see Refreshing GPS Intermediate Driver Configuration using IOCTL_SERVICE_REFRESH.