2003-05-16 00:55:37 +02:00
|
|
|
/*
|
|
|
|
* Global memory implementation of ILockBytes.
|
|
|
|
*
|
|
|
|
* Copyright 1999 Thuy Nguyen
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-05-16 00:55:37 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2003-05-16 00:55:37 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define NONAMELESSUNION
|
2015-03-16 19:06:46 +01:00
|
|
|
|
2003-05-16 00:55:37 +02:00
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2003-05-16 00:55:37 +02:00
|
|
|
#include "wine/winbase16.h"
|
2003-09-09 21:39:31 +02:00
|
|
|
#include "winuser.h"
|
2003-05-16 00:55:37 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
|
|
|
|
#include "ifs.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(ole);
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* HGLOBALLockBytesImpl16 definition.
|
|
|
|
*
|
2006-11-21 21:44:54 +01:00
|
|
|
* This class implements the ILockBytes interface and represents a byte array
|
2003-05-16 00:55:37 +02:00
|
|
|
* object supported by an HGLOBAL pointer.
|
|
|
|
*/
|
|
|
|
struct HGLOBALLockBytesImpl16
|
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
ILockBytes16 ILockBytes16_iface;
|
|
|
|
LONG ref;
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Support for the LockBytes object
|
|
|
|
*/
|
|
|
|
HGLOBAL16 supportHandle;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This flag is TRUE if the HGLOBAL is destroyed when the object
|
|
|
|
* is finally released.
|
|
|
|
*/
|
|
|
|
BOOL deleteOnRelease;
|
|
|
|
/*
|
|
|
|
* Helper variable that contains the size of the byte array
|
|
|
|
*/
|
|
|
|
ULARGE_INTEGER byteArraySize;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct HGLOBALLockBytesImpl16 HGLOBALLockBytesImpl16;
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* HGLOBALLockBytesImpl16 implementation
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-01-20 11:10:36 +01:00
|
|
|
static inline HGLOBALLockBytesImpl16 *impl_from_ILockBytes16(ILockBytes16 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HGLOBALLockBytesImpl16, ILockBytes16_iface);
|
|
|
|
}
|
|
|
|
|
2003-05-16 00:55:37 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* This is the constructor for the HGLOBALLockBytesImpl16 class.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* hGlobal - Handle that will support the stream. can be NULL.
|
|
|
|
* fDeleteOnRelease - Flag set to TRUE if the HGLOBAL16 will be released
|
|
|
|
* when the IStream object is destroyed.
|
|
|
|
*/
|
2005-07-22 20:26:31 +02:00
|
|
|
static HGLOBALLockBytesImpl16*
|
2003-05-16 00:55:37 +02:00
|
|
|
HGLOBALLockBytesImpl16_Construct(HGLOBAL16 hGlobal,
|
|
|
|
BOOL16 fDeleteOnRelease)
|
|
|
|
{
|
|
|
|
HGLOBALLockBytesImpl16* newLockBytes;
|
|
|
|
|
2004-08-13 01:00:51 +02:00
|
|
|
static ILockBytes16Vtbl vt16;
|
2003-05-16 00:55:37 +02:00
|
|
|
static SEGPTR msegvt16;
|
|
|
|
HMODULE16 hcomp = GetModuleHandle16("OLE2");
|
|
|
|
|
|
|
|
|
|
|
|
TRACE("(%x,%d)\n",hGlobal,fDeleteOnRelease);
|
|
|
|
newLockBytes = HeapAlloc(GetProcessHeap(), 0, sizeof(HGLOBALLockBytesImpl16));
|
|
|
|
if (newLockBytes == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the virtual function table and reference count.
|
|
|
|
*/
|
|
|
|
if (!msegvt16)
|
|
|
|
{
|
|
|
|
#define VTENT(x) vt16.x = (void*)GetProcAddress16(hcomp,"HGLOBALLockBytesImpl16_"#x);assert(vt16.x)
|
|
|
|
VTENT(QueryInterface);
|
|
|
|
VTENT(AddRef);
|
|
|
|
VTENT(Release);
|
|
|
|
VTENT(ReadAt);
|
|
|
|
VTENT(WriteAt);
|
|
|
|
VTENT(Flush);
|
|
|
|
VTENT(SetSize);
|
|
|
|
VTENT(LockRegion);
|
|
|
|
VTENT(UnlockRegion);
|
2011-01-20 11:09:54 +01:00
|
|
|
VTENT(Stat);
|
2003-05-16 00:55:37 +02:00
|
|
|
#undef VTENT
|
|
|
|
msegvt16 = MapLS( &vt16 );
|
|
|
|
}
|
2011-01-20 11:10:36 +01:00
|
|
|
newLockBytes->ILockBytes16_iface.lpVtbl = (const ILockBytes16Vtbl*)msegvt16;
|
|
|
|
newLockBytes->ref = 0;
|
2003-05-16 00:55:37 +02:00
|
|
|
/*
|
|
|
|
* Initialize the support.
|
|
|
|
*/
|
|
|
|
newLockBytes->supportHandle = hGlobal;
|
|
|
|
newLockBytes->deleteOnRelease = fDeleteOnRelease;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This method will allocate a handle if one is not supplied.
|
|
|
|
*/
|
|
|
|
if (newLockBytes->supportHandle == 0)
|
|
|
|
newLockBytes->supportHandle = GlobalAlloc16(GMEM_MOVEABLE | GMEM_NODISCARD, 0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the size of the array to the size of the handle.
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
newLockBytes->byteArraySize.u.HighPart = 0;
|
|
|
|
newLockBytes->byteArraySize.u.LowPart = GlobalSize16(
|
2003-05-16 00:55:37 +02:00
|
|
|
newLockBytes->supportHandle);
|
|
|
|
|
|
|
|
return (HGLOBALLockBytesImpl16*)MapLS(newLockBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This is the destructor of the HGLOBALStreamImpl class.
|
|
|
|
*
|
|
|
|
* This method will clean-up all the resources used-up by the given
|
|
|
|
* HGLOBALLockBytesImpl16 class. The pointer passed-in to this function will be
|
|
|
|
* freed and will not be valid anymore.
|
|
|
|
*/
|
2005-07-22 20:26:31 +02:00
|
|
|
static void HGLOBALLockBytesImpl16_Destroy(HGLOBALLockBytesImpl16* This)
|
2003-05-16 00:55:37 +02:00
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
/*
|
|
|
|
* Release the HGlobal if the constructor asked for that.
|
|
|
|
*/
|
|
|
|
if (This->deleteOnRelease)
|
|
|
|
{
|
|
|
|
GlobalFree16(This->supportHandle);
|
|
|
|
This->supportHandle = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, free the memory used-up by the class.
|
|
|
|
*/
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
}
|
|
|
|
|
2005-07-22 20:26:31 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* This implements the IUnknown method AddRef for this
|
|
|
|
* class
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
ULONG CDECL HGLOBALLockBytesImpl16_AddRef(ILockBytes16* iface)
|
2005-07-22 20:26:31 +02:00
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = impl_from_ILockBytes16(iface);
|
2005-07-22 20:26:31 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-05-16 00:55:37 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* This implements the IUnknown method QueryInterface for this
|
|
|
|
* class
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_QueryInterface(
|
2003-05-16 00:55:37 +02:00
|
|
|
ILockBytes16* iface, /* [in] SEGPTR */
|
|
|
|
REFIID riid, /* [in] */
|
2003-08-08 23:07:23 +02:00
|
|
|
void** ppvObject) /* [out][iid_is] (ptr to SEGPTR!) */
|
2003-05-16 00:55:37 +02:00
|
|
|
{
|
2008-11-05 23:04:10 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = MapSL((SEGPTR)iface);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
TRACE("(%p,%s,%p)\n",iface,debugstr_guid(riid),ppvObject);
|
|
|
|
/*
|
|
|
|
* Perform a sanity check on the parameters.
|
|
|
|
*/
|
|
|
|
if (ppvObject==0)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the return parameter.
|
|
|
|
*/
|
|
|
|
*ppvObject = 0;
|
|
|
|
/*
|
|
|
|
* Compare the riid with the interface IDs implemented by this object.
|
|
|
|
*/
|
|
|
|
if ( !memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) ||
|
|
|
|
!memcmp(&IID_ILockBytes, riid, sizeof(IID_ILockBytes))
|
|
|
|
)
|
|
|
|
*ppvObject = (void*)iface;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that we obtained an interface.
|
|
|
|
*/
|
2005-07-24 18:15:24 +02:00
|
|
|
if ((*ppvObject)==0) {
|
|
|
|
FIXME("Unknown IID %s\n", debugstr_guid(riid));
|
2003-05-16 00:55:37 +02:00
|
|
|
return E_NOINTERFACE;
|
2005-07-24 18:15:24 +02:00
|
|
|
}
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Query Interface always increases the reference count by one when it is
|
|
|
|
* successful
|
|
|
|
*/
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16_AddRef(&This->ILockBytes16_iface);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This implements the IUnknown method Release for this
|
|
|
|
* class
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
ULONG CDECL HGLOBALLockBytesImpl16_Release(ILockBytes16* iface)
|
2003-05-16 00:55:37 +02:00
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = impl_from_ILockBytes16(iface);
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the reference count goes down to 0, perform suicide.
|
|
|
|
*/
|
2004-09-24 03:16:53 +02:00
|
|
|
if (ref==0)
|
2003-05-16 00:55:37 +02:00
|
|
|
HGLOBALLockBytesImpl16_Destroy(This);
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
2003-05-16 00:55:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* It reads a block of information from the byte array at the specified
|
|
|
|
* offset.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_ReadAt(
|
2003-05-16 00:55:37 +02:00
|
|
|
ILockBytes16* iface,
|
|
|
|
ULARGE_INTEGER ulOffset, /* [in] */
|
2003-08-08 23:07:23 +02:00
|
|
|
void* pv, /* [out][length_is][size_is] */
|
2003-05-16 00:55:37 +02:00
|
|
|
ULONG cb, /* [in] */
|
|
|
|
ULONG* pcbRead) /* [out] */
|
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = impl_from_ILockBytes16(iface);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
void* supportBuffer;
|
|
|
|
ULONG bytesReadBuffer = 0;
|
|
|
|
ULONG bytesToReadFromBuffer;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p,%d,%p,%d,%p)\n",This,ulOffset.u.LowPart,pv,cb,pcbRead);
|
2003-05-16 00:55:37 +02:00
|
|
|
/*
|
|
|
|
* If the caller is not interested in the number of bytes read,
|
|
|
|
* we use another buffer to avoid "if" statements in the code.
|
|
|
|
*/
|
|
|
|
if (pcbRead == 0)
|
|
|
|
pcbRead = &bytesReadBuffer;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure the offset is valid.
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
if (ulOffset.u.LowPart > This->byteArraySize.u.LowPart)
|
2003-05-16 00:55:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Using the known size of the array, calculate the number of bytes
|
|
|
|
* to read.
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
bytesToReadFromBuffer = min(This->byteArraySize.u.LowPart -
|
|
|
|
ulOffset.u.LowPart, cb);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock the buffer in position and copy the data.
|
|
|
|
*/
|
|
|
|
supportBuffer = GlobalLock16(This->supportHandle);
|
|
|
|
|
|
|
|
memcpy(pv,
|
2004-01-23 02:51:33 +01:00
|
|
|
(char *) supportBuffer + ulOffset.u.LowPart,
|
2003-05-16 00:55:37 +02:00
|
|
|
bytesToReadFromBuffer);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the number of bytes read.
|
|
|
|
*/
|
|
|
|
*pcbRead = bytesToReadFromBuffer;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleanup
|
|
|
|
*/
|
|
|
|
GlobalUnlock16(This->supportHandle);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The function returns S_OK if the specified number of bytes were read
|
|
|
|
* or the end of the array was reached.
|
|
|
|
* It returns STG_E_READFAULT if the number of bytes to read does not equal
|
|
|
|
* the number of bytes actually read.
|
|
|
|
*/
|
|
|
|
if(*pcbRead == cb)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
return STG_E_READFAULT;
|
|
|
|
}
|
|
|
|
|
2005-07-22 20:26:31 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* It will change the size of the byte array.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_SetSize(
|
2005-07-22 20:26:31 +02:00
|
|
|
ILockBytes16* iface,
|
|
|
|
ULARGE_INTEGER libNewSize) /* [in] */
|
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = impl_from_ILockBytes16(iface);
|
2005-07-22 20:26:31 +02:00
|
|
|
HGLOBAL16 supportHandle;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p,%d)\n",This,libNewSize.u.LowPart);
|
2005-07-22 20:26:31 +02:00
|
|
|
/*
|
|
|
|
* As documented.
|
|
|
|
*/
|
|
|
|
if (libNewSize.u.HighPart != 0)
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
|
|
|
|
|
|
|
if (This->byteArraySize.u.LowPart == libNewSize.u.LowPart)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Re allocate the HGlobal to fit the new size of the stream.
|
|
|
|
*/
|
|
|
|
supportHandle = GlobalReAlloc16(This->supportHandle, libNewSize.u.LowPart, 0);
|
|
|
|
|
|
|
|
if (supportHandle == 0)
|
|
|
|
return STG_E_MEDIUMFULL;
|
|
|
|
|
|
|
|
This->supportHandle = supportHandle;
|
|
|
|
This->byteArraySize.u.LowPart = libNewSize.u.LowPart;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2003-05-16 00:55:37 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* It writes the specified bytes at the specified offset.
|
|
|
|
* position. If the array is too small, it will be resized.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_WriteAt(
|
2003-05-16 00:55:37 +02:00
|
|
|
ILockBytes16* iface,
|
|
|
|
ULARGE_INTEGER ulOffset, /* [in] */
|
2003-08-08 23:07:23 +02:00
|
|
|
const void* pv, /* [in][size_is] */
|
2003-05-16 00:55:37 +02:00
|
|
|
ULONG cb, /* [in] */
|
|
|
|
ULONG* pcbWritten) /* [out] */
|
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = impl_from_ILockBytes16(iface);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
void* supportBuffer;
|
|
|
|
ULARGE_INTEGER newSize;
|
|
|
|
ULONG bytesWritten = 0;
|
|
|
|
|
2006-10-15 12:28:08 +02:00
|
|
|
TRACE("(%p,%d,%p,%d,%p)\n",This,ulOffset.u.LowPart,pv,cb,pcbWritten);
|
2003-05-16 00:55:37 +02:00
|
|
|
/*
|
|
|
|
* If the caller is not interested in the number of bytes written,
|
|
|
|
* we use another buffer to avoid "if" statements in the code.
|
|
|
|
*/
|
|
|
|
if (pcbWritten == 0)
|
|
|
|
pcbWritten = &bytesWritten;
|
|
|
|
|
|
|
|
if (cb == 0)
|
|
|
|
return S_OK;
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
newSize.u.HighPart = 0;
|
|
|
|
newSize.u.LowPart = ulOffset.u.LowPart + cb;
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify if we need to grow the stream
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
if (newSize.u.LowPart > This->byteArraySize.u.LowPart)
|
2003-05-16 00:55:37 +02:00
|
|
|
{
|
|
|
|
/* grow stream */
|
|
|
|
if (HGLOBALLockBytesImpl16_SetSize(iface, newSize) == STG_E_MEDIUMFULL)
|
|
|
|
return STG_E_MEDIUMFULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lock the buffer in position and copy the data.
|
|
|
|
*/
|
|
|
|
supportBuffer = GlobalLock16(This->supportHandle);
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
memcpy((char *) supportBuffer + ulOffset.u.LowPart, pv, cb);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the number of bytes written.
|
|
|
|
*/
|
|
|
|
*pcbWritten = cb;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Cleanup
|
|
|
|
*/
|
|
|
|
GlobalUnlock16(This->supportHandle);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_Flush(ILockBytes16* iface)
|
2003-05-16 00:55:37 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n",iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* The global memory implementation of ILockBytes does not support locking.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_LockRegion(
|
2003-05-16 00:55:37 +02:00
|
|
|
ILockBytes16* iface,
|
|
|
|
ULARGE_INTEGER libOffset, /* [in] */
|
|
|
|
ULARGE_INTEGER cb, /* [in] */
|
|
|
|
DWORD dwLockType) /* [in] */
|
|
|
|
{
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* The global memory implementation of ILockBytes does not support locking.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_UnlockRegion(
|
2003-05-16 00:55:37 +02:00
|
|
|
ILockBytes16* iface,
|
|
|
|
ULARGE_INTEGER libOffset, /* [in] */
|
|
|
|
ULARGE_INTEGER cb, /* [in] */
|
|
|
|
DWORD dwLockType) /* [in] */
|
|
|
|
{
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* This method is part of the ILockBytes interface.
|
|
|
|
*
|
|
|
|
* This method returns information about the current
|
|
|
|
* byte array object.
|
|
|
|
*
|
|
|
|
* See the documentation of ILockBytes for more info.
|
|
|
|
*/
|
2006-06-12 21:34:59 +02:00
|
|
|
HRESULT CDECL HGLOBALLockBytesImpl16_Stat(
|
2003-05-16 00:55:37 +02:00
|
|
|
ILockBytes16*iface,
|
|
|
|
STATSTG16* pstatstg, /* [out] */
|
|
|
|
DWORD grfStatFlag) /* [in] */
|
|
|
|
{
|
2011-01-20 11:10:36 +01:00
|
|
|
HGLOBALLockBytesImpl16* const This = impl_from_ILockBytes16(iface);
|
2003-05-16 00:55:37 +02:00
|
|
|
|
|
|
|
memset(pstatstg, 0, sizeof(STATSTG16));
|
|
|
|
|
|
|
|
pstatstg->pwcsName = NULL;
|
|
|
|
pstatstg->type = STGTY_LOCKBYTES;
|
|
|
|
pstatstg->cbSize = This->byteArraySize;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CreateILockBytesOnHGlobal [OLE2.54]
|
2009-03-11 17:05:20 +01:00
|
|
|
*
|
2003-05-16 00:55:37 +02:00
|
|
|
* Creates an ILockBytes interface for a HGLOBAL handle.
|
|
|
|
*
|
2005-11-09 11:30:57 +01:00
|
|
|
* PARAMS
|
2003-05-16 00:55:37 +02:00
|
|
|
* hGlobal the global handle (16bit)
|
|
|
|
* fDeleteOnRelease delete handle on release.
|
|
|
|
* ppLkbyt pointer to ILockBytes interface.
|
|
|
|
*
|
2005-11-09 11:30:57 +01:00
|
|
|
* RETURNS
|
2003-05-16 00:55:37 +02:00
|
|
|
* Staddard OLE error return codes.
|
|
|
|
*
|
|
|
|
*/
|
2003-08-08 23:07:23 +02:00
|
|
|
HRESULT WINAPI CreateILockBytesOnHGlobal16(
|
|
|
|
HGLOBAL16 hGlobal, /* [in] */
|
|
|
|
BOOL16 fDeleteOnRelease, /* [in] */
|
|
|
|
LPLOCKBYTES16 *ppLkbyt) /* [out] (ptr to SEGPTR!) */
|
2003-05-16 00:55:37 +02:00
|
|
|
{
|
|
|
|
HGLOBALLockBytesImpl16* newLockBytes; /* SEGPTR */
|
|
|
|
|
|
|
|
newLockBytes = HGLOBALLockBytesImpl16_Construct(hGlobal, fDeleteOnRelease);
|
|
|
|
|
|
|
|
if (newLockBytes != NULL)
|
2011-01-20 11:10:36 +01:00
|
|
|
return HGLOBALLockBytesImpl16_QueryInterface(&newLockBytes->ILockBytes16_iface,
|
|
|
|
&IID_ILockBytes, (void**)ppLkbyt);
|
2003-05-16 00:55:37 +02:00
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|