From 6b280f34f5dfb02e4f2d7d25dadd22371962a6de Mon Sep 17 00:00:00 2001 From: winesync Date: Sat, 16 Sep 2023 21:46:50 +0200 Subject: [PATCH] [WINESYNC] setupapi: Add SetupQueryInfVersionInformationA/W stub. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52616 Signed-off-by: Gijs Vermeulen Signed-off-by: Alexandre Julliard wine commit id dc0aa67ce690f67ae8c12d7bed0a449c1af8c693 by Gijs Vermeulen [WINESYNC] uuid: Add devguid.h. Needed to compile Tera Term. wine commit id e72a16b57f66b63a16bb3d1619ac4d42632cb141 by Alex Henrie [WINESYNC] setupapi/tests: Add more tests for buffer size handling in SetupDiGetDeviceInterfaceDetail(). wine commit id 60af599bb916260e8bb8a2f5d0111815f741fef4 by Zebediah Figura [WINESYNC] setupapi: Correctly calculate the required size in SetupDiGetDeviceInterfaceDetailA(). Don't include the null terminator twice. wine commit id 5711f03e8479936ac5e3bc71ba7987f6b7cb5586 by Zebediah Figura [WINESYNC] setupapi: Fill the required size in SetupDiGetDeviceInterfaceDetail() also on success. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=53387 wine commit id d15262e464ba3536567ad73f68d95e6b7f88f3aa by Zebediah Figura [WINESYNC] setupapi: Use _S_I(READ|WRITE) from sys/stat.h instead of redefining them. wine commit id a1ae33a3efb7231adf683484e9de66f84abb04d1 by Alex Henrie --- dll/win32/setupapi/query.c | 18 ++++++++++ dll/win32/setupapi/setupapi.spec | 4 +-- dll/win32/setupapi/setupapi_private.h | 4 --- dll/win32/setupapi/setupcab.c | 2 ++ modules/rostests/winetests/setupapi/devinst.c | 35 ++++++++++++++----- sdk/tools/winesync/setupapi.cfg | 2 +- 6 files changed, 50 insertions(+), 15 deletions(-) diff --git a/dll/win32/setupapi/query.c b/dll/win32/setupapi/query.c index 2f453034b8b..570c68c533c 100644 --- a/dll/win32/setupapi/query.c +++ b/dll/win32/setupapi/query.c @@ -774,3 +774,21 @@ BOOL WINAPI SetupGetInfDriverStoreLocationW( } #endif // (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA) + +BOOL WINAPI SetupQueryInfVersionInformationA(SP_INF_INFORMATION *info, UINT index, const char *key, char *buff, + DWORD size, DWORD *req_size) +{ + FIXME("info %p, index %d, key %s, buff %p, size %ld, req_size %p stub!\n", info, index, debugstr_a(key), buff, + size, req_size); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +BOOL WINAPI SetupQueryInfVersionInformationW(SP_INF_INFORMATION *info, UINT index, const WCHAR *key, WCHAR *buff, + DWORD size, DWORD *req_size) +{ + FIXME("info %p, index %d, key %s, buff %p, size %ld, req_size %p stub!\n", info, index, debugstr_w(key), buff, + size, req_size); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} diff --git a/dll/win32/setupapi/setupapi.spec b/dll/win32/setupapi/setupapi.spec index 66d804add97..5da201b5579 100644 --- a/dll/win32/setupapi/setupapi.spec +++ b/dll/win32/setupapi/setupapi.spec @@ -477,8 +477,8 @@ @ stdcall SetupQueryInfFileInformationW(ptr long wstr long ptr) @ stdcall SetupQueryInfOriginalFileInformationA(ptr long ptr ptr) @ stdcall SetupQueryInfOriginalFileInformationW(ptr long ptr ptr) -@ stub SetupQueryInfVersionInformationA -@ stub SetupQueryInfVersionInformationW +@ stdcall SetupQueryInfVersionInformationA(ptr long str ptr long ptr) +@ stdcall SetupQueryInfVersionInformationW(ptr long wstr ptr long ptr) @ stub SetupQuerySourceListA @ stub SetupQuerySourceListW @ stdcall SetupQuerySpaceRequiredOnDriveA(long str ptr ptr long) diff --git a/dll/win32/setupapi/setupapi_private.h b/dll/win32/setupapi/setupapi_private.h index 0928a50befb..4145cadfec6 100644 --- a/dll/win32/setupapi/setupapi_private.h +++ b/dll/win32/setupapi/setupapi_private.h @@ -320,10 +320,6 @@ struct callback_WtoA_context UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification, UINT_PTR, UINT_PTR ); -/* from msvcrt/sys/stat.h */ -#define _S_IWRITE 0x0080 -#define _S_IREAD 0x0100 - /* devinst.c */ DWORD diff --git a/dll/win32/setupapi/setupcab.c b/dll/win32/setupapi/setupcab.c index a39ea464921..7ab8700120c 100644 --- a/dll/win32/setupapi/setupcab.c +++ b/dll/win32/setupapi/setupcab.c @@ -22,6 +22,8 @@ #include #include +#include + #include HINSTANCE SETUPAPI_hInstance = NULL; diff --git a/modules/rostests/winetests/setupapi/devinst.c b/modules/rostests/winetests/setupapi/devinst.c index 9f4a514479a..f92cadd4859 100644 --- a/modules/rostests/winetests/setupapi/devinst.c +++ b/modules/rostests/winetests/setupapi/devinst.c @@ -26,8 +26,8 @@ #include "wingdi.h" #include "winuser.h" #include "winreg.h" -#include "initguid.h" #include "devguid.h" +#include "initguid.h" #include "devpkey.h" #include "setupapi.h" #include "cfgmgr32.h" @@ -1196,7 +1196,7 @@ static void test_device_iface_detail(void) SP_DEVICE_INTERFACE_DETAIL_DATA_A *detail; SP_DEVICE_INTERFACE_DATA iface = {sizeof(iface)}; SP_DEVINFO_DATA device = {sizeof(device)}; - DWORD size = 0, expectedsize; + DWORD size = 0, expected_size; HDEVINFO set; BOOL ret; @@ -1235,37 +1235,56 @@ static void test_device_iface_detail(void) ok(!ret, "Expected failure.\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#lx.\n", GetLastError()); - detail = heap_alloc(size); - expectedsize = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath[strlen(path) + 1]); + expected_size = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_A, DevicePath[strlen(path) + 1]); + ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); + detail = heap_alloc(size * 2); detail->cbSize = 0; SetLastError(0xdeadbeef); - ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, size, &size, NULL); + size = 0xdeadbeef; + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, expected_size * 2, &size, NULL); ok(!ret, "Expected failure.\n"); ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#lx.\n", GetLastError()); + ok(size == 0xdeadbeef, "Expected size %lu, got %lu.\n", expected_size, size); detail->cbSize = size; SetLastError(0xdeadbeef); - ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, size, &size, NULL); + size = 0xdeadbeef; + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, expected_size * 2, &size, NULL); ok(!ret, "Expected failure.\n"); ok(GetLastError() == ERROR_INVALID_USER_BUFFER, "Got unexpected error %#lx.\n", GetLastError()); + ok(size == 0xdeadbeef, "Expected size %lu, got %lu.\n", expected_size, size); detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_A); SetLastError(0xdeadbeef); - ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, size, &size, NULL); + size = 0xdeadbeef; + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, expected_size, &size, NULL); ok(ret, "Failed to get interface detail, error %#lx.\n", GetLastError()); ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath); + ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); + SetLastError(0xdeadbeef); + size = 0xdeadbeef; + ret = SetupDiGetDeviceInterfaceDetailA(set, &iface, detail, expected_size * 2, &size, NULL); + ok(ret, "Failed to get interface detail, error %#lx.\n", GetLastError()); + ok(!strcasecmp(path, detail->DevicePath), "Got unexpected path %s.\n", detail->DevicePath); + ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); + + expected_size = FIELD_OFFSET(SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath[strlen(path) + 1]); + + size = 0xdeadbeef; ret = SetupDiGetDeviceInterfaceDetailW(set, &iface, NULL, 0, &size, NULL); ok(!ret, "Expected failure.\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#lx.\n", GetLastError()); - ok(size == expectedsize, "Got unexpected size %ld.\n", size); + ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); memset(&device, 0, sizeof(device)); device.cbSize = sizeof(device); + size = 0xdeadbeef; ret = SetupDiGetDeviceInterfaceDetailW(set, &iface, NULL, 0, &size, &device); ok(!ret, "Expected failure.\n"); ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Got unexpected error %#lx.\n", GetLastError()); + ok(size == expected_size, "Expected size %lu, got %lu.\n", expected_size, size); ok(IsEqualGUID(&device.ClassGuid, &guid), "Got unexpected class %s.\n", wine_dbgstr_guid(&device.ClassGuid)); heap_free(detail); diff --git a/sdk/tools/winesync/setupapi.cfg b/sdk/tools/winesync/setupapi.cfg index bda611e5299..a154d7a6559 100644 --- a/sdk/tools/winesync/setupapi.cfg +++ b/sdk/tools/winesync/setupapi.cfg @@ -10,4 +10,4 @@ files: dlls/setupapi/setupcab.c: dll/win32/setupapi/setupcab.c dlls/setupapi/stringtable.c: dll/win32/setupapi/stringtable_wine.c tags: - wine: b73e3102009cc7151ab58321800aeded24c1307f + wine: a1ae33a3efb7231adf683484e9de66f84abb04d1