diff --git a/base/applications/cmdutils/reg/import.c b/base/applications/cmdutils/reg/import.c index f7f87939e2..7fadbfeaf5 100644 --- a/base/applications/cmdutils/reg/import.c +++ b/base/applications/cmdutils/reg/import.c @@ -285,6 +285,15 @@ static BOOL parse_data_type(struct parser *parser, WCHAR **line) /* "hex(xx):" is special */ val = wcstoul(*line, &end, 16); +#if __REACTOS__ + /* We cannot handle more that 8 characters here, so return FALSE. + * Since errno is only implemented as a stub, + * we cannot depend upon it working correctly below. */ + /* FIXME: This can be removed when errno is implemented. + * Currently it always returns zero (0). */ + if ((ULONG)(end - *line) > 8) + return FALSE; +#endif if (*end != ')' || *(end + 1) != ':' || (val == ~0u && errno == ERANGE)) return FALSE; @@ -782,11 +791,41 @@ invalid: static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos) { WCHAR *line = pos; +#if __REACTOS__ + WCHAR Buffer[10] = { 0 }; + WCHAR* ret; + BOOL unicode_in_ansi = FALSE; + BOOL result; +#endif if (!*line) goto set_value; +#if __REACTOS__ + if ((!parser->is_unicode) && (parser->data_type == 2) && + (parser->parse_type == 3)) + { + memcpy(Buffer, pos, 18); + Buffer[9] = UNICODE_NULL; + ret = wcsstr(Buffer, L"00,"); + unicode_in_ansi = (ret != NULL); + } + + if (unicode_in_ansi) + { + 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) @@ -795,7 +834,20 @@ static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos) return line; } +#if __REACTOS__ + if (unicode_in_ansi) + { + 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);