From d3cebda659be16308ac86802daf37de7a0c1565b Mon Sep 17 00:00:00 2001 From: Sebastian Lackner Date: Sat, 20 Aug 2016 23:26:28 +0200 Subject: [PATCH] Added patch to fill out DeviceInfoData in SetupDiGetDeviceInterfaceDetail even if interface buffer is too small. --- patches/patchinstall.sh | 18 +++++ ...c-file-stub-entry-for-SetupDiInstall.patch | 33 ++++++++ ...GetDeviceInterfaceDetail-should-fill.patch | 80 +++++++++++++++++++ .../definition | 1 + 4 files changed, 132 insertions(+) create mode 100644 patches/setupapi-SetupDiGetDeviceInterfaceDetail/0001-setupapi-Add-spec-file-stub-entry-for-SetupDiInstall.patch create mode 100644 patches/setupapi-SetupDiGetDeviceInterfaceDetail/0002-setupapi-SetupDiGetDeviceInterfaceDetail-should-fill.patch create mode 100644 patches/setupapi-SetupDiGetDeviceInterfaceDetail/definition diff --git a/patches/patchinstall.sh b/patches/patchinstall.sh index 8c9d45b0..ba08690a 100755 --- a/patches/patchinstall.sh +++ b/patches/patchinstall.sh @@ -293,6 +293,7 @@ patch_enable_all () enable_setupapi_DiskSpaceList="$1" enable_setupapi_Display_Device="$1" enable_setupapi_HSPFILEQ_Check_Type="$1" + enable_setupapi_SetupDiGetDeviceInterfaceDetail="$1" enable_setupapi_SetupPromptForDisk="$1" enable_sfc_SfcGetNextProtectedFile="$1" enable_shdocvw_ParseURLFromOutsideSource_Tests="$1" @@ -1051,6 +1052,9 @@ patch_enable () setupapi-HSPFILEQ_Check_Type) enable_setupapi_HSPFILEQ_Check_Type="$2" ;; + setupapi-SetupDiGetDeviceInterfaceDetail) + enable_setupapi_SetupDiGetDeviceInterfaceDetail="$2" + ;; setupapi-SetupPromptForDisk) enable_setupapi_SetupPromptForDisk="$2" ;; @@ -6120,6 +6124,20 @@ if test "$enable_setupapi_HSPFILEQ_Check_Type" -eq 1; then ) >> "$patchlist" fi +# Patchset setupapi-SetupDiGetDeviceInterfaceDetail +# | +# | Modified files: +# | * dlls/setupapi/devinst.c, dlls/setupapi/setupapi.spec, dlls/setupapi/tests/devinst.c +# | +if test "$enable_setupapi_SetupDiGetDeviceInterfaceDetail" -eq 1; then + patch_apply setupapi-SetupDiGetDeviceInterfaceDetail/0001-setupapi-Add-spec-file-stub-entry-for-SetupDiInstall.patch + patch_apply setupapi-SetupDiGetDeviceInterfaceDetail/0002-setupapi-SetupDiGetDeviceInterfaceDetail-should-fill.patch + ( + echo '+ { "Michael Müller", "setupapi: Add spec file stub entry for SetupDiInstallDeviceInterfaces and SetupDiRegisterCoDeviceInstallers.", 1 },'; + echo '+ { "Michael Müller", "setupapi: SetupDiGetDeviceInterfaceDetail should fill out DeviceInfoData even if the buffer for DeviceInterfaceData is too small.", 1 },'; + ) >> "$patchlist" +fi + # Patchset setupapi-SetupPromptForDisk # | # | This patchset fixes the following Wine bugs: diff --git a/patches/setupapi-SetupDiGetDeviceInterfaceDetail/0001-setupapi-Add-spec-file-stub-entry-for-SetupDiInstall.patch b/patches/setupapi-SetupDiGetDeviceInterfaceDetail/0001-setupapi-Add-spec-file-stub-entry-for-SetupDiInstall.patch new file mode 100644 index 00000000..71b01e76 --- /dev/null +++ b/patches/setupapi-SetupDiGetDeviceInterfaceDetail/0001-setupapi-Add-spec-file-stub-entry-for-SetupDiInstall.patch @@ -0,0 +1,33 @@ +From 48b23f25de1d337f144d698423e3888036400d8e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +Date: Thu, 18 Aug 2016 18:37:29 +0200 +Subject: setupapi: Add spec file stub entry for SetupDiInstallDeviceInterfaces + and SetupDiRegisterCoDeviceInstallers. + +--- + dlls/setupapi/setupapi.spec | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec +index cc873ae..575607e 100644 +--- a/dlls/setupapi/setupapi.spec ++++ b/dlls/setupapi/setupapi.spec +@@ -366,6 +366,7 @@ + @ stub SetupDiInstallClassExW + @ stdcall SetupDiInstallClassW(long wstr long ptr) + @ stub SetupDiInstallDevice ++@ stub SetupDiInstallDeviceInterfaces + @ stub SetupDiInstallDriverFiles + @ stdcall SetupDiLoadClassIcon(ptr ptr ptr) + @ stub SetupDiMoveDuplicateDevice +@@ -378,6 +379,7 @@ + @ stdcall SetupDiOpenDeviceInterfaceA(ptr str long ptr) + @ stub SetupDiOpenDeviceInterfaceRegKey + @ stdcall SetupDiOpenDeviceInterfaceW(ptr wstr long ptr) ++@ stub SetupDiRegisterCoDeviceInstallers + @ stdcall SetupDiRegisterDeviceInfo(ptr ptr long ptr ptr ptr) + @ stdcall SetupDiRemoveDevice(ptr ptr) + @ stub SetupDiRemoveDeviceInterface +-- +2.9.0 + diff --git a/patches/setupapi-SetupDiGetDeviceInterfaceDetail/0002-setupapi-SetupDiGetDeviceInterfaceDetail-should-fill.patch b/patches/setupapi-SetupDiGetDeviceInterfaceDetail/0002-setupapi-SetupDiGetDeviceInterfaceDetail-should-fill.patch new file mode 100644 index 00000000..6d66f490 --- /dev/null +++ b/patches/setupapi-SetupDiGetDeviceInterfaceDetail/0002-setupapi-SetupDiGetDeviceInterfaceDetail-should-fill.patch @@ -0,0 +1,80 @@ +From 687fc3ff0c5ea37f782bd0f02c7fe856cab583a5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michael=20M=C3=BCller?= +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. + +--- + dlls/setupapi/devinst.c | 8 ++++---- + dlls/setupapi/tests/devinst.c | 6 +++++- + 2 files changed, 9 insertions(+), 5 deletions(-) + +diff --git a/dlls/setupapi/devinst.c b/dlls/setupapi/devinst.c +index 02e75b6..4dac40d 100644 +--- a/dlls/setupapi/devinst.c ++++ b/dlls/setupapi/devinst.c +@@ -2956,8 +2956,6 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA( + NULL, NULL); + else + DeviceInterfaceDetailData->DevicePath[0] = '\0'; +- if (DeviceInfoData && DeviceInfoData->cbSize == sizeof(SP_DEVINFO_DATA)) +- *DeviceInfoData = *info->device; + ret = TRUE; + } + else +@@ -2966,6 +2964,8 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailA( + *RequiredSize = bytesNeeded; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } ++ if (DeviceInfoData && DeviceInfoData->cbSize == sizeof(SP_DEVINFO_DATA)) ++ *DeviceInfoData = *info->device; + return ret; + } + +@@ -3024,8 +3024,6 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailW( + lstrcpyW(DeviceInterfaceDetailData->DevicePath, info->symbolicLink); + else + DeviceInterfaceDetailData->DevicePath[0] = '\0'; +- if (DeviceInfoData && DeviceInfoData->cbSize == sizeof(SP_DEVINFO_DATA)) +- *DeviceInfoData = *info->device; + ret = TRUE; + } + else +@@ -3034,6 +3032,8 @@ BOOL WINAPI SetupDiGetDeviceInterfaceDetailW( + *RequiredSize = bytesNeeded; + SetLastError(ERROR_INSUFFICIENT_BUFFER); + } ++ if (DeviceInfoData && DeviceInfoData->cbSize == sizeof(SP_DEVINFO_DATA)) ++ *DeviceInfoData = *info->device; + return ret; + } + +diff --git a/dlls/setupapi/tests/devinst.c b/dlls/setupapi/tests/devinst.c +index 319bb31..d349917 100644 +--- a/dlls/setupapi/tests/devinst.c ++++ b/dlls/setupapi/tests/devinst.c +@@ -833,6 +833,7 @@ static void testGetDeviceInterfaceDetail(void) + "\\\\?\\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; +@@ -860,9 +861,12 @@ static void testGetDeviceInterfaceDetail(void) + !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", +-- +2.9.0 + diff --git a/patches/setupapi-SetupDiGetDeviceInterfaceDetail/definition b/patches/setupapi-SetupDiGetDeviceInterfaceDetail/definition new file mode 100644 index 00000000..90be1042 --- /dev/null +++ b/patches/setupapi-SetupDiGetDeviceInterfaceDetail/definition @@ -0,0 +1 @@ +Fixes: Fill out DeviceInfoData in SetupDiGetDeviceInterfaceDetail even if interface buffer is too small