You need to check for error returns from your calls to GetRawInputDeviceList and GetRawInputDeviceInfo. Specifically, see
this MSDN article for details on handling errors from GetRawInputDeviceInfo. Based on the symptoms you describe, the call is failing and you're just writing garbage memory to the screen.
In general, when calling an API function,
always check for errors. You want your program to barf at the first sign that something might be wrong. The sooner you know that something has failed, the easier it is to figure out what exactly is going on. In this particular case, checking for errors from GetRawInputDeviceInfo would immediately highlight the cause of the problem.
Also, always initialize your variables before passing them into an API function. For example, whenever I need to pass a raw string buffer into an API, I use this trick:
// Not such a good plan:char buffer[512];APIFunction(buffer, sizeof(buffer));// If APIFunction() fails, buffer just has crap in it!// Better plan:char buffer[512] = "ERROR - buffer not filled by APIFunction";APIFunction(buffer, sizeof(buffer));// Now if APIFunction() fails, I immediately see it