INF having issues unable to install on Windows 10 Operating issue

Hello,

I’ve been tasked to make the Windows7 WDM USB driver code to make compatible with Windows 10 and Windows 11 Operating systems.

Installation using INF and HaveDisk method was successful for Windows7 Operating system but not for Windows10/11 Operating systems.
However, there is a sample application( which used to communicate with the device) installs the same driver on all three operating systems i.e. Windows 7/10/11.

I suspect that INF is compatible for Windows 10/11 operating systems.
Could you please help me understand what is the issue here

`[Version]
Signature=$Windows NT$
Class=WAUSB
ClassGUID={02CD7357-C6B4-4B0F-A27A-0326A7527B9E}
Provider=%WA_STR%
CatalogFile=wausb.cat
DriverVer=04/04/2018,1.9.12.0
;----------------------------------------------------------------------------

[SourceDisksNames]
1 = %DiskId1%,,,\i386

[SourceDisksNames.x86]
1 = %DiskId1%,,,\i386

[SourceDisksNames.amd64]
1 = %DiskId1%,,,\amd64

[SourceDisksFiles]
wausb.sys  	= 1,,
wausb.dll  	= 1,,

[SourceDisksFiles.amd64]
wausb.sys  	= 1,,
wausb.dll 	= 1,,
wausb32.dll 	= 1,,

[DestinationDirs]
DefaultDestDir=10
CopyDLLFiles = 11
CopyWOW64DLLFiles = 10, SysWOW64
CopyDrvFiles = 12
;----------------------------------------------------------------------------

[ClassInstall32]
AddReg=ClassAddReg

[ClassAddReg]
HKR,,,%REG_SZ%,%DeviceClassName%
HKR,,Icon,,"-20"
HKR,,NoInstallClass,,1
;-----------------------------------------------------------------------------

[Manufacturer]
%WAMfg%=DeviceList, NTx86, NTamd64

[DeviceList]
"WA CP150" = DriverInstall, USB\VID_0770&PID_1111

[DeviceList.NTx86]
"WA CP150" = DriverInstall, USB\VID_0770&PID_1111

[DeviceList.NTAMD64]
"WA CP150" = DriverInstall, USB\VID_0770&PID_1111

[DriverInstall]
CopyFiles=CopyDrvFiles
CopyFiles=CopyDLLFiles

[DriverInstall64]
CopyFiles=CopyDrvFiles
CopyFiles=CopyDLLFiles
CopyFiles=CopyWOW64DLLFiles

[CopyDrvFiles]
wausb.sys

[CopyDLLFiles]
wausb.dll

[CopyWOW64DLLFiles]
wausb.dll, wausb32.dll

[DriverInstall64.Services]
AddService=WAUsb,%SPSVCINST_ASSOCSERVICE%,DriverService

[DriverInstall.Services]
AddService=WAUsb,%SPSVCINST_ASSOCSERVICE%,DriverService

[DriverService]
DisplayName    = %DESCRIPTION_STR%
ServiceType    = %SERVICE_KERNEL_DRIVER%
StartType      = %SERVICE_DEMAND_START%
ErrorControl   = %SERVICE_ERROR_NORMAL%
ServiceBinary  = %12%\wausb.sys
;------------------------------------------------------------------------------

[Strings]
WAMfg =             "WA"
WA_STR =            "WA"
DESCRIPTION_STR=    "WA Generic USB Driver"
USBDEVDESC =        "WA USB Devices"
DiskId1 =           "WA Driver Installation Disk #1"
DeviceClassName =   "WA USB Devices"
;------------------------------------------------------------------------------

;Handy macro substitution
SERVICE_KERNEL_DRIVER = 1
SERVICE_DEMAND_START =  0X03
SERVICE_ERROR_NORMAL =  1
REG_EXPAND_SZ =         0X00020000
REG_DWORD =             0X00010001
FLG_ADDREG_TYPE_DWORD = 0X00010001
REG_MULTI_SZ =          0X00010000
REG_SZ =                0X00000000
DEVICECHARACTER_FLAGS=  0x00000100
DELFLG_IN_USE1 =        0x00010000
SPSVCINST_ASSOCSERVICE = 0x00000002
`

When ran Inf2cat it is giving an error. Please find the log below:

Inf2Cat Tool Output:
..........................
Signability test failed.

Errors:
22.9.1: wausb.sys in [copydrvfiles] of WaUsb\wausb.inf is missing or cannot be decompressed from source media.  Please verify all path values specified in SourceDisksNames, SouceDisksFiles, and CopyFiles sections resolve to the actual location of the file, and are expressed in terms relative to the location of the inf.
22.9.1: wausb.dll in [copydllfiles] of WaUsb\wausb.inf is missing or cannot be decompressed from source media.  Please verify all path values specified in SourceDisksNames, SouceDisksFiles, and CopyFiles sections resolve to the actual location of the file, and are expressed in terms relative to the location of the inf.
22.9.1: wausb.dll in [copywow64dllfiles] of WaUsb\wausb.inf is missing or cannot be decompressed from source media.  Please verify all path values specified in SourceDisksNames, SouceDisksFiles, and CopyFiles sections resolve to the actual location of the file, and are expressed in terms relative to the location of the inf.

Warnings:
None

Your install doesn’t work in Windows 10/11 because it is no longer possible to install self-signed drivers. The inf2cat errors are just because you tested the INF by itself, without having the subdirectories (i386 and amd64) set up.

Thanks Tim for your immediate reply.

Even in Test mode, can we not install self signed drivers?

I have installed the release driver which was compiled for Windows 7 OS and it is successfully installed.
When installed the same release driver on Win10 OS it is throwing error and encountered problem in installing driver.

Below is the Release Directory structure

Release
|--> amd64
|    |--> WaUsb.dll
|    |--> WaUsb.lib
|    |--> WaUsb.sys
|    |--> WaUsb32.dll
|--> i386
|    |--> WaUsb.dll
|    |--> WaUsb.lib
|    |--> WaUsb.sys
|--> Symbols
|    |--> amd64
|    |    |--> WaUsb.pdb
|    |--> i386
|    |    |--> WaUsb.pdb
|--> WaUsb.cat
|--> WaUsb.inf

When installed the same release driver on Win10 OS it is throwing error and encountered problem in installing driver.

Which error? There are hundreds. Don’t make us guess.

Hi Tim,

Below is the error I am getting when installing the driver on Windows 10 OS.

"Windows cannot load the device driver for this hardware. The driver may be corrupted or missing. (Code 39)

{Driver Entry Point Not Found}
The %hs device driver could not locate the entry point %hs in the driver %hs.

Please find my DriverEntry and Add device functions below:

_Use_decl_annotations_
NTSTATUS
DriverEntry( 
	IN PDRIVER_OBJECT  DriverObject,
    IN PUNICODE_STRING RegistryPath)
{
    NTSTATUS Status = STATUS_SUCCESS;

    DBGPRINT(5, ("Entering WAUsb.sys\n"));

#if DBG
	// The following line will raise an exception for debug builds. 
	// This will stop the system upon entry into the driver so that 
	// start up conditions can be checked/tested
	DbgBreakPoint();
#endif
	ExInitializeDriverRuntime(DrvRtPoolNxOptIn);

	// Setup the call back entry points
	DriverObject->MajorFunction[IRP_MJ_PNP]            = WAUSBPnpDispatch;
	DriverObject->MajorFunction[IRP_MJ_POWER]          = WAUSBPowerDispatch;
	DriverObject->MajorFunction[IRP_MJ_CREATE]         = WAUSBOpen;
	DriverObject->MajorFunction[IRP_MJ_CLOSE]		   = WAUSBClose;
	DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = WAUSBDispatchIoctl;
	DriverObject->MajorFunction[IRP_MJ_CLEANUP]        = WAUSBCleanup;
	DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = WAUSBSystemControl;
	DriverObject->DriverExtension->AddDevice           = WAUSBAddDevice;
	DriverObject->DriverUnload                         = WAUSBUnload;
	
    return Status;
	UNREFERENCED_PARAMETER(RegistryPath);
}

_Use_decl_annotations_
NTSTATUS 
WAUSBAddDevice(
	IN PDRIVER_OBJECT	pDriverObj,
	IN PDEVICE_OBJECT	pPdo)
{
	NTSTATUS		status;
	PDEVICE_OBJECT	pDevObj;

	PAGED_CODE();

	// Create the device object
	status = IoCreateDevice(pDriverObj,
							sizeof(WAUSB_EXT),
							NULL,
							FILE_DEVICE_UNKNOWN,
							0,
							FALSE,
							&pDevObj);

	if (!NT_SUCCESS(status))
	{
		DBGPRINT(5, ("WAUSBAddDevice: Failed to create the device object: %x\n", 
					status));
		return status;
	}

	// Initialize the device object
	pDevObj->Flags |= DO_DIRECT_IO;
	pDevObj->Flags |= DO_POWER_PAGABLE;	// Only allow power IRPs to be sent at passive level

	// Get the device extension
	PWAUSB_EXT pDevExt = (PWAUSB_EXT)pDevObj->DeviceExtension;

	// Save the driver and device object
	pDevExt->pDriver = pDriverObj;
	pDevExt->pSelf = pDevObj;
	pDevExt->pPdo = pPdo;

	// Attach to the lower device object
	pDevExt->pLowerDevice = IoAttachDeviceToDeviceStack(pDevObj, pPdo);

	if (pDevExt->pLowerDevice == NULL)
	{
		IoDeleteDevice(pDevObj);
		DBGPRINT(5, ("WAUSBAddDevice: Failed to attach to the lower device object: %x\n", status));
		return STATUS_UNSUCCESSFUL;
	}

	// Initialize the remove lock
	IoInitializeRemoveLock(&pDevExt->RemoveLock,
							(ULONG)LOCK_TAG,
							0,
							0);

	// Initialize the stop event. Initialize it to signaled state. 
	KeInitializeEvent(&pDevExt->StopEvent, NotificationEvent, TRUE);
	
	// Intialize the reset event. Initialize it to a signaled state	
	KeInitializeEvent(&pDevExt->ResetEvent, NotificationEvent, TRUE);

	// Initialize the cancel safe queues
	//
	// Initialize the Pending IO Queue. This queue will be used to hold IO requests
	// for endpoints that are currently busy.
	KeInitializeSpinLock(&pDevExt->PendingIoLock);
	IoCsqInitialize(&pDevExt->PendingIoQueue,
					WAUSBPendingIoInsertIrp,
					WAUSBPendingIoRemoveIrp,
					WAUSBPendingIoPeekNextIrp,
					WAUSBPendingIoAcquireLock,
					WAUSBPendingIoReleaseLock,
					WAUSBPendingIoCompleteCancelIrp);
	InitializeListHead(&pDevExt->PendingIoList);

	// Initialize the Paused IO queue. Paused IO are requests that are received while
	// the device is in an invalid state to process them
	KeInitializeSpinLock(&pDevExt->PausedIoLock);
	IoCsqInitialize(&pDevExt->PausedIoQueue,
					WAUSBPausedIoInsertIrp,
					WAUSBPausedIoRemoveIrp,
					WAUSBPausedIoPeekNextIrp,
					WAUSBPausedIoAcquireLock,
					WAUSBPausedIoReleaseLock,
					WAUSBPausedIoCompleteCancelIrp);
	InitializeListHead(&pDevExt->PausedIoList);

	// Initialize the end point lock
	KeInitializeSpinLock(&pDevExt->EndPointLock);

	// Intialize the outstanding IO count and the spin lock
	KeInitializeSpinLock(&pDevExt->IoLock);
	pDevExt->OutstandingIoRequests = 0;

	// Create a look aside list from non-paged pool that will be used
	// to store the URB and USB Context
	//
	// Get the max size of an URB
	ULONG size;
	size = GET_ISO_URB_SIZE(MAX_ISO_PACKETS);

	ExInitializeNPagedLookasideList(
					&pDevExt->URBList, 
					NULL,			// Use ExAllocatePool()
					NULL,			// Use ExFreePool()
					0,				// Flags
					sizeof(USB_CONTEXT) + size - 1,
					PNP_TAG,
					0);				// Depth - resevered

	// Register an interface
	status = IoRegisterDeviceInterface( pPdo,
                                        &WA_USB_GUID,
                                        NULL,
                                        &pDevExt->szUniInterfaceName);

	if (!NT_SUCCESS(status))
	{
		IoDetachDevice(pDevExt->pLowerDevice);
		IoDeleteDevice(pDevObj);
		DBGPRINT(5, 
			("WAUSBAddDevice: Failed to register the device interface: %x\n", status));
		return status;
	} 

	// Now we are ready to go
	pDevObj->Flags &= ~DO_DEVICE_INITIALIZING;

	return STATUS_SUCCESS;
}

There’s a contradiction here. You said “the release driver which was compiled for Windows 7 OS” but ExInitializeDriverRuntime wasn’t introduced until Windows 8. Did you modify and rebuild this source for Windows 10? Perhaps you should email the .sys file to me, and I’ll check the list of exports and imports.

Yes, It is modified to make Windows 10 compatible.
Sent you the sys file via mail. Please check.

EXACTLY which version of WIndows 10 are you installing in? Your newer code calls ExAllocatePool2, which only works on Windows 10 2004 or newer. If you need to run on older systems, then you need to build for the older systems. The general rule is, always target your build for the oldest system you need to support.

Windows 10 Enterprise 22H2 OS Build 19045.4046

Hello Tim,

I need clarification on two scenarios.

Scenario-1:
I want to support all the Win10 OS versions and Win11 OS versions. In this case, I have installed the SDK+WDK Ver.10.0.14393 which supports Windows 10 Version 1607.

If I retarget my project to the SDK+WDK mentioned above version, as ExAllocatePool2 is introduced from Windows 10 2004 or newer so I cannot use this API… Correct me if I am wrong here.
If my understanding is correct then I have to use the ExAllocatePoolWithTag API instead of ExAllocatePool2… Correct my understanding here.

Scenario-2:
When I target to Win11 OS,

  • For Running WHQL certification, I have to run CodeQL.
  • When I run CodeQL on the previous code, it gives an error to resolve the deprecated API ExAllocatePoolWithTag and replace it with ExAllocatePool2.

In Scenario 1, for WHQL runs, Can the CodeQL report be ignored? If not what needs to be done?
Do I have to maintain two code bases, one for Window10 previous to 2004 and another for later Win10/11 OS versions?

Can you please guide me on this?

Hello Tim,

I would require your suggestions in two scenarios.

Scenario-1:
My driver should support all versions of Windows 10. As per your suggestion, I have installed the SDK+WDK Version.10.0.14393 which supports Windows 10 1607 and later.
I have retargeted the projects to the above SDK+WDK versions, I cannot use ExAllocatePool2, as it is introduced later to Win10 2004. Instead, I have to use the ExAllocatePoolWithTag API… correct me if I am wrong.

Scenario-2:
To support Win10 2004 and Win11 OS versions,

  • For running WHQL certification, CodeQL is mandatory
  • As running CodeQL on the above code gives an error regarding the deprecated ExAllocatePoolWithTag API is used. To resolve this error I have to use ExAllocatePool2 API.

In Scenario-1, Can CodeQL reports be ignored? If not what needs to be done?
For both scenarios, do I have to maintain two code bases one for Win10 OS versions till 1903 and another for later versions?

Can you please guide me on this?

I don’t know about how CodeQL relates to WHQL. There must be a way to certify drivers for pre-2004 Win 10 versions.

Hi Tim,

I have retargeted the build to Windows 7 OS as suggested.
With Driver Verifier enabled, I am unable to install the driver. It is giving Kernel PnP 411 error:Device had a problem starting(Code 10).

With Driver Verifier Disabled, driver is installed properly and able to get data from the device as well.

@mahendrashravan

I struggle a bit to understand exactly your goals here. Are you trying to install a driver created for Windows 7 on Windows 10 and 11? If that is what you want to do, then there are a couple of ways to achieve this:

  1. Follow the guidance here to modify the driver and infs to target Windows 7 and up:

Your statement “I have installed the SDK+WDK Version.10.0.14393 which supports Windows 10 1607 and later.” is not entirely accurate. I would recommend you install, matching versions of WDK, SDK and Windows versions you are building for. Please refer to this page https://learn.microsoft.com/en-us/windows-hardware/drivers/other-wdk-downloads

CodeQL is mandatory starting from Windows 10 or so, however only the ‘must-fix’ rules violation will be enforced for Static Tools Logo Test purposes. I strongly recommend you address the codeql failures and do not hope it will be ignored. see https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/static-tools-and-codeql for more guidance

I hope this helps.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.