Damjan Jovanovic : atl: Add support for binary values in IRegistrar.
Alexandre Julliard
julliard at winehq.org
Wed Nov 24 11:28:40 CST 2010
Module: wine
Branch: master
Commit: cd4b9c11274640c3d7ee03ff9de9e4895669b884
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cd4b9c11274640c3d7ee03ff9de9e4895669b884
Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date: Wed Nov 24 11:10:13 2010 +0200
atl: Add support for binary values in IRegistrar.
---
dlls/atl/registrar.c | 35 +++++++++++++++++++++++++++++++++++
dlls/atl/tests/registrar.c | 17 +++++++++++++++++
2 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/dlls/atl/registrar.c b/dlls/atl/registrar.c
index 9a1154a..99dfe73 100644
--- a/dlls/atl/registrar.c
+++ b/dlls/atl/registrar.c
@@ -299,6 +299,41 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
}
break;
}
+ case 'b': {
+ BYTE *bytes;
+ DWORD count;
+ DWORD i;
+ hres = get_word(&iter, buf);
+ if(FAILED(hres))
+ break;
+ count = (lstrlenW(buf->str) + 1) / 2;
+ bytes = HeapAlloc(GetProcessHeap(), 0, count);
+ if(bytes == NULL) {
+ hres = E_OUTOFMEMORY;
+ break;
+ }
+ for(i = 0; i < count && buf->str[2*i]; i++) {
+ WCHAR digits[3];
+ if(!isxdigitW(buf->str[2*i]) || !isxdigitW(buf->str[2*i + 1])) {
+ hres = E_FAIL;
+ break;
+ }
+ digits[0] = buf->str[2*i];
+ digits[1] = buf->str[2*i + 1];
+ digits[2] = 0;
+ bytes[i] = (BYTE) strtoulW(digits, NULL, 16);
+ }
+ if(SUCCEEDED(hres)) {
+ lres = RegSetValueExW(hkey, name.len ? name.str : NULL, 0, REG_BINARY,
+ bytes, count);
+ if(lres != ERROR_SUCCESS) {
+ WARN("Could not set value of key: 0x%08x\n", lres);
+ hres = HRESULT_FROM_WIN32(lres);
+ }
+ }
+ HeapFree(GetProcessHeap(), 0, bytes);
+ break;
+ }
default:
WARN("Wrong resource type: %s\n", debugstr_w(buf->str));
hres = DISP_E_EXCEPTION;
diff --git a/dlls/atl/tests/registrar.c b/dlls/atl/tests/registrar.c
index cd2b755..422608b 100644
--- a/dlls/atl/tests/registrar.c
+++ b/dlls/atl/tests/registrar.c
@@ -47,6 +47,8 @@ static const char textA[] =
" val 'dword_unquoted_dec' = d 1 \n"
" val 'dword_quoted_hex' = d '0xA' \n"
" val 'dword_unquoted_hex' = d 0xA \n"
+" val 'binary_quoted' = b 'deadbeef' \n"
+" val 'binary_unquoted' = b deadbeef \n"
" } \n"
"}";
@@ -72,6 +74,7 @@ static void test_registrar(void)
DWORD size;
LONG lret;
HKEY key;
+ BYTE bytes[4];
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, count);
hr = IRegistrar_StringRegister(registrar, textW);
@@ -100,6 +103,20 @@ static void test_registrar(void)
ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
ok(dword == 1, "quoted dec is not supposed to be %d\n", dword);
+ size = 4;
+ lret = RegQueryValueExA(key, "binary_quoted", NULL, NULL, bytes, &size);
+ ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %d\n", lret);
+ ok(bytes[0] = 0xde && bytes[1] == 0xad && bytes[2] == 0xbe && bytes[3] == 0xef,
+ "binary quoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
+ 0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
+
+ size = 4;
+ lret = RegQueryValueExA(key, "binary_unquoted", NULL, NULL, bytes, &size);
+ ok(lret == ERROR_SUCCESS, "RegQueryValueA, failed, error %d\n", lret);
+ ok(bytes[0] = 0xde && bytes[1] == 0xad && bytes[2] == 0xbe && bytes[3] == 0xef,
+ "binary unquoted value was not preserved (it's 0x%02X%02X%02X%02X)\n",
+ 0xff & bytes[0], 0xff & bytes[1], 0xff & bytes[2], 0xff & bytes[3]);
+
hr = IRegistrar_StringUnregister(registrar, textW);
ok(SUCCEEDED(hr), "IRegistar_StringUnregister failed, hr = 0x%08X\n", hr);
RegCloseKey(key);
More information about the wine-cvs
mailing list