winusb: Check for ClassGuid changes on re-enumeration

Previously only the dev_id (VID/PID/serial) was checked, but if the
bcdDevice has changed, Windows will have re-enumerated the device and
possibly attributed another ClassGuid to it.

Fixes issue #897.
Closes #900

Thanks to Craig Hutchinson for reporting, suggestion and testing.

Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
diff --git a/libusb/os/windows_common.h b/libusb/os/windows_common.h
index 2de2b60..792a31e 100644
--- a/libusb/os/windows_common.h
+++ b/libusb/os/windows_common.h
@@ -259,6 +259,7 @@
 	} usb_interface[USB_MAXINTERFACES];
 	struct hid_device_priv *hid;
 	PUSB_CONFIGURATION_DESCRIPTOR *config_descriptor; // list of pointers to the cached config descriptors
+	GUID class_guid; // checked for change during re-enumeration
 };
 
 struct usbdk_device_handle_priv {
diff --git a/libusb/os/windows_winusb.c b/libusb/os/windows_winusb.c
index e1e599c..cdca6cb 100644
--- a/libusb/os/windows_winusb.c
+++ b/libusb/os/windows_winusb.c
@@ -1721,6 +1721,7 @@
 
 					priv = winusb_device_priv_init(dev);
 					priv->dev_id = _strdup(dev_id);
+					priv->class_guid = dev_info_data.ClassGuid;
 					if (priv->dev_id == NULL) {
 						libusb_unref_device(dev);
 						LOOP_BREAK(LIBUSB_ERROR_NO_MEM);
@@ -1735,6 +1736,12 @@
 						libusb_unref_device(dev);
 						goto alloc_device;
 					}
+					if (!IsEqualGUID(&priv->class_guid, &dev_info_data.ClassGuid)) {
+						usbi_dbg("device class GUID for session [%lX] changed", session_id);
+						usbi_disconnect_device(dev);
+						libusb_unref_device(dev);
+						goto alloc_device;
+					}
 				}
 
 			track_unref:
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 3924959..e0c04dc 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11625
+#define LIBUSB_NANO 11626