GlobalStream fix

Jürgen Schmied juergenschmied at lycos.de
Sat Jun 29 04:07:25 CDT 2002


- supporting large offsets (needed for negative offset)
- supporting negative offsets


---
juergen.schmied at debitel.net



-------------- next part --------------
Index: wine/dlls/ole32/ifs.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/ifs.c,v
retrieving revision 1.20
diff -d -u -r1.20 ifs.c
--- wine/dlls/ole32/ifs.c	31 May 2002 23:25:50 -0000	1.20
+++ wine/dlls/ole32/ifs.c	27 Jun 2002 09:51:04 -0000
@@ -260,14 +260,14 @@
 static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) {
 	ICOM_THIS(IMalloc32Impl,iface);
 
-	TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj);
-	if (	!memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
-		!memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc))
-	) {
+	TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
+
+	if (IsEqualIID(&IID_IUnknown,refiid) ||
+	    IsEqualIID(&IID_IMalloc,refiid)) {
 		*obj = This;
 		return S_OK;
 	}
-	return OLE_E_ENUM_NOMORE;
+	return E_NOINTERFACE;
 }
 
 /******************************************************************************
@@ -390,3 +390,4 @@
 		IsBadCodePtr((FARPROC)ICOM_VTBL(punk)->QueryInterface)
 	);
 }
+
Index: wine/dlls/ole32/hglobalstream.c
===================================================================
RCS file: /home/wine/wine/dlls/ole32/hglobalstream.c,v
retrieving revision 1.11
diff -d -u -r1.11 hglobalstream.c
--- wine/dlls/ole32/hglobalstream.c	31 May 2002 23:25:50 -0000	1.11
+++ wine/dlls/ole32/hglobalstream.c	27 Jun 2002 09:51:04 -0000
@@ -33,6 +33,7 @@
 #include "ole2.h"
 #include "winbase.h"
 #include "winerror.h"
+#include "ntddk.h"
 
 #include "wine/debug.h"
 
@@ -573,59 +574,35 @@
 	dlibMove.s.LowPart, dwOrigin, plibNewPosition);
 
   /*
-   * The caller is allowed to pass in NULL as the new position return value.
-   * If it happens, we assign it to a dynamic variable to avoid special cases
-   * in the code below.
-   */
-  if (plibNewPosition == 0)
-  {
-    plibNewPosition = &newPosition;
-  }
-
-  /*
    * The file pointer is moved depending on the given "function"
    * parameter.
    */
   switch (dwOrigin)
   {
     case STREAM_SEEK_SET:
-      plibNewPosition->s.HighPart = 0;
-      plibNewPosition->s.LowPart  = 0;
+      newPosition.s.HighPart = 0;
+      newPosition.s.LowPart = 0;
       break;
     case STREAM_SEEK_CUR:
-      *plibNewPosition = This->currentPosition;
+      newPosition = This->currentPosition;
       break;
     case STREAM_SEEK_END:
-      *plibNewPosition = This->streamSize;
+      newPosition = This->streamSize;
       break;
     default:
       return STG_E_INVALIDFUNCTION;
   }
 
   /*
-   * We don't support files with offsets of 64 bits.
-   */
-  assert(dlibMove.s.HighPart == 0);
-
-  /*
-   * Check if we end-up before the beginning of the file. That should trigger an
-   * error.
-   */
-  if ( (dlibMove.s.LowPart<0) && (plibNewPosition->s.LowPart < (ULONG)(-dlibMove.s.LowPart)) )
-  {
-    /*
-     * I don't know what error to send there.
-     */
-    return E_FAIL;
-  }
-
-  /*
    * Move the actual file pointer
    * 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.
    */
-  plibNewPosition->s.LowPart += dlibMove.s.LowPart;
-  This->currentPosition = *plibNewPosition;
+  newPosition.QuadPart = RtlLargeIntegerAdd(newPosition.QuadPart, dlibMove.QuadPart);
+  if (newPosition.QuadPart < 0) return STG_E_INVALIDFUNCTION;
+
+  if (plibNewPosition) *plibNewPosition = newPosition;
+  This->currentPosition = newPosition;
 
   return S_OK;
 }
@@ -846,3 +823,4 @@
   FIXME("not implemented!\n");
   return E_NOTIMPL;
 }
+



More information about the wine-patches mailing list