0

I am trying to create a pnp driver but when I run sc start driver-name I get an System error 1058 (disable disabled or no enabled device associated). However if I modify the code for nonpnp WDF_DRIVER_CONFIG_INIT(&config, WDF_NO_EVENT_CALLBACK); and config.DriverInitFlags |= WdfDriverInitNonPnpDriver; the service starts and I am able to debug.

I have tried different hwid values for the device verified through device manager. The DriverEntry runs fine, I've used windbg but the device add function is never called.

Driver Entry Code for pnp.

// prototype for add device function
EVT_WDF_DRIVER_DEVICE_ADD QDeviceAdd;

NTSTATUS DriverEntry(
    IN OUT PDRIVER_OBJECT   DriverObject,
    IN PUNICODE_STRING      RegistryPath
    )
{
    NTSTATUS                       status = STATUS_SUCCESS;
    WDF_DRIVER_CONFIG              config;
    WDFDRIVER                      hDriver;
    PWDFDEVICE_INIT                pInit = NULL;
    WDF_OBJECT_ATTRIBUTES          attributes;

    KdPrint(("enabling wpp tracing\n"));
    WPP_INIT_TRACING(DriverObject, RegistryPath);

    WDF_DRIVER_CONFIG_INIT(
        &config,
        QDeviceAdd // WDF_NO_EVENT_CALLBACK This is a non-pnp driver.
        );

    WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
    attributes.EvtCleanupCallback = QEvtDriverContextCleanup;

    status = WdfDriverCreate(DriverObject,
        RegistryPath,
        &attributes,
        &config,
        &hDriver);

    if (!NT_SUCCESS(status)) {
        KdPrint(("NonPnp: WdfDriverCreate failed with status 0x%x\n", status));
        WPP_CLEANUP(DriverObject);
        return status;
    }

    return status;
}
Luis
  • 114
  • 2
  • 10

1 Answers1

0

Apparently previous copies of the inf file remained in the store and registry wasn't being updated so after some digging I ended doing the following:

checking in C:\Windows\Inf\setupapi.dev.log and copying the the missing file. Then deleted the driver from store using pnputil

  • pnputil -d oemXX.inf
  • manually removed the key HKLM\SYSTEM\CurrentControlSet\Control\Class{your-class-id}
  • pnputil -i /path/to/inf

Thanks to this site and this post

Community
  • 1
  • 1
Luis
  • 114
  • 2
  • 10