mirror of
https://gitlab.winehq.org/wine/wine-staging.git
synced 2025-01-28 22:04:43 -08:00
Remove disabled reg-Cleanup patchset (only cleanup and not actively maintained).
This commit is contained in:
parent
15733c4eb8
commit
123214c032
2
debian/changelog
vendored
2
debian/changelog
vendored
@ -1,6 +1,8 @@
|
||||
wine-staging (1.7.55) UNRELEASED; urgency=low
|
||||
* Remove disabled shell32-Quoted_ShellExecute patchset (bug already fixed and
|
||||
all tests pass).
|
||||
* Remove disabled reg-Cleanup patchset (only cleanup and not actively
|
||||
maintained).
|
||||
-- Sebastian Lackner <sebastian@fds-team.de> Sun, 01 Nov 2015 01:06:20 +0100
|
||||
|
||||
wine-staging (1.7.54) unstable; urgency=low
|
||||
|
@ -1,104 +0,0 @@
|
||||
From 9680fcc2fc0686299984a04baa3e4088e1375b1b Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:21 +0100
|
||||
Subject: reg: Add system error printing function
|
||||
|
||||
---
|
||||
programs/reg/reg.c | 32 ++++++++++++++++++++++++++++----
|
||||
programs/reg/reg.h | 1 +
|
||||
programs/reg/reg.rc | 1 +
|
||||
3 files changed, 30 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index e9c7d16..a88512d 100644
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -67,6 +67,30 @@ static int reg_message(int msg)
|
||||
return reg_printfW(formatW, msg_buffer);
|
||||
}
|
||||
|
||||
+static void reg_print_error(LSTATUS error_code)
|
||||
+{
|
||||
+ switch (error_code)
|
||||
+ {
|
||||
+ case ERROR_SUCCESS:
|
||||
+ return;
|
||||
+ case ERROR_BAD_COMMAND:
|
||||
+ reg_message(STRING_INVALID_CMDLINE);
|
||||
+ return;
|
||||
+ default:
|
||||
+ {
|
||||
+ static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
|
||||
+ WCHAR *message = NULL;
|
||||
+ FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL,
|
||||
+ error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (WCHAR *)&message, 0, NULL);
|
||||
+
|
||||
+ reg_message(STRING_ERROR);
|
||||
+ reg_printfW(error_string, error_code, message);
|
||||
+ LocalFree(message);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len)
|
||||
{
|
||||
int i;
|
||||
@@ -413,7 +437,7 @@ int wmain(int argc, WCHAR *argvW[])
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
+ reg_print_error(ERROR_BAD_COMMAND);
|
||||
return 1;
|
||||
}
|
||||
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
|
||||
@@ -449,7 +473,7 @@ int wmain(int argc, WCHAR *argvW[])
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
+ reg_print_error(ERROR_BAD_COMMAND);
|
||||
return 1;
|
||||
}
|
||||
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
|
||||
@@ -480,7 +504,7 @@ int wmain(int argc, WCHAR *argvW[])
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
+ reg_print_error(ERROR_BAD_COMMAND);
|
||||
return 1;
|
||||
}
|
||||
else if (argc == 3 && (!lstrcmpW(argvW[2], slashHelpW) ||
|
||||
@@ -504,7 +528,7 @@ int wmain(int argc, WCHAR *argvW[])
|
||||
}
|
||||
else
|
||||
{
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
+ reg_print_error(ERROR_BAD_COMMAND);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
|
||||
index 2221647..1c2ae83 100644
|
||||
--- a/programs/reg/reg.h
|
||||
+++ b/programs/reg/reg.h
|
||||
@@ -30,3 +30,4 @@
|
||||
#define STRING_INVALID_CMDLINE 107
|
||||
#define STRING_NO_REMOTE 108
|
||||
#define STRING_CANNOT_FIND 109
|
||||
+#define STRING_ERROR 110
|
||||
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
|
||||
index 479912b..6183aaa 100644
|
||||
--- a/programs/reg/reg.rc
|
||||
+++ b/programs/reg/reg.rc
|
||||
@@ -35,4 +35,5 @@ STRINGTABLE
|
||||
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
|
||||
STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
|
||||
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
|
||||
+ STRING_ERROR, "Unexpected error: "
|
||||
}
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,104 +0,0 @@
|
||||
From f33dbf947516c606d9215f182224a00e027e5750 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:22 +0100
|
||||
Subject: reg: Add sane_path function to do preliniary key validation
|
||||
|
||||
---
|
||||
programs/reg/reg.c | 25 +++++++++++++++++++++----
|
||||
programs/reg/reg.rc | 2 +-
|
||||
2 files changed, 22 insertions(+), 5 deletions(-)
|
||||
mode change 100644 => 100755 programs/reg/reg.c
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
old mode 100644
|
||||
new mode 100755
|
||||
index a88512d..fef9313
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -20,6 +20,8 @@
|
||||
#include <wine/unicode.h>
|
||||
#include "reg.h"
|
||||
|
||||
+#define ERROR_NO_REMOTE 20000
|
||||
+
|
||||
static int reg_printfW(const WCHAR *msg, ...)
|
||||
{
|
||||
va_list va_args;
|
||||
@@ -76,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
|
||||
case ERROR_BAD_COMMAND:
|
||||
reg_message(STRING_INVALID_CMDLINE);
|
||||
return;
|
||||
+ case ERROR_NO_REMOTE:
|
||||
+ reg_message(STRING_NO_REMOTE);
|
||||
+ return;
|
||||
default:
|
||||
{
|
||||
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
|
||||
@@ -203,6 +208,14 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
|
||||
return out_data;
|
||||
}
|
||||
|
||||
+static LSTATUS sane_path(const WCHAR *key)
|
||||
+{
|
||||
+ if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
|
||||
+ return ERROR_NO_REMOTE;
|
||||
+
|
||||
+ return ERROR_SUCCESS;
|
||||
+}
|
||||
+
|
||||
static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
|
||||
{
|
||||
@@ -210,12 +223,14 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
|
||||
LPWSTR p;
|
||||
HKEY root,subkey;
|
||||
+ LONG err;
|
||||
|
||||
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
|
||||
|
||||
- if (key_name[0]=='\\' && key_name[1]=='\\')
|
||||
+ err = sane_path(key_name);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
{
|
||||
- reg_message(STRING_NO_REMOTE);
|
||||
+ reg_print_error(err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -280,15 +295,17 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
{
|
||||
LPWSTR p;
|
||||
HKEY root,subkey;
|
||||
+ LONG err;
|
||||
|
||||
static const WCHAR stubW[] = {'D','E','L','E','T','E',
|
||||
' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
|
||||
,0};
|
||||
reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
|
||||
|
||||
- if (key_name[0]=='\\' && key_name[1]=='\\')
|
||||
+ err = sane_path(key_name);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
{
|
||||
- reg_message(STRING_NO_REMOTE);
|
||||
+ reg_print_error(err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
|
||||
index 6183aaa..5fc5a76 100644
|
||||
--- a/programs/reg/reg.rc
|
||||
+++ b/programs/reg/reg.rc
|
||||
@@ -33,7 +33,7 @@ STRINGTABLE
|
||||
STRING_SUCCESS, "The operation completed successfully\n"
|
||||
STRING_INVALID_KEY, "Error: Invalid key name\n"
|
||||
STRING_INVALID_CMDLINE, "Error: Invalid command line parameters\n"
|
||||
- STRING_NO_REMOTE, "Error: Unable to add keys to remote machine\n"
|
||||
+ STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
|
||||
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
|
||||
STRING_ERROR, "Unexpected error: "
|
||||
}
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,56 +0,0 @@
|
||||
From 00f098bf99cb6c50222b5e46dcb00536b4177c34 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:23 +0100
|
||||
Subject: reg: Add check for multiple backslashes at the end of the key
|
||||
|
||||
---
|
||||
programs/reg/reg.c | 8 ++++++++
|
||||
programs/reg/tests/reg.c | 4 ++--
|
||||
2 files changed, 10 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index fef9313..f0c0b2e 100755
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -78,6 +78,9 @@ static void reg_print_error(LSTATUS error_code)
|
||||
case ERROR_BAD_COMMAND:
|
||||
reg_message(STRING_INVALID_CMDLINE);
|
||||
return;
|
||||
+ case ERROR_INVALID_HANDLE:
|
||||
+ reg_message(STRING_INVALID_KEY);
|
||||
+ return;
|
||||
case ERROR_NO_REMOTE:
|
||||
reg_message(STRING_NO_REMOTE);
|
||||
return;
|
||||
@@ -210,6 +213,11 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
|
||||
|
||||
static LSTATUS sane_path(const WCHAR *key)
|
||||
{
|
||||
+ int i = strlenW(key);
|
||||
+
|
||||
+ if (i < 3 || (key[i - 1] == '\\' && key[i - 2] == '\\'))
|
||||
+ return ERROR_INVALID_HANDLE;
|
||||
+
|
||||
if (key[0] == '\\' && key[1] == '\\' && key[2] != '\\')
|
||||
return ERROR_NO_REMOTE;
|
||||
|
||||
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
|
||||
index b7605e4..dbfce89 100644
|
||||
--- a/programs/reg/tests/reg.c
|
||||
+++ b/programs/reg/tests/reg.c
|
||||
@@ -129,10 +129,10 @@ static void test_add(void)
|
||||
ok(err == ERROR_FILE_NOT_FOUND, "got exit code %d\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest2\\\\ /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
|
||||
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
|
||||
"got exit code %u\n", r);
|
||||
err = RegDeleteKeyA(HKEY_CURRENT_USER, KEY_BASE "\\keytest2");
|
||||
- todo_wine ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
|
||||
+ ok(err == ERROR_FILE_NOT_FOUND || broken(err == ERROR_SUCCESS /* WinXP */),
|
||||
"got exit code %d\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE "\\keytest3\\ /f", &r);
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,239 +0,0 @@
|
||||
From ac0eef4019baefc758a06d21ccaa5aaa7dadf1c2 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:24 +0100
|
||||
Subject: reg: Add path/key conversion functions
|
||||
|
||||
---
|
||||
programs/reg/reg.c | 150 ++++++++++++++++++++++++++---------------------------
|
||||
1 file changed, 75 insertions(+), 75 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index f0c0b2e..e9b5b68 100755
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -20,8 +20,38 @@
|
||||
#include <wine/unicode.h>
|
||||
#include "reg.h"
|
||||
|
||||
+#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
|
||||
+
|
||||
#define ERROR_NO_REMOTE 20000
|
||||
|
||||
+static const WCHAR empty_wstr[] = {0};
|
||||
+
|
||||
+static const WCHAR short_hklm[] = {'H','K','L','M',0};
|
||||
+static const WCHAR short_hkcu[] = {'H','K','C','U',0};
|
||||
+static const WCHAR short_hkcr[] = {'H','K','C','R',0};
|
||||
+static const WCHAR short_hku[] = {'H','K','U',0};
|
||||
+static const WCHAR short_hkcc[] = {'H','K','C','C',0};
|
||||
+static const WCHAR long_hklm[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
|
||||
+static const WCHAR long_hkcu[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
|
||||
+static const WCHAR long_hkcr[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
|
||||
+static const WCHAR long_hku[] = {'H','K','E','Y','_','U','S','E','R','S',0};
|
||||
+static const WCHAR long_hkcc[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
|
||||
+
|
||||
+static const struct
|
||||
+{
|
||||
+ HKEY key;
|
||||
+ const WCHAR *short_name;
|
||||
+ const WCHAR *long_name;
|
||||
+}
|
||||
+root_rels[] =
|
||||
+{
|
||||
+ {HKEY_LOCAL_MACHINE, short_hklm, long_hklm},
|
||||
+ {HKEY_CURRENT_USER, short_hkcu, long_hkcu},
|
||||
+ {HKEY_CLASSES_ROOT, short_hkcr, long_hkcr},
|
||||
+ {HKEY_USERS, short_hku, long_hku},
|
||||
+ {HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
|
||||
+};
|
||||
+
|
||||
static int reg_printfW(const WCHAR *msg, ...)
|
||||
{
|
||||
va_list va_args;
|
||||
@@ -84,6 +114,9 @@ static void reg_print_error(LSTATUS error_code)
|
||||
case ERROR_NO_REMOTE:
|
||||
reg_message(STRING_NO_REMOTE);
|
||||
return;
|
||||
+ case ERROR_FILE_NOT_FOUND:
|
||||
+ reg_message(STRING_CANNOT_FIND);
|
||||
+ return;
|
||||
default:
|
||||
{
|
||||
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
|
||||
@@ -99,51 +132,40 @@ static void reg_print_error(LSTATUS error_code)
|
||||
}
|
||||
}
|
||||
|
||||
-static int reg_StrCmpNIW(LPCWSTR str, LPCWSTR comp, int len)
|
||||
+static inline BOOL path_rootname_cmp(const WCHAR *input_path, const WCHAR *rootkey_name)
|
||||
{
|
||||
- int i;
|
||||
+ DWORD length = strlenW(rootkey_name);
|
||||
+
|
||||
+ return (!strncmpiW(input_path, rootkey_name, length) &&
|
||||
+ (input_path[length] == 0 || input_path[length] == '\\'));
|
||||
+}
|
||||
|
||||
- for (i = 0; i < len; i++)
|
||||
+static HKEY path_get_rootkey(const WCHAR *path)
|
||||
+{
|
||||
+ DWORD i;
|
||||
+
|
||||
+ for (i = 0; i < ARRAY_SIZE(root_rels); i++)
|
||||
{
|
||||
- if (!str[i])
|
||||
- {
|
||||
- len = i + 1;
|
||||
- break;
|
||||
- }
|
||||
+ if (path_rootname_cmp(path, root_rels[i].short_name) ||
|
||||
+ path_rootname_cmp(path, root_rels[i].long_name))
|
||||
+ return root_rels[i].key;
|
||||
}
|
||||
|
||||
- return CompareStringW(CP_ACP, NORM_IGNORECASE, str, len, comp, len) - CSTR_EQUAL;
|
||||
+ return NULL;
|
||||
}
|
||||
|
||||
-static HKEY get_rootkey(LPWSTR key)
|
||||
+static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
|
||||
{
|
||||
- static const WCHAR szHKLM[] = {'H','K','L','M',0};
|
||||
- static const WCHAR szHKEY_LOCAL_MACHINE[] = {'H','K','E','Y','_','L','O','C','A','L','_','M','A','C','H','I','N','E',0};
|
||||
- static const WCHAR szHKCU[] = {'H','K','C','U',0};
|
||||
- static const WCHAR szHKEY_CURRENT_USER[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','U','S','E','R',0};
|
||||
- static const WCHAR szHKCR[] = {'H','K','C','R',0};
|
||||
- static const WCHAR szHKEY_CLASSES_ROOT[] = {'H','K','E','Y','_','C','L','A','S','S','E','S','_','R','O','O','T',0};
|
||||
- static const WCHAR szHKU[] = {'H','K','U',0};
|
||||
- static const WCHAR szHKEY_USERS[] = {'H','K','E','Y','_','U','S','E','R','S',0};
|
||||
- static const WCHAR szHKCC[] = {'H','K','C','C',0};
|
||||
- static const WCHAR szHKEY_CURRENT_CONFIG[] = {'H','K','E','Y','_','C','U','R','R','E','N','T','_','C','O','N','F','I','G',0};
|
||||
-
|
||||
- if (!reg_StrCmpNIW(key, szHKLM, 4) ||
|
||||
- !reg_StrCmpNIW(key, szHKEY_LOCAL_MACHINE, 18))
|
||||
- return HKEY_LOCAL_MACHINE;
|
||||
- else if (!reg_StrCmpNIW(key, szHKCU, 4) ||
|
||||
- !reg_StrCmpNIW(key, szHKEY_CURRENT_USER, 17))
|
||||
- return HKEY_CURRENT_USER;
|
||||
- else if (!reg_StrCmpNIW(key, szHKCR, 4) ||
|
||||
- !reg_StrCmpNIW(key, szHKEY_CLASSES_ROOT, 17))
|
||||
- return HKEY_CLASSES_ROOT;
|
||||
- else if (!reg_StrCmpNIW(key, szHKU, 3) ||
|
||||
- !reg_StrCmpNIW(key, szHKEY_USERS, 10))
|
||||
- return HKEY_USERS;
|
||||
- else if (!reg_StrCmpNIW(key, szHKCC, 4) ||
|
||||
- !reg_StrCmpNIW(key, szHKEY_CURRENT_CONFIG, 19))
|
||||
- return HKEY_CURRENT_CONFIG;
|
||||
- else return NULL;
|
||||
+ *out = path_get_rootkey(path);
|
||||
+
|
||||
+ path = strchrW(path, '\\');
|
||||
+ if (path)
|
||||
+ path++;
|
||||
+
|
||||
+ if (create)
|
||||
+ return RegCreateKeyW(*out, path, out);
|
||||
+ else
|
||||
+ return RegOpenKeyW(*out, path, out);
|
||||
}
|
||||
|
||||
static DWORD get_regtype(LPWSTR type)
|
||||
@@ -229,8 +251,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
{
|
||||
static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
|
||||
' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
|
||||
- LPWSTR p;
|
||||
- HKEY root,subkey;
|
||||
+ HKEY subkey;
|
||||
LONG err;
|
||||
|
||||
reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
|
||||
@@ -242,22 +263,8 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
return 1;
|
||||
}
|
||||
|
||||
- p = strchrW(key_name,'\\');
|
||||
- if (!p)
|
||||
- {
|
||||
- reg_message(STRING_INVALID_KEY);
|
||||
- return 1;
|
||||
- }
|
||||
- p++;
|
||||
-
|
||||
- root = get_rootkey(key_name);
|
||||
- if (!root)
|
||||
- {
|
||||
- reg_message(STRING_INVALID_KEY);
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
- if(RegCreateKeyW(root,p,&subkey)!=ERROR_SUCCESS)
|
||||
+ err = path_open(key_name, &subkey, TRUE);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
{
|
||||
reg_message(STRING_INVALID_KEY);
|
||||
return 1;
|
||||
@@ -301,8 +308,7 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
BOOL value_all, BOOL force)
|
||||
{
|
||||
- LPWSTR p;
|
||||
- HKEY root,subkey;
|
||||
+ HKEY subkey;
|
||||
LONG err;
|
||||
|
||||
static const WCHAR stubW[] = {'D','E','L','E','T','E',
|
||||
@@ -317,16 +323,8 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
return 1;
|
||||
}
|
||||
|
||||
- p = strchrW(key_name,'\\');
|
||||
- if (!p)
|
||||
- {
|
||||
- reg_message(STRING_INVALID_KEY);
|
||||
- return 1;
|
||||
- }
|
||||
- p++;
|
||||
-
|
||||
- root = get_rootkey(key_name);
|
||||
- if (!root)
|
||||
+ err = path_open(key_name, &subkey, FALSE);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
{
|
||||
reg_message(STRING_INVALID_KEY);
|
||||
return 1;
|
||||
@@ -352,21 +350,23 @@ static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
/* Delete subtree only if no /v* option is given */
|
||||
if (!value_name && !value_empty && !value_all)
|
||||
{
|
||||
- if (RegDeleteTreeW(root,p)!=ERROR_SUCCESS)
|
||||
+ err = RegDeleteTreeW(subkey, NULL);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
{
|
||||
- reg_message(STRING_CANNOT_FIND);
|
||||
+ reg_print_error(err);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ err = RegDeleteKeyW(subkey, empty_wstr);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ {
|
||||
+ reg_print_error(err);
|
||||
return 1;
|
||||
}
|
||||
reg_message(STRING_SUCCESS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
- if(RegOpenKeyW(root,p,&subkey)!=ERROR_SUCCESS)
|
||||
- {
|
||||
- reg_message(STRING_CANNOT_FIND);
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
if (value_all)
|
||||
{
|
||||
LPWSTR szValue;
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,136 +0,0 @@
|
||||
From c7ea9e4dfd765ca4221d39276d09ec872d45ba9a Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:25 +0100
|
||||
Subject: reg: Add wchar/type conversion functions
|
||||
|
||||
---
|
||||
programs/reg/reg.c | 65 ++++++++++++++++++++++++++++++++++-------------------
|
||||
programs/reg/reg.h | 1 +
|
||||
programs/reg/reg.rc | 1 +
|
||||
3 files changed, 44 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index e9b5b68..3ffcc25 100755
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -52,6 +52,32 @@ root_rels[] =
|
||||
{HKEY_CURRENT_CONFIG, short_hkcc, long_hkcc},
|
||||
};
|
||||
|
||||
+static const WCHAR type_none[] = {'R','E','G','_','N','O','N','E',0};
|
||||
+static const WCHAR type_sz[] = {'R','E','G','_','S','Z',0};
|
||||
+static const WCHAR type_expand_sz[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
|
||||
+static const WCHAR type_binary[] = {'R','E','G','_','B','I','N','A','R','Y',0};
|
||||
+static const WCHAR type_dword[] = {'R','E','G','_','D','W','O','R','D',0};
|
||||
+static const WCHAR type_dword_le[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
|
||||
+static const WCHAR type_dword_be[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
|
||||
+static const WCHAR type_multi_sz[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
|
||||
+
|
||||
+static const struct
|
||||
+{
|
||||
+ DWORD type;
|
||||
+ const WCHAR *name;
|
||||
+}
|
||||
+type_rels[] =
|
||||
+{
|
||||
+ {REG_NONE, type_none},
|
||||
+ {REG_SZ, type_sz},
|
||||
+ {REG_EXPAND_SZ, type_expand_sz},
|
||||
+ {REG_BINARY, type_binary},
|
||||
+ {REG_DWORD, type_dword},
|
||||
+ {REG_DWORD_LITTLE_ENDIAN, type_dword_le},
|
||||
+ {REG_DWORD_BIG_ENDIAN, type_dword_be},
|
||||
+ {REG_MULTI_SZ, type_multi_sz},
|
||||
+};
|
||||
+
|
||||
static int reg_printfW(const WCHAR *msg, ...)
|
||||
{
|
||||
va_list va_args;
|
||||
@@ -117,6 +143,9 @@ static void reg_print_error(LSTATUS error_code)
|
||||
case ERROR_FILE_NOT_FOUND:
|
||||
reg_message(STRING_CANNOT_FIND);
|
||||
return;
|
||||
+ case ERROR_UNSUPPORTED_TYPE:
|
||||
+ reg_message(STRING_UNSUPPORTED_TYPE);
|
||||
+ return;
|
||||
default:
|
||||
{
|
||||
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
|
||||
@@ -168,30 +197,20 @@ static LSTATUS path_open(const WCHAR *path, HKEY *out, BOOL create)
|
||||
return RegOpenKeyW(*out, path, out);
|
||||
}
|
||||
|
||||
-static DWORD get_regtype(LPWSTR type)
|
||||
+static DWORD wchar_get_type(const WCHAR *type_name)
|
||||
{
|
||||
- static const WCHAR szREG_SZ[] = {'R','E','G','_','S','Z',0};
|
||||
- static const WCHAR szREG_MULTI_SZ[] = {'R','E','G','_','M','U','L','T','I','_','S','Z',0};
|
||||
- static const WCHAR szREG_DWORD_BIG_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','B','I','G','_','E','N','D','I','A','N',0};
|
||||
- static const WCHAR szREG_DWORD[] = {'R','E','G','_','D','W','O','R','D',0};
|
||||
- static const WCHAR szREG_BINARY[] = {'R','E','G','_','B','I','N','A','R','Y',0};
|
||||
- static const WCHAR szREG_DWORD_LITTLE_ENDIAN[] = {'R','E','G','_','D','W','O','R','D','_','L','I','T','T','L','E','_','E','N','D','I','A','N',0};
|
||||
- static const WCHAR szREG_NONE[] = {'R','E','G','_','N','O','N','E',0};
|
||||
- static const WCHAR szREG_EXPAND_SZ[] = {'R','E','G','_','E','X','P','A','N','D','_','S','Z',0};
|
||||
-
|
||||
- if (!type)
|
||||
+ DWORD i;
|
||||
+
|
||||
+ if (!type_name)
|
||||
return REG_SZ;
|
||||
|
||||
- if (lstrcmpiW(type,szREG_SZ)==0) return REG_SZ;
|
||||
- if (lstrcmpiW(type,szREG_DWORD)==0) return REG_DWORD;
|
||||
- if (lstrcmpiW(type,szREG_MULTI_SZ)==0) return REG_MULTI_SZ;
|
||||
- if (lstrcmpiW(type,szREG_EXPAND_SZ)==0) return REG_EXPAND_SZ;
|
||||
- if (lstrcmpiW(type,szREG_DWORD_BIG_ENDIAN)==0) return REG_DWORD_BIG_ENDIAN;
|
||||
- if (lstrcmpiW(type,szREG_DWORD_LITTLE_ENDIAN)==0) return REG_DWORD_LITTLE_ENDIAN;
|
||||
- if (lstrcmpiW(type,szREG_BINARY)==0) return REG_BINARY;
|
||||
- if (lstrcmpiW(type,szREG_NONE)==0) return REG_NONE;
|
||||
+ for (i = 0; i < ARRAY_SIZE(type_rels); i++)
|
||||
+ {
|
||||
+ if (!strcmpiW(type_rels[i].name, type_name))
|
||||
+ return type_rels[i].type;
|
||||
+ }
|
||||
|
||||
- return -1;
|
||||
+ return ~0u;
|
||||
}
|
||||
|
||||
static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
|
||||
@@ -284,11 +303,11 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
}
|
||||
}
|
||||
|
||||
- reg_type = get_regtype(type);
|
||||
- if (reg_type == -1)
|
||||
+ reg_type = wchar_get_type(type);
|
||||
+ if (reg_type == ~0u)
|
||||
{
|
||||
RegCloseKey(subkey);
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
+ reg_print_error(ERROR_UNSUPPORTED_TYPE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
|
||||
index 1c2ae83..42de422 100644
|
||||
--- a/programs/reg/reg.h
|
||||
+++ b/programs/reg/reg.h
|
||||
@@ -31,3 +31,4 @@
|
||||
#define STRING_NO_REMOTE 108
|
||||
#define STRING_CANNOT_FIND 109
|
||||
#define STRING_ERROR 110
|
||||
+#define STRING_UNSUPPORTED_TYPE 111
|
||||
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
|
||||
index 5fc5a76..beafd4f 100644
|
||||
--- a/programs/reg/reg.rc
|
||||
+++ b/programs/reg/reg.rc
|
||||
@@ -36,4 +36,5 @@ STRINGTABLE
|
||||
STRING_NO_REMOTE, "Error: Unable to access remote machine\n"
|
||||
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
|
||||
STRING_ERROR, "Unexpected error: "
|
||||
+ STRING_UNSUPPORTED_TYPE, "Error: Unsupported type\n"
|
||||
}
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,407 +0,0 @@
|
||||
From ff3494f11d42dc38e2455b21a95981b6e7d48a8d Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:26 +0100
|
||||
Subject: reg: Add wchar/raw data conversion functions
|
||||
|
||||
In the case of REG_SZ and the like, it may seem like the functions
|
||||
perform an unncessary copy of the strings which should already be
|
||||
in memory ripe for the taking.
|
||||
|
||||
However because these functions handle more than one type of data
|
||||
the calling function needs to be able to free the data afterwards.
|
||||
|
||||
Simply returning the input string would result in a function
|
||||
freeing one of it's own parameters, so we make sure to return
|
||||
new memory by making a copy.
|
||||
---
|
||||
programs/reg/reg.c | 140 +++++++++++++++++++++++++++++++++++++++--------
|
||||
programs/reg/reg.h | 1 +
|
||||
programs/reg/reg.rc | 1 +
|
||||
programs/reg/tests/reg.c | 57 ++++++++++---------
|
||||
4 files changed, 146 insertions(+), 53 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index 3ffcc25..0d892fd 100755
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -18,11 +18,15 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <wine/unicode.h>
|
||||
+#include <wine/debug.h>
|
||||
#include "reg.h"
|
||||
|
||||
#define ARRAY_SIZE(A) (sizeof(A)/sizeof(*A))
|
||||
|
||||
#define ERROR_NO_REMOTE 20000
|
||||
+#define ERROR_INVALID_DWORD 20001
|
||||
+
|
||||
+WINE_DEFAULT_DEBUG_CHANNEL(reg);
|
||||
|
||||
static const WCHAR empty_wstr[] = {0};
|
||||
|
||||
@@ -146,6 +150,9 @@ static void reg_print_error(LSTATUS error_code)
|
||||
case ERROR_UNSUPPORTED_TYPE:
|
||||
reg_message(STRING_UNSUPPORTED_TYPE);
|
||||
return;
|
||||
+ case ERROR_INVALID_DWORD:
|
||||
+ reg_message(STRING_INVALID_DWORD);
|
||||
+ return;
|
||||
default:
|
||||
{
|
||||
static const WCHAR error_string[] = {'%','0','5','d',':',' ','%','s',0};
|
||||
@@ -213,43 +220,120 @@ static DWORD wchar_get_type(const WCHAR *type_name)
|
||||
return ~0u;
|
||||
}
|
||||
|
||||
-static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *reg_count)
|
||||
+static LSTATUS wchar_get_data(const WCHAR *input, const DWORD type, const WCHAR separator,
|
||||
+ DWORD *size_out, BYTE **out)
|
||||
{
|
||||
- LPBYTE out_data = NULL;
|
||||
- *reg_count = 0;
|
||||
+ DWORD i;
|
||||
+
|
||||
+ if (!input)
|
||||
+ input = empty_wstr;
|
||||
|
||||
- switch (reg_type)
|
||||
+ switch (type)
|
||||
{
|
||||
+ case REG_NONE:
|
||||
case REG_SZ:
|
||||
+ case REG_EXPAND_SZ:
|
||||
{
|
||||
- *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR);
|
||||
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
|
||||
- lstrcpyW((LPWSTR)out_data,data);
|
||||
- break;
|
||||
+ i = (strlenW(input) + 1) * sizeof(WCHAR);
|
||||
+ *out = HeapAlloc(GetProcessHeap(), 0, i);
|
||||
+ memcpy(*out, input, i);
|
||||
+ *size_out = i;
|
||||
+ return ERROR_SUCCESS;
|
||||
}
|
||||
case REG_DWORD:
|
||||
+ case REG_DWORD_BIG_ENDIAN:
|
||||
+ {
|
||||
+ WCHAR *temp;
|
||||
+
|
||||
+ if (input[0] == '0' && (input[1] == 'x' || input[1] == 'X'))
|
||||
+ i = strtoulW(input, &temp, 16);
|
||||
+ else
|
||||
+ i = strtoulW(input, &temp, 10);
|
||||
+
|
||||
+ if (input[0] == '-' || temp[0] || temp == input)
|
||||
+ return ERROR_INVALID_DWORD;
|
||||
+
|
||||
+ if (i == 0xffffffff)
|
||||
+ WINE_FIXME("Check for integer overflow.\n");
|
||||
+
|
||||
+ *out = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
|
||||
+ **(DWORD **) out = i;
|
||||
+ *size_out = sizeof(DWORD);
|
||||
+ return ERROR_SUCCESS;
|
||||
+ }
|
||||
+ case REG_MULTI_SZ:
|
||||
{
|
||||
- LPWSTR rest;
|
||||
- DWORD val;
|
||||
- val = strtolW(data, &rest, 0);
|
||||
- if (rest == data) {
|
||||
- static const WCHAR nonnumber[] = {'E','r','r','o','r',':',' ','/','d',' ','r','e','q','u','i','r','e','s',' ','n','u','m','b','e','r','.','\n',0};
|
||||
- reg_printfW(nonnumber);
|
||||
- break;
|
||||
+ WCHAR *temp = HeapAlloc(GetProcessHeap(), 0, (strlenW(input) + 1) * sizeof(WCHAR));
|
||||
+ DWORD p;
|
||||
+
|
||||
+ for (i = 0, p = 0; i <= strlenW(input); i++, p++)
|
||||
+ {
|
||||
+ /* If this character is the separator, or no separator has been given and these
|
||||
+ * characters are "\\0", then add a 0 indicating the end of this string */
|
||||
+ if ( (separator && input[i] == separator) ||
|
||||
+ (!separator && input[i] == '\\' && input[i + 1] == '0') )
|
||||
+ {
|
||||
+ /* If it's the first character or the previous one was a separator */
|
||||
+ if (!p || temp[p - 1] == 0)
|
||||
+ {
|
||||
+ HeapFree(GetProcessHeap(), 0, temp);
|
||||
+ return ERROR_INVALID_DATA;
|
||||
+ }
|
||||
+ temp[p] = 0;
|
||||
+
|
||||
+ if (!separator)
|
||||
+ i++;
|
||||
+ }
|
||||
+ else
|
||||
+ temp[p] = input[i];
|
||||
}
|
||||
- *reg_count = sizeof(DWORD);
|
||||
- out_data = HeapAlloc(GetProcessHeap(),0,*reg_count);
|
||||
- ((LPDWORD)out_data)[0] = val;
|
||||
- break;
|
||||
+
|
||||
+ /* Add a 0 to the end if the string wasn't "", and it wasn't
|
||||
+ * double-0-terminated already (In the case of a trailing separator) */
|
||||
+ if (p > 1 && temp[p - 2])
|
||||
+ temp[p++] = 0;
|
||||
+
|
||||
+ *size_out = p * sizeof(WCHAR);
|
||||
+ *out = (BYTE *) temp;
|
||||
+ return ERROR_SUCCESS;
|
||||
+ }
|
||||
+ case REG_BINARY:
|
||||
+ {
|
||||
+ BYTE *temp = HeapAlloc(GetProcessHeap(), 0, strlenW(input));
|
||||
+ DWORD p, odd;
|
||||
+
|
||||
+ for (i = 0, p = 0; i < strlenW(input); i++, p++)
|
||||
+ {
|
||||
+ if (input[i] >= '0' && input[i] <= '9')
|
||||
+ temp[p] = input[i] - '0';
|
||||
+ else if (input[i] >= 'a' && input[i] <= 'f')
|
||||
+ temp[p] = input[i] - 'a' + 10;
|
||||
+ else if (input[i] >= 'A' && input[i] <= 'F')
|
||||
+ temp[p] = input[i] - 'A' + 10;
|
||||
+ else
|
||||
+ {
|
||||
+ HeapFree(GetProcessHeap(), 0, temp);
|
||||
+ return ERROR_INVALID_DATA;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ *out = temp;
|
||||
+ odd = p & 1;
|
||||
+ temp += odd;
|
||||
+ p >>= 1;
|
||||
+
|
||||
+ for (i = 0; i < p; i++)
|
||||
+ temp[i] = (temp[i * 2] << 4) | temp[i * 2 + 1];
|
||||
+
|
||||
+ *size_out = p + odd;
|
||||
+ return ERROR_SUCCESS;
|
||||
}
|
||||
default:
|
||||
{
|
||||
- static const WCHAR unhandled[] = {'U','n','h','a','n','d','l','e','d',' ','T','y','p','e',' ','0','x','%','x',' ',' ','d','a','t','a',' ','%','s','\n',0};
|
||||
- reg_printfW(unhandled, reg_type,data);
|
||||
+ WINE_FIXME("Add support for registry type: %u\n", type);
|
||||
+ return ERROR_UNSUPPORTED_TYPE;
|
||||
}
|
||||
}
|
||||
-
|
||||
- return out_data;
|
||||
}
|
||||
|
||||
static LSTATUS sane_path(const WCHAR *key)
|
||||
@@ -312,7 +396,15 @@ static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
}
|
||||
|
||||
if (data)
|
||||
- reg_data = get_regdata(data,reg_type,separator,®_count);
|
||||
+ {
|
||||
+ err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ {
|
||||
+ RegCloseKey(subkey);
|
||||
+ reg_print_error(err);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
|
||||
RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
|
||||
HeapFree(GetProcessHeap(),0,reg_data);
|
||||
diff --git a/programs/reg/reg.h b/programs/reg/reg.h
|
||||
index 42de422..00c4d66 100644
|
||||
--- a/programs/reg/reg.h
|
||||
+++ b/programs/reg/reg.h
|
||||
@@ -32,3 +32,4 @@
|
||||
#define STRING_CANNOT_FIND 109
|
||||
#define STRING_ERROR 110
|
||||
#define STRING_UNSUPPORTED_TYPE 111
|
||||
+#define STRING_INVALID_DWORD 112
|
||||
diff --git a/programs/reg/reg.rc b/programs/reg/reg.rc
|
||||
index beafd4f..730d421 100644
|
||||
--- a/programs/reg/reg.rc
|
||||
+++ b/programs/reg/reg.rc
|
||||
@@ -37,4 +37,5 @@ STRINGTABLE
|
||||
STRING_CANNOT_FIND, "Error: The system was unable to find the specified registry key or value\n"
|
||||
STRING_ERROR, "Unexpected error: "
|
||||
STRING_UNSUPPORTED_TYPE, "Error: Unsupported type\n"
|
||||
+ STRING_INVALID_DWORD, "Error: /d must be positive number\n"
|
||||
}
|
||||
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
|
||||
index dbfce89..99b4813 100644
|
||||
--- a/programs/reg/tests/reg.c
|
||||
+++ b/programs/reg/tests/reg.c
|
||||
@@ -154,7 +154,7 @@ static void test_add(void)
|
||||
/* REG_NONE */
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v none0 /d deadbeef /t REG_NONE /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d\n", r);
|
||||
- verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "none0", REG_NONE, "d\0e\0a\0d\0b\0e\0e\0f\0\0", 18, 0);
|
||||
|
||||
/* REG_SZ */
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /d WineTest /f", &r);
|
||||
@@ -188,11 +188,11 @@ static void test_add(void)
|
||||
/* REG_EXPAND_SZ */
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand0 /t REG_EXpand_sz /d \"dead%PATH%beef\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "expand0", REG_EXPAND_SZ, "dead%PATH%beef", 15, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v expand1 /t REG_EXpand_sz /d \"dead^%PATH^%beef\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "expand1", REG_EXPAND_SZ, "dead^%PATH^%beef", 17, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
@@ -200,11 +200,11 @@ static void test_add(void)
|
||||
|
||||
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "", REG_EXPAND_SZ, "WineTEST", 9, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand3 /f /d \"\"", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "expand3", REG_EXPAND_SZ, "", 1, 0);
|
||||
|
||||
/* REG_BINARY */
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin0 /f", &r);
|
||||
@@ -214,14 +214,14 @@ static void test_add(void)
|
||||
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_BINARY /d deadbeef /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
dword = 0xefbeadde;
|
||||
- verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "", REG_BINARY, &dword, sizeof(DWORD), 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin2 /f /d x01", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin3 /f /d 01x", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin4 /f /d DeAdBeEf0DD", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
@@ -235,8 +235,8 @@ static void test_add(void)
|
||||
err = RegQueryValueExA(hkey, "bin4", NULL, &type, (void *) (buffer+12), &size);
|
||||
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
|
||||
ok(type == REG_BINARY, "got wrong type %u\n", type);
|
||||
- todo_wine ok(size == 6, "got wrong size %u\n", size);
|
||||
- todo_wine ok(memcmp(buffer, buffer+12, 6) == 0 ||
|
||||
+ ok(size == 6, "got wrong size %u\n", size);
|
||||
+ ok(memcmp(buffer, buffer+12, 6) == 0 ||
|
||||
broken(memcmp(buffer+6, buffer+12, 6) == 0 /* WinXP */), "got wrong data\n");
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_BINARY /v bin5 /d \"\" /f", &r);
|
||||
@@ -257,11 +257,11 @@ static void test_add(void)
|
||||
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
|
||||
"got exit code %d, expected 0\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword3 /t REG_DWORD /d deadbeef /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword4 /t REG_DWORD /d 123xyz /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword5 /t reg_dword /d 12345678 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
@@ -275,22 +275,21 @@ static void test_add(void)
|
||||
ok(err == ERROR_SUCCESS, "RegQueryValueEx failed: got %d\n", err);
|
||||
ok(type == REG_DWORD, "got wrong type %d, expected %d\n", type, REG_DWORD);
|
||||
ok(size == sizeof(DWORD), "got wrong size %d, expected %d\n", size, (int)sizeof(DWORD));
|
||||
- todo_wine ok(dword == 123 || broken(dword == 0123 /* WinXP */),
|
||||
+ ok(dword == 123 || broken(dword == 0123 /* WinXP */),
|
||||
"got wrong data %d, expected %d\n", dword, 123);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword7 /t reg_dword /d 0xabcdefg /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0xdeadbeef /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
dword = 0xdeadbeef;
|
||||
- verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword),
|
||||
- (sizeof(long) > sizeof(DWORD)) ? 0 : TODO_REG_DATA);
|
||||
+ verify_reg(hkey, "dword8", REG_DWORD, &dword, sizeof(dword), 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword9 /f /d -1", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_DWORD /v dword10 /f /d -0x1", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %u\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword8 /t REG_dword /d 0x01ffffffff /f", &r);
|
||||
todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */), "got exit code %d\n", r);
|
||||
@@ -305,7 +304,7 @@ static void test_add(void)
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v DWORD_BE /t REG_DWORD_BIG_ENDIAN /d 456 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
dword = 456;
|
||||
- verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "DWORD_BE", REG_DWORD_BIG_ENDIAN, &dword, sizeof(dword), 0);
|
||||
/* REG_DWORD_BIG_ENDIAN is broken in every version of windows. It behaves like
|
||||
* an ordinary REG_DWORD - that is little endian. GG */
|
||||
|
||||
@@ -313,15 +312,15 @@ static void test_add(void)
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v multi0 /t REG_MULTI_SZ /d \"three\\0little\\0strings\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
memcpy(buffer, "three\0little\0strings\0", 22);
|
||||
- verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "multi0", REG_MULTI_SZ, buffer, 22, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi1 /s \"#\" /d \"three#little#strings\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "multi1", REG_MULTI_SZ, buffer, 22, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi2 /d \"\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "multi2", REG_MULTI_SZ, &buffer[21], 1, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
@@ -329,7 +328,7 @@ static void test_add(void)
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
|
||||
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
@@ -338,16 +337,16 @@ static void test_add(void)
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
|
||||
todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi10 /s \"#\" /d \"#a\" /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi11 /s \"#\" /d \"a#\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
buffer[0]='a'; buffer[1]=0; buffer[2]=0;
|
||||
- verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "multi11", REG_MULTI_SZ, buffer, 3, 0);
|
||||
|
||||
RegCloseKey(hkey);
|
||||
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,226 +0,0 @@
|
||||
From 41951b170a3de9adade891c290c161793582f32e Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:27 +0100
|
||||
Subject: reg: Clean up reg_add
|
||||
|
||||
You'll notice that bad value input leaves a zombie key after this
|
||||
call, but this is consistant with native.
|
||||
---
|
||||
programs/reg/reg.c | 91 +++++++++++++++++++++++++-----------------------
|
||||
programs/reg/tests/reg.c | 22 ++++++------
|
||||
2 files changed, 59 insertions(+), 54 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index 0d892fd..084a8d5 100755
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -349,71 +349,69 @@ static LSTATUS sane_path(const WCHAR *key)
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
-static int reg_add(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
- WCHAR *type, WCHAR separator, WCHAR *data, BOOL force)
|
||||
+static int reg_add( const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
|
||||
+ const WCHAR *type, const WCHAR separator, const WCHAR *data,
|
||||
+ const BOOL force)
|
||||
{
|
||||
- static const WCHAR stubW[] = {'A','D','D',' ','-',' ','%','s',
|
||||
- ' ','%','s',' ','%','d',' ','%','s',' ','%','s',' ','%','d','\n',0};
|
||||
- HKEY subkey;
|
||||
- LONG err;
|
||||
-
|
||||
- reg_printfW(stubW, key_name, value_name, value_empty, type, data, force);
|
||||
-
|
||||
- err = sane_path(key_name);
|
||||
+ HKEY key = NULL;
|
||||
+ LONG err = sane_path(key_name);
|
||||
if (err != ERROR_SUCCESS)
|
||||
+ goto error;
|
||||
+
|
||||
+ if (value_name && value_empty)
|
||||
{
|
||||
- reg_print_error(err);
|
||||
- return 1;
|
||||
+ err = ERROR_BAD_COMMAND;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
- err = path_open(key_name, &subkey, TRUE);
|
||||
+ err = path_open(key_name, &key, TRUE);
|
||||
if (err != ERROR_SUCCESS)
|
||||
- {
|
||||
- reg_message(STRING_INVALID_KEY);
|
||||
- return 1;
|
||||
- }
|
||||
+ goto error;
|
||||
|
||||
if (value_name || data)
|
||||
{
|
||||
- DWORD reg_type;
|
||||
- DWORD reg_count = 0;
|
||||
- BYTE* reg_data = NULL;
|
||||
+ DWORD size, reg_type;
|
||||
+ BYTE *data_out;
|
||||
+
|
||||
+ if (value_name && !value_name[0])
|
||||
+ value_name = NULL;
|
||||
|
||||
- if (!force)
|
||||
+ if (type && !type[0])
|
||||
{
|
||||
- if (RegQueryValueW(subkey,value_name,NULL,NULL)==ERROR_SUCCESS)
|
||||
- {
|
||||
- /* FIXME: Prompt for overwrite */
|
||||
- }
|
||||
+ data = NULL;
|
||||
+ type = NULL;
|
||||
}
|
||||
|
||||
- reg_type = wchar_get_type(type);
|
||||
- if (reg_type == ~0u)
|
||||
+ if (!force && RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
|
||||
{
|
||||
- RegCloseKey(subkey);
|
||||
- reg_print_error(ERROR_UNSUPPORTED_TYPE);
|
||||
- return 1;
|
||||
+ WINE_FIXME("Prompt for overwrite\n");
|
||||
}
|
||||
|
||||
- if (data)
|
||||
+ reg_type = wchar_get_type(type);
|
||||
+ if (reg_type == ~0u)
|
||||
{
|
||||
- err = wchar_get_data(data, reg_type, separator, ®_count, ®_data);
|
||||
- if (err != ERROR_SUCCESS)
|
||||
- {
|
||||
- RegCloseKey(subkey);
|
||||
- reg_print_error(err);
|
||||
- return 1;
|
||||
- }
|
||||
+ err = ERROR_INVALID_DATATYPE;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
- RegSetValueExW(subkey,value_name,0,reg_type,reg_data,reg_count);
|
||||
- HeapFree(GetProcessHeap(),0,reg_data);
|
||||
+ err = wchar_get_data(data, reg_type, separator, &size, &data_out);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ goto error;
|
||||
+
|
||||
+ err = RegSetValueExW(key, value_name, 0, reg_type, data_out, size);
|
||||
+ HeapFree(GetProcessHeap(), 0, data_out);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
- RegCloseKey(subkey);
|
||||
+ RegCloseKey(key);
|
||||
reg_message(STRING_SUCCESS);
|
||||
-
|
||||
return 0;
|
||||
+
|
||||
+error:
|
||||
+ RegCloseKey(key);
|
||||
+ reg_print_error(err);
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
@@ -593,7 +591,14 @@ int wmain(int argc, WCHAR *argvW[])
|
||||
else if (!lstrcmpiW(argvW[i], slashTW))
|
||||
type = argvW[++i];
|
||||
else if (!lstrcmpiW(argvW[i], slashSW))
|
||||
- separator = argvW[++i][0];
|
||||
+ {
|
||||
+ if (!argvW[++i][0] || argvW[i][1])
|
||||
+ {
|
||||
+ reg_print_error(ERROR_BAD_COMMAND);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ separator = argvW[i][0];
|
||||
+ }
|
||||
else if (!lstrcmpiW(argvW[i], slashDW))
|
||||
data = argvW[++i];
|
||||
else if (!lstrcmpiW(argvW[i], slashFW))
|
||||
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
|
||||
index 99b4813..a3ecdfb 100644
|
||||
--- a/programs/reg/tests/reg.c
|
||||
+++ b/programs/reg/tests/reg.c
|
||||
@@ -110,12 +110,12 @@ static void test_add(void)
|
||||
|
||||
/* Test empty type */
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v emptyType /t \"\" /d WineTest /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
|
||||
+ ok(r == REG_EXIT_SUCCESS || broken(r == REG_EXIT_FAILURE /* WinXP */),
|
||||
"got exit code %u\n", r);
|
||||
if (r == REG_EXIT_SUCCESS)
|
||||
- todo_wine verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
|
||||
+ verify_reg(hkey, "emptyType", REG_SZ, "", 1, 0);
|
||||
else
|
||||
- todo_wine win_skip("broken reg.exe detected\n");
|
||||
+ win_skip("broken reg.exe detected\n");
|
||||
|
||||
/* Test input key formats */
|
||||
run_reg_exe("reg add \\HKCU\\" KEY_BASE "\\keytest0 /f", &r);
|
||||
@@ -171,7 +171,7 @@ static void test_add(void)
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v test /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
- verify_reg(hkey, "test", REG_SZ, "", 1, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "test", REG_SZ, "", 1, 0);
|
||||
|
||||
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /d WineTEST /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
@@ -179,7 +179,7 @@ static void test_add(void)
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test2 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
- verify_reg(hkey, "test2", REG_SZ, "", 1, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "test2", REG_SZ, "", 1, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_SZ /v test3 /f /d \"\"", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
@@ -196,7 +196,7 @@ static void test_add(void)
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_EXPAND_SZ /v expand2 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "expand2", REG_EXPAND_SZ, "", 1, 0);
|
||||
|
||||
run_reg_exe("reg add HKEY_CURRENT_USER\\" KEY_BASE " /ve /t REG_EXPAND_SZ /d WineTEST /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
@@ -254,7 +254,7 @@ static void test_add(void)
|
||||
win_skip("broken reg.exe detected\n");
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword1 /t REG_DWORD /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
|
||||
+ ok(r == REG_EXIT_FAILURE || broken(r == REG_EXIT_SUCCESS /* WinXP */),
|
||||
"got exit code %d, expected 0\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /v dword2 /t REG_DWORD /d zzz /f", &r);
|
||||
ok(r == REG_EXIT_FAILURE, "got exit code %d, expected 1\n", r);
|
||||
@@ -324,18 +324,18 @@ static void test_add(void)
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi3 /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
- verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, TODO_REG_SIZE);
|
||||
+ verify_reg(hkey, "multi3", REG_MULTI_SZ, &buffer[21], 1, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi4 /s \"#\" /d \"threelittlestrings\" /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %u\n", r);
|
||||
verify_reg(hkey, "multi4", REG_MULTI_SZ, "threelittlestrings\0", 20, 0);
|
||||
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi5 /s \"#randomgibberish\" /d \"three#little#strings\" /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi6 /s \"\\0\" /d \"three\\0little\\0strings\" /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi7 /s \"\" /d \"three#little#strings\" /f", &r);
|
||||
- todo_wine ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
+ ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi8 /s \"#\" /d \"##\" /f", &r);
|
||||
ok(r == REG_EXIT_FAILURE, "got exit code %u\n", r);
|
||||
run_reg_exe("reg add HKCU\\" KEY_BASE " /t REG_MULTI_SZ /v multi9 /s \"#\" /d \"two##strings\" /f", &r);
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1,228 +0,0 @@
|
||||
From c1794766d8e9d1a1ddf46f4b81236e71a12fcbc4 Mon Sep 17 00:00:00 2001
|
||||
From: Jonathan Vollebregt <jnvsor@gmail.com>
|
||||
Date: Wed, 14 Jan 2015 18:12:28 +0100
|
||||
Subject: reg: Clean up reg_delete
|
||||
|
||||
---
|
||||
programs/reg/reg.c | 152 ++++++++++++++++++++++++-----------------------
|
||||
programs/reg/tests/reg.c | 2 +-
|
||||
2 files changed, 78 insertions(+), 76 deletions(-)
|
||||
|
||||
diff --git a/programs/reg/reg.c b/programs/reg/reg.c
|
||||
index 084a8d5..5d7db3b 100755
|
||||
--- a/programs/reg/reg.c
|
||||
+++ b/programs/reg/reg.c
|
||||
@@ -414,120 +414,122 @@ error:
|
||||
return 1;
|
||||
}
|
||||
|
||||
-static int reg_delete(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
- BOOL value_all, BOOL force)
|
||||
+static int reg_delete(const WCHAR *key_name, const WCHAR *value_name, const BOOL value_empty,
|
||||
+ const BOOL value_all, const BOOL force)
|
||||
{
|
||||
- HKEY subkey;
|
||||
- LONG err;
|
||||
-
|
||||
- static const WCHAR stubW[] = {'D','E','L','E','T','E',
|
||||
- ' ','-',' ','%','s',' ','%','s',' ','%','d',' ','%','d',' ','%','d','\n'
|
||||
- ,0};
|
||||
- reg_printfW(stubW, key_name, value_name, value_empty, value_all, force);
|
||||
-
|
||||
- err = sane_path(key_name);
|
||||
+ HKEY key = NULL;
|
||||
+ LONG err = sane_path(key_name);
|
||||
if (err != ERROR_SUCCESS)
|
||||
{
|
||||
reg_print_error(err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
- err = path_open(key_name, &subkey, FALSE);
|
||||
+ err = path_open(key_name, &key, FALSE);
|
||||
if (err != ERROR_SUCCESS)
|
||||
- {
|
||||
- reg_message(STRING_INVALID_KEY);
|
||||
- return 1;
|
||||
- }
|
||||
-
|
||||
- if (value_name && value_empty)
|
||||
- {
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
- return 1;
|
||||
- }
|
||||
+ goto error;
|
||||
|
||||
- if (value_empty && value_all)
|
||||
+ /* Mutually exclusive options */
|
||||
+ if ((!!value_name + !!value_empty + !!value_all) > 1)
|
||||
{
|
||||
- reg_message(STRING_INVALID_CMDLINE);
|
||||
- return 1;
|
||||
+ err = ERROR_BAD_COMMAND;
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
if (!force)
|
||||
{
|
||||
- /* FIXME: Prompt for delete */
|
||||
+ WINE_FIXME("Prompt for delete\n");
|
||||
}
|
||||
|
||||
- /* Delete subtree only if no /v* option is given */
|
||||
- if (!value_name && !value_empty && !value_all)
|
||||
+ if (value_empty || value_name)
|
||||
{
|
||||
- err = RegDeleteTreeW(subkey, NULL);
|
||||
- if (err != ERROR_SUCCESS)
|
||||
- {
|
||||
- reg_print_error(err);
|
||||
- return 1;
|
||||
- }
|
||||
+ if (value_name && value_name[0])
|
||||
+ err = RegDeleteValueW(key, value_name);
|
||||
+ else
|
||||
+ err = RegDeleteValueW(key, NULL);
|
||||
|
||||
- err = RegDeleteKeyW(subkey, empty_wstr);
|
||||
if (err != ERROR_SUCCESS)
|
||||
- {
|
||||
- reg_print_error(err);
|
||||
- return 1;
|
||||
- }
|
||||
- reg_message(STRING_SUCCESS);
|
||||
- return 0;
|
||||
+ goto error;
|
||||
}
|
||||
-
|
||||
- if (value_all)
|
||||
+ else if (value_all)
|
||||
{
|
||||
- LPWSTR szValue;
|
||||
- DWORD maxValue;
|
||||
- DWORD count;
|
||||
- LONG rc;
|
||||
-
|
||||
- rc = RegQueryInfoKeyW(subkey, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
- &maxValue, NULL, NULL, NULL);
|
||||
- if (rc != ERROR_SUCCESS)
|
||||
+ WCHAR *enum_v_name;
|
||||
+ DWORD count, max_size, this_size, i = 0;
|
||||
+ BOOL incomplete = FALSE;
|
||||
+
|
||||
+ err = RegQueryInfoKeyW(key, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
+ &count, &max_size, NULL, NULL, NULL);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ goto error;
|
||||
+
|
||||
+ max_size++;
|
||||
+ enum_v_name = HeapAlloc(GetProcessHeap(), 0, max_size * sizeof(WCHAR));
|
||||
+ if (!enum_v_name)
|
||||
{
|
||||
- /* FIXME: failure */
|
||||
- RegCloseKey(subkey);
|
||||
- return 1;
|
||||
+ err = ERROR_NOT_ENOUGH_MEMORY;
|
||||
+ goto error;
|
||||
}
|
||||
- maxValue++;
|
||||
- szValue = HeapAlloc(GetProcessHeap(),0,maxValue*sizeof(WCHAR));
|
||||
|
||||
- while (1)
|
||||
+ while (i < count)
|
||||
{
|
||||
- count = maxValue;
|
||||
- rc = RegEnumValueW(subkey, 0, szValue, &count, NULL, NULL, NULL, NULL);
|
||||
- if (rc == ERROR_SUCCESS)
|
||||
+ this_size = max_size;
|
||||
+
|
||||
+ err = RegEnumValueW(key, i, enum_v_name, &this_size, NULL, NULL, NULL, NULL);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ {
|
||||
+ reg_print_error(err);
|
||||
+ incomplete = TRUE;
|
||||
+ i++;
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ err = RegDeleteValueW(key, enum_v_name);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
{
|
||||
- rc = RegDeleteValueW(subkey, szValue);
|
||||
- if (rc != ERROR_SUCCESS)
|
||||
- break;
|
||||
+ reg_print_error(err);
|
||||
+ incomplete = TRUE;
|
||||
+ i++;
|
||||
+ continue;
|
||||
}
|
||||
- else break;
|
||||
+
|
||||
+ count--;
|
||||
}
|
||||
- if (rc != ERROR_SUCCESS)
|
||||
+
|
||||
+ HeapFree(GetProcessHeap(), 0, enum_v_name);
|
||||
+
|
||||
+ if (incomplete)
|
||||
{
|
||||
- /* FIXME delete failed */
|
||||
+ RegCloseKey(key);
|
||||
+ return 1;
|
||||
}
|
||||
}
|
||||
- else if (value_name)
|
||||
+ /* Delete subtree only if no /v* option is given */
|
||||
+ else
|
||||
{
|
||||
- if (RegDeleteValueW(subkey,value_name) != ERROR_SUCCESS)
|
||||
+ if (key == path_get_rootkey(key_name))
|
||||
{
|
||||
- RegCloseKey(subkey);
|
||||
- reg_message(STRING_CANNOT_FIND);
|
||||
+ /* "This works well enough on native to make you regret you pressed enter" - stefand */
|
||||
+ WINE_FIXME("Deleting a root key is not implemented.\n");
|
||||
+ RegCloseKey(key);
|
||||
return 1;
|
||||
}
|
||||
- }
|
||||
- else if (value_empty)
|
||||
- {
|
||||
- RegSetValueExW(subkey,NULL,0,REG_SZ,NULL,0);
|
||||
+
|
||||
+ err = RegDeleteTreeW(key, NULL);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ goto error;
|
||||
+ err = RegDeleteKeyW(key, empty_wstr);
|
||||
+ if (err != ERROR_SUCCESS)
|
||||
+ goto error;
|
||||
}
|
||||
|
||||
- RegCloseKey(subkey);
|
||||
+ RegCloseKey(key);
|
||||
reg_message(STRING_SUCCESS);
|
||||
return 0;
|
||||
+
|
||||
+error:
|
||||
+ RegCloseKey(key);
|
||||
+ reg_print_error(err);
|
||||
+ return 1;
|
||||
}
|
||||
|
||||
static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
|
||||
diff --git a/programs/reg/tests/reg.c b/programs/reg/tests/reg.c
|
||||
index a3ecdfb..20ef7af 100644
|
||||
--- a/programs/reg/tests/reg.c
|
||||
+++ b/programs/reg/tests/reg.c
|
||||
@@ -388,7 +388,7 @@ static void test_delete(void)
|
||||
run_reg_exe("reg delete HKCU\\" KEY_BASE " /ve /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
err = RegQueryValueExA(hkey, "", NULL, NULL, NULL, NULL);
|
||||
- todo_wine ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
|
||||
+ ok(err == ERROR_FILE_NOT_FOUND, "got %d\n", err);
|
||||
|
||||
run_reg_exe("reg delete HKCU\\" KEY_BASE " /va /f", &r);
|
||||
ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r);
|
||||
--
|
||||
2.2.2
|
||||
|
@ -1 +0,0 @@
|
||||
Disabled: true
|
Loading…
x
Reference in New Issue
Block a user