2018-08-16 21:11:33 -07:00
|
|
|
From e9a6546ce13c09f63a180aceb7181d8145c120d3 Mon Sep 17 00:00:00 2001
|
2016-08-20 14:26:28 -07:00
|
|
|
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
|
|
|
|
Date: Fri, 19 Aug 2016 00:47:08 +0200
|
|
|
|
Subject: setupapi: SetupDiGetDeviceInterfaceDetail should fill out
|
|
|
|
DeviceInfoData even if the buffer for DeviceInterfaceData is too small.
|
|
|
|
|
|
|
|
---
|
2018-08-16 21:11:33 -07:00
|
|
|
dlls/setupapi/devinst.c | 14 ++++++++------
|
|
|
|
dlls/setupapi/tests/devinst.c | 6 +++++-
|
|
|
|
2 files changed, 13 insertions(+), 7 deletions(-)
|
2016-08-20 14:26:28 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c
|
2018-08-16 21:11:33 -07:00
|
|
|
index 9f77669..f8c347b 100644
|
2016-08-20 14:26:28 -07:00
|
|
|
--- a/dlls/setupapi/devinst.c
|
|
|
|
+++ b/dlls/setupapi/devinst.c
|
2018-08-16 21:11:33 -07:00
|
|
|
@@ -2844,9 +2844,6 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(
|
2016-08-20 14:26:28 -07:00
|
|
|
else
|
|
|
|
DeviceInterfaceDetailData->DevicePath[0] = '\0';
|
2018-08-16 21:11:33 -07:00
|
|
|
|
|
|
|
- if (device_data && device_data->cbSize == sizeof(SP_DEVINFO_DATA))
|
|
|
|
- copy_device_data(device_data, iface->device);
|
|
|
|
-
|
2016-08-20 14:26:28 -07:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
2018-08-16 21:11:33 -07:00
|
|
|
@@ -2855,6 +2852,10 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA(
|
2016-08-20 14:26:28 -07:00
|
|
|
*RequiredSize = bytesNeeded;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
}
|
2018-08-16 21:11:33 -07:00
|
|
|
+
|
|
|
|
+ if (device_data && device_data->cbSize == sizeof(SP_DEVINFO_DATA))
|
|
|
|
+ copy_device_data(device_data, iface->device);
|
|
|
|
+
|
2016-08-20 14:26:28 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2018-08-16 21:11:33 -07:00
|
|
|
@@ -2914,9 +2915,6 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(
|
2016-08-20 14:26:28 -07:00
|
|
|
else
|
|
|
|
DeviceInterfaceDetailData->DevicePath[0] = '\0';
|
2018-08-16 21:11:33 -07:00
|
|
|
|
|
|
|
- if (device_data && device_data->cbSize == sizeof(SP_DEVINFO_DATA))
|
|
|
|
- copy_device_data(device_data, iface->device);
|
|
|
|
-
|
2016-08-20 14:26:28 -07:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
2018-08-16 21:11:33 -07:00
|
|
|
@@ -2925,6 +2923,10 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailW(
|
2016-08-20 14:26:28 -07:00
|
|
|
*RequiredSize = bytesNeeded;
|
|
|
|
SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
}
|
2018-08-16 21:11:33 -07:00
|
|
|
+
|
|
|
|
+ if (device_data && device_data->cbSize == sizeof(SP_DEVINFO_DATA))
|
|
|
|
+ copy_device_data(device_data, iface->device);
|
|
|
|
+
|
2016-08-20 14:26:28 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c
|
2018-08-16 21:11:33 -07:00
|
|
|
index 9a8ecbc..187e022 100644
|
2016-08-20 14:26:28 -07:00
|
|
|
--- a/dlls/setupapi/tests/devinst.c
|
|
|
|
+++ b/dlls/setupapi/tests/devinst.c
|
2018-08-16 21:11:33 -07:00
|
|
|
@@ -674,6 +674,7 @@ static void testGetDeviceInterfaceDetail(void)
|
2016-08-20 14:26:28 -07:00
|
|
|
"\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}";
|
|
|
|
static const char path_w2k[] =
|
|
|
|
"\\\\?\\root#legacy_bogus#0000#{6a55b5a4-3f65-11db-b704-0011955c2bdb}\\";
|
|
|
|
+ SP_DEVINFO_DATA devinfo;
|
|
|
|
LPBYTE buf = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail =
|
|
|
|
(SP_DEVICE_INTERFACE_DETAIL_DATA_A *)buf;
|
2018-08-16 21:11:33 -07:00
|
|
|
@@ -701,9 +702,12 @@ static void testGetDeviceInterfaceDetail(void)
|
2016-08-20 14:26:28 -07:00
|
|
|
!lstrcmpiA(path_w2k, detail->DevicePath), "Unexpected path %s\n",
|
|
|
|
detail->DevicePath);
|
|
|
|
/* Check SetupDiGetDeviceInterfaceDetailW */
|
|
|
|
- ret = pSetupDiGetDeviceInterfaceDetailW(set, &interfaceData, NULL, 0, &size, NULL);
|
|
|
|
+ memset(&devinfo, 0, sizeof(devinfo));
|
|
|
|
+ devinfo.cbSize = sizeof(devinfo);
|
|
|
|
+ ret = pSetupDiGetDeviceInterfaceDetailW(set, &interfaceData, NULL, 0, &size, &devinfo);
|
|
|
|
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER,
|
|
|
|
"Expected ERROR_INSUFFICIENT_BUFFER, got error code: %d\n", GetLastError());
|
|
|
|
+ ok(devinfo.DevInst, "Expected DevInst to be set\n");
|
|
|
|
ok(expectedsize == size ||
|
|
|
|
(expectedsize + sizeof(WCHAR)) == size /* W2K adds a backslash */,
|
|
|
|
"SetupDiGetDeviceInterfaceDetailW returned wrong reqsize, got %d\n",
|
|
|
|
--
|
2018-08-16 21:11:33 -07:00
|
|
|
2.7.4
|
2016-08-20 14:26:28 -07:00
|
|
|
|