forked from Mirrors/wine-wine
ole32: Fix property name handling for dictionary entries in CP_UNICODE case.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=42046
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 3cb18cc656
)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
oldstable
parent
54cdf4c92d
commit
63cd49cb2a
|
@ -1015,20 +1015,25 @@ static HRESULT PropertyStorage_ReadDictionary(PropertyStorage_impl *This,
|
||||||
ptr += sizeof(PROPID);
|
ptr += sizeof(PROPID);
|
||||||
StorageUtl_ReadDWord(ptr, 0, &cbEntry);
|
StorageUtl_ReadDWord(ptr, 0, &cbEntry);
|
||||||
ptr += sizeof(DWORD);
|
ptr += sizeof(DWORD);
|
||||||
TRACE("Reading entry with ID 0x%08x, %d bytes\n", propid, cbEntry);
|
|
||||||
/* Make sure the source string is NULL-terminated */
|
/* Make sure the source string is NULL-terminated */
|
||||||
if (This->codePage != CP_UNICODE)
|
if (This->codePage != CP_UNICODE)
|
||||||
ptr[cbEntry - 1] = '\0';
|
ptr[cbEntry - 1] = '\0';
|
||||||
else
|
else
|
||||||
*((LPWSTR)ptr + cbEntry / sizeof(WCHAR)) = '\0';
|
((WCHAR *)ptr)[cbEntry - 1] = '\0';
|
||||||
|
|
||||||
|
TRACE("Reading entry with ID %#x, %d chars, name %s.\n", propid, cbEntry, This->codePage == CP_UNICODE ?
|
||||||
|
debugstr_wn((WCHAR *)ptr, cbEntry) : debugstr_an((char *)ptr, cbEntry));
|
||||||
|
|
||||||
hr = PropertyStorage_StoreNameWithId(This, (char*)ptr, This->codePage, propid);
|
hr = PropertyStorage_StoreNameWithId(This, (char*)ptr, This->codePage, propid);
|
||||||
if (This->codePage == CP_UNICODE)
|
if (This->codePage == CP_UNICODE)
|
||||||
{
|
{
|
||||||
|
cbEntry *= sizeof(WCHAR);
|
||||||
|
|
||||||
/* Unicode entries are padded to DWORD boundaries */
|
/* Unicode entries are padded to DWORD boundaries */
|
||||||
if (cbEntry % sizeof(DWORD))
|
if (cbEntry % sizeof(DWORD))
|
||||||
ptr += sizeof(DWORD) - (cbEntry % sizeof(DWORD));
|
ptr += sizeof(DWORD) - (cbEntry % sizeof(DWORD));
|
||||||
}
|
}
|
||||||
ptr += sizeof(DWORD) + cbEntry;
|
ptr += cbEntry;
|
||||||
}
|
}
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -1573,7 +1578,7 @@ static inline HRESULT PropertStorage_WriteWStringToStream(IStream *stm,
|
||||||
HeapFree(GetProcessHeap(), 0, leStr);
|
HeapFree(GetProcessHeap(), 0, leStr);
|
||||||
return hr;
|
return hr;
|
||||||
#else
|
#else
|
||||||
return IStream_Write(stm, str, len, written);
|
return IStream_Write(stm, str, len * sizeof(WCHAR), written);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,7 +1593,7 @@ static BOOL PropertyStorage_DictionaryWriter(const void *key,
|
||||||
{
|
{
|
||||||
PropertyStorage_impl *This = extra;
|
PropertyStorage_impl *This = extra;
|
||||||
struct DictionaryClosure *c = closure;
|
struct DictionaryClosure *c = closure;
|
||||||
DWORD propid;
|
DWORD propid, keyLen;
|
||||||
ULONG count;
|
ULONG count;
|
||||||
|
|
||||||
assert(key);
|
assert(key);
|
||||||
|
@ -1600,10 +1605,9 @@ static BOOL PropertyStorage_DictionaryWriter(const void *key,
|
||||||
c->bytesWritten += sizeof(DWORD);
|
c->bytesWritten += sizeof(DWORD);
|
||||||
if (This->codePage == CP_UNICODE)
|
if (This->codePage == CP_UNICODE)
|
||||||
{
|
{
|
||||||
DWORD keyLen, pad = 0;
|
DWORD pad = 0, pad_len;
|
||||||
|
|
||||||
StorageUtl_WriteDWord((LPBYTE)&keyLen, 0,
|
StorageUtl_WriteDWord((LPBYTE)&keyLen, 0, lstrlenW((LPCWSTR)key) + 1);
|
||||||
(lstrlenW((LPCWSTR)key) + 1) * sizeof(WCHAR));
|
|
||||||
c->hr = IStream_Write(This->stm, &keyLen, sizeof(keyLen), &count);
|
c->hr = IStream_Write(This->stm, &keyLen, sizeof(keyLen), &count);
|
||||||
if (FAILED(c->hr))
|
if (FAILED(c->hr))
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -1612,20 +1616,21 @@ static BOOL PropertyStorage_DictionaryWriter(const void *key,
|
||||||
&count);
|
&count);
|
||||||
if (FAILED(c->hr))
|
if (FAILED(c->hr))
|
||||||
goto end;
|
goto end;
|
||||||
c->bytesWritten += keyLen * sizeof(WCHAR);
|
keyLen *= sizeof(WCHAR);
|
||||||
if (keyLen % sizeof(DWORD))
|
c->bytesWritten += keyLen;
|
||||||
|
|
||||||
|
/* Align to 4 bytes. */
|
||||||
|
pad_len = sizeof(DWORD) - keyLen % sizeof(DWORD);
|
||||||
|
if (pad_len)
|
||||||
{
|
{
|
||||||
c->hr = IStream_Write(This->stm, &pad,
|
c->hr = IStream_Write(This->stm, &pad, pad_len, &count);
|
||||||
sizeof(DWORD) - keyLen % sizeof(DWORD), &count);
|
|
||||||
if (FAILED(c->hr))
|
if (FAILED(c->hr))
|
||||||
goto end;
|
goto end;
|
||||||
c->bytesWritten += sizeof(DWORD) - keyLen % sizeof(DWORD);
|
c->bytesWritten += pad_len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DWORD keyLen;
|
|
||||||
|
|
||||||
StorageUtl_WriteDWord((LPBYTE)&keyLen, 0, strlen((LPCSTR)key) + 1);
|
StorageUtl_WriteDWord((LPBYTE)&keyLen, 0, strlen((LPCSTR)key) + 1);
|
||||||
c->hr = IStream_Write(This->stm, &keyLen, sizeof(keyLen), &count);
|
c->hr = IStream_Write(This->stm, &keyLen, sizeof(keyLen), &count);
|
||||||
if (FAILED(c->hr))
|
if (FAILED(c->hr))
|
||||||
|
|
Loading…
Reference in New Issue