From f7ff9e76f9b32759d8d1f79ce440762debfad4a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Nicolaysen=20S=C3=B8rnes?= Date: Wed, 27 Aug 2008 23:29:08 +0200 Subject: [PATCH] regedit: Avoid conversion to ANSI when importing hex values. --- programs/regedit/regproc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/programs/regedit/regproc.c b/programs/regedit/regproc.c index b65595e9d55..eb724bea31d 100644 --- a/programs/regedit/regproc.c +++ b/programs/regedit/regproc.c @@ -113,28 +113,28 @@ static BOOL convertHexToDWord(WCHAR* str, DWORD *dw) /****************************************************************************** * Converts a hex comma separated values list into a binary string. */ -static BYTE* convertHexCSVToHex(WCHAR *strW, DWORD *size) +static BYTE* convertHexCSVToHex(WCHAR *str, DWORD *size) { - char *s; + WCHAR *s; BYTE *d, *data; - char* strA = GetMultiByteString(strW); /* The worst case is 1 digit + 1 comma per byte */ - *size=(strlen(strA)+1)/2; + *size=(lstrlenW(str)+1)/2; data=HeapAlloc(GetProcessHeap(), 0, *size); CHECK_ENOUGH_MEMORY(data); - s = strA; + s = str; d = data; *size=0; while (*s != '\0') { UINT wc; - char *end; + WCHAR *end; - wc = strtoul(s,&end,16); + wc = strtoulW(s,&end,16); if (end == s || wc > 0xff || (*end && *end != ',')) { + char* strA = GetMultiByteString(s); fprintf(stderr,"%s: ERROR converting CSV hex stream. Invalid value at '%s'\n", - getAppName(), s); + getAppName(), strA); HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, strA); return NULL; @@ -145,8 +145,6 @@ static BYTE* convertHexCSVToHex(WCHAR *strW, DWORD *size) s = end; } - HeapFree(GetProcessHeap(), 0, strA); - return data; }