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;
}