ole32: Support VT_BSTR for PropertyStorage reading and writing

André Hentschel nerv at dawncrow.de
Sat Jun 18 10:52:01 CDT 2011


---
 dlls/ole32/Makefile.in |    2 +-
 dlls/ole32/stg_prop.c  |   30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/dlls/ole32/Makefile.in b/dlls/ole32/Makefile.in
index ea9c9cb..5c9f677 100644
--- a/dlls/ole32/Makefile.in
+++ b/dlls/ole32/Makefile.in
@@ -1,6 +1,6 @@
 MODULE    = ole32.dll
 IMPORTLIB = ole32
-IMPORTS   = uuid advapi32 user32 gdi32 rpcrt4
+IMPORTS   = uuid advapi32 user32 gdi32 rpcrt4 oleaut32
 EXTRADEFS = -D_OLE32_ -DCOM_NO_WINDOWS_H \
     -DENTRY_PREFIX=OLE32_ -DPROXY_CLSID=CLSID_PSFactoryBuffer -DWINE_REGISTER_DLL
 
diff --git a/dlls/ole32/stg_prop.c b/dlls/ole32/stg_prop.c
index cc29c0e..7d9b9a1 100644
--- a/dlls/ole32/stg_prop.c
+++ b/dlls/ole32/stg_prop.c
@@ -1130,6 +1130,24 @@ static HRESULT PropertyStorage_ReadProperty(PropertyStorage_impl *This,
             hr = STG_E_INSUFFICIENTMEMORY;
         break;
     }
+    case VT_BSTR:
+    {
+        DWORD count;
+
+        StorageUtl_ReadDWord(data, 0, &count);
+        prop->u.bstrVal = SysAllocStringLen(NULL, count);
+        if (prop->u.bstrVal)
+        {
+            memcpy(prop->u.bstrVal, data + sizeof(DWORD), count * sizeof(WCHAR));
+            /* make sure string is NULL-terminated */
+            prop->u.bstrVal[count - 1] = '\0';
+            PropertyStorage_ByteSwapString(prop->u.bstrVal, count);
+            TRACE("Read string value %s\n", debugstr_w(prop->u.pwszVal));
+        }
+        else
+            hr = STG_E_INSUFFICIENTMEMORY;
+        break;
+    }
     case VT_FILETIME:
         StorageUtl_ReadULargeInteger(data, 0,
          (ULARGE_INTEGER *)&prop->u.filetime);
@@ -1719,6 +1737,18 @@ static HRESULT PropertyStorage_WritePropertyToStream(PropertyStorage_impl *This,
         bytesWritten = count + sizeof(DWORD);
         break;
     }
+    case VT_BSTR:
+    {
+        DWORD len = SysStringLen(var->u.bstrVal) + 1, dwTemp;
+
+        StorageUtl_WriteDWord((LPBYTE)&dwTemp, 0, len);
+        hr = IStream_Write(This->stm, &dwTemp, sizeof(dwTemp), &count);
+        if (FAILED(hr))
+            goto end;
+        hr = IStream_Write(This->stm, var->u.bstrVal, len * sizeof(WCHAR), &count);
+        bytesWritten = count + sizeof(DWORD);
+        break;
+    }
     case VT_FILETIME:
     {
         FILETIME temp;
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list