Commit cd4b9c11 authored by Damjan Jovanovic's avatar Damjan Jovanovic Committed by Alexandre Julliard

atl: Add support for binary values in IRegistrar.

parent d2a221d2
...@@ -299,6 +299,41 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO ...@@ -299,6 +299,41 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
} }
break; 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: default:
WARN("Wrong resource type: %s\n", debugstr_w(buf->str)); WARN("Wrong resource type: %s\n", debugstr_w(buf->str));
hres = DISP_E_EXCEPTION; hres = DISP_E_EXCEPTION;
......
...@@ -47,6 +47,8 @@ static const char textA[] = ...@@ -47,6 +47,8 @@ static const char textA[] =
" val 'dword_unquoted_dec' = d 1 \n" " val 'dword_unquoted_dec' = d 1 \n"
" val 'dword_quoted_hex' = d '0xA' \n" " val 'dword_quoted_hex' = d '0xA' \n"
" val 'dword_unquoted_hex' = d 0xA \n" " val 'dword_unquoted_hex' = d 0xA \n"
" val 'binary_quoted' = b 'deadbeef' \n"
" val 'binary_unquoted' = b deadbeef \n"
" } \n" " } \n"
"}"; "}";
...@@ -72,6 +74,7 @@ static void test_registrar(void) ...@@ -72,6 +74,7 @@ static void test_registrar(void)
DWORD size; DWORD size;
LONG lret; LONG lret;
HKEY key; HKEY key;
BYTE bytes[4];
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, count); MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, count);
hr = IRegistrar_StringRegister(registrar, textW); hr = IRegistrar_StringRegister(registrar, textW);
...@@ -100,6 +103,20 @@ static void test_registrar(void) ...@@ -100,6 +103,20 @@ static void test_registrar(void)
ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret); ok(lret == ERROR_SUCCESS, "RegQueryValueExA failed, error %d\n", lret);
ok(dword == 1, "quoted dec is not supposed to be %d\n", dword); 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); hr = IRegistrar_StringUnregister(registrar, textW);
ok(SUCCEEDED(hr), "IRegistar_StringUnregister failed, hr = 0x%08X\n", hr); ok(SUCCEEDED(hr), "IRegistar_StringUnregister failed, hr = 0x%08X\n", hr);
RegCloseKey(key); RegCloseKey(key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment