Rob Shearman : oleaut32: Fix the SAFEARRAY marshalling on 64-bit platforms.

Alexandre Julliard julliard at winehq.org
Tue Apr 7 09:04:39 CDT 2009


Module: wine
Branch: master
Commit: 47ae95ccce211ba48c1ea165c2c1f3c5ba6e8754
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=47ae95ccce211ba48c1ea165c2c1f3c5ba6e8754

Author: Rob Shearman <robertshearman at gmail.com>
Date:   Tue Apr  7 12:27:49 2009 +0100

oleaut32: Fix the SAFEARRAY marshalling on 64-bit platforms.

The pointers should be written as NDR 4-byte fields instead of a
platform-dependent size.

---

 dlls/oleaut32/tests/usrmarshal.c |    4 ++--
 dlls/oleaut32/usrmarshal.c       |   22 +++++++++++-----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/dlls/oleaut32/tests/usrmarshal.c b/dlls/oleaut32/tests/usrmarshal.c
index cb6f45d..38827b1 100644
--- a/dlls/oleaut32/tests/usrmarshal.c
+++ b/dlls/oleaut32/tests/usrmarshal.c
@@ -146,8 +146,8 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
     wiresa += sizeof(DWORD);
     ok(*(DWORD *)wiresa == cell_count, "wiresa + 0x1c should be %u instead of %u\n", cell_count, *(DWORD *)wiresa);
     wiresa += sizeof(DWORD);
-    ok(*(DWORD_PTR *)wiresa == (DWORD_PTR)lpsa->pvData, "wiresa + 0x20 should be lpsa->pvData instead of 0x%08lx\n", *(DWORD_PTR *)wiresa);
-    wiresa += sizeof(DWORD_PTR);
+    ok(*(DWORD *)wiresa, "wiresa + 0x20 should be non-zero instead of 0x%08x\n", *(DWORD *)wiresa);
+    wiresa += sizeof(DWORD);
     if(sftype == SF_HAVEIID)
     {
         GUID guid;
diff --git a/dlls/oleaut32/usrmarshal.c b/dlls/oleaut32/usrmarshal.c
index 14c655c..1e20c3c 100644
--- a/dlls/oleaut32/usrmarshal.c
+++ b/dlls/oleaut32/usrmarshal.c
@@ -755,7 +755,7 @@ ULONG WINAPI LPSAFEARRAY_UserSize(ULONG *pFlags, ULONG StartingSize, LPSAFEARRAY
     TRACE("("); dump_user_flags(pFlags); TRACE(", %d, %p\n", StartingSize, *ppsa);
 
     ALIGN_LENGTH(size, 3);
-    size += sizeof(ULONG_PTR);
+    size += sizeof(ULONG);
     if (*ppsa)
     {
         SAFEARRAY *psa = *ppsa;
@@ -770,7 +770,7 @@ ULONG WINAPI LPSAFEARRAY_UserSize(ULONG *pFlags, ULONG StartingSize, LPSAFEARRAY
         size += sizeof(ULONG);
 
         size += sizeof(ULONG);
-        size += sizeof(ULONG_PTR);
+        size += sizeof(ULONG);
         if (sftype == SF_HAVEIID)
             size += sizeof(IID);
 
@@ -843,8 +843,8 @@ unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buf
     TRACE("("); dump_user_flags(pFlags); TRACE(", %p, &%p\n", Buffer, *ppsa);
 
     ALIGN_POINTER(Buffer, 3);
-    *(ULONG_PTR *)Buffer = *ppsa ? TRUE : FALSE;
-    Buffer += sizeof(ULONG_PTR);
+    *(ULONG *)Buffer = *ppsa ? 0x1 : 0x0;
+    Buffer += sizeof(ULONG);
     if (*ppsa)
     {
         VARTYPE vt;
@@ -874,8 +874,8 @@ unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buf
 
         *(ULONG *)Buffer = ulCellCount;
         Buffer += sizeof(ULONG);
-        *(ULONG_PTR *)Buffer = (ULONG_PTR)psa->pvData;
-        Buffer += sizeof(ULONG_PTR);
+        *(ULONG *)Buffer = psa->pvData ? 0x2 : 0x0;
+        Buffer += sizeof(ULONG);
         if (sftype == SF_HAVEIID)
         {
             SafeArrayGetIID(psa, &guid);
@@ -958,7 +958,7 @@ unsigned char * WINAPI LPSAFEARRAY_UserMarshal(ULONG *pFlags, unsigned char *Buf
 
 unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *Buffer, LPSAFEARRAY *ppsa)
 {
-    ULONG_PTR ptr;
+    ULONG ptr;
     wireSAFEARRAY wiresa;
     ULONG cDims;
     HRESULT hr;
@@ -971,8 +971,8 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
     TRACE("("); dump_user_flags(pFlags); TRACE(", %p, %p\n", Buffer, ppsa);
 
     ALIGN_POINTER(Buffer, 3);
-    ptr = *(ULONG_PTR *)Buffer;
-    Buffer += sizeof(ULONG_PTR);
+    ptr = *(ULONG *)Buffer;
+    Buffer += sizeof(ULONG);
 
     if (!ptr)
     {
@@ -1001,8 +1001,8 @@ unsigned char * WINAPI LPSAFEARRAY_UserUnmarshal(ULONG *pFlags, unsigned char *B
 
     cell_count = *(ULONG *)Buffer;
     Buffer += sizeof(ULONG);
-    ptr = *(ULONG_PTR *)Buffer;
-    Buffer += sizeof(ULONG_PTR);
+    ptr = *(ULONG *)Buffer;
+    Buffer += sizeof(ULONG);
     if (sftype == SF_HAVEIID)
     {
         memcpy(&guid, Buffer, sizeof(guid));




More information about the wine-cvs mailing list