Question: I'm messing around with a USB RFID scanner and trying to read input with [raw input](http://msdn.microsoft.com/en-us/library/ms645536%28v=VS.85%29.aspx), so far I have this

```
#define _WIN32_WINNT 0x0601
#include <windows.h>
#include <stdio.h>

int main(void)
{
    PRAWINPUTDEVICELIST pRawInputDeviceList;
    PUINT puiNumDevices, pcbSize;
    UINT cbSize = sizeof(RAWINPUTDEVICELIST);
    char *pData[1000];

    GetRawInputDeviceList(NULL, puiNumDevices, cbSize);    
    pRawInputDeviceList = malloc(cbSize * *puiNumDevices);   
    GetRawInputDeviceList(pRawInputDeviceList, puiNumDevices, cbSize);

    // gives a correct RIM_TYPE for all devices 0-7 (GetRawInputDeviceList returns 8 devices for me)
    printf("%I32u\n", pRawInputDeviceList[0].dwType); 

    GetRawInputDeviceInfo(pRawInputDeviceList[1].hDevice, RIDI_DEVICENAME, pData, pcbSize);

    // gives a huge number (garbage?), should be the length of the name
    printf("%u\n", pcbSize);        

    // "E" in my case
    printf("%s\n", pData);

    // error 87, apparently ERROR_INVALID_PARAMETER
    printf("%I32u\n", GetLastError()); 

    return 0;

}

```

Answer: 
When you call `GetRawInputDeviceInfo`, it expects `pcbSize` to be a pointer. You have it as a pointer, but its not pointing to anything. Try this:

1. Get rid of `pcbSize` (everywhere).
2. Create a variable `UINT cbDataSize = 1000`. This is the size of your `pData` array.
3. For the last argument of `GetRawInputDeviceInfo`, use `&cbDataSize`. This takes the address of `cbDataSize`, the address is a pointer.
4. Change `printf("%u\n", pcbSize);` to `printf("%u\n", cbDataSize);`.

See how that works for you.

[edit]

Also, you should do the same thing for `puiNumDevices`. Instead, create a `UINT` called `uiNumDevices`. Use `&uiNumDevices` where the functions expect pointers.
I am going to go out on a limb here and guess that this thing may actually be a HID device. Do you know if it is?

HID Devices are actually pretty easy to talk to; you connect to them via CreateFile() -- the same way that you would open a COM port -- and then just ReadFile() to get data.

Most of the problem is figuring out the correct path to connect to. It's actually a value called DevicePath that you get from SetupDiGetDeviceInterfaceDetail().

A rough map of it looks like this:

HidD\_GetHidGuid() to get the HID guid  

 SetupDiGetClassDevs() to get the list of dev  

 Looping through devs, until you find yours:  

* SetupDiEnumDeviceInterfaces() to enum the device interfaces
* SetupDiGetDeviceInterfaceDetail() to get the detail
* CreateFile() to open the device with the DevicePath from the detail.
* HidD\_GetAttributes to get the vendorid and productid to see if it's your device.

If it is, remember it, and use ReadFile() to get data.