Use full comparison when searching for a tap driver

This commit is contained in:
Monsterovich 2024-03-28 02:24:26 +02:00
parent fdc2532aee
commit 6101c61988

View file

@ -31,9 +31,9 @@
#define ADAPTER_KEY "SYSTEM\\CurrentControlSet\\Control\\Class\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
#define NETWORK_CONNECTIONS_KEY "SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}"
#ifdef USE_TAPV9
#define TAP_COMPONENT_ID_PREFIX "root\\tap0901"
#define TAP_COMPONENT_ID "root\\tap0901"
#else
#define TAP_COMPONENT_ID_PREFIX "tap"
#define TAP_COMPONENT_ID "tapoas"
#endif
#define USERMODEDEVICEDIR "\\\\.\\Global\\"
@ -98,8 +98,7 @@ int findTapDevice(char *deviceID, int deviceIDLen, char *deviceName, int deviceN
len = sizeof(componentId);
status = RegQueryValueEx(key, "ComponentId", NULL, NULL, componentId, &len);
if (status == ERROR_SUCCESS &&
strncmp(componentId, TAP_COMPONENT_ID_PREFIX, strlen(TAP_COMPONENT_ID_PREFIX)) == 0) {
if (status == ERROR_SUCCESS && strcmp(componentId, TAP_COMPONENT_ID) == 0) {
if (skip < 1) {
len = deviceIDLen;
RegQueryValueEx(key, "NetCfgInstanceId", NULL, NULL, deviceID, &len);