Module: wine Branch: master Commit: 38e36e8fdaf6dc682ce5af7b5b00cb795fffd967 URL: https://gitlab.winehq.org/wine/wine/-/commit/38e36e8fdaf6dc682ce5af7b5b00cb7...
Author: Zebediah Figura zfigura@codeweavers.com Date: Mon Feb 6 19:43:08 2023 -0600
setupapi: Create the registry value if it doesn't exist in append_multi_sz_value().
---
dlls/setupapi/install.c | 21 ++++++++++++++++++++- dlls/setupapi/tests/install.c | 11 ++++------- 2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c index 435918e815e..8a28bfcc4e1 100644 --- a/dlls/setupapi/install.c +++ b/dlls/setupapi/install.c @@ -233,8 +233,27 @@ static bool append_multi_sz_value( HKEY hkey, const WCHAR *value, const WCHAR *s { DWORD size, type, total; WCHAR *buffer, *p; + LONG ret; + + if ((ret = RegQueryValueExW( hkey, value, NULL, &type, NULL, &size ))) + { + if (ret != ERROR_FILE_NOT_FOUND) + { + ERR( "failed to query value %s, error %lu\n", debugstr_w(value), ret ); + SetLastError( ret ); + return false; + } + + if ((ret = RegSetValueExW( hkey, value, 0, REG_MULTI_SZ, (BYTE *)strings, str_size * sizeof(WCHAR) ))) + { + ERR( "failed to set value %s, error %lu\n", debugstr_w(value), ret ); + SetLastError( ret ); + return false; + } + + return true; + }
- if (RegQueryValueExW( hkey, value, NULL, &type, NULL, &size )) return true; if (type != REG_MULTI_SZ) { WARN( "value %s exists but has wrong type %#lx\n", debugstr_w(value), type ); diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index 10c93482ece..318f1294210 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -2332,13 +2332,10 @@ static void test_append_reg(void) ok(!l, "Got error %lu.\n", l); size = sizeof(value); l = RegQueryValueExA(key, "value", NULL, &type, (BYTE *)value, &size); - todo_wine ok(!l, "Got error %lu.\n", l); - if (!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)); - } + 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. */