[Spice-devel] The solution of usbredir display problems for windows, temporarily

Cody Chan int64ago at gmail.com
Thu Sep 4 02:11:57 PDT 2014

Ok, this's not a patch, for I don't think it's good enough to be applied to
For windows client, it's really not friendly for usbredir:
1. We need usbclerk service to let it redirect automatically --> not stably
2. The display of redir-list is ALL "USB DEVICE" -->  make users confused
3. Filtering by class doesn't work at all --> usually need to filter input
devices, etc.

The reason for all the above is that libusb supports windows poorly.
So here's the solution for problem 2 & 3,
this's a vs2010 project built with libwdi
<http://sourceforge.net/projects/libwdi/>, the output is usbutils.dll,
and I put the project in github <https://github.com/int64Ago/UsbUtils4Spice>

After building libwdi, add LIBWDI_DIR=path\to\libwdi in environment
then build usbutils project

In gtk/usbutil.c or gtk/usb-device-manager.c ...
do something like this(just an example):
#define MAX_LEN_ 256
typedef struct{
        char desc[MAX_LEN_];
        int pid;
        int vid;
        int clas;

    UsbInfo usbInfo[20];
    typedef int (*fpFun)(UsbInfo[]);
    HMODULE hDllLib = LoadLibraryA("usbutils.dll");
    fpFun getUsbList = (fpFun)GetProcAddress(hDllLib,"getUsbList");
    int num = getUsbList(usbInfo);
    for(int i = 0; i < num; ++i){
        if(usbInfo[i].pid == pid && usbInfo[i].vid == vid)
            return g_strdup_printf("%s [%02X:%04X:%04X]", usbInfo[i].desc,
                usbInfo[i].clas, usbInfo[i].vid, usbInfo[i].pid);

​And at last, here's the effect:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20140904/4b8d3f72/attachment.html>

More information about the Spice-devel mailing list