[PATCH 2/2] ole32: Fix the HGLOBAL stream Seek implementation. [try 3]

Reece Dunn msclrhd at googlemail.com
Thu Feb 25 03:22:10 CST 2010


try 1: fix the IStream_Seek implementation
try 2: correct the implementation based on the updated tests
try 3: don't seek when given an invalid seek type

- Reece
-------------- next part --------------
From a13f09cbe799f9f7eb3039e1c3b3a5da26239448 Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Thu, 25 Feb 2010 09:14:37 +0000
Subject: [PATCH 2/2] ole32: Fix the HGLOBAL stream Seek implementation.

---
 dlls/ole32/hglobalstream.c       |   21 ++++++++++++++-------
 dlls/ole32/tests/hglobalstream.c |   14 --------------
 2 files changed, 14 insertions(+), 21 deletions(-)

diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index c43d499..5742f99 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -365,11 +365,18 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
 {
   HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
 
-  ULARGE_INTEGER newPosition;
+  ULARGE_INTEGER newPosition = This->currentPosition;
+  HRESULT hr = S_OK;
 
   TRACE("(%p, %x%08x, %d, %p)\n", iface, dlibMove.u.HighPart,
 	dlibMove.u.LowPart, dwOrigin, plibNewPosition);
 
+  if (dlibMove.u.LowPart >= 0x80000000)
+  {
+    hr = STG_E_SEEKERROR;
+    goto end;
+  }
+
   /*
    * The file pointer is moved depending on the given "function"
    * parameter.
@@ -381,13 +388,13 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
       newPosition.u.LowPart = 0;
       break;
     case STREAM_SEEK_CUR:
-      newPosition = This->currentPosition;
       break;
     case STREAM_SEEK_END:
       newPosition = This->streamSize;
       break;
     default:
-      return STG_E_INVALIDFUNCTION;
+      hr = STG_E_SEEKERROR;
+      goto end;
   }
 
   /*
@@ -395,14 +402,14 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
    * If the file pointer ends-up after the end of the stream, the next Write operation will
    * make the file larger. This is how it is documented.
    */
-  if (dlibMove.QuadPart < 0 && newPosition.QuadPart < -dlibMove.QuadPart) return STG_E_INVALIDFUNCTION;
-
-  newPosition.QuadPart += dlibMove.QuadPart;
+  newPosition.u.HighPart = 0;
+  newPosition.u.LowPart += dlibMove.QuadPart;
 
+end:
   if (plibNewPosition) *plibNewPosition = newPosition;
   This->currentPosition = newPosition;
 
-  return S_OK;
+  return hr;
 }
 
 /***
diff --git a/dlls/ole32/tests/hglobalstream.c b/dlls/ole32/tests/hglobalstream.c
index d95a7c4..1fed237 100644
--- a/dlls/ole32/tests/hglobalstream.c
+++ b/dlls/ole32/tests/hglobalstream.c
@@ -97,11 +97,8 @@ static void test_streamonhglobal(IStream *pStream)
     ll.u.HighPart = 0;
     ll.u.LowPart = 123;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_END+1, &ull);
-    todo_wine
     ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
-    todo_wine
     ok(ull.u.LowPart == sizeof(data), "should have set LowPart to %d instead of %d\n", sizeof(data), ull.u.LowPart);
-    todo_wine
     ok(ull.u.HighPart == 0, "should not have changed HighPart, got %d\n", ull.u.HighPart);
 
     /* IStream_Seek -- valid position argument (seek to beginning) */
@@ -135,11 +132,8 @@ static void test_streamonhglobal(IStream *pStream)
     ll.u.HighPart = -1;
     ll.u.LowPart = 0;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
-    todo_wine
     ok_ole_success(hr, "IStream_Seek");
-    todo_wine
     ok(ull.u.LowPart == sizeof(data), "should have set LowPart to %d instead of %d\n", sizeof(data), ull.u.LowPart);
-    todo_wine
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
     /* IStream_Seek -- ignore HighPart in the move value (seek to beginning) */
@@ -153,11 +147,8 @@ static void test_streamonhglobal(IStream *pStream)
     ll.u.HighPart = -1;
     ll.u.LowPart = 0;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
-    todo_wine
     ok_ole_success(hr, "IStream_Seek");
-    todo_wine
     ok(ull.u.LowPart == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
-    todo_wine
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
     /* IStream_Seek -- invalid LowPart value (seek from current position) */
@@ -171,9 +162,7 @@ static void test_streamonhglobal(IStream *pStream)
     ll.u.HighPart = 0;
     ll.u.LowPart = 0x80000000;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
-    todo_wine
     ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
-    todo_wine
     ok(ull.u.LowPart == sizeof(data), "should have set LowPart to %d instead of %d\n", sizeof(data), ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
@@ -188,9 +177,7 @@ static void test_streamonhglobal(IStream *pStream)
     ll.u.HighPart = 0;
     ll.u.LowPart = 0x80000000;
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_SET, &ull);
-    todo_wine
     ok(hr == STG_E_SEEKERROR, "IStream_Seek should have returned STG_E_SEEKERROR instead of 0x%08x\n", hr);
-    todo_wine
     ok(ull.u.LowPart == sizeof(data), "should have set LowPart to %d instead of %d\n", sizeof(data), ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
@@ -237,7 +224,6 @@ static void test_streamonhglobal(IStream *pStream)
     hr = IStream_Seek(pStream, ll, STREAM_SEEK_CUR, &ull);
     ok_ole_success(hr, "IStream_Seek");
     ok(ull.u.LowPart == 0x00000007, "should have set LowPart to 0x00000007 instead of %08x\n", ull.u.LowPart);
-    todo_wine
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
     hr = IStream_Commit(pStream, STGC_DEFAULT);
-- 
1.6.3.3


More information about the wine-patches mailing list