[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.
This commit is contained in:
Doug Lyons
2026-01-11 13:08:46 -06:00
committed by GitHub
parent ced7700392
commit 2f5a67fa2a

View File

@@ -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);