Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I develop windows driver that does not touch hardware?

Tags:

windows

inf

wdk

I need to create a WDM driver that emulates a device that is not present. The driver needs to be loaded when the O/S boots, opened and closed via SetupDiXXX and CreateFile, needs to respond to DeviceIoControl, etc.

I have the driver coded, but XP refuses to load it. The system event viewer says:

The MyDevice service failed to start due to the following error: The service cannot be started, either because it is disabled or because it has no enabled devices associated with it.

Given that, I think the problem is in the INF file (reference below). Is it? How should I go about fixing it?

;; MyDevice.inf

[Version]
Signature="$Windows 95$"

Class=MyDeviceDeviceClass
ClassGUID={ff646f80-8def-11d2-9449-00105a075f6b}
Provider=%ProviderName%
DriverVer= 12/21/2009,1.0.0.1

[ClassInstall32]
Addreg=Class_AddReg

[Class_AddReg]
HKR,,,,%DeviceClassName%
HKR,,Icon,,"-18"

[DestinationDirs]
MyDevice_Files_Driver = 10,System32\Drivers


[Manufacturer]
%MfgName%=Mfg0

[Mfg0]
%DeviceDesc%=MyDevice_DDI, *MyDevice


[MyDevice_DDI]
CopyFiles=MyDevice_Files_Driver
AddReg=MyDevice_9X_AddReg


[MyDevice_DDI.NT]
CopyFiles=MyDevice_Files_Driver
AddReg=MyDevice_NT_AddReg

[MyDevice_DDI.NT.Services]
Addservice = MyDevice, 0x00000002, MyDevice_AddService

[MyDevice_AddService]
DisplayName    = %SvcDesc%
ServiceType    = 1
StartType      = 3
ErrorControl   = 1
ServiceBinary  = %10%\System32\Drivers\MyDevice.sys

[MyDevice_NT_AddReg]
HKLM, "System\CurrentControlSet\Services\MyDevice\Parameters","BreakOnEntry", 0x00010001, 0

[MyDevice_Files_Driver]
MyDevice.sys


[Strings]
ProviderName="Acme"
MfgName="Acme"
DeviceDesc="Acme"
DeviceClassName="Device class for MyDevice"
SvcDesc="MyDevice NT service"
like image 891
Clay Avatar asked Dec 22 '09 04:12

Clay


People also ask

Is it possible to use a piece of hardware without having a driver?

Today's operating systems have many generic drivers that allow hardware to work at a basic level without needing drivers or software. However, if that device has features unknown to the operating system, it will not work without drivers.

How do I create a Windows driver?

Create a new driver from a template (File->New Project->Create New Project->Project Type->Driver->Select the template of interest). After you create the project, in the Solution Explorer pane, select and hold (or right-click) the solution and choose Configuration Manager.


1 Answers

Self answered:

I changed the INF to include the following:

[Mfg0] %DeviceDesc%=MyDevice_DDI, *MyDevice\ipm1

The "\ipm1" is new, and a little voodoo in my eyes. I got it from an example in Chris Cant's "Writing Windows WDM Device Drvers".

The big change is using the "Add New Hardware" wizard from the control panel to install the driver. Right-click installing the INF is not enough. I suspect the reason is that it invokes the PnP manager which correctly fails to find hardware for the driver to control.

like image 168
Clay Avatar answered Oct 03 '22 08:10

Clay