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

Reece Dunn msclrhd at googlemail.com
Wed Feb 24 16:10:24 CST 2010


Hi,

This corrects wine's implementation of IStream_Seek for HGLOBAL
streams as indicated by the improved tests.

- Reece
-------------- next part --------------
From 39cac16cde61d3621466781be0087f5522c10e81 Mon Sep 17 00:00:00 2001
From: Reece Dunn <msclrhd at gmail.com>
Date: Wed, 24 Feb 2010 22:04:27 +0000
Subject: [PATCH 2/2] ole32: Fix the HGLOBAL stream Seek implementation.

---
 dlls/ole32/hglobalstream.c       |   15 ++++++++++-----
 dlls/ole32/tests/hglobalstream.c |   11 -----------
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/dlls/ole32/hglobalstream.c b/dlls/ole32/hglobalstream.c
index c43d499..821c895 100644
--- a/dlls/ole32/hglobalstream.c
+++ b/dlls/ole32/hglobalstream.c
@@ -366,6 +366,7 @@ static HRESULT WINAPI HGLOBALStreamImpl_Seek(
   HGLOBALStreamImpl* const This=(HGLOBALStreamImpl*)iface;
 
   ULARGE_INTEGER newPosition;
+  HRESULT hr = S_OK;
 
   TRACE("(%p, %x%08x, %d, %p)\n", iface, dlibMove.u.HighPart,
 	dlibMove.u.LowPart, dwOrigin, plibNewPosition);
@@ -395,14 +396,18 @@ 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;
+  if (dlibMove.u.LowPart >= 0x80000000)
+    hr = STG_E_SEEKERROR;
+  else
+  {
+    newPosition.u.HighPart = 0;
+    newPosition.u.LowPart += dlibMove.u.LowPart;
 
-  newPosition.QuadPart += dlibMove.QuadPart;
+    This->currentPosition = newPosition;
+  }
 
   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 aab89cb..3f036f3 100644
--- a/dlls/ole32/tests/hglobalstream.c
+++ b/dlls/ole32/tests/hglobalstream.c
@@ -107,11 +107,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 == 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 -- ignore HighPart in the move value (seek to beginning) */
@@ -120,11 +117,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) */
@@ -133,9 +127,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 == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
@@ -145,9 +137,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 == 0, "should have set LowPart to 0 instead of %d\n", ull.u.LowPart);
     ok(ull.u.HighPart == 0, "should have set HighPart to 0 instead of %d\n", ull.u.HighPart);
 
@@ -179,7 +169,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 %8x\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