Reactos

[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.

authored by

Doug Lyons and committed by
GitHub
2f5a67fa ced77003

+44
+44
base/applications/cmdutils/reg/import.c
··· 772 772 static WCHAR *hex_data_state(struct parser *parser, WCHAR *pos) 773 773 { 774 774 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 775 781 776 782 if (!*line) 777 783 goto set_value; 778 784 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 779 809 if (!convert_hex_csv_to_hex(parser, &line)) 810 + #endif 780 811 goto invalid; 781 812 782 813 if (parser->backslash) ··· 785 816 return line; 786 817 } 787 818 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 788 831 prepare_hex_string_data(parser); 832 + #endif 789 833 790 834 set_value: 791 835 set_state(parser, SET_VALUE);