Filter driver for inbox usb composite driver

Hi

I am writing a filter driver for inbox usb composite driver. In the filter driver I have only DriverEntry and EvtDeviceAdd, (for now, later I will add actual stuff) with a default queue created and a EvtIodefault.

After installation control is never going to EvtIoDefault for the Pnp requests (or any other). I need to handle IRP_MN_QUERY_INTERFACE.

In WDM we have DiaptchPnp to receive all PNP request. Is there any way to configure the queue to receive only Pnp requests.

TIA
jitender Singh

Jitender Singh wrote:

After installation control is never going to EvtIoDefault for the Pnp
requests (or any other). I need to handle IRP_MN_QUERY_INTERFACE.

Yeah, that’s because IRP_MN_QUERY_INTERFACE is not “I/O”, and thus it does not arrive at your queue. You want to register a WDM IRP preprocess routine, see the docs for details.

Although I think we’re all wondering what you’re up to…

Yes, what are you trying to do? Which QI are you trying to filter?

d

Sent from my phone with no t9, all spilling mistakes are not intentional.

-----Original Message-----
From: xxxxx@gmail.com
Sent: Thursday, October 29, 2009 8:21 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Filter driver for inbox usb composite driver

Jitender Singh wrote:

> After installation control is never going to EvtIoDefault for the Pnp
> requests (or any other). I need to handle IRP_MN_QUERY_INTERFACE.

Yeah, that’s because IRP_MN_QUERY_INTERFACE is not “I/O”, and thus it does not arrive at your queue. You want to register a WDM IRP preprocess routine, see the docs for details.

Although I think we’re all wondering what you’re up to…


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

I would guess that his intention is described on this page at msdn.

http://msdn.microsoft.com/en-us/library/aa476427.aspx

/Faik

That would have been my guess, but it is always good to be explicit. If this is your final goal, register a handler for the QI by calling WdfDeviceAddQueryInterface, http://msdn.microsoft.com/en-us/library/aa490707.aspx

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Faik Riza
Sent: Thursday, October 29, 2009 8:45 AM
To: Windows System Software Devs Interest List
Subject: Re: RE:[ntdev] Filter driver for inbox usb composite driver

I would guess that his intention is described on this page at msdn.

http://msdn.microsoft.com/en-us/library/aa476427.aspx

/Faik
— 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

Hi ,

Chris Aseltine, Doron Holan and Velio Roumenov thanks for the useful guidance/replies.

(Sorry, I forgot to mention it in previous post )
I am trying for custom enumeration of usb interfaces and referring to
http://msdn.microsoft.com/en-us/library/aa476427.aspx

TIA
Jitender Singh

Hi,

I am exposing the driver defined interface for the GUID USB_BUS_INTERFACE_USBC_CONFIGURATION_GUID and control is going to the callback of the interface.

Now If I define a structure

typedef struct _FILTER_INTERFACE {
INTERFACE InterfaceHeader;
USBC_DEVICE_CONFIGURATION_INTERFACE_V1 DevConfigurationInterfaceV1;
} FILTER_INTERFACE, *PFILTER_INTERFACE;

Oops pressed wrong key :frowning:

I am exposing the driver defined interface for the GUID USB_BUS_INTERFACE_USBC_CONFIGURATION_GUID and control is going to the callback of the interface.

Now If I define a structure
typedef struct _FILTER_INTERFACE
{
INTERFACE InterfaceHeader;
USBC_DEVICE_CONFIGURATION_INTERFACE_V1 DevConfigurationInterfaceV1;
} FILTER_INTERFACE, *PFILTER_INTERFACE;

After defining the structure and filling the members when I create the interface using this FILTER_INTERFACE, the control is not going to the interface callback.

Am I doing something wrong?

Should I return the USB interface collection in EvtDeviceProcessQueryInterfaceRequests’s PINTERFACE?
But how to get descriptors here, as there is no WDFUSBDEVICE.

HOw to expose USBC_DEVICE_CONFIGURATION_INTERFACE_V1/USBC_START_DEVICE_CALLBACK
to the usbccgp.sys ?

TIA
Jitender Singh

Post the code that you use to make the call to WdfDeviceAddQueryInterface. You do not need a WDM preprocess routine for this query interface, KMDF can handle everything you need if you make the right API call

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Monday, November 02, 2009 11:00 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Filter driver for inbox usb composite driver

Oops pressed wrong key :frowning:

I am exposing the driver defined interface for the GUID USB_BUS_INTERFACE_USBC_CONFIGURATION_GUID and control is going to the callback of the interface.

Now If I define a structure
typedef struct _FILTER_INTERFACE
{
INTERFACE InterfaceHeader;
USBC_DEVICE_CONFIGURATION_INTERFACE_V1 DevConfigurationInterfaceV1;
} FILTER_INTERFACE, *PFILTER_INTERFACE;

After defining the structure and filling the members when I create the interface using this FILTER_INTERFACE, the control is not going to the interface callback.

Am I doing something wrong?

Should I return the USB interface collection in EvtDeviceProcessQueryInterfaceRequests’s PINTERFACE?
But how to get descriptors here, as there is no WDFUSBDEVICE.

HOw to expose USBC_DEVICE_CONFIGURATION_INTERFACE_V1/USBC_START_DEVICE_CALLBACK
to the usbccgp.sys ?

TIA
Jitender Singh


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

Hi doron

Here is the code snippet for WdfDeviceAddQueryInterface. In USBC_START_DEVIEC_CALLBACK I have not implemented anything (for now, atleast control should come there, then i can think of implementing that)

****************filter.h
typedef struct _FILTER_INTERFACE {
INTERFACE InterfaceHeader;
USBC_DEVICE_CONFIGURATION_INTERFACE_V1 DevConfigurationInterfaceV1;
} FILTER_INTERFACE, *PFILTER_INTERFACE;

typedef struct _FILTER_EXTENSION
{
ULONG DummyParameter;
FILTER_INTERFACE filterInterface;

} FILTER_EXTENSION, *PFILTER_EXTENSION;

***********filter.c
***************code from EvtDeviceAdd


WDF_QUERY_INTERFACE_CONFIG qiConfig;
PFILTER_EXTENSION filterExtension;


filterExtension = FilterGetExtension(Device);

filterExtension->filterInterface.InterfaceHeader.Size = sizeof(filterExtension->filterInterface);
filterExtension->filterInterface.InterfaceHeader.Version = 1;
filterExtension->filterInterface.InterfaceHeader.Context = (PVOID) Device;
filterExtension->filterInterface.InterfaceHeader.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
filterExtension->filterInterface.InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;

filterExtension->filterInterface.DevConfigurationInterfaceV1.Size = sizeof(USBC_DEVICE_CONFIGURATION_INTERFACE_V1);
filterExtension->filterInterface.DevConfigurationInterfaceV1.Version = 1;
filterExtension->filterInterface.DevConfigurationInterfaceV1.Context = (PVOID) Device;
filterExtension->filterInterface.DevConfigurationInterfaceV1.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
filterExtension->filterInterface.DevConfigurationInterfaceV1.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
filterExtension->filterInterface.DevConfigurationInterfaceV1.StartDeviceCallback = MyStartDeviceCallback;

//
// Initialize the qiConfig structure.
//
WDF_QUERY_INTERFACE_CONFIG_INIT(&qiConfig,
(PINTERFACE) &filterExtension->filterInterface,
&USB_BUS_INTERFACE_USBC_CONFIGURATION_GUID,
NULL);

//
// Create the interface.
//
status = WdfDeviceAddQueryInterface(Device, &qiConfig);
if(!NT_SUCCESS(status))
{
return status;
}

**************************USBC_START_DEVICE_CALLBACK

NTSTATUS
MyStartDeviceCallback(
__in PUSB_DEVICE_DESCRIPTOR DeviceDescriptor,
__in PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor,
PUSBC_FUNCTION_DESCRIPTOR *FunctionDescriptorBuffer,
__out PULONG FunctionDescriptorBufferLength,
__in PDEVICE_OBJECT FdoDeviceObject,
__in PDEVICE_OBJECT PdoDeviceObject
)

{
UNREFERENCED_PARAMETER(DeviceDescriptor);
UNREFERENCED_PARAMETER(ConfigurationDescriptor);
UNREFERENCED_PARAMETER(FunctionDescriptorBuffer);
UNREFERENCED_PARAMETER(FunctionDescriptorBufferLength);
UNREFERENCED_PARAMETER(FdoDeviceObject);
UNREFERENCED_PARAMETER(PdoDeviceObject);

DebugPrint((“%s(IN)\n”,FUNCTION));
//create collection and return to the usbccgp (not implemented)
DebugPrint((“%s(OUT)\n”,FUNCTION));
return STATUS_SUCCESS; //dummy

}

TIA
Jitender Singh

Hi all,

I am done with the Callback function, by exposing the interface ,B

sorry for that.

I have implemented StartDevicecallback function in my driver. but while installing the driver I am getting
ERROR: This device cannot start .(code 10).

I am using same inf to load the composite driver and my upper filter driver.

In StartDevicecallback :

  1. I am allocating memory for (*FunctionDescriptorBuffer) = ExAllocatePoolWithTag(…).
    Since I want only one functionDescriptor size is sizeof(USBC_FUNCTION_DESCRIPTOR)

  2. Allocating memory for pointer to array of pointer ;(*FunctionDescriptorBuffer)->InterfaceDescriptorList
    here I have two interfaces of the device.

ref:http://c-faq.com/aryptr/dynmuldimary.html array1

  1. I am extracting interface descriptors using USBD_ParseConfigurationDescriptorEx and copying it using RtlCopyMemory to (*FunctionDescriptorBuffer)->InterfaceDescriptorList[0] &(*FunctionDescriptorBuffer)->InterfaceDescriptorList [1]

  2. I am also allocating memory for UNICODE_STRINGS in USBC_FUNCTION_DESCRIPTOR
    hradwareId is L"USB\vid_xxxx&pid_xxxx&MI_01"
    compatibleId is L"USB\Class_xx"
    FunctionDescription is L"some description"

(*FunctionDescriptorBuffer)->FunctionNumber = 0;

(*FunctionDescriptorBuffer)->NumberofInterfaces= 2;

(*FunctionDescriptorBuffer)->FunctionFlags = 0;

*FunctionDescriptorBufferLength = sizeof(USBC_FUNCTION_DESCRIPTOR);

No idea how to debug Code 10 error. Read in one post that it may be because of START_DEVICE failure.

thanks for your help

> No idea how to debug Code 10 error. Read in one post that it may be because of START_DEVICE

failure.

So, you don’t know why your own function returns error?


Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com

My function is does not returns error, it is the usbccgp.sys which returns error, I would have debugged that if I had the source :slight_smile:

I was asking what might be the cause, sys or inf or something else?

I might be overlooking something which some of the experienced guys here can figure out

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

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

xxxxx@gmail.com wrote:

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.

Are you getting in to your StartDevice callback? Did you trace through
it to see where it goes awry?

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 =

This code has memory leaks. If any of the allocations fail, you don’t
clean up the previous ones that succeeded. However, none of those
allocations are necessary. You can pass HardwareId and friends directly
to RtlInitUnicodeString, unless you need to modify the strings.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

yes, the XYZStartDeviceCallback is being called.
The data sent in the function pointers are verified using WInDbg and the pointers are correct.
I fixed the memory leaks.

If I use
RtlInitUniceodeString(pointer_to_uniccode_string,L"some_id");
the bug check 0xC2 (BAD_POOL_CALLER)occurs with first parameter 99( The current thread attempted to free pool with an invalid address.This code can also indicate corruption in the pool header.)

Do usbccgp also tries to free the buffer member of UNICODE_STRING? As when I use RtlInitUnicodeString as in previous post , the bug check disappears.

regards,
Jitender

Well, it would appear that yes, usbccgp frees the buffer so you must allocate it from pool. Are you sure that USBD_ParseConfigurationDescriptorEx is returning a non NULL pointer for each interface in the loop? I looked at the usbccgp validation code and the docs do not clearly spell out the requirements here

the HardwareId and CompatibleId fields in USBC_FUNCTION_DESCRIPTOR need to be a multi sz string, which means you need to change the declaration of these 2 vars (note the embedded \0)

WCHAR HardwareId = L"USB\vid_xxxx&PID_yyyy&MI_zz\0";
WCHAR CaompatibleId = L"USB\Class_ww\0";

RtlInitUnicodeString(&((*FunctionDescriptorBuffer)->HardwareId), p1); <== remove this
RtlInitUnicodeString(&((*FunctionDescriptorBuffer)->CompatibleId), p2); <== remove this

Replace them with
FunctionDescriptorBuffer->HardwareId.Buffer = p1;
FunctionDescriptorBuffer->HardwareId.Length = FunctionDescriptorBuffe)->HardwareId.MaximumLength = sizeof(p1);
FunctionDescriptorBuffer->CompatibleId.Buffer = p2;
FunctionDescriptorBuffer->CompatibleId.Length = FunctionDescriptorBuffer->CompatibleId.MaximumLength = sizeof(p2);

You have to manually initialize the UNICODE_STRING because RtlInitUnicodeString takes the length of the passed in string and that will be one character too short since it stops at the first NULL, not the 2nd one.

d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Wednesday, December 16, 2009 11:51 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Filter driver for inbox usb composite driver

yes, the XYZStartDeviceCallback is being called.
The data sent in the function pointers are verified using WInDbg and the pointers are correct.
I fixed the memory leaks.

If I use
RtlInitUniceodeString(pointer_to_uniccode_string,L"some_id");
the bug check 0xC2 (BAD_POOL_CALLER)occurs with first parameter 99( The current thread attempted to free pool with an invalid address.This code can also indicate corruption in the pool header.)

Do usbccgp also tries to free the buffer member of UNICODE_STRING? As when I use RtlInitUnicodeString as in previous post , the bug check disappears.

regards,
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

I made the changes as suggested by you.with modification(s)

(*FunctionDescriptorBuffer)->HardwareId.Buffer = p1;
(*FunctionDescriptorBuffer)->HardwareId.Length = sizeof(HardwareId) -1; (*FunctionDescriptorBuffe)->HardwareId.MaximumLength = sizeof(HardwareId);

as sizeof(p1) would return 4.

USBD_ParseConfigurationDescriptorEx is returning non NULL pointers to interface descriptors in the loop.
(I attached driver to WinDbg;set breakpoints;and checked the memory location returned by USBD_ParseConfigurationDescriptorEx).
Also interfaces are getting printed.

Still the Driver installs with the error code 10. :frowning:

regards
Jitender