Commit 33817372 authored by Juergen Schmied's avatar Juergen Schmied Committed by Alexandre Julliard

Support for large and negative offsets.

parent 4227bf4a
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "ole2.h" #include "ole2.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h" #include "winerror.h"
#include "ntddk.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -573,59 +574,35 @@ HRESULT WINAPI HGLOBALStreamImpl_Seek( ...@@ -573,59 +574,35 @@ HRESULT WINAPI HGLOBALStreamImpl_Seek(
dlibMove.s.LowPart, dwOrigin, plibNewPosition); 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" * The file pointer is moved depending on the given "function"
* parameter. * parameter.
*/ */
switch (dwOrigin) switch (dwOrigin)
{ {
case STREAM_SEEK_SET: case STREAM_SEEK_SET:
plibNewPosition->s.HighPart = 0; newPosition.s.HighPart = 0;
plibNewPosition->s.LowPart = 0; newPosition.s.LowPart = 0;
break; break;
case STREAM_SEEK_CUR: case STREAM_SEEK_CUR:
*plibNewPosition = This->currentPosition; newPosition = This->currentPosition;
break; break;
case STREAM_SEEK_END: case STREAM_SEEK_END:
*plibNewPosition = This->streamSize; newPosition = This->streamSize;
break; break;
default: default:
return STG_E_INVALIDFUNCTION; 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 * Move the actual file pointer
* If the file pointer ends-up after the end of the stream, the next Write operation will * 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. * make the file larger. This is how it is documented.
*/ */
plibNewPosition->s.LowPart += dlibMove.s.LowPart; newPosition.QuadPart = RtlLargeIntegerAdd(newPosition.QuadPart, dlibMove.QuadPart);
This->currentPosition = *plibNewPosition; if (newPosition.QuadPart < 0) return STG_E_INVALIDFUNCTION;
if (plibNewPosition) *plibNewPosition = newPosition;
This->currentPosition = newPosition;
return S_OK; return S_OK;
} }
......
...@@ -260,14 +260,14 @@ typedef struct ...@@ -260,14 +260,14 @@ typedef struct
static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) { static HRESULT WINAPI IMalloc_fnQueryInterface(LPMALLOC iface,REFIID refiid,LPVOID *obj) {
ICOM_THIS(IMalloc32Impl,iface); ICOM_THIS(IMalloc32Impl,iface);
TRACE("(%p)->QueryInterface(%s,%p)\n",This,debugstr_guid(refiid),obj); TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(refiid),obj);
if ( !memcmp(&IID_IUnknown,refiid,sizeof(IID_IUnknown)) ||
!memcmp(&IID_IMalloc,refiid,sizeof(IID_IMalloc)) if (IsEqualIID(&IID_IUnknown,refiid) ||
) { IsEqualIID(&IID_IMalloc,refiid)) {
*obj = This; *obj = This;
return S_OK; return S_OK;
} }
return OLE_E_ENUM_NOMORE; return E_NOINTERFACE;
} }
/****************************************************************************** /******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment