I need to crea开发者_StackOverflow中文版te 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"
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.
精彩评论