Skip to content

Commit 2f5a67f

Browse files
authored
[REG] Fix importing ASCII *.reg file creating a Unicode registry entry (reactos#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.
1 parent ced7700 commit 2f5a67f

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

base/applications/cmdutils/reg/import.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,42 @@ static WCHAR *dword_data_state(struct parser *parser, WCHAR *pos)
772772
static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos)
773773
{
774774
WCHAR *line = pos;
775+
#ifdef __REACTOS__
776+
WCHAR Buffer[10] = { 0 };
777+
WCHAR* ret;
778+
BOOL unicode_in_ascii = FALSE;
779+
BOOL result;
780+
#endif
775781

776782
if (!*line)
777783
goto set_value;
778784

785+
#ifdef __REACTOS__
786+
if ((!parser->is_unicode) &&
787+
(parser->data_type == REG_EXPAND_SZ) &&
788+
(parser->parse_type == REG_BINARY))
789+
{
790+
memcpy(Buffer, pos, 18);
791+
Buffer[_countof(Buffer) - 1] = UNICODE_NULL;
792+
ret = wcsstr(Buffer, L"00,"); // Any UNICODE characters?
793+
unicode_in_ascii = (ret != NULL);
794+
}
795+
796+
if (unicode_in_ascii)
797+
{
798+
parser->is_unicode = TRUE;
799+
result = convert_hex_csv_to_hex(parser, &line);
800+
parser->is_unicode = FALSE;
801+
}
802+
else
803+
{
804+
result = convert_hex_csv_to_hex(parser, &line);
805+
}
806+
807+
if (!result)
808+
#else
779809
if (!convert_hex_csv_to_hex(parser, &line))
810+
#endif
780811
goto invalid;
781812

782813
if (parser->backslash)
@@ -785,7 +816,20 @@ static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos)
785816
return line;
786817
}
787818

819+
#ifdef __REACTOS__
820+
if (unicode_in_ascii)
821+
{
822+
parser->is_unicode = TRUE;
823+
prepare_hex_string_data(parser);
824+
parser->is_unicode = FALSE;
825+
}
826+
else
827+
{
828+
prepare_hex_string_data(parser);
829+
}
830+
#else
788831
prepare_hex_string_data(parser);
832+
#endif
789833

790834
set_value:
791835
set_state(parser, SET_VALUE);

0 commit comments

Comments
 (0)