From 2f5a67fa2a56d99bdfdeb5488878196f17e674c6 Mon Sep 17 00:00:00 2001 From: Doug Lyons Date: Sun, 11 Jan 2026 13:08:46 -0600 Subject: [PATCH] [REG] Fix importing ASCII *.reg file creating a Unicode registry entry (#6450) * When source REG file is ASCII encoded, detect presence of UNICODE value and force 'parser->is_unicode' to TRUE when dealing with Unicode imports. --- base/applications/cmdutils/reg/import.c | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/base/applications/cmdutils/reg/import.c b/base/applications/cmdutils/reg/import.c index 91442cf06b3..5c268f80f0b 100644 --- a/base/applications/cmdutils/reg/import.c +++ b/base/applications/cmdutils/reg/import.c @@ -772,11 +772,42 @@ invalid: static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos) { WCHAR *line = pos; +#ifdef __REACTOS__ + WCHAR Buffer[10] = { 0 }; + WCHAR* ret; + BOOL unicode_in_ascii = FALSE; + BOOL result; +#endif if (!*line) goto set_value; +#ifdef __REACTOS__ + if ((!parser->is_unicode) && + (parser->data_type == REG_EXPAND_SZ) && + (parser->parse_type == REG_BINARY)) + { + memcpy(Buffer, pos, 18); + Buffer[_countof(Buffer) - 1] = UNICODE_NULL; + ret = wcsstr(Buffer, L"00,"); // Any UNICODE characters? + unicode_in_ascii = (ret != NULL); + } + + if (unicode_in_ascii) + { + parser->is_unicode = TRUE; + result = convert_hex_csv_to_hex(parser, &line); + parser->is_unicode = FALSE; + } + else + { + result = convert_hex_csv_to_hex(parser, &line); + } + + if (!result) +#else if (!convert_hex_csv_to_hex(parser, &line)) +#endif goto invalid; if (parser->backslash) @@ -785,7 +816,20 @@ static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos) return line; } +#ifdef __REACTOS__ + if (unicode_in_ascii) + { + parser->is_unicode = TRUE; + prepare_hex_string_data(parser); + parser->is_unicode = FALSE; + } + else + { + prepare_hex_string_data(parser); + } +#else prepare_hex_string_data(parser); +#endif set_value: set_state(parser, SET_VALUE);