views:

215

answers:

6

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;
struct {
  UCHAR  NumberConfiguredPipes;
  WDFUSBINTERFACE  ConfiguredUsbInterface;
} SingleInterface;
struct {
  UCHAR  NumberInterfaces;
  PWDF_USB_INTERFACE_SETTING_PAIR  Pairs;
  UCHAR  NumberOfConfiguredInterfaces;
} MultiInterface;

} 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

+4  A: 
(*someIntDesc)->iInterface
Ignacio Vazquez-Abrams
+2  A: 
IntDesc foo;
// somehow initialize foo to actually point to (a pointer to) a valid structure
(*foo)->iInterface = 10;
DevSolar
You mean point at a pointer to a structure.
Roger Pate
You're right, of course. I shouldn't take linguistic shortcuts.
DevSolar
A: 

Deference it like this

(*intDesc)->iInterface
hab
Wrong member. But close.
Ignacio Vazquez-Abrams
thanks, edited :)
hab
+1  A: 

IntDesc is a type, not a variable. So the first thing you need to do is create a variable of the correct type:

IntDesc id;

Next, you'll need to have it point to allocated memory. I'm going to put everything on the stack, you may have other needs:

USB_INTERFACE_DESCRIPTOR usb;
PUSB_INTERFACE_DESCRIPTOR pusb = &usb;
id = &pusb;

Now that you have a valid pointer, you can go ahead an dereference it. Since this is a double pointer, you will need to dereference it twice:

(*(*id)).iInterface = 10;

Because C defines -> as a combination of * and ., you can express that more succinctly with:

(*id)->iInterface = 10; 
R Samuel Klatchko
+1  A: 

From the name InterfaceDescriptors, it would appear to point to an array of pointers to the structure. So the more idiomatic way would be:

InterfaceDescriptors[0]->iInterface = 10;
caf
A: 

Your code is quite wrong

NODE* ptr;
k.N.iInterface = 100;
ptr = (NODE*)malloc(sizeof(NODE));

And before accesing:

ptr->N1->iInterface

N1 should be initialized to something.

piotr