Introduction
A .drv file is, in the explorer’s extension list, a Windows installable
driver. Microsoft’s page on creating a DriverProc function describes the
driver through the function it provides, which receives driver messages. The pages
consulted do not name the .drv extension or say what kind of file a
driver is; the explorer reads a file dropped here as an
NE or PE
file, with the structure of that container.
A file dropped on any page opens in the explorer, with its structure, resources and code, like any NE or PE file.
What is particular: DriverProc
Microsoft says a DriverProc function is created much like a window
procedure: a switch on the message, each case returning success or
failure. Its form is
LONG DriverProc(DWORD dwDriverId, HDRVR hdrvr, UINT msg, LONG lParam1, LONG lParam2),
and unhandled messages go to DefDriverProc. The messages named on that
page:
| Message | Meaning (Microsoft) |
|---|---|
DRV_LOAD | Sent when the driver is loaded; always the first message. Return 0 to fail. |
DRV_FREE | Sent when the driver is about to be discarded; the last message before it is freed. |
DRV_OPEN | Sent when the driver is opened; the value returned is used afterwards as dwDriverId. |
DRV_CLOSE | Sent when the driver is closed; drivers are unloaded when the open count reaches zero. |
DRV_ENABLE, DRV_DISABLE | Sent when the driver is loaded or reloaded and when Windows is enabled, and before the driver is freed or Windows is disabled. |
DRV_INSTALL, DRV_REMOVE | Sent when the driver is installed or removed. |
DRV_QUERYCONFIGURE, DRV_CONFIGURE | Sent to ask whether the driver can be configured (zero means not supported) and to show its configuration dialog box. |
The pages consulted do not state that the function is exported under the name
DriverProc; exports can be read in the
export directory of a Win32 file. The
.acm page describes the related callback of the
audio compression manager.
Not described
Unknown
- Extension, container and registration: the pages consulted do not name the .drv extension, say what kind of file a driver is, or say how a driver is registered or found.
Known, not yet covered
- Reference: the message numbers and the return codes.
Links
Software
Reference
- PE Format – Microsoft’s specification of PE32 and PE32+
- Creating a DriverProc Function – the form of DriverProc and its driver messages