ole32: On big endian machines, copy strings to little endian order without mucking with the map they're stored in.
This commit is contained in:
parent
d82cbcf049
commit
c664e9f494
|
@ -1477,6 +1477,25 @@ static void PropertyStorage_MakePropertyIdOffset(DWORD propid, DWORD dwOffset,
|
|||
offsetof(PROPERTYIDOFFSET, dwOffset), dwOffset);
|
||||
}
|
||||
|
||||
static inline HRESULT PropertStorage_WriteWStringToStream(IStream *stm,
|
||||
LPCWSTR str, DWORD len, DWORD *written)
|
||||
{
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
WCHAR *leStr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||
HRESULT hr;
|
||||
|
||||
if (!leStr)
|
||||
return E_OUTOFMEMORY;
|
||||
memcpy(leStr, str, len * sizeof(WCHAR));
|
||||
PropertyStorage_ByteSwapString(leStr, len);
|
||||
hr = IStream_Write(stm, leStr, len, written);
|
||||
HeapFree(GetProcessHeap(), 0, leStr);
|
||||
return hr;
|
||||
#else
|
||||
return IStream_Write(stm, str, len, written);
|
||||
#endif
|
||||
}
|
||||
|
||||
struct DictionaryClosure
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -1508,12 +1527,8 @@ static BOOL PropertyStorage_DictionaryWriter(const void *key,
|
|||
if (FAILED(c->hr))
|
||||
goto end;
|
||||
c->bytesWritten += sizeof(DWORD);
|
||||
/* Rather than allocate a copy, I'll swap the string to little-endian
|
||||
* in-place, write it, then swap it back.
|
||||
*/
|
||||
PropertyStorage_ByteSwapString(key, keyLen);
|
||||
c->hr = IStream_Write(This->stm, key, keyLen, &count);
|
||||
PropertyStorage_ByteSwapString(key, keyLen);
|
||||
c->hr = PropertStorage_WriteWStringToStream(This->stm, key, keyLen,
|
||||
&count);
|
||||
if (FAILED(c->hr))
|
||||
goto end;
|
||||
c->bytesWritten += keyLen;
|
||||
|
|
Loading…
Reference in New Issue