Is XYZStartDeviceCallback being called?
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, December 16, 2009 5:14 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Filter driver for inbox usb composite driver
Hi,
I have written a upper filter driver for the usbccgp.sys to customize the enumeration of interfaces of the usb composite device for Win-7. Single INF file is used to load both the drivers(As recommended by DDK).
The problem is, driver is getting installed with error code 10. I tried to find the details of the error by attaching to WinDbg. But could not get any hints for the resolution. Neither setupapi.dev.log helped.
This is the relevant code for the flter driver:-
NTSTATUS XYZEvtDeviceAdd(IN WDFDRIVER Driver, IN PWDFDEVICE_INIT DeviceInit) {
…
WDFDEVICE hDevice;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_QUERY_INTERFACE_CONFIG qiConfig;
USBC_DEVICE_CONFIGURATION_INTERFACE_V1 devConfigurationInterfaceV1;
…
WdfFdoInitSetFilter(DeviceInit);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&attributes,DEVICE_EXTENSION);
status =WdfDeviceCreate(&DeviceInit,&attributes,&hDevice);
if(!NT_SUCCESS(status))
{
return status;
}
devConfigurationInterfaceV1.Size = sizeof(USBC_DEVICE_CONFIGURATION_INTERFACE_V1);
devConfigurationInterfaceV1.Version = 1;
devConfigurationInterfaceV1.Context = NULL;
devConfigurationInterfaceV1.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
devConfigurationInterfaceV1.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
devConfigurationInterfaceV1.StartDeviceCallback = XYZStartDeviceCallback;
WDF_QUERY_INTERFACE_CONFIG_INIT(&qiConfig,(PINTERFACE) devConfigurationInterfaceV1,
&USB_BUS_INTERFACE_USBC_CONFIGURATION_GUID,
NULL);
//importInterface and sendQueryToParentStack are both FALSE
status = WdfDeviceAddQueryInterface(hDevice, &qiConfig);
if(!NT_SUCCESS(status))
{
return status;
}
…
}
NTSTATUS XYZStartDeviceCallback(__in PUSB_DEVICE_DESCRIPTOR DeviceDescriptor,
__in PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
__deref_out_bcount_opt (*FunctionDescriptorBufferLength) PUSBC_FUNCTION_DESCRIPTOR * FunctionDescriptorBuffer,
__out PULONG FunctionDescriptorBufferLength,
__in PDEVICE_OBJECT FdoDeviceObject,
__in PDEVICE_OBJECT PdoDeviceObject) {
WCHAR *p1 = NULL;
WCHAR *p2 = NULL;
WCHAR *p3 = NULL;
UCHAR count = 0;
WCHAR HardwareId = L"USB\vid_xxxx&PID_yyyy&MI_zz";
WCHAR CaompatibleId = L"USB\Class_ww";
WCHAR FunctionDescription = L"XYZFunctionDescription";
PUSB_INTERFACE_DESCRIPTOR usbInterfaceDescriptor = NULL;
/////////////////////////////////////////////////////
p1 = (WCHAR *) ExAllocatePoolWithTag(NonPagedPool, sizeof(HardwareId), POOL_TAG);
if(NULL == p1)
{
return STATUS_UNSUCCESSFUL;
}
RtlCopyMemory(p1, HardwareId, sizeof(HardwareId)); /////////////////////////////////////////////////////
p2 = (WCHAR *) ExAllocatePoolWithTag(NonPagedPool,sizeof(CaompatibleId), POOL_TAG);
if(NULL == p2)
{
return STATUS_UNSUCCESSFUL;
}
RtlCopyMemory(p2, CaompatibleId, sizeof(CaompatibleId)); /////////////////////////////////////////////////////
p3 = (WCHAR *) ExAllocatePoolWithTag(NonPagedPool,sizeof(FunctionDescription),POOL_TAG);
if(NULL == p3)
{
return STATUS_UNSUCCESSFUL;
}
RtlCopyMemory(p3, FunctionDescription, sizeof(FunctionDescription)); //////////////////////////////////////////////////////
*FunctionDescriptorBuffer =(PUSBC_FUNCTION_DESCRIPTOR) ExAllocatePoolWithTag(NonPagedPool, sizeof(USBC_FUNCTION_DESCRIPTOR), POOL_TAG);
if(NULL == *FunctionDescriptorBuffer)
{
return STATUS_UNSUCCESSFUL;
}
RtlZeroMemory(*FunctionDescriptorBuffer, sizeof(USBC_FUNCTION_DESCRIPTOR));
//////////////////////////////////////////////////////
(*FunctionDescriptorBuffer)->InterfaceDescriptorList =(PUSB_INTERFACE_DESCRIPTOR *) ExAllocatePoolWithTag(NonPagedPool,
sizeof(USB_INTERFACE_DESCRIPTOR *) * ConfigurationDescriptor->bNumInterfaces,
POOL_TAG);
if(NULL == (*FunctionDescriptorBuffer)->InterfaceDescriptorList)
{
return STATUS_UNSUCCESSFUL;
}
RtlZeroMemory((*FunctionDescriptorBuffer)->InterfaceDescriptorList,
sizeof(USB_INTERFACE_DESCRIPTOR *) * ConfigurationDescriptor->bNumInterfaces);
///////////////////////////////////////////////////////////
for(count = 0; count < ConfigurationDescriptor->bNumInterfaces;count++)
{
usbInterfaceDescriptor = NULL;
usbInterfaceDescriptor = USBD_ParseConfigurationDescriptorEx(ConfigurationDescriptor,
(PUSB_CONFIGURATION_DESCRIPTOR) ConfigurationDescriptor,
count,
-1,
-1,
-1,
-1);
(*FunctionDescriptorBuffer)->InterfaceDescriptorList[count] = usbInterfaceDescriptor;
DevMgmtPrintUsbInterfaceDescriptor((*FunctionDescriptorBuffer)->InterfaceDescriptorList[count]);
}
RtlInitUnicodeString(&((*FunctionDescriptorBuffer)->HardwareId), p1);
RtlInitUnicodeString(&((*FunctionDescriptorBuffer)->CompatibleId), p2);
RtlInitUnicodeString(&((*FunctionDescriptorBuffer)->FunctionDescription), p3);
(*FunctionDescriptorBuffer)->FunctionNumber = 0;
(*FunctionDescriptorBuffer)->NumberOfInterfaces = ConfigurationDescriptor->bNumInterfaces;
(*FunctionDescriptorBuffer)->FunctionFlags = 0;
*FunctionDescriptorBufferLength = sizeof(USBC_FUNCTION_DESCRIPTOR);
return STATUS_SUCCESS;
}
Appreciate the help.
Thanks,
Jitender
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer