How to create .inf file for PnP Driver?

Done! Thank you so much Tim_Roberts! AddDevice function was called! (But IRP_MJ_PNP not accepted, after my driver was loaded, it is automatically unloaded after AddDevice function is finished. May be i should change my AddDevice function and create device for IRP can be accepted?)… P.S: I am installed my driver through Device Manager → Update Driver

My final inf file looks like that

[Version]
Signature=“$Windows NT$”
Class=Mouse
ClassGUID={4D36E96F-E325-11CE-BFC1-08002BE10318}
Provider=%Provider%
DriverVer=03/17/2001,1.0.0.1
CatalogFile=MouseDriver.cat
CatalogFile.NTAMD64 = MouseDriver.cat
PnpLockdown=1

[DestinationDirs]
DefaultDestDir = 13

[SourceDisksNames]
1 = %DiskName%

[SourceDisksFiles]
MouseDriver.sys = 1

[ControlFlags]
; We don’t want our device to be installable via the non-PnP hardware dialogs
ExcludeFromSelect = *

; Manufacturer Section
; ---------------------------------------------------------
[Manufacturer]
%ShinyThings%=ShinyThingsMfg,NT,NTAMD64

; Devices Section
; ---------------------------------------------------------
[ShinyThingsMfg.NTAMD64]
%HID\Vid_045E&Pid_001E.DeviceDesc%=MouseDriver_Inst, HID\Vid_045E&Pid_001E
%HID\Vid_045E&Pid_0029.DeviceDesc%=MouseDriver_Inst, HID\Vid_045E&Pid_0029
%HID\Vid_045E&Pid_0039.DeviceDesc%=MouseDriver_Inst, HID\Vid_045E&Pid_0039
%HID\Vid_045E&Pid_0040.DeviceDesc%=MouseDriver_Inst, HID\Vid_045E&Pid_0040
%HID\Vid_045E&Pid_0047.DeviceDesc%=MouseDriver_Inst, HID\Vid_045E&Pid_0047
%HID\Vid_10C4&PID_8108.DeviceDesc%=MouseDriver_Inst, HID\Vid_10C4&PID_8108

; Install Section
; ---------------------------------------------------------
[MouseDriver_Inst.NTAMD64]
Include = MSMOUSE.INF
Needs = HID_Mouse_Inst.NT
CopyFiles = MouseDriver_Inst_CopyFiles.NT

[MouseDriver_Inst.NTAMD64.HW]
Include = MSMOUSE.INF
Needs = HID_Mouse_Inst.NT.Hw
AddReg = MouseDriver_Inst_HWAddReg.NT

[MouseDriver_Inst_HWAddReg.NTAMD64]
HKR,“UpperFilters”,0x00010000,“MouseDriver”

[MouseDriver_Inst_CopyFiles.NTAMD64]
MouseDriver.sys

[MouseDriver_Inst.NTAMD64.Services]
Include = MSMOUSE.INF
Needs = HID_Mouse_Inst.NT.Services
AddService = MouseDriver, 2, MouseDriver_Service_Inst

[MouseDriver_Service_Inst]
DisplayName = %MouseDriver.SvcDesc%
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL
ServiceBinary = %13%\MouseDriver.sys

;[MouseDriver_Inst.NT.Wdf]
;KmdfService = MouseDriver, MouseDriver_wdfsect

;[MouseDriver_wdfsect]
;KmdfLibraryVersion = $KMDFVERSION$

; Strings Section
; ---------------------------------------------------------
[Strings]
; Provider names
Provider = “TODO-Set-Provider”

; Mfg names
ShinyThings = “Shiny Things”

; Service names
MouseDriver.SvcDesc = “MouseDriver Service”

; Media names
DiskName = “MouseDriver Driver Disk”

; HID device IDs
HID\VID_045E&PID_001E.DeviceDesc = “Shiny Things MouseDriver Mouse”
HID\VID_045E&PID_0029.DeviceDesc = “Shiny Things MouseDriver Mouse”
HID\VID_045E&PID_0039.DeviceDesc = “Shiny Things MouseDriver Mouse”
HID\VID_045E&PID_0040.DeviceDesc = “Shiny Things MouseDriver Mouse”
HID\VID_045E&PID_0047.DeviceDesc = “Shiny Things MouseDriver Mouse”
HID\VID_10C4&PID_8108.DeviceDesc = “Shiny Things MouseDriver Mouse”

; Standard defs
SPSVCINST_TAGTOFRONT = 0x00000001
SPSVCINST_ASSOCSERVICE= 0x00000002
SERVICE_KERNEL_DRIVER = 1
SERVICE_BOOT_START = 0
SERVICE_SYSTEM_START = 1
SERVICE_AUTO_START = 2
SERVICE_ERROR_NORMAL = 1
SERVICE_ERROR_IGNORE = 0
REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001
REG_SZ = 0x00000000

Finally, i am run this example successfully: https://github.com/9176324/WinDDK/tree/master/3790.1830/src/input/moufiltr

But mouse not working :(( driver is successfully loads, AddDevice also was called, but mouse is stuck and i can`t understand why

Still have a problem with USB mouse… it does not work despite the moufiltr driver is loaded successfully. It just stuck and no service callback function called

… WinDDK/tree/master/3790.1830/c/input/moufiltr

Good God, man! That source code is from the Windows Server 2003 DDK. It is, quite literally, 20 years old! Remember, source code doesn’t age like wine – it’s ages like milk.

Here is the current driver sample from the actual source, not a bootleg copy posted by someone who didn’t have the right to do so:

https://github.com/microsoft/Windows-driver-samples/tree/main/input/moufiltr

But mouse not working

If you read the readme, that filter is intended to be a filter to the i8042 driver, which means it is designed for PS/2 mice. I doubt you’ve ever even SEEN a PS/2 mouse. It doesn’t know anything about USB. Check out the current moufiltr sample – it’s INF should allow it to be inserted in any mouse stack.

Again, I’m disturbed by the direction you’re going. You’re just hacking around, throwing stuff together without any understanding of what it’s for or how it works, and apparently without reading the reference material. You really need to have a plan.

Tim_Roberts

You are right, I am little bit lost in the driver development :slight_smile:

Yes, I saw the implementation in WDF, but I want to study WDM first. Moreover, I find more examples for legacy drivers, including books/articles. But for WDF i can`t find enough information (only source codes with comments)

OSR has found that learning WDM first is not the best path. Remember that WDF has now existed far longer than WDM existed before WDF. WDM had a 10 year lifetime before WDF. WDF has now been around for 18 years. It’s not the new kid on the block – it is the correct way to write Windows drivers.

It is true there are fewer textbook-type materials for WDF, but that’s only because it arrived at a point when books were dying out. There are tutorials galore, and OSR has some excellent articles on their web site.

For me WDF something like black box and i think to better understand WDF i should know WDM. Also as i know, WDF have some limitations and for good confidence in driver development i think WDM knowledge is must have for every kernel developer.

Let me ask you question about WDM moufiltr. How i can modify moufiltr and use it for USB driver? :slight_smile:

Can anyone please explain to me what exactly is the problem?

Is this an inf file problem or driver architecture problem? Driver loads successfully by PnP Manager, the AddDevice function is called and I also get the IOCTL_INTERNAL_MOUSE_CONNECT IRP. But service callback function is never called when i try to use USB mouse, it is stuck. I need a direction in which to search for a solution to the problem

Have you changed the source? There’s not much to go wrong in that code.

No, I didn’t change the code. Just added DebugPrintEx to make sure the functions are called. https://github.com/9176324/WinDDK/tree/master/3790.1830/src/input/moufiltr

Still can`t use my USB mouse. Why is it so difficult when all you need to do is install a standard driver so that the mouse works? What do I need to read to understand what the problem is?

[Content deleted by mods: Unhelpful, snarky, adds no value, and creates a new discussion. @Janeer is warned to please not repeat this behavior.]