From 24d5860370b1fe91e4070996e08057dc055738ef Mon Sep 17 00:00:00 2001 From: winesync Date: Thu, 14 Sep 2023 22:08:41 +0200 Subject: [PATCH] [WINESYNC] setupapi/tests: Don't test function directly when reporting GetLastError(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit wine commit id 4b09ed1486b4c880c7ed1cbbfd3d9b1335f4d4ab by André Zwing [WINESYNC] setupapi/tests: Add tests for FLG_ADDREG_APPEND. wine commit id d7c8279c08c25e2afddb33184522386e928d5497 by Zebediah Figura [WINESYNC] setupapi: Fail installation when trying to append to a registry value of the wrong type. wine commit id 0ab56b88dfdca442ab0820eacc14f6397f628924 by Zebediah Figura [WINESYNC] setupapi: Create the registry value if it doesn't exist in append_multi_sz_value(). wine commit id 38e36e8fdaf6dc682ce5af7b5b00cb795fffd967 by Zebediah Figura [WINESYNC] setupapi: Use standard va_list instead of __ms_va_list. wine commit id d3a9fa181cbf81f6b920d6ddc3760e78d1d18601 by Alexandre Julliard --- dll/win32/setupapi/dialog.c | 2 +- modules/rostests/winetests/setupapi/install.c | 103 +++++++++++++++++- sdk/tools/winesync/setupapi.cfg | 2 +- 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/dll/win32/setupapi/dialog.c b/dll/win32/setupapi/dialog.c index a3456a1920f..e8d7e06df5b 100644 --- a/dll/win32/setupapi/dialog.c +++ b/dll/win32/setupapi/dialog.c @@ -60,7 +60,7 @@ static void promptdisk_init(HWND hwnd, struct promptdisk_params *params) args[1] = (DWORD_PTR)unknown; } FormatMessageW(FORMAT_MESSAGE_FROM_STRING|FORMAT_MESSAGE_ARGUMENT_ARRAY, - format, 0, 0, message, ARRAY_SIZE(message), (__ms_va_list*)args); + format, 0, 0, message, ARRAY_SIZE(message), (va_list *)args); SetDlgItemTextW(hwnd, IDC_FILENEEDED, message); LoadStringW(SETUPAPI_hInstance, IDS_INFO, message, ARRAY_SIZE(message)); diff --git a/modules/rostests/winetests/setupapi/install.c b/modules/rostests/winetests/setupapi/install.c index f53740a8824..318f1294210 100644 --- a/modules/rostests/winetests/setupapi/install.c +++ b/modules/rostests/winetests/setupapi/install.c @@ -2291,8 +2291,106 @@ static void test_rename(void) ok(delete_file("a/six.txt"), "File should exist.\n"); SetupCloseFileQueue(queue); - ok(delete_file("a/"), "Failed to delete directory, error %lu.\n", GetLastError()); - ok(delete_file("b/"), "Failed to delete directory, error %lu.\n", GetLastError()); + ret = delete_file("a/"); + ok(ret, "Failed to delete directory, error %lu.\n", GetLastError()); + ret = delete_file("b/"); + ok(ret, "Failed to delete directory, error %lu.\n", GetLastError()); +} + +static void test_append_reg(void) +{ + static const char inf_data[] = "[Version]\n" + "Signature=\"$Chicago$\"\n" + "[DefaultInstall]\n" + "AddReg=reg_section\n" + "[reg_section]\n" + "HKCU,Software\\winetest_setupapi,value,0x10008,\"data\"\n"; + + void *context = SetupInitDefaultQueueCallbackEx(NULL, INVALID_HANDLE_VALUE, 0, 0, 0); + char path[MAX_PATH]; + DWORD type, size; + char value[20]; + HINF hinf; + BOOL ret; + HKEY key; + LONG l; + + create_inf_file("test.inf", inf_data); + sprintf(path, "%s\\test.inf", CURR_DIR); + hinf = SetupOpenInfFileA(path, NULL, INF_STYLE_WIN4, NULL); + ok(hinf != INVALID_HANDLE_VALUE, "Failed to open INF file, error %#lx.\n", GetLastError()); + + /* Key doesn't exist yet. */ + + RegDeleteKeyA(HKEY_CURRENT_USER, "winetest_setupapi"); + + ret = SetupInstallFromInfSectionA(NULL, hinf, "DefaultInstall", SPINST_REGISTRY, + NULL, "C:\\", 0, SetupDefaultQueueCallbackA, context, NULL, NULL); + ok(ret, "Failed to install, error %#lx.\n", GetLastError()); + + l = RegOpenKeyA(HKEY_CURRENT_USER, "Software\\winetest_setupapi", &key); + ok(!l, "Got error %lu.\n", l); + size = sizeof(value); + l = RegQueryValueExA(key, "value", NULL, &type, (BYTE *)value, &size); + ok(!l, "Got error %lu.\n", l); + ok(type == REG_MULTI_SZ, "Got type %#lx.\n", type); + ok(size == sizeof("data\0"), "Got size %lu.\n", size); + ok(!memcmp(value, "data\0", size), "Got data %s.\n", debugstr_an(value, size)); + + /* Key exists and already has a value. */ + + l = RegSetValueExA(key, "value", 0, REG_MULTI_SZ, (const BYTE *)"foo\0bar\0", sizeof("foo\0bar\0")); + ok(!l, "Got error %lu.\n", l); + + ret = SetupInstallFromInfSectionA(NULL, hinf, "DefaultInstall", SPINST_REGISTRY, + NULL, "C:\\", 0, SetupDefaultQueueCallbackA, context, NULL, NULL); + ok(ret, "Failed to install, error %#lx.\n", GetLastError()); + + size = sizeof(value); + l = RegQueryValueExA(key, "value", NULL, &type, (BYTE *)value, &size); + ok(!l, "Got error %lu.\n", l); + ok(type == REG_MULTI_SZ, "Got type %#lx.\n", type); + ok(size == sizeof("foo\0bar\0data\0"), "Got size %lu.\n", size); + ok(!memcmp(value, "foo\0bar\0data\0", size), "Got data %s.\n", debugstr_an(value, size)); + + /* Key exists and already has the value to be added. */ + + ret = SetupInstallFromInfSectionA(NULL, hinf, "DefaultInstall", SPINST_REGISTRY, + NULL, "C:\\", 0, SetupDefaultQueueCallbackA, context, NULL, NULL); + ok(ret, "Failed to install, error %#lx.\n", GetLastError()); + + size = sizeof(value); + l = RegQueryValueExA(key, "value", NULL, &type, (BYTE *)value, &size); + ok(!l, "Got error %lu.\n", l); + ok(type == REG_MULTI_SZ, "Got type %#lx.\n", type); + ok(size == sizeof("foo\0bar\0data\0"), "Got size %lu.\n", size); + ok(!memcmp(value, "foo\0bar\0data\0", size), "Got data %s.\n", debugstr_an(value, size)); + + /* Key exists and already has a value of the wrong type. */ + + l = RegSetValueExA(key, "value", 0, REG_SZ, (const BYTE *)"string", sizeof("string")); + ok(!l, "Got error %lu.\n", l); + + ret = SetupInstallFromInfSectionA(NULL, hinf, "DefaultInstall", SPINST_REGISTRY, + NULL, "C:\\", 0, SetupDefaultQueueCallbackA, context, NULL, NULL); + ok(!ret, "Expected failure.\n"); + ok(GetLastError() == ERROR_INVALID_DATA, "Got error %#lx.\n", GetLastError()); + + size = sizeof(value); + l = RegQueryValueExA(key, "value", NULL, &type, (BYTE *)value, &size); + ok(!l, "Got error %lu.\n", l); + ok(type == REG_SZ, "Got type %#lx.\n", type); + ok(size == sizeof("string"), "Got size %lu.\n", size); + ok(!memcmp(value, "string", size), "Got data %s.\n", debugstr_an(value, size)); + + RegCloseKey(key); + + l = RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\winetest_setupapi"); + ok(!l, "Got error %lu.\n", l); + + SetupCloseInfFile(hinf); + ret = DeleteFileA("test.inf"); + ok(ret, "Failed to delete INF file, error %lu.\n", GetLastError()); } static WCHAR service_name[] = L"Wine Test Service"; @@ -2404,6 +2502,7 @@ START_TEST(install) test_start_copy(); test_register_dlls(); test_rename(); + test_append_reg(); UnhookWindowsHookEx(hhook); diff --git a/sdk/tools/winesync/setupapi.cfg b/sdk/tools/winesync/setupapi.cfg index 8cc790115da..92c34ef9b62 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: 1172e66e5b7fa96decf89f8866e71b77e5773ec7 + wine: d3a9fa181cbf81f6b920d6ddc3760e78d1d18601