0

Some code:

typedef struct _WDF_USB_DEVICE_SELECT_CONFIG_PARAMS { 
ULONG Size;
WdfUsbTargetDeviceSelectConfigType Type;
union {   
     struct {
     PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor;
     PUSB_INTERFACE_DESCRIPTOR*  InterfaceDescriptors;
     ULONG NumInterfaceDescriptors;
     } Descriptor;

     struct {
     PURB  Urb;
     } Urb;
   } Types;

} WDF_USB_DEVICE_SELECT_CONFIG_PARAMS,*PWDF_USB_DEVICE_SELECT_CONFIG_PARAMS; WDF_USB_DEVICE_SELECT_CONFIG_PARAMS params;

typedef struct _USB_INTERFACE_DESCRIPTOR {
UCHAR bLength ;
UCHAR bInterfaceClass ;
UCHAR bInterfaceSubClass ;
} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR ;

Able to acess NumInterfaceDescriptors via -> params.Types.Descriptor.NumInterfaceDescriptors

I want to acess bInterfaceClass via WDF_USB_DEVICE_SELECT_CONFIG_PARAMS . Please note that this structure is filled by the library I have to just access it

7
  • 1
    I have rolled this back so at least the code is legible. Please take any further edits forward from this point, and when you have done an edit, check that what you have done produces legible output! Commented Jan 18, 2010 at 12:12
  • 2
    And remember that what appears in the edit preview is NOT necessarily what appears on the final page. Commented Jan 18, 2010 at 12:17
  • @Neil: good work ... I tried a couple of times, including copying the code to an external editor and tidying it up there, but I gave up. I find it very hard to decipher still, when the union's members aren't indented. Not your fault of course, it was quite a mouthfall to begin with. Commented Jan 18, 2010 at 12:20
  • @unwind - Yeah, I can't make head nor tail of it myself :-) Commented Jan 18, 2010 at 12:24
  • 1
    With regards to stackoverflow.com/questions/2084077/accessing-double-pointer (and my comment to it), please try to proof-read your questions before submitting, and pretty please try not to significantly change the question once you asked it. I'd also recommend learning to walk before you run, i.e. learning how to handle structs, pointers and typedef's before you go into USB interface programming. Commented Jan 18, 2010 at 14:00

2 Answers 2

2

It appears that what you want is:

ULONG iface;

for (iface = 0; iface < params.Types.Descriptor.NumInterfaceDescriptors; iface++)
{
    do_something_with(params.Types.Descriptor.InterfaceDescriptors[iface]);
}

..but you should really put some more time into making your questions clear so that people don't have to guess what you mean.

Sign up to request clarification or add additional context in comments.

2 Comments

InterfaceDescriptors is a double pointer pointing to structure
I can see that. The structure definition strongly implies that it is a pointer to an array of NumInterfaceDescriptors pointers to structures.
1

Google for WDF_USB_DEVICE_SELECT_CONFIG_PARAMS. The first hit leads you to the relevant MSDN page, which tells you that Types.Descriptor.InterfaceDescriptors

contains a driver-supplied pointer to an array of USB_INTERFACE_DESCRIPTOR structures

and that Types.Descriptor.NumInterfaceDescriptors indeed

contains the number of elements that are in the interface array that Types.Descriptor.InterfaceDescriptors points to.

Ergo, your "pointer to pointer" is actually an array of USB_INTERFACE_DESCRIPTOR pointers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.