I am new to the windows driver and don’t get very good information. I know that using IoCreateDevice we can give the driver name and create a symbolic link for the device name but I am using WdfDeviceCreate and don’t have any idea of how to the device name when creating the
wdfdevice. Below is the code for the DeviceAdd function.
NTSTATUS EvtDeviceAdd(
IN WDFDRIVER Driver,
IN PWDFDEVICE_INIT DeviceInit
)
{
NTSTATUS status;
WDFDEVICE device;
PDEVICE_CONTEXT devCtx = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks;
WDF_IO_QUEUE_CONFIG ioQConfig;
UNREFERENCED_PARAMETER(Driver);
KdPrint((__DRIVER_NAME “–> EvtDeviceAdd\n”));
/*set the callback functions that will be executed on PNP and Power events*/
WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks);
pnpPowerCallbacks.EvtDevicePrepareHardware = EvtDevicePrepareHardware;
pnpPowerCallbacks.EvtDeviceD0Entry = EvtDeviceD0Entry;
pnpPowerCallbacks.EvtDeviceD0Exit = EvtDeviceD0Exit;
WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks);
WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoBuffered);
/*initialize storage for the device context*/
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes, DEVICE_CONTEXT);
/*create a device instance.*/
status = WdfDeviceCreate(&DeviceInit, &attributes, &device);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreate failed with status 0x%08x\n”, status));
return status;
}
devCtx = GetDeviceContext(device);
/*create the default IO queue. this one will be used for ioctl requests*/
WDF_IO_QUEUE_CONFIG_INIT_DEFAULT_QUEUE(&ioQConfig,
WdfIoQueueDispatchSequential);
ioQConfig.EvtIoDefault = EvtDeviceIoDefault;
status = WdfIoQueueCreate(device,
&ioQConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&devCtx->IoDefaultQueue);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfIoQueueCreate failed with status 0x%08x\n”, status));
return status;
}
status = WdfDeviceCreateDeviceInterface(device, &GUID_DEV_IF_BASIC, NULL);
if(!NT_SUCCESS(status))
{
KdPrint((__DRIVER_NAME
“WdfDeviceCreateDeviceInterface failed with status 0x%08x\n”, status));
return status;
}
KdPrint((__DRIVER_NAME “<– EvtDeviceAdd\n”));
return status;
}
Can you please tell me how to give the device name so that i can use it in CreateFile().
Thanks & regards,
Nilam