Last active
September 3, 2016 00:34
-
-
Save drojf/8661066e7d0d4c29d41591cf290aae1b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Make sure this device is of Setup Class "HIDClass" and has a | |
driver bound to it. */ | |
#define ENABLE_HIDCLASS_CHECK 1 | |
#define ENABLE_FOR_LOOP 1 | |
#if ENABLE_FOR_LOOP | |
for (i = 0; ; i++) { | |
#else | |
i = device_index; | |
#endif | |
char driver_name[256]; | |
/* Populate devinfo_data. This function will return failure | |
when there are no more interfaces left. */ | |
res = SetupDiEnumDeviceInfo(device_info_set, i, &devinfo_data); | |
if (!res) | |
{ | |
printf("failure on SetupDiEnumDeviceInfo()!\n"); | |
goto cont; | |
} | |
printf("Getting driver of i: [%d] Instance: [%d] guid: [%d]", i, devinfo_data.DevInst, devinfo_data.ClassGuid); | |
res = SetupDiGetDeviceRegistryPropertyA(device_info_set, &devinfo_data, | |
SPDRP_CLASS, NULL, (PBYTE)driver_name, sizeof(driver_name), NULL); | |
if (!res) | |
{ | |
printf("failure on SetupDiGetDeviceRegistryPropertyA()!\n"); | |
goto cont; | |
} | |
printf(" Driver: %s\n", driver_name); | |
#if ENABLE_HIDCLASS_CHECK | |
#if ENABLE_FOR_LOOP | |
if (strcmp(driver_name, "HIDClass") == 0) { | |
res = SetupDiGetDeviceRegistryPropertyA(device_info_set, &devinfo_data, | |
SPDRP_DRIVER, NULL, (PBYTE)driver_name, sizeof(driver_name), NULL); | |
if (res) | |
break; | |
} | |
#else | |
if (strcmp(driver_name, "HIDClass") != 0) { | |
goto cont; | |
} | |
#endif | |
#endif | |
#if ENABLE_FOR_LOOP | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment