ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
June 2022
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
17 participants
236 discussions
Start a n
N
ew thread
[reactos] 38/158: [WINESYNC] reg: Move 'import' syntax checks to reg_import().
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b4d8b76a2fffd45509da8…
commit b4d8b76a2fffd45509da88655e920bd9c86277ce Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:31:21 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:30 2022 +0200 [WINESYNC] reg: Move 'import' syntax checks to reg_import(). Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 4cbf47054fc7d95bcbab368fa53fc71908472309 by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- base/applications/cmdutils/reg/import.c | 13 +++++++++++-- base/applications/cmdutils/reg/reg.c | 9 +-------- base/applications/cmdutils/reg/reg.h | 2 +- sdk/tools/winesync/reg.cfg | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/base/applications/cmdutils/reg/import.c b/base/applications/cmdutils/reg/import.c index 9e21bcc6a7e..13e54e6a69a 100644 --- a/base/applications/cmdutils/reg/import.c +++ b/base/applications/cmdutils/reg/import.c @@ -983,13 +983,22 @@ cleanup: return NULL; } -int reg_import(const WCHAR *filename) +int reg_import(int argc, WCHAR *argvW[]) { + WCHAR *filename, *pos; FILE *fp; static const WCHAR rb_mode[] = {'r','b',0}; BYTE s[2]; struct parser parser; - WCHAR *pos; + + if (argc > 3) + { + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); + return 1; + } + + filename = argvW[2]; fp = _wfopen(filename, rb_mode); if (!fp) diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 7f3db0fdcde..8a27756b974 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -390,15 +390,8 @@ int __cdecl wmain(int argc, WCHAR *argvW[]) return 0; } - if (op == REG_IMPORT && argc > 3) - { - output_message(STRING_INVALID_SYNTAX); - output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); - return 1; - } - if (op == REG_IMPORT) - return reg_import(argvW[2]); + return reg_import(argc, argvW); if (op == REG_EXPORT) return reg_export(argc, argvW); diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h index b29c2c21a1f..703dd0d37af 100644 --- a/base/applications/cmdutils/reg/reg.h +++ b/base/applications/cmdutils/reg/reg.h @@ -56,7 +56,7 @@ int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, int reg_export(int argc, WCHAR *argv[]); /* import.c */ -int reg_import(const WCHAR *filename); +int reg_import(int argc, WCHAR *argvW[]); /* query.c */ int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 55ca7c38a86..e1852985669 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 8801118e384b7388a0fa5c43b5540bfd7f257ab6 + wine: 4cbf47054fc7d95bcbab368fa53fc71908472309
2 years, 6 months
1
0
0
0
[reactos] 37/158: [WINESYNC] reg: Simplify basic syntax checks.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f16c791548b8307ff5bdc…
commit f16c791548b8307ff5bdcf1a306019c39868c0f6 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:25:19 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:30 2022 +0200 [WINESYNC] reg: Simplify basic syntax checks. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 8801118e384b7388a0fa5c43b5540bfd7f257ab6 by Hugh McMaster <hugh.mcmaster(a)outlook.com> manual adjustments needed --- base/applications/cmdutils/reg/reg.c | 16 ++++++++++------ sdk/tools/winesync/reg.cfg | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 4645f22aec7..7f3db0fdcde 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -349,7 +349,6 @@ static enum operations get_operation(const WCHAR *str, int *op_help) int __cdecl wmain(int argc, WCHAR *argvW[]) { int i, op, op_help, ret; - BOOL show_op_help = FALSE; static const WCHAR switchVAW[] = {'v','a',0}; static const WCHAR switchVEW[] = {'v','e',0}; WCHAR *key_name, *path, *value_name = NULL, *type = NULL, *data = NULL, separator = '\0'; @@ -378,21 +377,26 @@ int __cdecl wmain(int argc, WCHAR *argvW[]) return 1; } - if (argc > 2) - show_op_help = is_help_switch(argvW[2]); - - if (argc == 2 || ((show_op_help || op == REG_IMPORT) && argc > 3)) + else if (argc == 2) /* Valid operation, no arguments supplied */ { output_message(STRING_INVALID_SYNTAX); output_message(STRING_FUNC_HELP, _wcsupr(argvW[1])); return 1; } - else if (show_op_help) + + if (is_help_switch(argvW[2])) { output_message(op_help); return 0; } + if (op == REG_IMPORT && argc > 3) + { + output_message(STRING_INVALID_SYNTAX); + output_message(STRING_FUNC_HELP, wcsupr(argvW[1])); + return 1; + } + if (op == REG_IMPORT) return reg_import(argvW[2]); diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index c83a928ad45..55ca7c38a86 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 7803c53cfe6635a5d3e0d9f58e743235746ec9d2 + wine: 8801118e384b7388a0fa5c43b5540bfd7f257ab6
2 years, 6 months
1
0
0
0
[reactos] 36/158: [WINESYNC] reg: Merge common header #includes into reg.h.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=01c1091e51bb6cd50d671…
commit 01c1091e51bb6cd50d6712a2bb0e6ac9acbe37d3 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:25:19 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:30 2022 +0200 [WINESYNC] reg: Merge common header #includes into reg.h. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7803c53cfe6635a5d3e0d9f58e743235746ec9d2 by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- base/applications/cmdutils/reg/add.c | 2 -- base/applications/cmdutils/reg/delete.c | 2 -- base/applications/cmdutils/reg/export.c | 4 ---- base/applications/cmdutils/reg/import.c | 6 +----- base/applications/cmdutils/reg/query.c | 2 -- base/applications/cmdutils/reg/reg.c | 4 +--- base/applications/cmdutils/reg/reg.h | 2 ++ sdk/tools/winesync/reg.cfg | 2 +- 8 files changed, 5 insertions(+), 19 deletions(-) diff --git a/base/applications/cmdutils/reg/add.c b/base/applications/cmdutils/reg/add.c index 2d8521f9234..054023df7ab 100644 --- a/base/applications/cmdutils/reg/add.c +++ b/base/applications/cmdutils/reg/add.c @@ -18,8 +18,6 @@ #include <errno.h> #include <stdlib.h> -#include <windows.h> -#include <wine/heap.h> #include "reg.h" static DWORD wchar_get_type(const WCHAR *type_name) diff --git a/base/applications/cmdutils/reg/delete.c b/base/applications/cmdutils/reg/delete.c index 530d4513ece..e0730e5c12f 100644 --- a/base/applications/cmdutils/reg/delete.c +++ b/base/applications/cmdutils/reg/delete.c @@ -16,8 +16,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> -#include <wine/heap.h> #include "reg.h" int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, diff --git a/base/applications/cmdutils/reg/export.c b/base/applications/cmdutils/reg/export.c index 50d27b45d37..4e069bdda18 100644 --- a/base/applications/cmdutils/reg/export.c +++ b/base/applications/cmdutils/reg/export.c @@ -16,12 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> #include <stdio.h> #include <stdlib.h> - -#include <wine/heap.h> - #include "reg.h" static void write_file(HANDLE hFile, const WCHAR *str) diff --git a/base/applications/cmdutils/reg/import.c b/base/applications/cmdutils/reg/import.c index 7ad7b35d5dc..9e21bcc6a7e 100644 --- a/base/applications/cmdutils/reg/import.c +++ b/base/applications/cmdutils/reg/import.c @@ -16,15 +16,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> - -#include <wine/debug.h> -#include <wine/heap.h> - #include "reg.h" +#include <wine/debug.h> WINE_DEFAULT_DEBUG_CHANNEL(reg); diff --git a/base/applications/cmdutils/reg/query.c b/base/applications/cmdutils/reg/query.c index 3d81d120bd2..b24edb2f0b2 100644 --- a/base/applications/cmdutils/reg/query.c +++ b/base/applications/cmdutils/reg/query.c @@ -17,8 +17,6 @@ */ #include <stdio.h> -#include <windows.h> -#include <wine/heap.h> #include "reg.h" static const WCHAR *reg_type_to_wchar(DWORD type) diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 26cb3e26b96..4645f22aec7 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -16,11 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include <windows.h> #include <stdlib.h> -#include <wine/debug.h> -#include <wine/heap.h> #include "reg.h" +#include <wine/debug.h> WINE_DEFAULT_DEBUG_CHANNEL(reg); diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h index 4cb31c4671a..b29c2c21a1f 100644 --- a/base/applications/cmdutils/reg/reg.h +++ b/base/applications/cmdutils/reg/reg.h @@ -19,6 +19,8 @@ #ifndef __REG_H__ #define __REG_H__ +#include <windows.h> +#include <wine/heap.h> #include "resource.h" #define MAX_SUBKEY_LEN 257 diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 769f8b11b04..c83a928ad45 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: ab94653e8bb093b88406f7c509c7157ac7033f28 + wine: 7803c53cfe6635a5d3e0d9f58e743235746ec9d2
2 years, 6 months
1
0
0
0
[reactos] 35/158: [WINESYNC] reg: Use is_switch() where possible.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=fa84e69673bb2eef7c4fc…
commit fa84e69673bb2eef7c4fc7805fc9b3d331673c85 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:25:18 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:30 2022 +0200 [WINESYNC] reg: Use is_switch() where possible. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id ab94653e8bb093b88406f7c509c7157ac7033f28 by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- base/applications/cmdutils/reg/export.c | 8 +------- base/applications/cmdutils/reg/reg.c | 7 ++----- base/applications/cmdutils/reg/reg.h | 1 + sdk/tools/winesync/reg.cfg | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/base/applications/cmdutils/reg/export.c b/base/applications/cmdutils/reg/export.c index b5796d5fef3..50d27b45d37 100644 --- a/base/applications/cmdutils/reg/export.c +++ b/base/applications/cmdutils/reg/export.c @@ -361,13 +361,7 @@ static HANDLE get_file_handle(WCHAR *filename, BOOL overwrite_file) static BOOL is_overwrite_switch(const WCHAR *s) { - if (lstrlenW(s) > 2) - return FALSE; - - if ((s[0] == '/' || s[0] == '-') && (s[1] == 'y' || s[1] == 'Y')) - return TRUE; - - return FALSE; + return is_switch(s, 'y'); } int reg_export(int argc, WCHAR *argv[]) diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 8be4a6e5b40..26cb3e26b96 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -289,7 +289,7 @@ BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long return TRUE; } -static BOOL is_switch(const WCHAR *s, const WCHAR c) +BOOL is_switch(const WCHAR *s, const WCHAR c) { if (lstrlenW(s) > 2) return FALSE; @@ -302,10 +302,7 @@ static BOOL is_switch(const WCHAR *s, const WCHAR c) static BOOL is_help_switch(const WCHAR *s) { - if (is_switch(s, '?') || is_switch(s, 'h')) - return TRUE; - - return FALSE; + return (is_switch(s, '?') || is_switch(s, 'h')); } enum operations { diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h index b14470b2cbf..4cb31c4671a 100644 --- a/base/applications/cmdutils/reg/reg.h +++ b/base/applications/cmdutils/reg/reg.h @@ -40,6 +40,7 @@ BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info); HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); +BOOL is_switch(const WCHAR *s, const WCHAR c); /* add.c */ int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 49526f7bef5..769f8b11b04 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 7e7d92d5e97f89a409db0dd091419b4f1bfe7ed4 + wine: ab94653e8bb093b88406f7c509c7157ac7033f28
2 years, 6 months
1
0
0
0
[reactos] 34/158: [WINESYNC] reg: Split 'add' functions from reg.c.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=bcb87edb6ac6482ac6f9c…
commit bcb87edb6ac6482ac6f9c3cbd96e4b0603699023 Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:25:08 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:29 2022 +0200 [WINESYNC] reg: Split 'add' functions from reg.c. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 7e7d92d5e97f89a409db0dd091419b4f1bfe7ed4 by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- base/applications/cmdutils/reg/add.c | 213 +++++++++++++++++++++++++++++++++++ base/applications/cmdutils/reg/reg.c | 192 ------------------------------- base/applications/cmdutils/reg/reg.h | 4 + sdk/tools/winesync/reg.cfg | 2 +- 4 files changed, 218 insertions(+), 193 deletions(-) diff --git a/base/applications/cmdutils/reg/add.c b/base/applications/cmdutils/reg/add.c new file mode 100644 index 00000000000..2d8521f9234 --- /dev/null +++ b/base/applications/cmdutils/reg/add.c @@ -0,0 +1,213 @@ +/* + * Copyright 2016-2017, 2021 Hugh McMaster + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <errno.h> +#include <stdlib.h> +#include <windows.h> +#include <wine/heap.h> +#include "reg.h" + +static DWORD wchar_get_type(const WCHAR *type_name) +{ + DWORD i; + + if (!type_name) + return REG_SZ; + + for (i = 0; i < ARRAY_SIZE(type_rels); i++) + { + if (!wcsicmp(type_rels[i].name, type_name)) + return type_rels[i].type; + } + + return ~0u; +} + +/* hexchar_to_byte from programs/regedit/hexedit.c */ +static inline BYTE hexchar_to_byte(WCHAR ch) +{ + if (ch >= '0' && ch <= '9') + return ch - '0'; + else if (ch >= 'a' && ch <= 'f') + return ch - 'a' + 10; + else if (ch >= 'A' && ch <= 'F') + return ch - 'A' + 10; + else + return -1; +} + +static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWORD *reg_count) +{ + static const WCHAR empty; + LPBYTE out_data = NULL; + *reg_count = 0; + + if (!data) data = ∅ + + switch (reg_type) + { + case REG_NONE: + case REG_SZ: + case REG_EXPAND_SZ: + { + *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR); + out_data = heap_xalloc(*reg_count); + lstrcpyW((LPWSTR)out_data,data); + break; + } + case REG_DWORD: + /* case REG_DWORD_LITTLE_ENDIAN: */ + case REG_DWORD_BIG_ENDIAN: /* Yes, this is correct! */ + { + LPWSTR rest; + unsigned long val; + val = wcstoul(data, &rest, (towlower(data[1]) == 'x') ? 16 : 10); + if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) { + output_message(STRING_MISSING_INTEGER); + break; + } + *reg_count = sizeof(DWORD); + out_data = heap_xalloc(*reg_count); + ((LPDWORD)out_data)[0] = val; + break; + } + case REG_BINARY: + { + BYTE hex0, hex1; + int i = 0, destByteIndex = 0, datalen = lstrlenW(data); + *reg_count = ((datalen + datalen % 2) / 2) * sizeof(BYTE); + out_data = heap_xalloc(*reg_count); + if(datalen % 2) + { + hex1 = hexchar_to_byte(data[i++]); + if(hex1 == 0xFF) + goto no_hex_data; + out_data[destByteIndex++] = hex1; + } + for(;i + 1 < datalen;i += 2) + { + hex0 = hexchar_to_byte(data[i]); + hex1 = hexchar_to_byte(data[i + 1]); + if(hex0 == 0xFF || hex1 == 0xFF) + goto no_hex_data; + out_data[destByteIndex++] = (hex0 << 4) | hex1; + } + break; + no_hex_data: + /* cleanup, print error */ + heap_free(out_data); + output_message(STRING_MISSING_HEXDATA); + out_data = NULL; + break; + } + case REG_MULTI_SZ: + { + int i, destindex, len = lstrlenW(data); + WCHAR *buffer = heap_xalloc((len + 2) * sizeof(WCHAR)); + + for (i = 0, destindex = 0; i < len; i++, destindex++) + { + if (!separator && data[i] == '\\' && data[i + 1] == '0') + { + buffer[destindex] = 0; + i++; + } + else if (data[i] == separator) + buffer[destindex] = 0; + else + buffer[destindex] = data[i]; + + if (destindex && !buffer[destindex - 1] && (!buffer[destindex] || destindex == 1)) + { + heap_free(buffer); + output_message(STRING_INVALID_STRING); + return NULL; + } + } + buffer[destindex] = 0; + if (destindex && buffer[destindex - 1]) + buffer[++destindex] = 0; + *reg_count = (destindex + 1) * sizeof(WCHAR); + return (BYTE *)buffer; + } + default: + output_message(STRING_UNHANDLED_TYPE, reg_type, data); + } + + return out_data; +} + +int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, + WCHAR *type, WCHAR separator, WCHAR *data, BOOL force) +{ + HKEY key; + + if (RegCreateKeyW(root, path, &key) != ERROR_SUCCESS) + { + output_message(STRING_INVALID_KEY); + return 1; + } + + if (value_name || value_empty || data) + { + DWORD reg_type; + DWORD reg_count = 0; + BYTE* reg_data = NULL; + + if (!force) + { + if (RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) + { + if (!ask_confirm(STRING_OVERWRITE_VALUE, value_name)) + { + RegCloseKey(key); + output_message(STRING_CANCELLED); + return 0; + } + } + } + + reg_type = wchar_get_type(type); + if (reg_type == ~0u) + { + RegCloseKey(key); + output_message(STRING_UNSUPPORTED_TYPE, type); + return 1; + } + if ((reg_type == REG_DWORD || reg_type == REG_DWORD_BIG_ENDIAN) && !data) + { + RegCloseKey(key); + output_message(STRING_INVALID_CMDLINE); + return 1; + } + + if (!(reg_data = get_regdata(data, reg_type, separator, ®_count))) + { + RegCloseKey(key); + return 1; + } + + RegSetValueExW(key, value_name, 0, reg_type, reg_data, reg_count); + heap_free(reg_data); + } + + RegCloseKey(key); + output_message(STRING_SUCCESS); + + return 0; +} diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 81b2f1b295e..8be4a6e5b40 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -17,8 +17,6 @@ */ #include <windows.h> -#include <errno.h> -#include <stdio.h> #include <stdlib.h> #include <wine/debug.h> #include <wine/heap.h> @@ -213,136 +211,6 @@ HKEY path_get_rootkey(const WCHAR *path) return NULL; } -static DWORD wchar_get_type(const WCHAR *type_name) -{ - DWORD i; - - if (!type_name) - return REG_SZ; - - for (i = 0; i < ARRAY_SIZE(type_rels); i++) - { - if (!wcsicmp(type_rels[i].name, type_name)) - return type_rels[i].type; - } - - return ~0u; -} - -/* hexchar_to_byte from programs/regedit/hexedit.c */ -static inline BYTE hexchar_to_byte(WCHAR ch) -{ - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'a' && ch <= 'f') - return ch - 'a' + 10; - else if (ch >= 'A' && ch <= 'F') - return ch - 'A' + 10; - else - return -1; -} - -static LPBYTE get_regdata(const WCHAR *data, DWORD reg_type, WCHAR separator, DWORD *reg_count) -{ - static const WCHAR empty; - LPBYTE out_data = NULL; - *reg_count = 0; - - if (!data) data = ∅ - - switch (reg_type) - { - case REG_NONE: - case REG_SZ: - case REG_EXPAND_SZ: - { - *reg_count = (lstrlenW(data) + 1) * sizeof(WCHAR); - out_data = heap_xalloc(*reg_count); - lstrcpyW((LPWSTR)out_data,data); - break; - } - case REG_DWORD: - /* case REG_DWORD_LITTLE_ENDIAN: */ - case REG_DWORD_BIG_ENDIAN: /* Yes, this is correct! */ - { - LPWSTR rest; - unsigned long val; - val = wcstoul(data, &rest, (towlower(data[1]) == 'x') ? 16 : 10); - if (*rest || data[0] == '-' || (val == ~0u && errno == ERANGE)) { - output_message(STRING_MISSING_INTEGER); - break; - } - *reg_count = sizeof(DWORD); - out_data = heap_xalloc(*reg_count); - ((LPDWORD)out_data)[0] = val; - break; - } - case REG_BINARY: - { - BYTE hex0, hex1; - int i = 0, destByteIndex = 0, datalen = lstrlenW(data); - *reg_count = ((datalen + datalen % 2) / 2) * sizeof(BYTE); - out_data = heap_xalloc(*reg_count); - if(datalen % 2) - { - hex1 = hexchar_to_byte(data[i++]); - if(hex1 == 0xFF) - goto no_hex_data; - out_data[destByteIndex++] = hex1; - } - for(;i + 1 < datalen;i += 2) - { - hex0 = hexchar_to_byte(data[i]); - hex1 = hexchar_to_byte(data[i + 1]); - if(hex0 == 0xFF || hex1 == 0xFF) - goto no_hex_data; - out_data[destByteIndex++] = (hex0 << 4) | hex1; - } - break; - no_hex_data: - /* cleanup, print error */ - heap_free(out_data); - output_message(STRING_MISSING_HEXDATA); - out_data = NULL; - break; - } - case REG_MULTI_SZ: - { - int i, destindex, len = lstrlenW(data); - WCHAR *buffer = heap_xalloc((len + 2) * sizeof(WCHAR)); - - for (i = 0, destindex = 0; i < len; i++, destindex++) - { - if (!separator && data[i] == '\\' && data[i + 1] == '0') - { - buffer[destindex] = 0; - i++; - } - else if (data[i] == separator) - buffer[destindex] = 0; - else - buffer[destindex] = data[i]; - - if (destindex && !buffer[destindex - 1] && (!buffer[destindex] || destindex == 1)) - { - heap_free(buffer); - output_message(STRING_INVALID_STRING); - return NULL; - } - } - buffer[destindex] = 0; - if (destindex && buffer[destindex - 1]) - buffer[++destindex] = 0; - *reg_count = (destindex + 1) * sizeof(WCHAR); - return (BYTE *)buffer; - } - default: - output_message(STRING_UNHANDLED_TYPE, reg_type, data); - } - - return out_data; -} - static BOOL sane_path(const WCHAR *key) { unsigned int i = lstrlenW(key); @@ -362,66 +230,6 @@ static BOOL sane_path(const WCHAR *key) return TRUE; } -static int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, - WCHAR *type, WCHAR separator, WCHAR *data, BOOL force) -{ - HKEY key; - - if (RegCreateKeyW(root, path, &key) != ERROR_SUCCESS) - { - output_message(STRING_INVALID_KEY); - return 1; - } - - if (value_name || value_empty || data) - { - DWORD reg_type; - DWORD reg_count = 0; - BYTE* reg_data = NULL; - - if (!force) - { - if (RegQueryValueExW(key, value_name, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) - { - if (!ask_confirm(STRING_OVERWRITE_VALUE, value_name)) - { - RegCloseKey(key); - output_message(STRING_CANCELLED); - return 0; - } - } - } - - reg_type = wchar_get_type(type); - if (reg_type == ~0u) - { - RegCloseKey(key); - output_message(STRING_UNSUPPORTED_TYPE, type); - return 1; - } - if ((reg_type == REG_DWORD || reg_type == REG_DWORD_BIG_ENDIAN) && !data) - { - RegCloseKey(key); - output_message(STRING_INVALID_CMDLINE); - return 1; - } - - if (!(reg_data = get_regdata(data, reg_type, separator, ®_count))) - { - RegCloseKey(key); - return 1; - } - - RegSetValueExW(key, value_name, 0, reg_type, reg_data, reg_count); - heap_free(reg_data); - } - - RegCloseKey(key); - output_message(STRING_SUCCESS); - - return 0; -} - WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len) { WCHAR *subkey_path; diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h index c8baaa0f9a9..b14470b2cbf 100644 --- a/base/applications/cmdutils/reg/reg.h +++ b/base/applications/cmdutils/reg/reg.h @@ -41,6 +41,10 @@ HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); +/* add.c */ +int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, + WCHAR *type, WCHAR separator, WCHAR *data, BOOL force); + /* delete.c */ int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, BOOL value_empty, BOOL value_all, BOOL force); diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index bf7d17e38a6..49526f7bef5 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 81a3eecc3c2e7ddced2f25cabc6de47101fd4fb1 + wine: 7e7d92d5e97f89a409db0dd091419b4f1bfe7ed4
2 years, 6 months
1
0
0
0
[reactos] 33/158: [WINESYNC] reg: Split 'delete' functions from reg.c.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=6fc87692b3e02ec702479…
commit 6fc87692b3e02ec70247939dc093bab99e668bce Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:22:40 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:29 2022 +0200 [WINESYNC] reg: Split 'delete' functions from reg.c. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 81a3eecc3c2e7ddced2f25cabc6de47101fd4fb1 by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- base/applications/cmdutils/reg/delete.c | 109 ++++++++++++++++++++++++++++++++ base/applications/cmdutils/reg/reg.c | 88 -------------------------- base/applications/cmdutils/reg/reg.h | 4 ++ sdk/tools/winesync/reg.cfg | 2 +- 4 files changed, 114 insertions(+), 89 deletions(-) diff --git a/base/applications/cmdutils/reg/delete.c b/base/applications/cmdutils/reg/delete.c new file mode 100644 index 00000000000..530d4513ece --- /dev/null +++ b/base/applications/cmdutils/reg/delete.c @@ -0,0 +1,109 @@ +/* + * Copyright 2016-2017, 2021 Hugh McMaster + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <windows.h> +#include <wine/heap.h> +#include "reg.h" + +int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, + BOOL value_empty, BOOL value_all, BOOL force) +{ + HKEY key; + + if (!force) + { + BOOL ret; + + if (value_name || value_empty) + ret = ask_confirm(STRING_DELETE_VALUE, value_name); + else if (value_all) + ret = ask_confirm(STRING_DELETE_VALUEALL, key_name); + else + ret = ask_confirm(STRING_DELETE_SUBKEY, key_name); + + if (!ret) + { + output_message(STRING_CANCELLED); + return 0; + } + } + + /* Delete subtree only if no /v* option is given */ + if (!value_name && !value_empty && !value_all) + { + if (RegDeleteTreeW(root, path) != ERROR_SUCCESS) + { + output_message(STRING_CANNOT_FIND); + return 1; + } + output_message(STRING_SUCCESS); + return 0; + } + + if (RegOpenKeyW(root, path, &key) != ERROR_SUCCESS) + { + output_message(STRING_CANNOT_FIND); + return 1; + } + + if (value_all) + { + DWORD max_value_len = 256, value_len; + WCHAR *value_name; + LONG rc; + + value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); + + while (1) + { + value_len = max_value_len; + rc = RegEnumValueW(key, 0, value_name, &value_len, NULL, NULL, NULL, NULL); + if (rc == ERROR_SUCCESS) + { + rc = RegDeleteValueW(key, value_name); + if (rc != ERROR_SUCCESS) + { + heap_free(value_name); + RegCloseKey(key); + output_message(STRING_VALUEALL_FAILED, key_name); + return 1; + } + } + else if (rc == ERROR_MORE_DATA) + { + max_value_len *= 2; + value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR)); + } + else break; + } + heap_free(value_name); + } + else if (value_name || value_empty) + { + if (RegDeleteValueW(key, value_empty ? NULL : value_name) != ERROR_SUCCESS) + { + RegCloseKey(key); + output_message(STRING_CANNOT_FIND); + return 1; + } + } + + RegCloseKey(key); + output_message(STRING_SUCCESS); + return 0; +} diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 81535b5c7de..81b2f1b295e 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -422,94 +422,6 @@ static int reg_add(HKEY root, WCHAR *path, WCHAR *value_name, BOOL value_empty, return 0; } -static int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, - BOOL value_empty, BOOL value_all, BOOL force) -{ - HKEY key; - - if (!force) - { - BOOL ret; - - if (value_name || value_empty) - ret = ask_confirm(STRING_DELETE_VALUE, value_name); - else if (value_all) - ret = ask_confirm(STRING_DELETE_VALUEALL, key_name); - else - ret = ask_confirm(STRING_DELETE_SUBKEY, key_name); - - if (!ret) - { - output_message(STRING_CANCELLED); - return 0; - } - } - - /* Delete subtree only if no /v* option is given */ - if (!value_name && !value_empty && !value_all) - { - if (RegDeleteTreeW(root, path) != ERROR_SUCCESS) - { - output_message(STRING_CANNOT_FIND); - return 1; - } - output_message(STRING_SUCCESS); - return 0; - } - - if (RegOpenKeyW(root, path, &key) != ERROR_SUCCESS) - { - output_message(STRING_CANNOT_FIND); - return 1; - } - - if (value_all) - { - DWORD max_value_len = 256, value_len; - WCHAR *value_name; - LONG rc; - - value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); - - while (1) - { - value_len = max_value_len; - rc = RegEnumValueW(key, 0, value_name, &value_len, NULL, NULL, NULL, NULL); - if (rc == ERROR_SUCCESS) - { - rc = RegDeleteValueW(key, value_name); - if (rc != ERROR_SUCCESS) - { - heap_free(value_name); - RegCloseKey(key); - output_message(STRING_VALUEALL_FAILED, key_name); - return 1; - } - } - else if (rc == ERROR_MORE_DATA) - { - max_value_len *= 2; - value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR)); - } - else break; - } - heap_free(value_name); - } - else if (value_name || value_empty) - { - if (RegDeleteValueW(key, value_empty ? NULL : value_name) != ERROR_SUCCESS) - { - RegCloseKey(key); - output_message(STRING_CANNOT_FIND); - return 1; - } - } - - RegCloseKey(key); - output_message(STRING_SUCCESS); - return 0; -} - WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len) { WCHAR *subkey_path; diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h index 471ed9c4d55..c8baaa0f9a9 100644 --- a/base/applications/cmdutils/reg/reg.h +++ b/base/applications/cmdutils/reg/reg.h @@ -41,6 +41,10 @@ HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); +/* delete.c */ +int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, + BOOL value_empty, BOOL value_all, BOOL force); + /* export.c */ int reg_export(int argc, WCHAR *argv[]); diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 8dc6fd16966..bf7d17e38a6 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: b80de8721690947bcd2e86b658b261f201002039 + wine: 81a3eecc3c2e7ddced2f25cabc6de47101fd4fb1
2 years, 6 months
1
0
0
0
[reactos] 32/158: [WINESYNC] reg: Split 'query' functions from reg.c.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=761c3c9835da80926e550…
commit 761c3c9835da80926e5508680521d0fb734013ab Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:19:05 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:29 2022 +0200 [WINESYNC] reg: Split 'query' functions from reg.c. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id b80de8721690947bcd2e86b658b261f201002039 by Hugh McMaster <hugh.mcmaster(a)outlook.com> manual adjustments needed --- base/applications/cmdutils/reg/query.c | 329 +++++++++++++++++++++++++++++++++ base/applications/cmdutils/reg/reg.c | 315 +------------------------------ base/applications/cmdutils/reg/reg.h | 16 +- sdk/tools/winesync/reg.cfg | 2 +- 4 files changed, 346 insertions(+), 316 deletions(-) diff --git a/base/applications/cmdutils/reg/query.c b/base/applications/cmdutils/reg/query.c new file mode 100644 index 00000000000..3d81d120bd2 --- /dev/null +++ b/base/applications/cmdutils/reg/query.c @@ -0,0 +1,329 @@ +/* + * Copyright 2016-2017, 2021 Hugh McMaster + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdio.h> +#include <windows.h> +#include <wine/heap.h> +#include "reg.h" + +static const WCHAR *reg_type_to_wchar(DWORD type) +{ + int i, array_size = ARRAY_SIZE(type_rels); + + for (i = 0; i < array_size; i++) + { + if (type == type_rels[i].type) + return type_rels[i].name; + } + + return NULL; +} + +static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes) +{ + WCHAR *buffer = NULL; + int i; + + switch (type) + { + case REG_SZ: + case REG_EXPAND_SZ: + buffer = heap_xalloc(size_bytes); + lstrcpyW(buffer, (WCHAR *)src); + break; + case REG_NONE: + case REG_BINARY: + { + WCHAR *ptr; + static const WCHAR fmt[] = {'%','0','2','X',0}; + + buffer = heap_xalloc((size_bytes * 2 + 1) * sizeof(WCHAR)); + ptr = buffer; + for (i = 0; i < size_bytes; i++) + ptr += swprintf(ptr, 3, fmt, src[i]); + break; + } + case REG_DWORD: + /* case REG_DWORD_LITTLE_ENDIAN: */ + case REG_DWORD_BIG_ENDIAN: + { + const int zero_x_dword = 10; + static const WCHAR fmt[] = {'0','x','%','x',0}; + + buffer = heap_xalloc((zero_x_dword + 1) * sizeof(WCHAR)); + swprintf(buffer, zero_x_dword + 1, fmt, *(DWORD *)src); + break; + } + case REG_MULTI_SZ: + { + const int two_wchars = 2 * sizeof(WCHAR); + DWORD tmp_size; + const WCHAR *tmp = (const WCHAR *)src; + int len, destindex; + + if (size_bytes <= two_wchars) + { + buffer = heap_xalloc(sizeof(WCHAR)); + *buffer = 0; + return buffer; + } + + tmp_size = size_bytes - two_wchars; /* exclude both null terminators */ + buffer = heap_xalloc(tmp_size * 2 + sizeof(WCHAR)); + len = tmp_size / sizeof(WCHAR); + + for (i = 0, destindex = 0; i < len; i++, destindex++) + { + if (tmp[i]) + buffer[destindex] = tmp[i]; + else + { + buffer[destindex++] = '\\'; + buffer[destindex] = '0'; + } + } + buffer[destindex] = 0; + break; + } + } + return buffer; +} + +static const WCHAR newlineW[] = {'\n',0}; + +static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD data_size) +{ + static const WCHAR fmt[] = {' ',' ',' ',' ','%','1',0}; + WCHAR defval[32]; + WCHAR *reg_data; + + if (value_name && value_name[0]) + output_string(fmt, value_name); + else + { + LoadStringW(GetModuleHandleW(NULL), STRING_DEFAULT_VALUE, defval, ARRAY_SIZE(defval)); + output_string(fmt, defval); + } + output_string(fmt, reg_type_to_wchar(type)); + + if (data) + { + reg_data = reg_data_to_wchar(type, data, data_size); + output_string(fmt, reg_data); + heap_free(reg_data); + } + else + { + LoadStringW(GetModuleHandleW(NULL), STRING_VALUE_NOT_SET, defval, ARRAY_SIZE(defval)); + output_string(fmt, defval); + } + output_string(newlineW); +} + +static unsigned int num_values_found = 0; + +static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse) +{ + LONG rc; + DWORD max_data_bytes = 2048, data_size; + DWORD subkey_len; + DWORD type, path_len, i; + BYTE *data; + WCHAR fmt[] = {'%','1','\n',0}; + WCHAR *subkey_name, *subkey_path; + HKEY subkey; + + data = heap_xalloc(max_data_bytes); + + for (;;) + { + data_size = max_data_bytes; + rc = RegQueryValueExW(key, value_name, NULL, &type, data, &data_size); + if (rc == ERROR_MORE_DATA) + { + max_data_bytes = data_size; + data = heap_xrealloc(data, max_data_bytes); + } + else break; + } + + if (rc == ERROR_SUCCESS) + { + output_string(fmt, path); + output_value(value_name, type, data, data_size); + output_string(newlineW); + num_values_found++; + } + + heap_free(data); + + if (!recurse) + { + if (rc == ERROR_FILE_NOT_FOUND) + { + if (value_name && *value_name) + { + output_message(STRING_CANNOT_FIND); + return 1; + } + output_string(fmt, path); + output_value(NULL, REG_SZ, NULL, 0); + } + return 0; + } + + subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); + + path_len = lstrlenW(path); + + i = 0; + for (;;) + { + subkey_len = MAX_SUBKEY_LEN; + rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); + if (rc == ERROR_SUCCESS) + { + subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len); + if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey)) + { + query_value(subkey, value_name, subkey_path, recurse); + RegCloseKey(subkey); + } + heap_free(subkey_path); + i++; + } + else break; + } + + heap_free(subkey_name); + return 0; +} + +static int query_all(HKEY key, WCHAR *path, BOOL recurse) +{ + LONG rc; + DWORD max_value_len = 256, value_len; + DWORD max_data_bytes = 2048, data_size; + DWORD subkey_len; + DWORD i, type, path_len; + WCHAR fmt[] = {'%','1','\n',0}; + WCHAR fmt_path[] = {'%','1','\\','%','2','\n',0}; + WCHAR *value_name, *subkey_name, *subkey_path; + BYTE *data; + HKEY subkey; + + output_string(fmt, path); + + value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); + data = heap_xalloc(max_data_bytes); + + i = 0; + for (;;) + { + value_len = max_value_len; + data_size = max_data_bytes; + rc = RegEnumValueW(key, i, value_name, &value_len, NULL, &type, data, &data_size); + if (rc == ERROR_SUCCESS) + { + output_value(value_name, type, data, data_size); + i++; + } + else if (rc == ERROR_MORE_DATA) + { + if (data_size > max_data_bytes) + { + max_data_bytes = data_size; + data = heap_xrealloc(data, max_data_bytes); + } + else + { + max_value_len *= 2; + value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR)); + } + } + else break; + } + + heap_free(data); + heap_free(value_name); + + if (i || recurse) + output_string(newlineW); + + subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); + + path_len = lstrlenW(path); + + i = 0; + for (;;) + { + subkey_len = MAX_SUBKEY_LEN; + rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); + if (rc == ERROR_SUCCESS) + { + if (recurse) + { + subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len); + if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey)) + { + query_all(subkey, subkey_path, recurse); + RegCloseKey(subkey); + } + heap_free(subkey_path); + } + else output_string(fmt_path, path, subkey_name); + i++; + } + else break; + } + + heap_free(subkey_name); + + if (i && !recurse) + output_string(newlineW); + + return 0; +} + +int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, + BOOL value_empty, BOOL recurse) +{ + HKEY key; + int ret; + + if (RegOpenKeyExW(root, path, 0, KEY_READ, &key) != ERROR_SUCCESS) + { + output_message(STRING_CANNOT_FIND); + return 1; + } + + output_string(newlineW); + + if (value_name || value_empty) + { + ret = query_value(key, value_name, key_name, recurse); + if (recurse) + output_message(STRING_MATCHES_FOUND, num_values_found); + } + else + ret = query_all(key, key_name, recurse); + + RegCloseKey(key); + + return ret; +} diff --git a/base/applications/cmdutils/reg/reg.c b/base/applications/cmdutils/reg/reg.c index 22e54c069c1..81535b5c7de 100644 --- a/base/applications/cmdutils/reg/reg.c +++ b/base/applications/cmdutils/reg/reg.c @@ -61,12 +61,7 @@ static const WCHAR type_dword_le[] = {'R','E','G','_','D','W','O','R','D','_','L 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[] = +const struct reg_type_rels type_rels[] = { {REG_NONE, type_none}, {REG_SZ, type_sz}, @@ -78,8 +73,6 @@ type_rels[] = {REG_MULTI_SZ, type_multi_sz}, }; -static const WCHAR newlineW[] = {'\n',0}; - void *heap_xalloc(size_t size) { void *buf = heap_alloc(size); @@ -158,7 +151,7 @@ void WINAPIV output_message(unsigned int id, ...) __ms_va_end(va_args); } -static void WINAPIV output_string(const WCHAR *fmt, ...) +void WINAPIV output_string(const WCHAR *fmt, ...) { __ms_va_list va_args; @@ -517,117 +510,6 @@ static int reg_delete(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name return 0; } -static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes) -{ - WCHAR *buffer = NULL; - int i; - - switch (type) - { - case REG_SZ: - case REG_EXPAND_SZ: - buffer = heap_xalloc(size_bytes); - lstrcpyW(buffer, (WCHAR *)src); - break; - case REG_NONE: - case REG_BINARY: - { - WCHAR *ptr; - static const WCHAR fmt[] = {'%','0','2','X',0}; - - buffer = heap_xalloc((size_bytes * 2 + 1) * sizeof(WCHAR)); - ptr = buffer; - for (i = 0; i < size_bytes; i++) - ptr += swprintf(ptr, fmt, src[i]); - break; - } - case REG_DWORD: - /* case REG_DWORD_LITTLE_ENDIAN: */ - case REG_DWORD_BIG_ENDIAN: - { - const int zero_x_dword = 10; - static const WCHAR fmt[] = {'0','x','%','x',0}; - - buffer = heap_xalloc((zero_x_dword + 1) * sizeof(WCHAR)); - swprintf(buffer, fmt, *(DWORD *)src); - break; - } - case REG_MULTI_SZ: - { - const int two_wchars = 2 * sizeof(WCHAR); - DWORD tmp_size; - const WCHAR *tmp = (const WCHAR *)src; - int len, destindex; - - if (size_bytes <= two_wchars) - { - buffer = heap_xalloc(sizeof(WCHAR)); - *buffer = 0; - return buffer; - } - - tmp_size = size_bytes - two_wchars; /* exclude both null terminators */ - buffer = heap_xalloc(tmp_size * 2 + sizeof(WCHAR)); - len = tmp_size / sizeof(WCHAR); - - for (i = 0, destindex = 0; i < len; i++, destindex++) - { - if (tmp[i]) - buffer[destindex] = tmp[i]; - else - { - buffer[destindex++] = '\\'; - buffer[destindex] = '0'; - } - } - buffer[destindex] = 0; - break; - } - } - return buffer; -} - -static const WCHAR *reg_type_to_wchar(DWORD type) -{ - int i, array_size = ARRAY_SIZE(type_rels); - - for (i = 0; i < array_size; i++) - { - if (type == type_rels[i].type) - return type_rels[i].name; - } - return NULL; -} - -static void output_value(const WCHAR *value_name, DWORD type, BYTE *data, DWORD data_size) -{ - static const WCHAR fmt[] = {' ',' ',' ',' ','%','1',0}; - WCHAR defval[32]; - WCHAR *reg_data; - - if (value_name && value_name[0]) - output_string(fmt, value_name); - else - { - LoadStringW(GetModuleHandleW(NULL), STRING_DEFAULT_VALUE, defval, ARRAY_SIZE(defval)); - output_string(fmt, defval); - } - output_string(fmt, reg_type_to_wchar(type)); - - if (data) - { - reg_data = reg_data_to_wchar(type, data, data_size); - output_string(fmt, reg_data); - heap_free(reg_data); - } - else - { - LoadStringW(GetModuleHandleW(NULL), STRING_VALUE_NOT_SET, defval, ARRAY_SIZE(defval)); - output_string(fmt, defval); - } - output_string(newlineW); -} - WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len) { WCHAR *subkey_path; @@ -639,199 +521,6 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD return subkey_path; } -static unsigned int num_values_found = 0; - -static int query_value(HKEY key, WCHAR *value_name, WCHAR *path, BOOL recurse) -{ - LONG rc; - DWORD max_data_bytes = 2048, data_size; - DWORD subkey_len; - DWORD type, path_len, i; - BYTE *data; - WCHAR fmt[] = {'%','1','\n',0}; - WCHAR *subkey_name, *subkey_path; - HKEY subkey; - - data = heap_xalloc(max_data_bytes); - - for (;;) - { - data_size = max_data_bytes; - rc = RegQueryValueExW(key, value_name, NULL, &type, data, &data_size); - if (rc == ERROR_MORE_DATA) - { - max_data_bytes = data_size; - data = heap_xrealloc(data, max_data_bytes); - } - else break; - } - - if (rc == ERROR_SUCCESS) - { - output_string(fmt, path); - output_value(value_name, type, data, data_size); - output_string(newlineW); - num_values_found++; - } - - heap_free(data); - - if (!recurse) - { - if (rc == ERROR_FILE_NOT_FOUND) - { - if (value_name && *value_name) - { - output_message(STRING_CANNOT_FIND); - return 1; - } - output_string(fmt, path); - output_value(NULL, REG_SZ, NULL, 0); - } - return 0; - } - - subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); - - path_len = lstrlenW(path); - - i = 0; - for (;;) - { - subkey_len = MAX_SUBKEY_LEN; - rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); - if (rc == ERROR_SUCCESS) - { - subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len); - if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey)) - { - query_value(subkey, value_name, subkey_path, recurse); - RegCloseKey(subkey); - } - heap_free(subkey_path); - i++; - } - else break; - } - - heap_free(subkey_name); - return 0; -} - -static int query_all(HKEY key, WCHAR *path, BOOL recurse) -{ - LONG rc; - DWORD max_value_len = 256, value_len; - DWORD max_data_bytes = 2048, data_size; - DWORD subkey_len; - DWORD i, type, path_len; - WCHAR fmt[] = {'%','1','\n',0}; - WCHAR fmt_path[] = {'%','1','\\','%','2','\n',0}; - WCHAR *value_name, *subkey_name, *subkey_path; - BYTE *data; - HKEY subkey; - - output_string(fmt, path); - - value_name = heap_xalloc(max_value_len * sizeof(WCHAR)); - data = heap_xalloc(max_data_bytes); - - i = 0; - for (;;) - { - value_len = max_value_len; - data_size = max_data_bytes; - rc = RegEnumValueW(key, i, value_name, &value_len, NULL, &type, data, &data_size); - if (rc == ERROR_SUCCESS) - { - output_value(value_name, type, data, data_size); - i++; - } - else if (rc == ERROR_MORE_DATA) - { - if (data_size > max_data_bytes) - { - max_data_bytes = data_size; - data = heap_xrealloc(data, max_data_bytes); - } - else - { - max_value_len *= 2; - value_name = heap_xrealloc(value_name, max_value_len * sizeof(WCHAR)); - } - } - else break; - } - - heap_free(data); - heap_free(value_name); - - if (i || recurse) - output_string(newlineW); - - subkey_name = heap_xalloc(MAX_SUBKEY_LEN * sizeof(WCHAR)); - - path_len = lstrlenW(path); - - i = 0; - for (;;) - { - subkey_len = MAX_SUBKEY_LEN; - rc = RegEnumKeyExW(key, i, subkey_name, &subkey_len, NULL, NULL, NULL, NULL); - if (rc == ERROR_SUCCESS) - { - if (recurse) - { - subkey_path = build_subkey_path(path, path_len, subkey_name, subkey_len); - if (!RegOpenKeyExW(key, subkey_name, 0, KEY_READ, &subkey)) - { - query_all(subkey, subkey_path, recurse); - RegCloseKey(subkey); - } - heap_free(subkey_path); - } - else output_string(fmt_path, path, subkey_name); - i++; - } - else break; - } - - heap_free(subkey_name); - - if (i && !recurse) - output_string(newlineW); - - return 0; -} - -static int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, - BOOL value_empty, BOOL recurse) -{ - HKEY key; - int ret; - - if (RegOpenKeyExW(root, path, 0, KEY_READ, &key) != ERROR_SUCCESS) - { - output_message(STRING_CANNOT_FIND); - return 1; - } - - output_string(newlineW); - - if (value_name || value_empty) - { - ret = query_value(key, value_name, key_name, recurse); - if (recurse) - output_message(STRING_MATCHES_FOUND, num_values_found); - } - else - ret = query_all(key, key_name, recurse); - - RegCloseKey(key); - - return ret; -} - static WCHAR *get_long_key(HKEY root, WCHAR *path) { DWORD i, array_size = ARRAY_SIZE(root_rels), len; diff --git a/base/applications/cmdutils/reg/reg.h b/base/applications/cmdutils/reg/reg.h index a27399d06a4..471ed9c4d55 100644 --- a/base/applications/cmdutils/reg/reg.h +++ b/base/applications/cmdutils/reg/reg.h @@ -24,19 +24,31 @@ #define MAX_SUBKEY_LEN 257 /* reg.c */ +struct reg_type_rels { + DWORD type; + const WCHAR *name; +}; + +extern const struct reg_type_rels type_rels[8]; + void *heap_xalloc(size_t size); void *heap_xrealloc(void *buf, size_t size); void output_writeconsole(const WCHAR *str, DWORD wlen); void WINAPIV output_message(unsigned int id, ...); +void WINAPIV output_string(const WCHAR *fmt, ...); BOOL ask_confirm(unsigned int msgid, WCHAR *reg_info); HKEY path_get_rootkey(const WCHAR *path); WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD subkey_len); BOOL parse_registry_key(const WCHAR *key, HKEY *root, WCHAR **path, WCHAR **long_key); +/* export.c */ +int reg_export(int argc, WCHAR *argv[]); + /* import.c */ int reg_import(const WCHAR *filename); -/* export.c */ -int reg_export(int argc, WCHAR *argv[]); +/* query.c */ +int reg_query(HKEY root, WCHAR *path, WCHAR *key_name, WCHAR *value_name, + BOOL value_empty, BOOL recurse); #endif /* __REG_H__ */ diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 597dcb68e13..8dc6fd16966 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 272d35afc6905dfdf1ffcf0ef2963e3bded1303d + wine: b80de8721690947bcd2e86b658b261f201002039
2 years, 6 months
1
0
0
0
[reactos] 31/158: [WINESYNC] reg: Stop parsing REG_SZ values containing NUL character sequences.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1007673889a6c394af098…
commit 1007673889a6c394af098f8436eecfa4c132e14a Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:10:05 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:29 2022 +0200 [WINESYNC] reg: Stop parsing REG_SZ values containing NUL character sequences. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 272d35afc6905dfdf1ffcf0ef2963e3bded1303d by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- base/applications/cmdutils/reg/import.c | 3 +-- modules/rostests/winetests/reg/import.c | 24 ++++++++++++------------ sdk/tools/winesync/reg.cfg | 2 +- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/base/applications/cmdutils/reg/import.c b/base/applications/cmdutils/reg/import.c index f7f87939e23..7ad7b35d5dc 100644 --- a/base/applications/cmdutils/reg/import.c +++ b/base/applications/cmdutils/reg/import.c @@ -324,8 +324,7 @@ static BOOL unescape_string(WCHAR *str, WCHAR **unparsed) str[val_idx] = '\r'; break; case '0': - str[val_idx] = '\0'; - break; + return FALSE; case '\\': case '"': str[val_idx] = str[str_idx]; diff --git a/modules/rostests/winetests/reg/import.c b/modules/rostests/winetests/reg/import.c index f8e7e4b7acb..06f9cb05f6c 100644 --- a/modules/rostests/winetests/reg/import.c +++ b/modules/rostests/winetests/reg/import.c @@ -1600,12 +1600,12 @@ static void test_import(void) "\"Wine70e\"=\"Value3\\0Value4\"\n" "\"Wine70f\"=\"\\0Value5\"\n\n", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - todo_wine verify_reg_nonexist(hkey, "Wine70a"); - todo_wine verify_reg_nonexist(hkey, "Wine70b"); - todo_wine verify_reg_nonexist(hkey, "Wine70c"); - todo_wine verify_reg_nonexist(hkey, "Wine70d"); - todo_wine verify_reg_nonexist(hkey, "Wine70e"); - todo_wine verify_reg_nonexist(hkey, "Wine70f"); + verify_reg_nonexist(hkey, "Wine70a"); + verify_reg_nonexist(hkey, "Wine70b"); + verify_reg_nonexist(hkey, "Wine70c"); + verify_reg_nonexist(hkey, "Wine70d"); + verify_reg_nonexist(hkey, "Wine70e"); + verify_reg_nonexist(hkey, "Wine70f"); /* Test forward and back slashes */ test_import_str("REGEDIT4\n\n" @@ -3149,12 +3149,12 @@ static void test_unicode_import(void) "\"Wine70e\"=\"Value3\\0Value4\"\n" "\"Wine70f\"=\"\\0Value5\"\n\n", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - todo_wine verify_reg_nonexist(hkey, "Wine70a"); - todo_wine verify_reg_nonexist(hkey, "Wine70b"); - todo_wine verify_reg_nonexist(hkey, "Wine70c"); - todo_wine verify_reg_nonexist(hkey, "Wine70d"); - todo_wine verify_reg_nonexist(hkey, "Wine70e"); - todo_wine verify_reg_nonexist(hkey, "Wine70f"); + verify_reg_nonexist(hkey, "Wine70a"); + verify_reg_nonexist(hkey, "Wine70b"); + verify_reg_nonexist(hkey, "Wine70c"); + verify_reg_nonexist(hkey, "Wine70d"); + verify_reg_nonexist(hkey, "Wine70e"); + verify_reg_nonexist(hkey, "Wine70f"); /* Test forward and back slashes */ test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 74acd6bb4d9..597dcb68e13 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 53fd4df85f004597161a26d86333755e7cbff0ff + wine: 272d35afc6905dfdf1ffcf0ef2963e3bded1303d
2 years, 6 months
1
0
0
0
[reactos] 30/158: [WINESYNC] reg/tests: Try exporting registry values with escaped null characters.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=252e8fd1c787677f201e3…
commit 252e8fd1c787677f201e32c488335fbacfd50f9a Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:10:05 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:29 2022 +0200 [WINESYNC] reg/tests: Try exporting registry values with escaped null characters. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 53fd4df85f004597161a26d86333755e7cbff0ff by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- modules/rostests/winetests/reg/export.c | 25 +++++++++++++++++++++++++ sdk/tools/winesync/reg.cfg | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/modules/rostests/winetests/reg/export.c b/modules/rostests/winetests/reg/export.c index 32c99e36376..2c7ba88fb59 100644 --- a/modules/rostests/winetests/reg/export.c +++ b/modules/rostests/winetests/reg/export.c @@ -168,6 +168,16 @@ static void test_export(void) "\"\\\\foo\\\\bar\"=\"\"\r\n\r\n" "[HKEY_CURRENT_USER\\" KEY_BASE "\\https://winehq.org]\r\n\r\n"; + const char *escaped_null_test = + "\xef\xbb\xbfWindows Registry Editor Version 5.00\r\n\r\n" + "[HKEY_CURRENT_USER\\" KEY_BASE "]\r\n" + "\"Wine5a\"=\"\\\\0\"\r\n" + "\"Wine5b\"=\"\\\\0\\\\0\"\r\n" + "\"Wine5c\"=\"Value1\\\\0\"\r\n" + "\"Wine5d\"=\"Value2\\\\0\\\\0\\\\0\\\\0\"\r\n" + "\"Wine5e\"=\"Value3\\\\0Value4\"\r\n" + "\"Wine5f\"=\"\\\\0Value5\"\r\n\r\n"; + delete_tree(HKEY_CURRENT_USER, KEY_BASE); verify_key_nonexist(HKEY_CURRENT_USER, KEY_BASE); @@ -402,6 +412,21 @@ static void test_export(void) ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); ok(compare_export("file.reg", slashes_test, TODO_REG_COMPARE), "compare_export() failed\n"); delete_tree(HKEY_CURRENT_USER, KEY_BASE); + + /* Test escaped null characters */ + add_key(HKEY_CURRENT_USER, KEY_BASE, &hkey); + add_value(hkey, "Wine5a", REG_SZ, "\\0", 3); + add_value(hkey, "Wine5b", REG_SZ, "\\0\\0", 5); + add_value(hkey, "Wine5c", REG_SZ, "Value1\\0", 9); + add_value(hkey, "Wine5d", REG_SZ, "Value2\\0\\0\\0\\0", 15); + add_value(hkey, "Wine5e", REG_SZ, "Value3\\0Value4", 15); + add_value(hkey, "Wine5f", REG_SZ, "\\0Value5", 9); + close_key(hkey); + + run_reg_exe("reg export HKEY_CURRENT_USER\\" KEY_BASE " file.reg /y", &r); + ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); + ok(compare_export("file.reg", escaped_null_test, 0), "compare_export() failed\n"); + delete_tree(HKEY_CURRENT_USER, KEY_BASE); } START_TEST(export) diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index e3965809336..74acd6bb4d9 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: 1c2b96699973e198e72a01a969af0876387f08e1 + wine: 53fd4df85f004597161a26d86333755e7cbff0ff
2 years, 6 months
1
0
0
0
[reactos] 29/158: [WINESYNC] reg/tests: Try importing registry files with escaped null characters.
by winesync
https://git.reactos.org/?p=reactos.git;a=commitdiff;h=60a4a6313b1e99cae2980…
commit 60a4a6313b1e99cae29804444fa586521fcdd84b Author: winesync <ros-dev(a)reactos.org> AuthorDate: Sun Jan 16 20:10:05 2022 +0100 Commit: Thomas Csovcsity <thc.fr13nd(a)gmail.com> CommitDate: Sun Jun 19 13:06:29 2022 +0200 [WINESYNC] reg/tests: Try importing registry files with escaped null characters. Signed-off-by: Hugh McMaster <hugh.mcmaster(a)outlook.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> wine commit id 1c2b96699973e198e72a01a969af0876387f08e1 by Hugh McMaster <hugh.mcmaster(a)outlook.com> --- modules/rostests/winetests/reg/import.c | 50 ++++++++++++++++----------------- sdk/tools/winesync/reg.cfg | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/modules/rostests/winetests/reg/import.c b/modules/rostests/winetests/reg/import.c index 9b7a90ac99c..f8e7e4b7acb 100644 --- a/modules/rostests/winetests/reg/import.c +++ b/modules/rostests/winetests/reg/import.c @@ -1574,22 +1574,22 @@ static void test_import(void) verify_reg(hkey, "Wine68h", REG_BINARY, NULL, 0, 0); verify_reg(hkey, "Wine68i", REG_NONE, NULL, 0, 0); - /* Test with embedded null characters */ + /* Test with escaped null characters */ test_import_str("REGEDIT4\n\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n" - "\"Wine69a\"=\"\\0\n" - "\"Wine69b\"=\"\\0\\0\n" - "\"Wine69c\"=\"Value1\\0\n" - "\"Wine69d\"=\"Value2\\0\\0\\0\\0\n" - "\"Wine69e\"=\"Value3\\0Value4\n" - "\"Wine69f\"=\"\\0Value5\n\n", &r); + "\"Wine69a\"=\"\\\\0\"\n" + "\"Wine69b\"=\"\\\\0\\\\0\"\n" + "\"Wine69c\"=\"Value1\\\\0\"\n" + "\"Wine69d\"=\"Value2\\\\0\\\\0\\\\0\\\\0\"\n" + "\"Wine69e\"=\"Value3\\\\0Value4\"\n" + "\"Wine69f\"=\"\\\\0Value5\"\n\n", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - verify_reg_nonexist(hkey, "Wine69a"); - verify_reg_nonexist(hkey, "Wine69b"); - verify_reg_nonexist(hkey, "Wine69c"); - verify_reg_nonexist(hkey, "Wine69d"); - verify_reg_nonexist(hkey, "Wine69e"); - verify_reg_nonexist(hkey, "Wine69f"); + verify_reg(hkey, "Wine69a", REG_SZ, "\\0", 3, 0); + verify_reg(hkey, "Wine69b", REG_SZ, "\\0\\0", 5, 0); + verify_reg(hkey, "Wine69c", REG_SZ, "Value1\\0", 9, 0); + verify_reg(hkey, "Wine69d", REG_SZ, "Value2\\0\\0\\0\\0", 15, 0); + verify_reg(hkey, "Wine69e", REG_SZ, "Value3\\0Value4", 15, 0); + verify_reg(hkey, "Wine69f", REG_SZ, "\\0Value5", 9, 0); test_import_str("REGEDIT4\n\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n" @@ -3126,19 +3126,19 @@ static void test_unicode_import(void) /* Test with embedded null characters */ test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n" - "\"Wine69a\"=\"\\0\n" - "\"Wine69b\"=\"\\0\\0\n" - "\"Wine69c\"=\"Value1\\0\n" - "\"Wine69d\"=\"Value2\\0\\0\\0\\0\n" - "\"Wine69e\"=\"Value3\\0Value4\n" - "\"Wine69f\"=\"\\0Value5\n\n", &r); + "\"Wine69a\"=\"\\\\0\"\n" + "\"Wine69b\"=\"\\\\0\\\\0\"\n" + "\"Wine69c\"=\"Value1\\\\0\"\n" + "\"Wine69d\"=\"Value2\\\\0\\\\0\\\\0\\\\0\"\n" + "\"Wine69e\"=\"Value3\\\\0Value4\"\n" + "\"Wine69f\"=\"\\\\0Value5\"\n\n", &r); ok(r == REG_EXIT_SUCCESS, "got exit code %d, expected 0\n", r); - verify_reg_nonexist(hkey, "Wine69a"); - verify_reg_nonexist(hkey, "Wine69b"); - verify_reg_nonexist(hkey, "Wine69c"); - verify_reg_nonexist(hkey, "Wine69d"); - verify_reg_nonexist(hkey, "Wine69e"); - verify_reg_nonexist(hkey, "Wine69f"); + verify_reg(hkey, "Wine69a", REG_SZ, "\\0", 3, 0); + verify_reg(hkey, "Wine69b", REG_SZ, "\\0\\0", 5, 0); + verify_reg(hkey, "Wine69c", REG_SZ, "Value1\\0", 9, 0); + verify_reg(hkey, "Wine69d", REG_SZ, "Value2\\0\\0\\0\\0", 15, 0); + verify_reg(hkey, "Wine69e", REG_SZ, "Value3\\0Value4", 15, 0); + verify_reg(hkey, "Wine69f", REG_SZ, "\\0Value5", 9, 0); test_import_wstr("\xef\xbb\xbfWindows Registry Editor Version 5.00\n\n" "[HKEY_CURRENT_USER\\" KEY_BASE "]\n" diff --git a/sdk/tools/winesync/reg.cfg b/sdk/tools/winesync/reg.cfg index 98463213ef7..e3965809336 100644 --- a/sdk/tools/winesync/reg.cfg +++ b/sdk/tools/winesync/reg.cfg @@ -4,4 +4,4 @@ directories: files: programs/reg/resource.h: base/applications/cmdutils/reg/resource.h tags: - wine: aa98e3f6da78135ecffaa50bb78ad906dfd4570d + wine: 1c2b96699973e198e72a01a969af0876387f08e1
2 years, 6 months
1
0
0
0
← Newer
1
...
13
14
15
16
17
18
19
...
24
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Results per page:
10
25
50
100
200