} AntiMonikerImpl;
+static inline IMoniker *impl_from_IROTData( IROTData *iface )
+{
+ return (IMoniker *)((char*)iface - FIELD_OFFSET(AntiMonikerImpl, lpvtbl2));
+}
+
/*******************************************************************************
* AntiMoniker_QueryInterface
static HRESULT WINAPI
AntiMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
*/
static ULONG WINAPI AntiMonikerROTDataImpl_AddRef(IROTData *iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
*/
static ULONG WINAPI AntiMonikerROTDataImpl_Release(IROTData* iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
apt = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*apt));
apt->tid = GetCurrentThreadId();
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
- GetCurrentProcess(), &apt->thread,
- THREAD_ALL_ACCESS, FALSE, 0);
list_init(&apt->proxies);
list_init(&apt->stubmgrs);
DEBUG_CLEAR_CRITSEC_NAME(&apt->cs);
DeleteCriticalSection(&apt->cs);
- CloseHandle(apt->thread);
HeapFree(GetProcessHeap(), 0, apt);
}
*/
HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id)
{
- const BYTE *s = (const BYTE *) idstr;
+ const BYTE *s;
int i;
BYTE table[256];
- if (!s)
- s = "{00000000-0000-0000-0000-000000000000}";
- else { /* validate the CLSID string */
+ if (!idstr) {
+ memset( id, 0, sizeof (CLSID) );
+ return S_OK;
+ }
- if (strlen(s) != 38)
- return CO_E_CLASSSTRING;
+ /* validate the CLSID string */
+ if (strlen(idstr) != 38)
+ return CO_E_CLASSSTRING;
- if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
- return CO_E_CLASSSTRING;
+ s = (const BYTE *) idstr;
+ if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
+ return CO_E_CLASSSTRING;
- for (i=1; i<37; i++) {
- if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
- if (!(((s[i] >= '0') && (s[i] <= '9')) ||
- ((s[i] >= 'a') && (s[i] <= 'f')) ||
- ((s[i] >= 'A') && (s[i] <= 'F'))))
- return CO_E_CLASSSTRING;
- }
+ for (i=1; i<37; i++) {
+ if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
+ if (!(((s[i] >= '0') && (s[i] <= '9')) ||
+ ((s[i] >= 'a') && (s[i] <= 'f')) ||
+ ((s[i] >= 'A') && (s[i] <= 'F'))))
+ return CO_E_CLASSSTRING;
}
TRACE("%s -> %p\n", s, id);
if (ret == S_OK)
{
- DWORD progidlen = 0;
+ LONG progidlen = 0;
if (RegQueryValueW(hkey, NULL, NULL, &progidlen))
ret = REGDB_E_CLASSNOTREG;
HRESULT WINAPI CLSIDFromProgID16(LPCOLESTR16 progid, LPCLSID riid)
{
char *buf,buf2[80];
- DWORD buf2len;
+ LONG buf2len;
HRESULT err;
HKEY xhkey;
{
static const WCHAR clsidW[] = { '\\','C','L','S','I','D',0 };
WCHAR buf2[CHARS_IN_GUID];
- DWORD buf2len = sizeof(buf2);
+ LONG buf2len = sizeof(buf2);
HKEY xhkey;
WCHAR *buf = HeapAlloc( GetProcessHeap(),0,(strlenW(progid)+8) * sizeof(WCHAR) );
static const WCHAR wszPSC[] = {'\\','P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0};
WCHAR path[ARRAYSIZE(wszInterface) - 1 + CHARS_IN_GUID - 1 + ARRAYSIZE(wszPSC)];
WCHAR value[CHARS_IN_GUID];
- DWORD len;
+ LONG len;
HKEY hkey;
TRACE("() riid=%s, pclsid=%p\n", debugstr_guid(riid), pclsid);
}
/***********************************************************************
- * CoGetClassObject [COMPOBJ.7]
* CoGetClassObject [OLE32.@]
*
* FIXME. If request allows of several options and there is a failure
return hres;
}
+
+/***********************************************************************
+ * CoGetClassObject [COMPOBJ.7]
+ *
+ */
+HRESULT WINAPI CoGetClassObject16(
+ REFCLSID rclsid, DWORD dwClsContext, COSERVERINFO *pServerInfo,
+ REFIID iid, LPVOID *ppv)
+{
+ FIXME(", stub!\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
+
+ if (pServerInfo) {
+ FIXME("\tpServerInfo: name=%s\n",debugstr_w(pServerInfo->pwszName));
+ FIXME("\t\tpAuthInfo=%p\n",pServerInfo->pAuthInfo);
+ }
+ return E_NOTIMPL;
+}
/***********************************************************************
* CoResumeClassObjects (OLE32.@)
*
return MK_E_INVALIDEXTENSION;
}
+
/***********************************************************************
- * CoCreateInstance [COMPOBJ.13]
* CoCreateInstance [OLE32.@]
*/
HRESULT WINAPI CoCreateInstance(
return hres;
}
+/***********************************************************************
+ * CoCreateInstance [COMPOBJ.13]
+ */
+HRESULT WINAPI CoCreateInstance16(
+ REFCLSID rclsid,
+ LPUNKNOWN pUnkOuter,
+ DWORD dwClsContext,
+ REFIID iid,
+ LPVOID *ppv)
+{
+ FIXME("(%s, %p, %lx, %s, %p), stub!\n",
+ debugstr_guid(rclsid), pUnkOuter, dwClsContext, debugstr_guid(iid),
+ ppv
+ );
+ return E_NOTIMPL;
+}
+
/***********************************************************************
* CoCreateInstanceEx [OLE32.@]
*/
static const WCHAR wszAutoConvertTo[] = {'A','u','t','o','C','o','n','v','e','r','t','T','o',0};
HKEY hkey = NULL;
WCHAR buf[CHARS_IN_GUID];
- DWORD len;
+ LONG len;
HRESULT res = S_OK;
if (ERROR_SUCCESS != COM_OpenKeyForCLSID(clsidOld, KEY_READ, &hkey))
return TRUE;
}
+
+/***********************************************************************
+ * CoAllowSetForegroundWindow [OLE32.@]
+ *
+ */
+HRESULT WINAPI CoAllowSetForegroundWindow(IUnknown *pUnk, void *pvReserved)
+{
+ FIXME("(%p, %p): stub\n", pUnk, pvReserved);
+ return S_OK;
+}
/***********************************************************************
* CoQueryProxyBlanket [OLE32.@]
4 pascal CoGetMalloc(long ptr) CoGetMalloc16
5 pascal CoRegisterClassObject(ptr ptr long long ptr) CoRegisterClassObject16
6 pascal CoRevokeClassObject(long) CoRevokeClassObject16
-7 pascal CoGetClassObject(ptr long ptr ptr ptr) CoGetClassObject
+7 pascal CoGetClassObject(ptr long ptr ptr ptr) CoGetClassObject16
8 stub COMARSHALINTERFACE
9 stub COUNMARSHALINTERFACE
10 stub COLOADLIBRARY
11 stub COFREELIBRARY
12 stub COFREEALLLIBRARIES
-13 pascal CoCreateInstance(ptr ptr long ptr ptr) CoCreateInstance
+13 pascal CoCreateInstance(ptr ptr long ptr ptr) CoCreateInstance16
14 stub STRINGFROMIID
15 pascal CoDisconnectObject(ptr long) CoDisconnectObject
16 stub CORELEASEMARSHALDATA
struct list entry; /* entry in proxy_manager list (CS parent->cs) */
struct proxy_manager *parent; /* owning proxy_manager (RO) */
LPVOID iface; /* interface pointer (RO) */
+ STDOBJREF stdobjref; /* marshal data that represents this object (RO) */
IID iid; /* interface ID (RO) */
- IPID ipid; /* imported interface ID (RO) */
LPRPCPROXYBUFFER proxy; /* interface proxy (RO) */
DWORD refs; /* imported (public) references (MUTEX parent->remoting_mutex) */
IRpcChannelBuffer *chan; /* channel to object (CS parent->cs) */
struct proxy_manager
{
const IMultiQIVtbl *lpVtbl;
+ const IMarshalVtbl *lpVtblMarshal;
struct apartment *parent; /* owning apartment (RO) */
struct list entry; /* entry in apartment (CS parent->cs) */
OXID oxid; /* object exported ID (RO) */
LONG refs; /* refcount of the apartment (LOCK) */
DWORD model; /* threading model (RO) */
DWORD tid; /* thread id (RO) */
- HANDLE thread; /* thread handle (RO) */
OXID oxid; /* object exporter ID (RO) */
LONG ipidc; /* interface pointer ID counter, starts at 1 (LOCK) */
HWND win; /* message window (RO) */
} EnumMonikerImpl;
+static inline IMoniker *impl_from_IROTData( IROTData *iface )
+{
+ return (IMoniker *)((char*)iface - FIELD_OFFSET(CompositeMonikerImpl, lpvtbl2));
+}
static HRESULT EnumMonikerImpl_CreateEnumMoniker(IMoniker** tabMoniker,ULONG tabSize,ULONG currentPos,BOOL leftToRigth,IEnumMoniker ** ppmk);
VOID** ppvObject)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
static ULONG WINAPI
CompositeMonikerROTDataImpl_AddRef(IROTData *iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
*/
static ULONG WINAPI CompositeMonikerROTDataImpl_Release(IROTData* iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
/*
* List all interface VTables here
*/
- const IDataObjectVtbl* lpvtbl1;
- const IUnknownVtbl* lpvtbl2;
- const IPersistStorageVtbl* lpvtbl3;
- const IViewObject2Vtbl* lpvtbl4;
- const IOleCache2Vtbl* lpvtbl5;
- const IOleCacheControlVtbl* lpvtbl6;
+ const IDataObjectVtbl* lpVtbl;
+ const IUnknownVtbl* lpvtblNDIUnknown;
+ const IPersistStorageVtbl* lpvtblIPersistStorage;
+ const IViewObject2Vtbl* lpvtblIViewObject;
+ const IOleCache2Vtbl* lpvtblIOleCache2;
+ const IOleCacheControlVtbl* lpvtblIOleCacheControl;
/*
* Reference count of this object
* There is a version to accommodate all of the VTables implemented
* by this object.
*/
-#define _ICOM_THIS_From_IDataObject(class,name) class* this = (class*)name
-#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
-#define _ICOM_THIS_From_IPersistStorage(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
-#define _ICOM_THIS_From_IViewObject2(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
-#define _ICOM_THIS_From_IOleCache2(class, name) class* this = (class*)(((char*)name)-4*sizeof(void*))
-#define _ICOM_THIS_From_IOleCacheControl(class, name) class* this = (class*)(((char*)name)-5*sizeof(void*))
+
+static inline DataCache *impl_from_IDataObject( IDataObject *iface )
+{
+ return (DataCache *)((char*)iface - FIELD_OFFSET(DataCache, lpVtbl));
+}
+
+static inline DataCache *impl_from_NDIUnknown( IUnknown *iface )
+{
+ return (DataCache *)((char*)iface - FIELD_OFFSET(DataCache, lpvtblNDIUnknown));
+}
+
+static inline DataCache *impl_from_IPersistStorage( IPersistStorage *iface )
+{
+ return (DataCache *)((char*)iface - FIELD_OFFSET(DataCache, lpvtblIPersistStorage));
+}
+
+static inline DataCache *impl_from_IViewObject2( IViewObject2 *iface )
+{
+ return (DataCache *)((char*)iface - FIELD_OFFSET(DataCache, lpvtblIViewObject));
+}
+
+static inline DataCache *impl_from_IOleCache2( IOleCache2 *iface )
+{
+ return (DataCache *)((char*)iface - FIELD_OFFSET(DataCache, lpvtblIOleCache2));
+}
+
+static inline DataCache *impl_from_IOleCacheControl( IOleCacheControl *iface )
+{
+ return (DataCache *)((char*)iface - FIELD_OFFSET(DataCache, lpvtblIOleCacheControl));
+}
+
/*
* Prototypes for the methods of the DataCache class.
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_NDIUnknown(DataCache, iface);
+ DataCache *this = impl_from_NDIUnknown(iface);
/*
* Perform a sanity check on the parameters.
}
else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
{
- *ppvObject = (IDataObject*)&(this->lpvtbl1);
+ *ppvObject = (IDataObject*)&(this->lpVtbl);
}
else if ( (memcmp(&IID_IPersistStorage, riid, sizeof(IID_IPersistStorage)) == 0) ||
(memcmp(&IID_IPersist, riid, sizeof(IID_IPersist)) == 0) )
{
- *ppvObject = (IPersistStorage*)&(this->lpvtbl3);
+ *ppvObject = (IPersistStorage*)&(this->lpvtblIPersistStorage);
}
else if ( (memcmp(&IID_IViewObject, riid, sizeof(IID_IViewObject)) == 0) ||
(memcmp(&IID_IViewObject2, riid, sizeof(IID_IViewObject2)) == 0) )
{
- *ppvObject = (IViewObject2*)&(this->lpvtbl4);
+ *ppvObject = (IViewObject2*)&(this->lpvtblIViewObject);
}
else if ( (memcmp(&IID_IOleCache, riid, sizeof(IID_IOleCache)) == 0) ||
(memcmp(&IID_IOleCache2, riid, sizeof(IID_IOleCache2)) == 0) )
{
- *ppvObject = (IOleCache2*)&(this->lpvtbl5);
+ *ppvObject = (IOleCache2*)&(this->lpvtblIOleCache2);
}
else if (memcmp(&IID_IOleCacheControl, riid, sizeof(IID_IOleCacheControl)) == 0)
{
- *ppvObject = (IOleCacheControl*)&(this->lpvtbl6);
+ *ppvObject = (IOleCacheControl*)&(this->lpvtblIOleCacheControl);
}
/*
static ULONG WINAPI DataCache_NDIUnknown_AddRef(
IUnknown* iface)
{
- _ICOM_THIS_From_NDIUnknown(DataCache, iface);
+ DataCache *this = impl_from_NDIUnknown(iface);
return InterlockedIncrement(&this->ref);
}
static ULONG WINAPI DataCache_NDIUnknown_Release(
IUnknown* iface)
{
- _ICOM_THIS_From_NDIUnknown(DataCache, iface);
+ DataCache *this = impl_from_NDIUnknown(iface);
ULONG ref;
/*
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IDataObject(DataCache, iface);
+ DataCache *this = impl_from_IDataObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DataCache_IDataObject_AddRef(
IDataObject* iface)
{
- _ICOM_THIS_From_IDataObject(DataCache, iface);
+ DataCache *this = impl_from_IDataObject(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DataCache_IDataObject_Release(
IDataObject* iface)
{
- _ICOM_THIS_From_IDataObject(DataCache, iface);
+ DataCache *this = impl_from_IDataObject(iface);
return IUnknown_Release(this->outerUnknown);
}
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IPersistStorage(DataCache, iface);
+ DataCache *this = impl_from_IPersistStorage(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DataCache_IPersistStorage_AddRef(
IPersistStorage* iface)
{
- _ICOM_THIS_From_IPersistStorage(DataCache, iface);
+ DataCache *this = impl_from_IPersistStorage(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DataCache_IPersistStorage_Release(
IPersistStorage* iface)
{
- _ICOM_THIS_From_IPersistStorage(DataCache, iface);
+ DataCache *this = impl_from_IPersistStorage(iface);
return IUnknown_Release(this->outerUnknown);
}
IPersistStorage* iface,
IStorage* pStg)
{
- _ICOM_THIS_From_IPersistStorage(DataCache, iface);
+ DataCache *this = impl_from_IPersistStorage(iface);
TRACE("(%p, %p)\n", iface, pStg);
IStorage* pStg,
BOOL fSameAsLoad)
{
- _ICOM_THIS_From_IPersistStorage(DataCache, iface);
+ DataCache *this = impl_from_IPersistStorage(iface);
TRACE("(%p, %p, %d)\n", iface, pStg, fSameAsLoad);
static HRESULT WINAPI DataCache_HandsOffStorage(
IPersistStorage* iface)
{
- _ICOM_THIS_From_IPersistStorage(DataCache, iface);
+ DataCache *this = impl_from_IPersistStorage(iface);
TRACE("(%p)\n", iface);
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DataCache_IViewObject2_AddRef(
IViewObject2* iface)
{
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DataCache_IViewObject2_Release(
IViewObject2* iface)
{
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
return IUnknown_Release(this->outerUnknown);
}
HMETAFILE presMetafile = 0;
HRESULT hres;
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
TRACE("(%p, %lx, %ld, %p, %p, %p, %p, %p, %p, %lx)\n",
iface,
DWORD advf,
IAdviseSink* pAdvSink)
{
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
TRACE("(%p, %lx, %lx, %p)\n", iface, aspects, advf, pAdvSink);
DWORD* pAdvf,
IAdviseSink** ppAdvSink)
{
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
TRACE("(%p, %p, %p, %p)\n", iface, pAspects, pAdvf, ppAdvSink);
PresentationDataHeader presData;
HRESULT hres = E_FAIL;
- _ICOM_THIS_From_IViewObject2(DataCache, iface);
+ DataCache *this = impl_from_IViewObject2(iface);
TRACE("(%p, %lx, %ld, %p, %p)\n",
iface, dwDrawAspect, lindex, ptd, lpsizel);
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IOleCache2(DataCache, iface);
+ DataCache *this = impl_from_IOleCache2(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DataCache_IOleCache2_AddRef(
IOleCache2* iface)
{
- _ICOM_THIS_From_IOleCache2(DataCache, iface);
+ DataCache *this = impl_from_IOleCache2(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DataCache_IOleCache2_Release(
IOleCache2* iface)
{
- _ICOM_THIS_From_IOleCache2(DataCache, iface);
+ DataCache *this = impl_from_IOleCache2(iface);
return IUnknown_Release(this->outerUnknown);
}
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
+ DataCache *this = impl_from_IOleCacheControl(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DataCache_IOleCacheControl_AddRef(
IOleCacheControl* iface)
{
- _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
+ DataCache *this = impl_from_IOleCacheControl(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DataCache_IOleCacheControl_Release(
IOleCacheControl* iface)
{
- _ICOM_THIS_From_IOleCacheControl(DataCache, iface);
+ DataCache *this = impl_from_IOleCacheControl(iface);
return IUnknown_Release(this->outerUnknown);
}
/*
* Make sure it supports the interface required by the caller.
*/
- hr = IUnknown_QueryInterface((IUnknown*)&(newCache->lpvtbl2), riid, ppvObj);
+ hr = IUnknown_QueryInterface((IUnknown*)&(newCache->lpvtblNDIUnknown), riid, ppvObj);
/*
* Release the reference obtained in the constructor. If
* the QueryInterface was unsuccessful, it will free the class.
*/
- IUnknown_Release((IUnknown*)&(newCache->lpvtbl2));
+ IUnknown_Release((IUnknown*)&(newCache->lpvtblNDIUnknown));
return hr;
}
/*
* Initialize the virtual function table.
*/
- newObject->lpvtbl1 = &DataCache_IDataObject_VTable;
- newObject->lpvtbl2 = &DataCache_NDIUnknown_VTable;
- newObject->lpvtbl3 = &DataCache_IPersistStorage_VTable;
- newObject->lpvtbl4 = &DataCache_IViewObject2_VTable;
- newObject->lpvtbl5 = &DataCache_IOleCache2_VTable;
- newObject->lpvtbl6 = &DataCache_IOleCacheControl_VTable;
+ newObject->lpVtbl = &DataCache_IDataObject_VTable;
+ newObject->lpvtblNDIUnknown = &DataCache_NDIUnknown_VTable;
+ newObject->lpvtblIPersistStorage = &DataCache_IPersistStorage_VTable;
+ newObject->lpvtblIViewObject = &DataCache_IViewObject2_VTable;
+ newObject->lpvtblIOleCache2 = &DataCache_IOleCache2_VTable;
+ newObject->lpvtblIOleCacheControl = &DataCache_IOleCacheControl_VTable;
/*
* Start with one reference count. The caller of this function
* lifetime.
*/
if (pUnkOuter==NULL)
- pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
+ pUnkOuter = (IUnknown*)&(newObject->lpvtblNDIUnknown);
newObject->outerUnknown = pUnkOuter;
/*
* List all interface VTables here
*/
- const IOleObjectVtbl* lpvtbl1;
- const IUnknownVtbl* lpvtbl2;
- const IDataObjectVtbl* lpvtbl3;
- const IRunnableObjectVtbl* lpvtbl4;
+ const IOleObjectVtbl* lpVtbl;
+ const IUnknownVtbl* lpvtblIUnknown;
+ const IDataObjectVtbl* lpvtblIDataObject;
+ const IRunnableObjectVtbl* lpvtblIRunnableObject;
/*
* Reference count of this object
/*
* IUnknown implementation of the outer object.
- */
+p */
IUnknown* outerUnknown;
/*
typedef struct DefaultHandler DefaultHandler;
/*
- * Here, I define utility macros to help with the casting of the
+ * Here, I define utility functions to help with the casting of the
* "this" parameter.
* There is a version to accommodate all of the VTables implemented
* by this object.
*/
-#define _ICOM_THIS_From_IOleObject(class,name) class* this = (class*)name
-#define _ICOM_THIS_From_NDIUnknown(class, name) class* this = (class*)(((char*)name)-sizeof(void*))
-#define _ICOM_THIS_From_IDataObject(class, name) class* this = (class*)(((char*)name)-2*sizeof(void*))
-#define _ICOM_THIS_From_IRunnableObject(class, name) class* this = (class*)(((char*)name)-3*sizeof(void*))
+static inline DefaultHandler *impl_from_IOleObject( IOleObject *iface )
+{
+ return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpVtbl));
+}
+
+static inline DefaultHandler *impl_from_NDIUnknown( IUnknown *iface )
+{
+ return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIUnknown));
+}
+
+static inline DefaultHandler *impl_from_IDataObject( IDataObject *iface )
+{
+ return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIDataObject));
+}
+
+static inline DefaultHandler *impl_from_IRunnableObject( IRunnableObject *iface )
+{
+ return (DefaultHandler *)((char*)iface - FIELD_OFFSET(DefaultHandler, lpvtblIRunnableObject));
+}
+
/*
* Prototypes for the methods of the DefaultHandler class.
/*
* Make sure it supports the interface required by the caller.
*/
- hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtbl2), riid, ppvObj);
+ hr = IUnknown_QueryInterface((IUnknown*)&(newHandler->lpvtblIUnknown), riid, ppvObj);
/*
* Release the reference obtained in the constructor. If
* the QueryInterface was unsuccessful, it will free the class.
*/
- IUnknown_Release((IUnknown*)&(newHandler->lpvtbl2));
+ IUnknown_Release((IUnknown*)&(newHandler->lpvtblIUnknown));
return hr;
}
/*
* Initialize the virtual function table.
*/
- newObject->lpvtbl1 = &DefaultHandler_IOleObject_VTable;
- newObject->lpvtbl2 = &DefaultHandler_NDIUnknown_VTable;
- newObject->lpvtbl3 = &DefaultHandler_IDataObject_VTable;
- newObject->lpvtbl4 = &DefaultHandler_IRunnableObject_VTable;
+ newObject->lpVtbl = &DefaultHandler_IOleObject_VTable;
+ newObject->lpvtblIUnknown = &DefaultHandler_NDIUnknown_VTable;
+ newObject->lpvtblIDataObject = &DefaultHandler_IDataObject_VTable;
+ newObject->lpvtblIRunnableObject = &DefaultHandler_IRunnableObject_VTable;
/*
* Start with one reference count. The caller of this function
* lifetime.
*/
if (pUnkOuter==NULL)
- pUnkOuter = (IUnknown*)&(newObject->lpvtbl2);
+ pUnkOuter = (IUnknown*)&(newObject->lpvtblIUnknown);
newObject->outerUnknown = pUnkOuter;
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_NDIUnknown(iface);
/*
* Perform a sanity check on the parameters.
}
else if (memcmp(&IID_IOleObject, riid, sizeof(IID_IOleObject)) == 0)
{
- *ppvObject = (IOleObject*)&(this->lpvtbl1);
+ *ppvObject = (IOleObject*)&(this->lpVtbl);
}
else if (memcmp(&IID_IDataObject, riid, sizeof(IID_IDataObject)) == 0)
{
- *ppvObject = (IDataObject*)&(this->lpvtbl3);
+ *ppvObject = (IDataObject*)&(this->lpvtblIDataObject);
}
else if (memcmp(&IID_IRunnableObject, riid, sizeof(IID_IRunnableObject)) == 0)
{
- *ppvObject = (IRunnableObject*)&(this->lpvtbl4);
+ *ppvObject = (IRunnableObject*)&(this->lpvtblIRunnableObject);
}
else
{
static ULONG WINAPI DefaultHandler_NDIUnknown_AddRef(
IUnknown* iface)
{
- _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_NDIUnknown(iface);
return InterlockedIncrement(&this->ref);
}
static ULONG WINAPI DefaultHandler_NDIUnknown_Release(
IUnknown* iface)
{
- _ICOM_THIS_From_NDIUnknown(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_NDIUnknown(iface);
ULONG ref;
/*
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DefaultHandler_AddRef(
IOleObject* iface)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DefaultHandler_Release(
IOleObject* iface)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
return IUnknown_Release(this->outerUnknown);
}
IOleObject* iface,
IOleClientSite* pClientSite)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, pClientSite);
IOleObject* iface,
IOleClientSite** ppClientSite)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
/*
* Sanity check.
LPCOLESTR szContainerApp,
LPCOLESTR szContainerObj)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %s, %s)\n",
iface,
DWORD dwWhichMoniker,
IMoniker** ppmk)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %ld, %ld, %p)\n",
iface, dwAssign, dwWhichMoniker, ppmk);
IOleObject* iface,
IEnumOLEVERB** ppEnumOleVerb)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, ppEnumOleVerb);
IOleObject* iface,
CLSID* pClsid)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, pClsid);
DWORD dwFormOfType,
LPOLESTR* pszUserType)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %ld, %p)\n", iface, dwFormOfType, pszUserType);
IViewObject2* cacheView = NULL;
HRESULT hres;
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %lx, %p)\n", iface, dwDrawAspect, psizel);
DWORD* pdwConnection)
{
HRESULT hres = S_OK;
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %p, %p)\n", iface, pAdvSink, pdwConnection);
IOleObject* iface,
DWORD dwConnection)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %ld)\n", iface, dwConnection);
IOleObject* iface,
IEnumSTATDATA** ppenumAdvise)
{
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %p)\n", iface, ppenumAdvise);
DWORD* pdwStatus)
{
HRESULT hres;
- _ICOM_THIS_From_IOleObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IOleObject(iface);
TRACE("(%p, %lx, %p)\n", iface, dwAspect, pdwStatus);
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DefaultHandler_IDataObject_AddRef(
IDataObject* iface)
{
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DefaultHandler_IDataObject_Release(
IDataObject* iface)
{
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
return IUnknown_Release(this->outerUnknown);
}
IDataObject* cacheDataObject = NULL;
HRESULT hres;
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %p, %p)\n", iface, pformatetcIn, pmedium);
IDataObject* cacheDataObject = NULL;
HRESULT hres;
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %p)\n", iface, pformatetc);
IDataObject* cacheDataObject = NULL;
HRESULT hres;
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %p, %p, %d)\n", iface, pformatetc, pmedium, fRelease);
IEnumFORMATETC** ppenumFormatEtc)
{
HRESULT hres;
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %lx, %p)\n", iface, dwDirection, ppenumFormatEtc);
DWORD* pdwConnection)
{
HRESULT hres = S_OK;
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %p, %ld, %p, %p)\n",
iface, pformatetc, advf, pAdvSink, pdwConnection);
IDataObject* iface,
DWORD dwConnection)
{
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %ld)\n", iface, dwConnection);
IDataObject* iface,
IEnumSTATDATA** ppenumAdvise)
{
- _ICOM_THIS_From_IDataObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IDataObject(iface);
TRACE("(%p, %p)\n", iface, ppenumAdvise);
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IRunnableObject(iface);
return IUnknown_QueryInterface(this->outerUnknown, riid, ppvObject);
}
static ULONG WINAPI DefaultHandler_IRunnableObject_AddRef(
IRunnableObject* iface)
{
- _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IRunnableObject(iface);
return IUnknown_AddRef(this->outerUnknown);
}
static ULONG WINAPI DefaultHandler_IRunnableObject_Release(
IRunnableObject* iface)
{
- _ICOM_THIS_From_IRunnableObject(DefaultHandler, iface);
+ DefaultHandler *this = impl_from_IRunnableObject(iface);
return IUnknown_Release(this->outerUnknown);
}
/*
converts an object pointer to This
*/
-#define _IErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtei)))
-#define _ICOM_THIS_From_IErrorInfo(class, name) class* This = (class*)(((char*)name)-_IErrorInfo_Offset)
-#define _ICreateErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtcei)))
-#define _ICOM_THIS_From_ICreateErrorInfo(class, name) class* This = (class*)(((char*)name)-_ICreateErrorInfo_Offset)
+static inline ErrorInfoImpl *impl_from_IErrorInfo( IErrorInfo *iface )
+{
+ return (ErrorInfoImpl *)((char*)iface - FIELD_OFFSET(ErrorInfoImpl, lpvtei));
+}
+
+static inline ErrorInfoImpl *impl_from_ICreateErrorInfo( ICreateErrorInfo *iface )
+{
+ return (ErrorInfoImpl *)((char*)iface - FIELD_OFFSET(ErrorInfoImpl, lpvtcei));
+}
+
+static inline ErrorInfoImpl *impl_from_ISupportErrorInfo( ISupportErrorInfo *iface )
+{
+ return (ErrorInfoImpl *)((char*)iface - FIELD_OFFSET(ErrorInfoImpl, lpvtsei));
+}
-#define _ISupportErrorInfo_Offset ((int)(&(((ErrorInfoImpl*)0)->lpvtsei)))
-#define _ICOM_THIS_From_ISupportErrorInfo(class, name) class* This = (class*)(((char*)name)-_ISupportErrorInfo_Offset)
/*
converts This to an object pointer
REFIID riid,
VOID** ppvoid)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(\n\tIID:\t%s,%p)\n",This,debugstr_guid(riid),ppvoid);
*ppvoid = NULL;
static ULONG WINAPI IErrorInfoImpl_AddRef(
IErrorInfo* iface)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(count=%lu)\n",This,This->ref);
return InterlockedIncrement(&This->ref);
}
static ULONG WINAPI IErrorInfoImpl_Release(
IErrorInfo* iface)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
ULONG ref = InterlockedDecrement(&This->ref);
TRACE("(%p)->(count=%lu)\n",This,ref+1);
IErrorInfo* iface,
GUID * pGUID)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(count=%lu)\n",This,This->ref);
if(!pGUID )return E_INVALIDARG;
memcpy(pGUID, &This->m_Guid, sizeof(GUID));
IErrorInfo* iface,
BSTR *pBstrSource)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(pBstrSource=%p)\n",This,pBstrSource);
if (pBstrSource == NULL)
return E_INVALIDARG;
IErrorInfo* iface,
BSTR *pBstrDescription)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(pBstrDescription=%p)\n",This,pBstrDescription);
if (pBstrDescription == NULL)
IErrorInfo* iface,
BSTR *pBstrHelpFile)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(pBstrHelpFile=%p)\n",This, pBstrHelpFile);
if (pBstrHelpFile == NULL)
IErrorInfo* iface,
DWORD *pdwHelpContext)
{
- _ICOM_THIS_From_IErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_IErrorInfo(iface);
TRACE("(%p)->(pdwHelpContext=%p)\n",This, pdwHelpContext);
if (pdwHelpContext == NULL)
return E_INVALIDARG;
REFIID riid,
VOID** ppvoid)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p)\n", This);
return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
}
static ULONG WINAPI ICreateErrorInfoImpl_AddRef(
ICreateErrorInfo* iface)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p)\n", This);
return IErrorInfo_AddRef(_IErrorInfo_(This));
}
static ULONG WINAPI ICreateErrorInfoImpl_Release(
ICreateErrorInfo* iface)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p)\n", This);
return IErrorInfo_Release(_IErrorInfo_(This));
}
ICreateErrorInfo* iface,
REFGUID rguid)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p)->(%s)\n", This, debugstr_guid(rguid));
memcpy(&This->m_Guid, rguid, sizeof(GUID));
return S_OK;
ICreateErrorInfo* iface,
LPOLESTR szSource)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p): %s\n",This, debugstr_w(szSource));
if (This->bstrSource != NULL)
ERRORINFO_SysFreeString(This->bstrSource);
ICreateErrorInfo* iface,
LPOLESTR szDescription)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p): %s\n",This, debugstr_w(szDescription));
if (This->bstrDescription != NULL)
ERRORINFO_SysFreeString(This->bstrDescription);
ICreateErrorInfo* iface,
LPOLESTR szHelpFile)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p,%s)\n",This,debugstr_w(szHelpFile));
if (This->bstrHelpFile != NULL)
ERRORINFO_SysFreeString(This->bstrHelpFile);
ICreateErrorInfo* iface,
DWORD dwHelpContext)
{
- _ICOM_THIS_From_ICreateErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ICreateErrorInfo(iface);
TRACE("(%p,%ld)\n",This,dwHelpContext);
This->m_dwHelpContext = dwHelpContext;
return S_OK;
REFIID riid,
VOID** ppvoid)
{
- _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
TRACE("(%p)\n", This);
return IErrorInfo_QueryInterface(_IErrorInfo_(This), riid, ppvoid);
static ULONG WINAPI ISupportErrorInfoImpl_AddRef(
ISupportErrorInfo* iface)
{
- _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
TRACE("(%p)\n", This);
return IErrorInfo_AddRef(_IErrorInfo_(This));
}
static ULONG WINAPI ISupportErrorInfoImpl_Release(
ISupportErrorInfo* iface)
{
- _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
TRACE("(%p)\n", This);
return IErrorInfo_Release(_IErrorInfo_(This));
}
ISupportErrorInfo* iface,
REFIID riid)
{
- _ICOM_THIS_From_ISupportErrorInfo(ErrorInfoImpl, iface);
+ ErrorInfoImpl *This = impl_from_ISupportErrorInfo(iface);
TRACE("(%p)->(%s)\n", This, debugstr_guid(riid));
return (IsEqualIID(riid, &This->m_Guid)) ? S_OK : S_FALSE;
}
IUnknown *pMarshal; /* custom marshaler */
} FileMonikerImpl;
+static inline IMoniker *impl_from_IROTData( IROTData *iface )
+{
+ return (IMoniker *)((char*)iface - FIELD_OFFSET(FileMonikerImpl, lpvtbl2));
+}
+
/* Local function used by filemoniker implementation */
static HRESULT WINAPI FileMonikerImpl_Construct(FileMonikerImpl* iface, LPCOLESTR lpszPathName);
static HRESULT WINAPI FileMonikerImpl_Destroy(FileMonikerImpl* iface);
FileMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p,%s,%p)\n",This,debugstr_guid(riid),ppvObject);
static ULONG WINAPI
FileMonikerROTDataImpl_AddRef(IROTData *iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",This);
static ULONG WINAPI
FileMonikerROTDataImpl_Release(IROTData* iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",This);
FileMonikerROTDataImpl_GetComparisonData(IROTData* iface, BYTE* pbData,
ULONG cbMax, ULONG* pcbData)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
FileMonikerImpl *This1 = (FileMonikerImpl *)This;
int len = (strlenW(This1->filePathName)+1);
int i;
#define _IFTMUnknown_(This)(IUnknown*)&(This->lpVtbl)
#define _IFTMarshal_(This) (IMarshal*)&(This->lpvtblFTM)
-#define _IFTMarshall_Offset ((int)(&(((FTMarshalImpl*)0)->lpvtblFTM)))
-#define _ICOM_THIS_From_IFTMarshal(class, name) class* This = (class*)(((char*)name)-_IFTMarshall_Offset);
+static inline FTMarshalImpl *impl_from_IMarshal( IMarshal *iface )
+{
+ return (FTMarshalImpl *)((char*)iface - FIELD_OFFSET(FTMarshalImpl, lpvtblFTM));
+}
/* inner IUnknown to handle aggregation */
static HRESULT WINAPI
FTMarshalImpl_QueryInterface (LPMARSHAL iface, REFIID riid, LPVOID * ppv)
{
- _ICOM_THIS_From_IFTMarshal (FTMarshalImpl, iface);
+ FTMarshalImpl *This = impl_from_IMarshal(iface);
TRACE ("(%p)->(\n\tIID:\t%s,%p)\n", This, debugstr_guid (riid), ppv);
return IUnknown_QueryInterface (This->pUnkOuter, riid, ppv);
FTMarshalImpl_AddRef (LPMARSHAL iface)
{
- _ICOM_THIS_From_IFTMarshal (FTMarshalImpl, iface);
+ FTMarshalImpl *This = impl_from_IMarshal(iface);
TRACE ("\n");
return IUnknown_AddRef (This->pUnkOuter);
FTMarshalImpl_Release (LPMARSHAL iface)
{
- _ICOM_THIS_From_IFTMarshal (FTMarshalImpl, iface);
+ FTMarshalImpl *This = impl_from_IMarshal(iface);
TRACE ("\n");
return IUnknown_Release (This->pUnkOuter);
IMarshal *pMarshal = NULL;
HRESULT hres;
- _ICOM_THIS_From_IFTMarshal (FTMarshalImpl, iface);
+ FTMarshalImpl *This = impl_from_IMarshal(iface);
FIXME ("(), stub!\n");
IMarshal *pMarshal = NULL;
HRESULT hres;
- _ICOM_THIS_From_IFTMarshal (FTMarshalImpl, iface);
+ FTMarshalImpl *This = impl_from_IMarshal(iface);
FIXME ("(), stub!\n");
*/
#undef INTERFACE
+typedef struct IMalloc16 *LPMALLOC16;
+
#define INTERFACE IMalloc16
DECLARE_INTERFACE_(IMalloc16,IUnknown)
{
/**********************************************************************/
+typedef struct ILockBytes16 *LPLOCKBYTES16;
+
#define INTERFACE ILockBytes16
DECLARE_INTERFACE_(ILockBytes16,IUnknown)
{
DWORD reserved;
} STATSTG16;
+typedef struct IStream16 *LPSTREAM16;
+
#define INTERFACE IStream16
DECLARE_INTERFACE_(IStream16,ISequentialStream)
{
typedef OLECHAR16 **SNB16;
+typedef struct IStorage16 *LPSTORAGE16;
+
#define INTERFACE IStorage16
DECLARE_INTERFACE_(IStorage16,IUnknown)
{
IUnknown *pMarshal; /* custom marshaler */
} ItemMonikerImpl;
+static inline IMoniker *impl_from_IROTData( IROTData *iface )
+{
+ return (IMoniker *)((char*)iface - FIELD_OFFSET(ItemMonikerImpl, lpvtbl2));
+}
+
/********************************************************************************/
/* ItemMoniker prototype functions : */
HRESULT WINAPI ItemMonikerROTDataImpl_QueryInterface(IROTData *iface,REFIID riid,VOID** ppvObject)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p,%p,%p)\n",iface,riid,ppvObject);
*/
ULONG WINAPI ItemMonikerROTDataImpl_AddRef(IROTData *iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
*/
ULONG WINAPI ItemMonikerROTDataImpl_Release(IROTData* iface)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
TRACE("(%p)\n",iface);
ULONG cbMax,
ULONG* pcbData)
{
- ICOM_THIS_From_IROTData(IMoniker, iface);
+ IMoniker *This = impl_from_IROTData(iface);
ItemMonikerImpl *This1 = (ItemMonikerImpl *)This;
int len = (strlenW(This1->itemName)+1);
int i;
/* get the ipid of the first entry */
/* FIXME: should we implement ClientIdentity on the ifproxies instead
* of the proxy_manager so we use the correct ipid here? */
- ipid = &LIST_ENTRY(list_head(&This->interfaces), struct ifproxy, entry)->ipid;
+ ipid = &LIST_ENTRY(list_head(&This->interfaces), struct ifproxy, entry)->stdobjref.ipid;
/* get IRemUnknown proxy so we can communicate with the remote object */
hr = proxy_manager_get_remunknown(This, &remunk);
ClientIdentity_QueryMultipleInterfaces
};
+static HRESULT WINAPI Proxy_QueryInterface(IMarshal *iface, REFIID riid, void **ppvObject)
+{
+ ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ return IMultiQI_QueryInterface((IMultiQI *)&This->lpVtbl, riid, ppvObject);
+}
+
+static ULONG WINAPI Proxy_AddRef(IMarshal *iface)
+{
+ ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ return IMultiQI_AddRef((IMultiQI *)&This->lpVtbl);
+}
+
+/* FIXME: remove these */
+static HRESULT WINAPI StdMarshalImpl_GetUnmarshalClass(LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext, void* pvDestContext, DWORD mshlflags, CLSID* pCid);
+static HRESULT WINAPI StdMarshalImpl_GetMarshalSizeMax(LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext, void* pvDestContext, DWORD mshlflags, DWORD* pSize);
+static HRESULT WINAPI StdMarshalImpl_UnmarshalInterface(LPMARSHAL iface, IStream *pStm, REFIID riid, void **ppv);
+static HRESULT WINAPI StdMarshalImpl_ReleaseMarshalData(LPMARSHAL iface, IStream *pStm);
+static HRESULT WINAPI StdMarshalImpl_DisconnectObject(LPMARSHAL iface, DWORD dwReserved);
+
+static ULONG WINAPI Proxy_Release(IMarshal *iface)
+{
+ ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ return IMultiQI_Release((IMultiQI *)&This->lpVtbl);
+}
+
+static HRESULT WINAPI Proxy_MarshalInterface(
+ LPMARSHAL iface, IStream *pStm, REFIID riid, void* pv, DWORD dwDestContext,
+ void* pvDestContext, DWORD mshlflags)
+{
+ ICOM_THIS_MULTI(struct proxy_manager, lpVtblMarshal, iface);
+ ULONG res;
+ HRESULT hr;
+ STDOBJREF stdobjref;
+ struct ifproxy *ifproxy;
+
+ TRACE("(...,%s,...)\n", debugstr_guid(riid));
+
+ hr = proxy_manager_find_ifproxy(This, riid, &ifproxy);
+ if (FAILED(hr))
+ {
+ ERR("couldn't find proxy for interface %s, error 0x%08lx\n", debugstr_guid(riid), hr);
+ return hr;
+ }
+
+ stdobjref = ifproxy->stdobjref;
+ /* FIXME: optimization - share out proxy's public references if possible
+ * instead of making new proxy do a roundtrip through the server */
+ stdobjref.cPublicRefs = 0; /* InterlockedDecrement(&This->stdobjref.cPublicRefs) >= 0 ? 1 : 0 */
+ hr = IStream_Write(pStm, &stdobjref, sizeof(stdobjref), &res);
+
+ return hr;
+}
+
+static const IMarshalVtbl ProxyMarshal_Vtbl =
+{
+ Proxy_QueryInterface,
+ Proxy_AddRef,
+ Proxy_Release,
+ StdMarshalImpl_GetUnmarshalClass,
+ StdMarshalImpl_GetMarshalSizeMax,
+ Proxy_MarshalInterface,
+ StdMarshalImpl_UnmarshalInterface,
+ StdMarshalImpl_ReleaseMarshalData,
+ StdMarshalImpl_DisconnectObject
+};
+
static HRESULT ifproxy_get_public_ref(struct ifproxy * This)
{
HRESULT hr = S_OK;
{
HRESULT hrref;
REMINTERFACEREF rif;
- rif.ipid = This->ipid;
+ rif.ipid = This->stdobjref.ipid;
rif.cPublicRefs = NORMALEXTREFS;
rif.cPrivateRefs = 0;
hr = IRemUnknown_RemAddRef(remunk, 1, &rif, &hrref);
if (hr == S_OK)
{
REMINTERFACEREF rif;
- rif.ipid = This->ipid;
+ rif.ipid = This->stdobjref.ipid;
rif.cPublicRefs = This->refs;
rif.cPrivateRefs = 0;
hr = IRemUnknown_RemRelease(remunk, 1, &rif);
}
This->lpVtbl = &ClientIdentity_Vtbl;
+ This->lpVtblMarshal = &ProxyMarshal_Vtbl;
list_init(&This->entry);
list_init(&This->interfaces);
IsEqualIID(riid, &IID_IMultiQI))
{
*ppv = (void *)&This->lpVtbl;
- IMultiQI_AddRef((IMultiQI *)&This->lpVtbl);
+ IUnknown_AddRef((IUnknown *)*ppv);
+ return S_OK;
+ }
+ if (IsEqualIID(riid, &IID_IMarshal))
+ {
+ *ppv = (void *)&This->lpVtblMarshal;
+ IUnknown_AddRef((IUnknown *)*ppv);
return S_OK;
}
+ if (IsEqualIID(riid, &IID_IClientSecurity))
+ {
+ FIXME("requesting IClientSecurity, but it is unimplemented\n");
+ *ppv = NULL;
+ return E_NOINTERFACE;
+ }
hr = proxy_manager_find_ifproxy(This, riid, &ifproxy);
if (hr == S_OK)
}
static HRESULT proxy_manager_create_ifproxy(
- struct proxy_manager * This, const IPID *ipid, REFIID riid, ULONG cPublicRefs,
+ struct proxy_manager * This, const STDOBJREF *stdobjref, REFIID riid,
IRpcChannelBuffer * channel, struct ifproxy ** iif_out)
{
HRESULT hr;
list_init(&ifproxy->entry);
ifproxy->parent = This;
- ifproxy->ipid = *ipid;
+ ifproxy->stdobjref = *stdobjref;
ifproxy->iid = *riid;
- ifproxy->refs = cPublicRefs;
+ ifproxy->refs = stdobjref->cPublicRefs;
ifproxy->proxy = NULL;
assert(channel);
*iif_out = ifproxy;
TRACE("ifproxy %p created for IPID %s, interface %s with %lu public refs\n",
- ifproxy, debugstr_guid(ipid), debugstr_guid(riid), cPublicRefs);
+ ifproxy, debugstr_guid(&stdobjref->ipid), debugstr_guid(riid), stdobjref->cPublicRefs);
}
else
ifproxy_destroy(ifproxy);
IRpcChannelBuffer *chanbuf;
hr = RPC_CreateClientChannel(&stdobjref->oxid, &stdobjref->ipid, &chanbuf);
if (hr == S_OK)
- hr = proxy_manager_create_ifproxy(proxy_manager, &stdobjref->ipid,
- riid, stdobjref->cPublicRefs,
- chanbuf, &ifproxy);
+ hr = proxy_manager_create_ifproxy(proxy_manager, stdobjref,
+ riid, chanbuf, &ifproxy);
}
if (hr == S_OK)
{
- /* FIXME: push this AddRef inside proxy_manager_find_ifproxy/create_ifproxy? */
ClientIdentity_AddRef((IMultiQI*)&proxy_manager->lpVtbl);
*object = ifproxy->iface;
}
/* unref the ifstub. FIXME: only do this on success? */
if (!stub_manager_is_table_marshaled(stubmgr))
- stub_manager_ext_release(stubmgr, 1);
+ stub_manager_ext_release(stubmgr, stdobjref.cPublicRefs);
stub_manager_int_release(stubmgr);
return hres;
/* Shared implementation of moniker marshaler based on saving and loading of
* monikers */
-#define ICOM_THIS_From_IMoniker(class, name) class* This = (class*)(((char*)name)-FIELD_OFFSET(class, lpVtblMarshal))
-
typedef struct MonikerMarshal
{
const IUnknownVtbl *lpVtbl;
IMoniker *moniker;
} MonikerMarshal;
+static inline MonikerMarshal *impl_from_IMarshal( IMarshal *iface )
+{
+ return (MonikerMarshal *)((char*)iface - FIELD_OFFSET(MonikerMarshal, lpVtblMarshal));
+}
+
static HRESULT WINAPI MonikerMarshalInner_QueryInterface(IUnknown *iface, REFIID riid, LPVOID *ppv)
{
MonikerMarshal *This = (MonikerMarshal *)iface;
static HRESULT WINAPI MonikerMarshal_QueryInterface(IMarshal *iface, REFIID riid, LPVOID *ppv)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
return IMoniker_QueryInterface(This->moniker, riid, ppv);
}
static ULONG WINAPI MonikerMarshal_AddRef(IMarshal *iface)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
return IMoniker_AddRef(This->moniker);
}
static ULONG WINAPI MonikerMarshal_Release(IMarshal *iface)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
return IMoniker_Release(This->moniker);
}
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags, CLSID* pCid)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
TRACE("(%s, %p, %lx, %p, %lx, %p)\n", debugstr_guid(riid), pv,
dwDestContext, pvDestContext, mshlflags, pCid);
LPMARSHAL iface, REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags, DWORD* pSize)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
HRESULT hr;
ULARGE_INTEGER size;
REFIID riid, void* pv, DWORD dwDestContext,
void* pvDestContext, DWORD mshlflags)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
TRACE("(%p, %s, %p, %lx, %p, %lx)\n", pStm, debugstr_guid(riid), pv,
dwDestContext, pvDestContext, mshlflags);
static HRESULT WINAPI MonikerMarshal_UnmarshalInterface(LPMARSHAL iface, IStream *pStm, REFIID riid, void **ppv)
{
- ICOM_THIS_From_IMoniker(MonikerMarshal, iface);
+ MonikerMarshal *This = impl_from_IMarshal(iface);
HRESULT hr;
TRACE("(%p, %s, %p)\n", pStm, debugstr_guid(riid), ppv);
#ifndef __WINE_MONIKER_H__
#define __WINE_MONIKER_H__
-#define ICOM_THIS_From_IROTData(class, name) class* This = (class*)(((char*)name)-sizeof(void*))
-
extern const CLSID CLSID_FileMoniker;
extern const CLSID CLSID_ItemMoniker;
extern const CLSID CLSID_AntiMoniker;
return __CLSIDFromStringA(idstr,id);
}
-extern BOOL WINAPI K32WOWCallback16Ex( DWORD vpfn16, DWORD dwFlags,
- DWORD cbArgs, LPVOID pArgs,
- LPDWORD pdwRetCode );
-
/******************************************************************************
* _xmalloc16 [internal]
* Allocates size bytes from the standard ole16 allocator.
/* No need for a Callback entry, we have WOWCallback16Ex which does
* everything we need.
*/
- if (!K32WOWCallback16Ex(
+ if (!WOWCallback16Ex(
(DWORD)((const IMalloc16Vtbl*)MapSL(
(SEGPTR)((LPMALLOC16)MapSL((SEGPTR)mllc))->lpVtbl )
)->Alloc,
/******************************************************************************
* OleDoAutoConvert [OLE32.@]
*/
-HRESULT WINAPI OleDoAutoConvert(IStorage *pStg, LPCLSID pClsidNew)
+HRESULT WINAPI OleDoAutoConvert(LPSTORAGE pStg, LPCLSID pClsidNew)
+{
+ FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
+ return E_NOTIMPL;
+}
+
+/******************************************************************************
+ * OleDoAutoConvert [OLE2.79]
+ */
+HRESULT WINAPI OleDoAutoConvert16(LPSTORAGE pStg, LPCLSID pClsidNew)
{
FIXME("(%p,%p) : stub\n",pStg,pClsidNew);
return E_NOTIMPL;
9 stub OLECREATELINKFROMDATA
10 stub OLECREATE
11 stub OLECREATELINK
-12 stub OLELOAD
+12 pascal OleLoad(segptr ptr segptr ptr) OleLoad16
13 stub OLESAVE
14 stub OLERUN
#15 ___EXPORTEDSTUB
16 stub OLEISRUNNING
17 stub OLELOCKRUNNING
-18 stub READCLASSSTG
+18 pascal ReadClassStg(segptr ptr) ReadClassStg16
19 stub WRITECLASSSTG
20 stub READCLASSSTM
21 stub WRITECLASSSTM
76 pascal -ret16 OleFlushClipboard() OleFlushClipboard16
77 stub OLEISCURRENTCLIPBOARD
78 stub OLETRANSLATEACCELERATOR
-79 stub OLEDOAUTOCONVERT
+79 pascal OleDoAutoConvert(ptr ptr) OleDoAutoConvert16
80 stub OLEGETAUTOCONVERT
81 stub OLESETAUTOCONVERT
-82 stub GETCONVERTSTG
+82 pascal GetConvertStg(ptr) GetConvertStg16
83 stub SETCONVERTSTG
84 stub CREATESTREAMONHGLOBAL
85 stub GETHGLOBALFROMSTREAM
return FALSE;
return TRUE;
}
+
+/******************************************************************************
+ * OleLoad [OLE2.12]
+ *
+ * PARAMS
+ * pStg Segmented LPSTORAGE pointer.
+ * pClientSite Segmented LPOLECLIENTSITE pointer.
+ */
+HRESULT WINAPI OleLoad16(
+ SEGPTR pStg,
+ REFIID riid,
+ SEGPTR pClientSite,
+ LPVOID* ppvObj)
+{
+ FIXME("(%lx,%s,%lx,%p), stub!\n", pStg, debugstr_guid(riid), pClientSite, ppvObj);
+ return E_NOTIMPL;
+}
@ stdcall CLSIDFromProgID(wstr ptr)
@ stdcall CLSIDFromString(wstr ptr)
@ stdcall CoAddRefServerProcess()
+@ stdcall CoAllowSetForegroundWindow(ptr ptr)
@ stdcall CoBuildVersion()
@ stdcall CoCopyProxy(ptr ptr)
@ stdcall CoCreateFreeThreadedMarshaler(ptr ptr)
@ stub CreatePointerMoniker #@ stdcall (ptr ptr) return 0,ERR_NOTIMPLEMENTED
@ stdcall CreateStreamOnHGlobal(ptr long ptr)
@ stdcall DllDebugObjectRPCHook(long ptr)
-@ stdcall -private DllGetClassObject (ptr ptr ptr) OLE32_DllGetClassObject
+@ stdcall -private DllGetClassObject (ptr ptr ptr)
@ stub DllGetClassObjectWOW
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
/***********************************************************************
* DllGetClassObject [OLE32.@]
*/
-HRESULT WINAPI OLE32_DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
+HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid,LPVOID *ppv)
{
*ppv = NULL;
if (IsEqualIID(rclsid, &CLSID_PSFactoryBuffer))
WINE_DEFAULT_DEBUG_CHANNEL(storage);
-#define _IPropertySetStorage_Offset ((int)(&(((StorageImpl*)0)->base.pssVtbl)))
-#define _ICOM_THIS_From_IPropertySetStorage(class, name) \
- class* This = (class*)(((char*)name)-_IPropertySetStorage_Offset)
+static inline StorageImpl *impl_from_IPropertySetStorage( IPropertySetStorage *iface )
+{
+ return (StorageImpl *)((char*)iface - FIELD_OFFSET(StorageImpl, base.pssVtbl));
+}
/* These are documented in MSDN, e.g.
* http://msdn.microsoft.com/library/en-us/stg/stg/property_set_header.asp
ptr[cbEntry - 1] = '\0';
else
*((LPWSTR)ptr + cbEntry / sizeof(WCHAR)) = '\0';
- hr = PropertyStorage_StoreNameWithId(This, ptr, This->codePage, propid);
+ hr = PropertyStorage_StoreNameWithId(This, (char*)ptr, This->codePage, propid);
if (This->codePage == CP_UNICODE)
{
/* Unicode entries are padded to DWORD boundaries */
TRACE("Read byte 0x%x\n", prop->u.bVal);
break;
case VT_I2:
- StorageUtl_ReadWord(data, 0, &prop->u.iVal);
+ StorageUtl_ReadWord(data, 0, (WORD*)&prop->u.iVal);
TRACE("Read short %d\n", prop->u.iVal);
break;
case VT_UI2:
break;
case VT_INT:
case VT_I4:
- StorageUtl_ReadDWord(data, 0, &prop->u.lVal);
+ StorageUtl_ReadDWord(data, 0, (DWORD*)&prop->u.lVal);
TRACE("Read long %ld\n", prop->u.lVal);
break;
case VT_UINT:
REFIID riid,
void** ppvObject)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
return IStorage_QueryInterface( (IStorage*)This, riid, ppvObject );
}
static ULONG WINAPI IPropertySetStorage_fnAddRef(
IPropertySetStorage *ppstg)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
return IStorage_AddRef( (IStorage*)This );
}
static ULONG WINAPI IPropertySetStorage_fnRelease(
IPropertySetStorage *ppstg)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
return IStorage_Release( (IStorage*)This );
}
DWORD grfMode,
IPropertyStorage** ppprstg)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
WCHAR name[CCH_MAX_PROPSTG_NAME];
IStream *stm = NULL;
HRESULT r;
DWORD grfMode,
IPropertyStorage** ppprstg)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
IStream *stm = NULL;
WCHAR name[CCH_MAX_PROPSTG_NAME];
HRESULT r;
IPropertySetStorage *ppstg,
REFFMTID rfmtid)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
IStorage *stg = NULL;
WCHAR name[CCH_MAX_PROPSTG_NAME];
HRESULT r;
IPropertySetStorage *ppstg,
IEnumSTATPROPSETSTG** ppenum)
{
- _ICOM_THIS_From_IPropertySetStorage(StorageImpl, ppstg);
+ StorageImpl *This = impl_from_IPropertySetStorage(ppstg);
FIXME("%p\n", This);
return E_NOTIMPL;
}
#define SMALLBLOCKS_PER_BIGBLOCK (BIGSIZE/SMALLSIZE)
-#define READ_HEADER STORAGE_get_big_block(hf,-1,(LPBYTE)&sth);assert(!memcmp(STORAGE_magic,sth.magic,sizeof(STORAGE_magic)));
+#define READ_HEADER(str) STORAGE_get_big_block(str,-1,(LPBYTE)&sth);assert(!memcmp(STORAGE_magic,sth.magic,sizeof(STORAGE_magic)));
static IStorage16Vtbl stvt16;
static const IStorage16Vtbl *segstvt16 = NULL;
static IStream16Vtbl strvt16;
* deeper (but never shallower) tree.
*/
+typedef struct {
+ HANDLE hf;
+ SEGPTR lockbytes;
+} stream_access16;
+/* --- IStorage16 implementation struct */
+
+typedef struct
+{
+ /* IUnknown fields */
+ const IStorage16Vtbl *lpVtbl;
+ LONG ref;
+ /* IStorage16 fields */
+ SEGPTR thisptr; /* pointer to this struct as segmented */
+ struct storage_pps_entry stde;
+ int ppsent;
+ stream_access16 str;
+} IStorage16Impl;
+
/******************************************************************************
* STORAGE_get_big_block [Internal]
* Reading OLE compound storage
*/
static BOOL
-STORAGE_get_big_block(HANDLE hf,int n,BYTE *block)
+STORAGE_get_big_block(stream_access16 *str,int n,BYTE *block)
{
DWORD result;
assert(n>=-1);
- if ((SetFilePointer( hf, (n+1)*BIGSIZE, NULL,
- SEEK_SET ) == INVALID_SET_FILE_POINTER) && GetLastError())
- {
- WARN(" seek failed (%ld)\n",GetLastError());
- return FALSE;
+ if (str->hf) {
+ if ((SetFilePointer( str->hf, (n+1)*BIGSIZE, NULL,
+ SEEK_SET ) == INVALID_SET_FILE_POINTER) && GetLastError())
+ {
+ WARN("(%p,%d,%p), seek failed (%ld)\n",str->hf, n, block, GetLastError());
+ return FALSE;
+ }
+ if (!ReadFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE)
+ {
+ WARN("(hf=%p, block size %d): read didn't read (%ld)\n",str->hf,n,GetLastError());
+ return FALSE;
+ }
+ } else {
+ DWORD args[6];
+ HRESULT hres;
+ HANDLE16 hsig;
+
+ args[0] = (DWORD)str->lockbytes; /* iface */
+ args[1] = (n+1)*BIGSIZE;
+ args[2] = 0; /* ULARGE_INTEGER offset */
+ args[3] = WOWGlobalAllocLock16( 0, BIGSIZE, &hsig ); /* sig */
+ args[4] = BIGSIZE;
+ args[5] = 0;
+
+ if (!WOWCallback16Ex(
+ (DWORD)((const ILockBytes16Vtbl*)MapSL(
+ (SEGPTR)((LPLOCKBYTES16)MapSL(str->lockbytes))->lpVtbl)
+ )->ReadAt,
+ WCB16_PASCAL,
+ 6*sizeof(DWORD),
+ (LPVOID)args,
+ (LPDWORD)&hres
+ )) {
+ ERR("CallTo16 ILockBytes16::ReadAt() failed, hres %lx\n",hres);
+ return FALSE;
+ }
+ memcpy(block, MapSL(args[3]), BIGSIZE);
+ WOWGlobalUnlockFree16(args[3]);
}
- if (!ReadFile( hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE)
- {
- WARN("(block size %d): read didn't read (%ld)\n",n,GetLastError());
- return FALSE;
+ return TRUE;
+}
+
+static BOOL
+_ilockbytes16_writeat(SEGPTR lockbytes, DWORD offset, DWORD length, void *buffer) {
+ DWORD args[6];
+ HRESULT hres;
+
+ args[0] = (DWORD)lockbytes; /* iface */
+ args[1] = offset;
+ args[2] = 0; /* ULARGE_INTEGER offset */
+ args[3] = (DWORD)MapLS( buffer );
+ args[4] = length;
+ args[5] = 0;
+
+ /* THIS_ ULARGE_INTEGER ulOffset, const void *pv, ULONG cb, ULONG *pcbWritten); */
+
+ if (!WOWCallback16Ex(
+ (DWORD)((const ILockBytes16Vtbl*)MapSL(
+ (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
+ )->WriteAt,
+ WCB16_PASCAL,
+ 6*sizeof(DWORD),
+ (LPVOID)args,
+ (LPDWORD)&hres
+ )) {
+ ERR("CallTo16 ILockBytes16::WriteAt() failed, hres %lx\n",hres);
+ return FALSE;
}
+ UnMapLS(args[3]);
return TRUE;
}
* STORAGE_put_big_block [INTERNAL]
*/
static BOOL
-STORAGE_put_big_block(HANDLE hf,int n,BYTE *block)
+STORAGE_put_big_block(stream_access16 *str,int n,BYTE *block)
{
DWORD result;
assert(n>=-1);
- if ((SetFilePointer( hf, (n+1)*BIGSIZE, NULL,
- SEEK_SET ) == INVALID_SET_FILE_POINTER) && GetLastError())
- {
- WARN("seek failed (%ld)\n",GetLastError());
- return FALSE;
- }
- if (!WriteFile( hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE)
- {
- WARN(" write failed (%ld)\n",GetLastError());
- return FALSE;
+ if (str->hf) {
+ if ((SetFilePointer( str->hf, (n+1)*BIGSIZE, NULL,
+ SEEK_SET ) == INVALID_SET_FILE_POINTER) && GetLastError())
+ {
+ WARN("seek failed (%ld)\n",GetLastError());
+ return FALSE;
+ }
+ if (!WriteFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE)
+ {
+ WARN(" write failed (%ld)\n",GetLastError());
+ return FALSE;
+ }
+ return TRUE;
+ } else {
+ _ilockbytes16_writeat(str->lockbytes, (n+1)*BIGSIZE, BIGSIZE, block);
+ return TRUE;
}
- return TRUE;
}
/******************************************************************************
* STORAGE_get_next_big_blocknr [INTERNAL]
*/
static int
-STORAGE_get_next_big_blocknr(HANDLE hf,int blocknr) {
+STORAGE_get_next_big_blocknr(stream_access16 *str,int blocknr) {
INT bbs[BIGSIZE/sizeof(INT)];
struct storage_header sth;
- READ_HEADER;
+ READ_HEADER(str);
assert(blocknr>>7<sth.num_of_bbd_blocks);
if (sth.bbd_list[blocknr>>7]==0xffffffff)
return -5;
- if (!STORAGE_get_big_block(hf,sth.bbd_list[blocknr>>7],(LPBYTE)bbs))
+ if (!STORAGE_get_big_block(str,sth.bbd_list[blocknr>>7],(LPBYTE)bbs))
return -5;
assert(bbs[blocknr&0x7f]!=STORAGE_CHAINENTRY_FREE);
return bbs[blocknr&0x7f];
* STORAGE_get_nth_next_big_blocknr [INTERNAL]
*/
static int
-STORAGE_get_nth_next_big_blocknr(HANDLE hf,int blocknr,int nr) {
+STORAGE_get_nth_next_big_blocknr(stream_access16 *str,int blocknr,int nr) {
INT bbs[BIGSIZE/sizeof(INT)];
int lastblock = -1;
struct storage_header sth;
- READ_HEADER;
+ TRACE("(blocknr=%d, nr=%d)\n", blocknr, nr);
+ READ_HEADER(str);
assert(blocknr>=0);
while (nr--) {
/* simple caching... */
if (lastblock!=sth.bbd_list[blocknr>>7]) {
- BOOL ret = STORAGE_get_big_block(hf,sth.bbd_list[blocknr>>7],(LPBYTE)bbs);
+ BOOL ret = STORAGE_get_big_block(str,sth.bbd_list[blocknr>>7],(LPBYTE)bbs);
assert(ret);
lastblock = sth.bbd_list[blocknr>>7];
}
* STORAGE_get_root_pps_entry [Internal]
*/
static BOOL
-STORAGE_get_root_pps_entry(HANDLE hf,struct storage_pps_entry *pstde) {
+STORAGE_get_root_pps_entry(stream_access16* str,struct storage_pps_entry *pstde) {
int blocknr,i;
BYTE block[BIGSIZE];
struct storage_pps_entry *stde=(struct storage_pps_entry*)block;
struct storage_header sth;
- READ_HEADER;
+ READ_HEADER(str);
blocknr = sth.root_startblock;
+ TRACE("startblock is %d\n", blocknr);
while (blocknr>=0) {
- BOOL ret = STORAGE_get_big_block(hf,blocknr,block);
+ BOOL ret = STORAGE_get_big_block(str,blocknr,block);
assert(ret);
for (i=0;i<4;i++) {
if (!stde[i].pps_sizeofname)
return TRUE;
}
}
- blocknr=STORAGE_get_next_big_blocknr(hf,blocknr);
+ blocknr=STORAGE_get_next_big_blocknr(str,blocknr);
+ TRACE("next block is %d\n", blocknr);
}
return FALSE;
}
* STORAGE_get_small_block [INTERNAL]
*/
static BOOL
-STORAGE_get_small_block(HANDLE hf,int blocknr,BYTE *sblock) {
+STORAGE_get_small_block(stream_access16 *str,int blocknr,BYTE *sblock) {
BYTE block[BIGSIZE];
int bigblocknr;
struct storage_pps_entry root;
BOOL ret;
+ TRACE("(blocknr=%d)\n", blocknr);
assert(blocknr>=0);
- ret = STORAGE_get_root_pps_entry(hf,&root);
+ ret = STORAGE_get_root_pps_entry(str,&root);
assert(ret);
- bigblocknr = STORAGE_get_nth_next_big_blocknr(hf,root.pps_sb,blocknr/SMALLBLOCKS_PER_BIGBLOCK);
+ bigblocknr = STORAGE_get_nth_next_big_blocknr(str,root.pps_sb,blocknr/SMALLBLOCKS_PER_BIGBLOCK);
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
memcpy(sblock,((LPBYTE)block)+SMALLSIZE*(blocknr&(SMALLBLOCKS_PER_BIGBLOCK-1)),SMALLSIZE);
* STORAGE_put_small_block [INTERNAL]
*/
static BOOL
-STORAGE_put_small_block(HANDLE hf,int blocknr,BYTE *sblock) {
+STORAGE_put_small_block(stream_access16 *str,int blocknr,BYTE *sblock) {
BYTE block[BIGSIZE];
int bigblocknr;
struct storage_pps_entry root;
BOOL ret;
assert(blocknr>=0);
+ TRACE("(blocknr=%d)\n", blocknr);
- ret = STORAGE_get_root_pps_entry(hf,&root);
+ ret = STORAGE_get_root_pps_entry(str,&root);
assert(ret);
- bigblocknr = STORAGE_get_nth_next_big_blocknr(hf,root.pps_sb,blocknr/SMALLBLOCKS_PER_BIGBLOCK);
+ bigblocknr = STORAGE_get_nth_next_big_blocknr(str,root.pps_sb,blocknr/SMALLBLOCKS_PER_BIGBLOCK);
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
memcpy(((LPBYTE)block)+SMALLSIZE*(blocknr&(SMALLBLOCKS_PER_BIGBLOCK-1)),sblock,SMALLSIZE);
- ret = STORAGE_put_big_block(hf,bigblocknr,block);
+ ret = STORAGE_put_big_block(str,bigblocknr,block);
assert(ret);
return TRUE;
}
* STORAGE_get_next_small_blocknr [INTERNAL]
*/
static int
-STORAGE_get_next_small_blocknr(HANDLE hf,int blocknr) {
+STORAGE_get_next_small_blocknr(stream_access16 *str,int blocknr) {
BYTE block[BIGSIZE];
LPINT sbd = (LPINT)block;
int bigblocknr;
struct storage_header sth;
BOOL ret;
- READ_HEADER;
+ TRACE("(blocknr=%d)\n", blocknr);
+ READ_HEADER(str);
assert(blocknr>=0);
- bigblocknr = STORAGE_get_nth_next_big_blocknr(hf,sth.sbd_startblock,blocknr/128);
+ bigblocknr = STORAGE_get_nth_next_big_blocknr(str,sth.sbd_startblock,blocknr/128);
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
assert(sbd[blocknr & 127]!=STORAGE_CHAINENTRY_FREE);
return sbd[blocknr & (128-1)];
* STORAGE_get_nth_next_small_blocknr [INTERNAL]
*/
static int
-STORAGE_get_nth_next_small_blocknr(HANDLE hf,int blocknr,int nr) {
+STORAGE_get_nth_next_small_blocknr(stream_access16*str,int blocknr,int nr) {
int lastblocknr=-1;
BYTE block[BIGSIZE];
LPINT sbd = (LPINT)block;
struct storage_header sth;
BOOL ret;
- READ_HEADER;
+ TRACE("(blocknr=%d, nr=%d)\n", blocknr, nr);
+ READ_HEADER(str);
assert(blocknr>=0);
while ((nr--) && (blocknr>=0)) {
if (lastblocknr/128!=blocknr/128) {
int bigblocknr;
- bigblocknr = STORAGE_get_nth_next_big_blocknr(hf,sth.sbd_startblock,blocknr/128);
+ bigblocknr = STORAGE_get_nth_next_big_blocknr(str,sth.sbd_startblock,blocknr/128);
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
lastblocknr = blocknr;
}
* STORAGE_get_pps_entry [INTERNAL]
*/
static int
-STORAGE_get_pps_entry(HANDLE hf,int n,struct storage_pps_entry *pstde) {
+STORAGE_get_pps_entry(stream_access16*str,int n,struct storage_pps_entry *pstde) {
int blocknr;
BYTE block[BIGSIZE];
struct storage_pps_entry *stde = (struct storage_pps_entry*)(((LPBYTE)block)+128*(n&3));
struct storage_header sth;
BOOL ret;
- READ_HEADER;
+ TRACE("(n=%d)\n", n);
+ READ_HEADER(str);
/* we have 4 pps entries per big block */
- blocknr = STORAGE_get_nth_next_big_blocknr(hf,sth.root_startblock,n/4);
+ blocknr = STORAGE_get_nth_next_big_blocknr(str,sth.root_startblock,n/4);
assert(blocknr>=0);
- ret = STORAGE_get_big_block(hf,blocknr,block);
+ ret = STORAGE_get_big_block(str,blocknr,block);
assert(ret);
*pstde=*stde;
* STORAGE_put_pps_entry [Internal]
*/
static int
-STORAGE_put_pps_entry(HANDLE hf,int n,struct storage_pps_entry *pstde) {
+STORAGE_put_pps_entry(stream_access16*str,int n,struct storage_pps_entry *pstde) {
int blocknr;
BYTE block[BIGSIZE];
struct storage_pps_entry *stde = (struct storage_pps_entry*)(((LPBYTE)block)+128*(n&3));
struct storage_header sth;
BOOL ret;
- READ_HEADER;
-
+ TRACE("(n=%d)\n", n);
+ READ_HEADER(str);
/* we have 4 pps entries per big block */
- blocknr = STORAGE_get_nth_next_big_blocknr(hf,sth.root_startblock,n/4);
+ blocknr = STORAGE_get_nth_next_big_blocknr(str,sth.root_startblock,n/4);
assert(blocknr>=0);
- ret = STORAGE_get_big_block(hf,blocknr,block);
+ ret = STORAGE_get_big_block(str,blocknr,block);
assert(ret);
*stde=*pstde;
- ret = STORAGE_put_big_block(hf,blocknr,block);
+ ret = STORAGE_put_big_block(str,blocknr,block);
assert(ret);
return 1;
}
* STORAGE_look_for_named_pps [Internal]
*/
static int
-STORAGE_look_for_named_pps(HANDLE hf,int n,LPOLESTR name) {
+STORAGE_look_for_named_pps(stream_access16*str,int n,LPOLESTR name) {
struct storage_pps_entry stde;
int ret;
+ TRACE("(n=%d,name=%s)\n", n, debugstr_w(name));
if (n==-1)
return -1;
- if (1!=STORAGE_get_pps_entry(hf,n,&stde))
+ if (1!=STORAGE_get_pps_entry(str,n,&stde))
return -1;
if (!lstrcmpW(name,stde.pps_rawname))
return n;
if (stde.pps_prev != -1) {
- ret=STORAGE_look_for_named_pps(hf,stde.pps_prev,name);
+ ret=STORAGE_look_for_named_pps(str,stde.pps_prev,name);
if (ret!=-1)
return ret;
}
if (stde.pps_next != -1) {
- ret=STORAGE_look_for_named_pps(hf,stde.pps_next,name);
+ ret=STORAGE_look_for_named_pps(str,stde.pps_next,name);
if (ret!=-1)
return ret;
}
* STORAGE_init_storage [INTERNAL]
*/
static BOOL
-STORAGE_init_storage(HANDLE hf) {
+STORAGE_init_storage(stream_access16 *str) {
BYTE block[BIGSIZE];
LPDWORD bbs;
struct storage_header *sth;
struct storage_pps_entry *stde;
DWORD result;
- SetFilePointer( hf, 0, NULL, SEEK_SET );
+ if (str->hf)
+ SetFilePointer( str->hf, 0, NULL, SEEK_SET );
/* block -1 is the storage header */
sth = (struct storage_header*)block;
memcpy(sth->magic,STORAGE_magic,8);
sth->sbd_startblock = 0xffffffff;
memset(sth->bbd_list,0xff,sizeof(sth->bbd_list));
sth->bbd_list[0] = 0;
- if (!WriteFile( hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE) return FALSE;
+ if (str->hf) {
+ if (!WriteFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE) return FALSE;
+ } else {
+ if (!_ilockbytes16_writeat(str->lockbytes, 0, BIGSIZE, block)) return FALSE;
+ }
/* block 0 is the big block directory */
bbs=(LPDWORD)block;
memset(block,0xff,sizeof(block)); /* mark all blocks as free */
bbs[0]=STORAGE_CHAINENTRY_ENDOFCHAIN; /* for this block */
bbs[1]=STORAGE_CHAINENTRY_ENDOFCHAIN; /* for directory entry */
- if (!WriteFile( hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE) return FALSE;
+ if (str->hf) {
+ if (!WriteFile( str->hf, block, BIGSIZE, &result, NULL ) || result != BIGSIZE) return FALSE;
+ } else {
+ if (!_ilockbytes16_writeat(str->lockbytes, BIGSIZE, BIGSIZE, block)) return FALSE;
+ }
/* block 1 is the root directory entry */
memset(block,0x00,sizeof(block));
stde = (struct storage_pps_entry*)block;
stde->pps_prev = -1;
stde->pps_sb = 0xffffffff;
stde->pps_size = 0;
- return (WriteFile( hf, block, BIGSIZE, &result, NULL ) && result == BIGSIZE);
+ if (str->hf) {
+ return (WriteFile( str->hf, block, BIGSIZE, &result, NULL ) && result == BIGSIZE);
+ } else {
+ return _ilockbytes16_writeat(str->lockbytes, BIGSIZE, BIGSIZE, block);
+ }
}
/******************************************************************************
* STORAGE_set_big_chain [Internal]
*/
static BOOL
-STORAGE_set_big_chain(HANDLE hf,int blocknr,INT type) {
+STORAGE_set_big_chain(stream_access16*str,int blocknr,INT type) {
BYTE block[BIGSIZE];
LPINT bbd = (LPINT)block;
int nextblocknr,bigblocknr;
struct storage_header sth;
BOOL ret;
- READ_HEADER;
+ READ_HEADER(str);
assert(blocknr!=type);
while (blocknr>=0) {
bigblocknr = sth.bbd_list[blocknr/128];
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
nextblocknr = bbd[blocknr&(128-1)];
bbd[blocknr&(128-1)] = type;
if (type>=0)
return TRUE;
- ret = STORAGE_put_big_block(hf,bigblocknr,block);
+ ret = STORAGE_put_big_block(str,bigblocknr,block);
assert(ret);
type = STORAGE_CHAINENTRY_FREE;
blocknr = nextblocknr;
* STORAGE_set_small_chain [Internal]
*/
static BOOL
-STORAGE_set_small_chain(HANDLE hf,int blocknr,INT type) {
+STORAGE_set_small_chain(stream_access16*str,int blocknr,INT type) {
BYTE block[BIGSIZE];
LPINT sbd = (LPINT)block;
int lastblocknr,nextsmallblocknr,bigblocknr;
struct storage_header sth;
BOOL ret;
- READ_HEADER;
+ READ_HEADER(str);
assert(blocknr!=type);
lastblocknr=-129;bigblocknr=-2;
while (blocknr>=0) {
/* cache block ... */
if (lastblocknr/128!=blocknr/128) {
- bigblocknr = STORAGE_get_nth_next_big_blocknr(hf,sth.sbd_startblock,blocknr/128);
+ bigblocknr = STORAGE_get_nth_next_big_blocknr(str,sth.sbd_startblock,blocknr/128);
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
}
lastblocknr = blocknr;
nextsmallblocknr = sbd[blocknr&(128-1)];
sbd[blocknr&(128-1)] = type;
- ret = STORAGE_put_big_block(hf,bigblocknr,block);
+ ret = STORAGE_put_big_block(str,bigblocknr,block);
assert(ret);
if (type>=0)
return TRUE;
* STORAGE_get_free_big_blocknr [Internal]
*/
static int
-STORAGE_get_free_big_blocknr(HANDLE hf) {
+STORAGE_get_free_big_blocknr(stream_access16 *str) {
BYTE block[BIGSIZE];
LPINT sbd = (LPINT)block;
int lastbigblocknr,i,bigblocknr;
struct storage_header sth;
BOOL ret;
- READ_HEADER;
+ READ_HEADER(str);
curblock = 0;
lastbigblocknr = -1;
bigblocknr = sth.bbd_list[curblock];
while (curblock<sth.num_of_bbd_blocks) {
assert(bigblocknr>=0);
- ret = STORAGE_get_big_block(hf,bigblocknr,block);
+ ret = STORAGE_get_big_block(str,bigblocknr,block);
assert(ret);
for (i=0;i<128;i++)
if (sbd[i]==STORAGE_CHAINENTRY_FREE) {
sbd[i] = STORAGE_CHAINENTRY_ENDOFCHAIN;
- ret = STORAGE_put_big_block(hf,bigblocknr,block);
+ ret = STORAGE_put_big_block(str,bigblocknr,block);
assert(ret);
memset(block,0x42,sizeof(block));
- ret = STORAGE_put_big_block(hf,i+curblock*128,block);
+ ret = STORAGE_put_big_block(str,i+curblock*128,block);
assert(ret);
return i+curblock*128;
}
memset(block,0xff,sizeof(block));
/* mark the block allocated and returned by this function */
sbd[1] = STORAGE_CHAINENTRY_ENDOFCHAIN;
- ret = STORAGE_put_big_block(hf,bigblocknr,block);
+ ret = STORAGE_put_big_block(str,bigblocknr,block);
assert(ret);
/* if we had a bbd block already (mostlikely) we need
* to link the new one into the chain
*/
if (lastbigblocknr!=-1) {
- ret = STORAGE_set_big_chain(hf,lastbigblocknr,bigblocknr);
+ ret = STORAGE_set_big_chain(str,lastbigblocknr,bigblocknr);
assert(ret);
}
sth.bbd_list[curblock]=bigblocknr;
sth.num_of_bbd_blocks++;
assert(sth.num_of_bbd_blocks==curblock+1);
- ret = STORAGE_put_big_block(hf,-1,(LPBYTE)&sth);
+ ret = STORAGE_put_big_block(str,-1,(LPBYTE)&sth);
assert(ret);
/* Set the end of the chain for the bigblockdepots */
- ret = STORAGE_set_big_chain(hf,bigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN);
+ ret = STORAGE_set_big_chain(str,bigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN);
assert(ret);
/* add 1, for the first entry is used for the additional big block
* depot. (means we already used bigblocknr) */
memset(block,0x42,sizeof(block));
/* allocate this block (filled with 0x42) */
- ret = STORAGE_put_big_block(hf,bigblocknr+1,block);
+ ret = STORAGE_put_big_block(str,bigblocknr+1,block);
assert(ret);
return bigblocknr+1;
}
* STORAGE_get_free_small_blocknr [Internal]
*/
static int
-STORAGE_get_free_small_blocknr(HANDLE hf) {
+STORAGE_get_free_small_blocknr(stream_access16 *str) {
BYTE block[BIGSIZE];
LPINT sbd = (LPINT)block;
int lastbigblocknr,newblocknr,i,curblock,bigblocknr;
struct storage_pps_entry root;
struct storage_header sth;
- READ_HEADER;
+ READ_HEADER(str);
bigblocknr = sth.sbd_startblock;
curblock = 0;
lastbigblocknr = -1;
newblocknr = -1;
while (bigblocknr>=0) {
- if (!STORAGE_get_big_block(hf,bigblocknr,block))
+ if (!STORAGE_get_big_block(str,bigblocknr,block))
return -1;
for (i=0;i<128;i++)
if (sbd[i]==STORAGE_CHAINENTRY_FREE) {
if (i!=128)
break;
lastbigblocknr = bigblocknr;
- bigblocknr = STORAGE_get_next_big_blocknr(hf,bigblocknr);
+ bigblocknr = STORAGE_get_next_big_blocknr(str,bigblocknr);
curblock++;
}
if (newblocknr==-1) {
- bigblocknr = STORAGE_get_free_big_blocknr(hf);
+ bigblocknr = STORAGE_get_free_big_blocknr(str);
if (bigblocknr<0)
return -1;
- READ_HEADER;
+ READ_HEADER(str);
memset(block,0xff,sizeof(block));
sbd[0]=STORAGE_CHAINENTRY_ENDOFCHAIN;
- if (!STORAGE_put_big_block(hf,bigblocknr,block))
+ if (!STORAGE_put_big_block(str,bigblocknr,block))
return -1;
if (lastbigblocknr==-1) {
sth.sbd_startblock = bigblocknr;
- if (!STORAGE_put_big_block(hf,-1,(LPBYTE)&sth)) /* need to write it */
+ if (!STORAGE_put_big_block(str,-1,(LPBYTE)&sth)) /* need to write it */
return -1;
} else {
- if (!STORAGE_set_big_chain(hf,lastbigblocknr,bigblocknr))
+ if (!STORAGE_set_big_chain(str,lastbigblocknr,bigblocknr))
return -1;
}
- if (!STORAGE_set_big_chain(hf,bigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(str,bigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return -1;
newblocknr = curblock*128;
}
/* allocate enough big blocks for storing the allocated small block */
- if (!STORAGE_get_root_pps_entry(hf,&root))
+ if (!STORAGE_get_root_pps_entry(str,&root))
return -1;
if (root.pps_sb==-1)
lastbigblocknr = -1;
else
- lastbigblocknr = STORAGE_get_nth_next_big_blocknr(hf,root.pps_sb,(root.pps_size-1)/BIGSIZE);
+ lastbigblocknr = STORAGE_get_nth_next_big_blocknr(str,root.pps_sb,(root.pps_size-1)/BIGSIZE);
while (root.pps_size < (newblocknr*SMALLSIZE+SMALLSIZE-1)) {
/* we need to allocate more stuff */
- bigblocknr = STORAGE_get_free_big_blocknr(hf);
+ bigblocknr = STORAGE_get_free_big_blocknr(str);
if (bigblocknr<0)
return -1;
- READ_HEADER;
+ READ_HEADER(str);
if (root.pps_sb==-1) {
root.pps_sb = bigblocknr;
root.pps_size += BIGSIZE;
} else {
- if (!STORAGE_set_big_chain(hf,lastbigblocknr,bigblocknr))
+ if (!STORAGE_set_big_chain(str,lastbigblocknr,bigblocknr))
return -1;
root.pps_size += BIGSIZE;
}
lastbigblocknr = bigblocknr;
}
- if (!STORAGE_set_big_chain(hf,lastbigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(str,lastbigblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return -1;
- if (!STORAGE_put_pps_entry(hf,0,&root))
+ if (!STORAGE_put_pps_entry(str,0,&root))
return -1;
return newblocknr;
}
* STORAGE_get_free_pps_entry [Internal]
*/
static int
-STORAGE_get_free_pps_entry(HANDLE hf) {
+STORAGE_get_free_pps_entry(stream_access16*str) {
int blocknr, i, curblock, lastblocknr=-1;
BYTE block[BIGSIZE];
struct storage_pps_entry *stde = (struct storage_pps_entry*)block;
struct storage_header sth;
- READ_HEADER;
+ READ_HEADER(str);
blocknr = sth.root_startblock;
assert(blocknr>=0);
curblock=0;
while (blocknr>=0) {
- if (!STORAGE_get_big_block(hf,blocknr,block))
+ if (!STORAGE_get_big_block(str,blocknr,block))
return -1;
for (i=0;i<4;i++)
if (stde[i].pps_sizeofname==0) /* free */
return curblock*4+i;
lastblocknr = blocknr;
- blocknr = STORAGE_get_next_big_blocknr(hf,blocknr);
+ blocknr = STORAGE_get_next_big_blocknr(str,blocknr);
curblock++;
}
assert(blocknr==STORAGE_CHAINENTRY_ENDOFCHAIN);
- blocknr = STORAGE_get_free_big_blocknr(hf);
+ blocknr = STORAGE_get_free_big_blocknr(str);
/* sth invalidated */
if (blocknr<0)
return -1;
- if (!STORAGE_set_big_chain(hf,lastblocknr,blocknr))
+ if (!STORAGE_set_big_chain(str,lastblocknr,blocknr))
return -1;
- if (!STORAGE_set_big_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return -1;
memset(block,0,sizeof(block));
- STORAGE_put_big_block(hf,blocknr,block);
+ STORAGE_put_big_block(str,blocknr,block);
return curblock*4;
}
SEGPTR thisptr; /* pointer to this struct as segmented */
struct storage_pps_entry stde;
int ppsent;
- HANDLE hf;
ULARGE_INTEGER offset;
+ stream_access16 str;
} IStream16Impl;
/******************************************************************************
return InterlockedIncrement(&This->ref);
}
+static void
+_ilockbytes16_addref(SEGPTR lockbytes) {
+ DWORD args[1];
+ HRESULT hres;
+
+ args[0] = (DWORD)lockbytes; /* iface */
+ if (!WOWCallback16Ex(
+ (DWORD)((const ILockBytes16Vtbl*)MapSL(
+ (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
+ )->AddRef,
+ WCB16_PASCAL,
+ 1*sizeof(DWORD),
+ (LPVOID)args,
+ (LPDWORD)&hres
+ ))
+ ERR("CallTo16 ILockBytes16::AddRef() failed, hres %lx\n",hres);
+}
+
+static void
+_ilockbytes16_release(SEGPTR lockbytes) {
+ DWORD args[1];
+ HRESULT hres;
+
+ args[0] = (DWORD)lockbytes; /* iface */
+ if (!WOWCallback16Ex(
+ (DWORD)((const ILockBytes16Vtbl*)MapSL(
+ (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
+ )->Release,
+ WCB16_PASCAL,
+ 1*sizeof(DWORD),
+ (LPVOID)args,
+ (LPDWORD)&hres
+ ))
+ ERR("CallTo16 ILockBytes16::Release() failed, hres %lx\n",hres);
+}
+
+static void
+_ilockbytes16_flush(SEGPTR lockbytes) {
+ DWORD args[1];
+ HRESULT hres;
+
+ args[0] = (DWORD)lockbytes; /* iface */
+ if (!WOWCallback16Ex(
+ (DWORD)((const ILockBytes16Vtbl*)MapSL(
+ (SEGPTR)((LPLOCKBYTES16)MapSL(lockbytes))->lpVtbl)
+ )->Flush,
+ WCB16_PASCAL,
+ 1*sizeof(DWORD),
+ (LPVOID)args,
+ (LPDWORD)&hres
+ ))
+ ERR("CallTo16 ILockBytes16::Flush() failed, hres %lx\n",hres);
+}
+
/******************************************************************************
* IStream16_Release [STORAGE.520]
*/
ULONG IStream16_fnRelease(IStream16* iface) {
IStream16Impl *This = (IStream16Impl *)iface;
ULONG ref;
- FlushFileBuffers(This->hf);
+
+ if (This->str.hf)
+ FlushFileBuffers(This->str.hf);
+ else
+ _ilockbytes16_flush(This->str.lockbytes);
ref = InterlockedDecrement(&This->ref);
- if (!ref) {
- CloseHandle(This->hf);
- UnMapLS( This->thisptr );
- HeapFree( GetProcessHeap(), 0, This );
- }
- return ref;
+ if (ref)
+ return ref;
+
+ if (This->str.hf)
+ CloseHandle(This->str.hf);
+ else
+ _ilockbytes16_release(This->str.lockbytes);
+ UnMapLS( This->thisptr );
+ HeapFree( GetProcessHeap(), 0, This );
+ return 0;
}
/******************************************************************************
cb=This->stde.pps_size-This->offset.u.LowPart;
if (This->stde.pps_size < 0x1000) {
/* use small block reader */
- blocknr = STORAGE_get_nth_next_small_blocknr(This->hf,This->stde.pps_sb,This->offset.u.LowPart/SMALLSIZE);
+ blocknr = STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/SMALLSIZE);
while (cb) {
unsigned int cc;
- if (!STORAGE_get_small_block(This->hf,blocknr,block)) {
+ if (!STORAGE_get_small_block(&This->str,blocknr,block)) {
WARN("small block read failed!!!\n");
return E_FAIL;
}
pbv+=cc;
*bytesread+=cc;
cb-=cc;
- blocknr = STORAGE_get_next_small_blocknr(This->hf,blocknr);
+ blocknr = STORAGE_get_next_small_blocknr(&This->str,blocknr);
}
} else {
/* use big block reader */
- blocknr = STORAGE_get_nth_next_big_blocknr(This->hf,This->stde.pps_sb,This->offset.u.LowPart/BIGSIZE);
+ blocknr = STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/BIGSIZE);
while (cb) {
unsigned int cc;
- if (!STORAGE_get_big_block(This->hf,blocknr,block)) {
+ if (!STORAGE_get_big_block(&This->str,blocknr,block)) {
WARN("big block read failed!!!\n");
return E_FAIL;
}
pbv+=cc;
*bytesread+=cc;
cb-=cc;
- blocknr=STORAGE_get_next_big_blocknr(This->hf,blocknr);
+ blocknr=STORAGE_get_next_big_blocknr(&This->str,blocknr);
}
}
return S_OK;
BYTE block[BIGSIZE];
ULONG *byteswritten=pcbWrite,xxwritten;
int oldsize,newsize,i,curoffset=0,lastblocknr,blocknr,cc;
- HANDLE hf = This->hf;
const BYTE* pbv = (const BYTE*)pv;
if (!pcbWrite) byteswritten=&xxwritten;
if (newsize < oldsize) {
if (oldsize < 0x1000) {
/* only small blocks */
- blocknr=STORAGE_get_nth_next_small_blocknr(hf,This->stde.pps_sb,newsize/SMALLSIZE);
+ blocknr=STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,newsize/SMALLSIZE);
assert(blocknr>=0);
/* will set the rest of the chain to 'free' */
- if (!STORAGE_set_small_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_small_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
} else {
if (newsize >= 0x1000) {
- blocknr=STORAGE_get_nth_next_big_blocknr(hf,This->stde.pps_sb,newsize/BIGSIZE);
+ blocknr=STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,newsize/BIGSIZE);
assert(blocknr>=0);
/* will set the rest of the chain to 'free' */
- if (!STORAGE_set_big_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
} else {
/* Migrate large blocks to small blocks
blocknr = This->stde.pps_sb;
curdata = data;
while (cc>0) {
- if (!STORAGE_get_big_block(hf,blocknr,curdata)) {
+ if (!STORAGE_get_big_block(&This->str,blocknr,curdata)) {
HeapFree(GetProcessHeap(),0,data);
return E_FAIL;
}
curdata += BIGSIZE;
cc -= BIGSIZE;
- blocknr = STORAGE_get_next_big_blocknr(hf,blocknr);
+ blocknr = STORAGE_get_next_big_blocknr(&This->str,blocknr);
}
/* frees complete chain for this stream */
- if (!STORAGE_set_big_chain(hf,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
+ if (!STORAGE_set_big_chain(&This->str,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
goto err;
curdata = data;
- blocknr = This->stde.pps_sb = STORAGE_get_free_small_blocknr(hf);
+ blocknr = This->stde.pps_sb = STORAGE_get_free_small_blocknr(&This->str);
if (blocknr<0)
goto err;
cc = newsize;
while (cc>0) {
- if (!STORAGE_put_small_block(hf,blocknr,curdata))
+ if (!STORAGE_put_small_block(&This->str,blocknr,curdata))
goto err;
cc -= SMALLSIZE;
if (cc<=0) {
- if (!STORAGE_set_small_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_small_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
goto err;
break;
} else {
- int newblocknr = STORAGE_get_free_small_blocknr(hf);
+ int newblocknr = STORAGE_get_free_small_blocknr(&This->str);
if (newblocknr<0)
goto err;
- if (!STORAGE_set_small_chain(hf,blocknr,newblocknr))
+ if (!STORAGE_set_small_chain(&This->str,blocknr,newblocknr))
goto err;
blocknr = newblocknr;
}
if (newsize > oldsize) {
if (oldsize >= 0x1000) {
/* should return the block right before the 'endofchain' */
- blocknr = STORAGE_get_nth_next_big_blocknr(hf,This->stde.pps_sb,This->stde.pps_size/BIGSIZE);
+ blocknr = STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,This->stde.pps_size/BIGSIZE);
assert(blocknr>=0);
lastblocknr = blocknr;
for (i=oldsize/BIGSIZE;i<newsize/BIGSIZE;i++) {
- blocknr = STORAGE_get_free_big_blocknr(hf);
+ blocknr = STORAGE_get_free_big_blocknr(&This->str);
if (blocknr<0)
return E_FAIL;
- if (!STORAGE_set_big_chain(hf,lastblocknr,blocknr))
+ if (!STORAGE_set_big_chain(&This->str,lastblocknr,blocknr))
return E_FAIL;
lastblocknr = blocknr;
}
- if (!STORAGE_set_big_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
} else {
if (newsize < 0x1000) {
/* find startblock */
if (!oldsize)
- This->stde.pps_sb = blocknr = STORAGE_get_free_small_blocknr(hf);
+ This->stde.pps_sb = blocknr = STORAGE_get_free_small_blocknr(&This->str);
else
- blocknr = STORAGE_get_nth_next_small_blocknr(hf,This->stde.pps_sb,This->stde.pps_size/SMALLSIZE);
+ blocknr = STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,This->stde.pps_size/SMALLSIZE);
if (blocknr<0)
return E_FAIL;
/* allocate required new small blocks */
lastblocknr = blocknr;
for (i=oldsize/SMALLSIZE;i<newsize/SMALLSIZE;i++) {
- blocknr = STORAGE_get_free_small_blocknr(hf);
+ blocknr = STORAGE_get_free_small_blocknr(&This->str);
if (blocknr<0)
return E_FAIL;
- if (!STORAGE_set_small_chain(hf,lastblocknr,blocknr))
+ if (!STORAGE_set_small_chain(&This->str,lastblocknr,blocknr))
return E_FAIL;
lastblocknr = blocknr;
}
/* and terminate the chain */
- if (!STORAGE_set_small_chain(hf,lastblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_small_chain(&This->str,lastblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
} else {
if (!oldsize) {
/* no single block allocated yet */
- blocknr=STORAGE_get_free_big_blocknr(hf);
+ blocknr=STORAGE_get_free_big_blocknr(&This->str);
if (blocknr<0)
return E_FAIL;
This->stde.pps_sb = blocknr;
curdata = data;
/* slurp in */
while (cc>0) {
- if (!STORAGE_get_small_block(hf,blocknr,curdata))
+ if (!STORAGE_get_small_block(&This->str,blocknr,curdata))
goto err2;
curdata += SMALLSIZE;
cc -= SMALLSIZE;
- blocknr = STORAGE_get_next_small_blocknr(hf,blocknr);
+ blocknr = STORAGE_get_next_small_blocknr(&This->str,blocknr);
}
/* free small block chain */
- if (!STORAGE_set_small_chain(hf,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
+ if (!STORAGE_set_small_chain(&This->str,This->stde.pps_sb,STORAGE_CHAINENTRY_FREE))
goto err2;
curdata = data;
- blocknr = This->stde.pps_sb = STORAGE_get_free_big_blocknr(hf);
+ blocknr = This->stde.pps_sb = STORAGE_get_free_big_blocknr(&This->str);
if (blocknr<0)
goto err2;
/* put the data into the big blocks */
cc = This->stde.pps_size;
while (cc>0) {
- if (!STORAGE_put_big_block(hf,blocknr,curdata))
+ if (!STORAGE_put_big_block(&This->str,blocknr,curdata))
goto err2;
cc -= BIGSIZE;
if (cc<=0) {
- if (!STORAGE_set_big_chain(hf,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(&This->str,blocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
goto err2;
break;
} else {
- int newblocknr = STORAGE_get_free_big_blocknr(hf);
+ int newblocknr = STORAGE_get_free_big_blocknr(&This->str);
if (newblocknr<0)
goto err2;
- if (!STORAGE_set_big_chain(hf,blocknr,newblocknr))
+ if (!STORAGE_set_big_chain(&This->str,blocknr,newblocknr))
goto err2;
blocknr = newblocknr;
}
/* generate big blocks to fit the new data */
lastblocknr = blocknr;
for (i=oldsize/BIGSIZE;i<newsize/BIGSIZE;i++) {
- blocknr = STORAGE_get_free_big_blocknr(hf);
+ blocknr = STORAGE_get_free_big_blocknr(&This->str);
if (blocknr<0)
return E_FAIL;
- if (!STORAGE_set_big_chain(hf,lastblocknr,blocknr))
+ if (!STORAGE_set_big_chain(&This->str,lastblocknr,blocknr))
return E_FAIL;
lastblocknr = blocknr;
}
/* terminate chain */
- if (!STORAGE_set_big_chain(hf,lastblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
+ if (!STORAGE_set_big_chain(&This->str,lastblocknr,STORAGE_CHAINENTRY_ENDOFCHAIN))
return E_FAIL;
}
}
/* There are just some cases where we didn't modify it, we write it out
* everytime
*/
- if (!STORAGE_put_pps_entry(hf,This->ppsent,&(This->stde)))
+ if (!STORAGE_put_pps_entry(&This->str,This->ppsent,&(This->stde)))
return E_FAIL;
/* finally the write pass */
if (This->stde.pps_size < 0x1000) {
- blocknr = STORAGE_get_nth_next_small_blocknr(hf,This->stde.pps_sb,This->offset.u.LowPart/SMALLSIZE);
+ blocknr = STORAGE_get_nth_next_small_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/SMALLSIZE);
assert(blocknr>=0);
while (cb>0) {
/* we ensured that it is allocated above */
/* Read old block everytime, since we can have
* overlapping data at START and END of the write
*/
- if (!STORAGE_get_small_block(hf,blocknr,block))
+ if (!STORAGE_get_small_block(&This->str,blocknr,block))
return E_FAIL;
cc = SMALLSIZE-(This->offset.u.LowPart&(SMALLSIZE-1));
pbv+curoffset,
cc
);
- if (!STORAGE_put_small_block(hf,blocknr,block))
+ if (!STORAGE_put_small_block(&This->str,blocknr,block))
return E_FAIL;
cb -= cc;
curoffset += cc;
pbv += cc;
This->offset.u.LowPart += cc;
*byteswritten += cc;
- blocknr = STORAGE_get_next_small_blocknr(hf,blocknr);
+ blocknr = STORAGE_get_next_small_blocknr(&This->str,blocknr);
}
} else {
- blocknr = STORAGE_get_nth_next_big_blocknr(hf,This->stde.pps_sb,This->offset.u.LowPart/BIGSIZE);
+ blocknr = STORAGE_get_nth_next_big_blocknr(&This->str,This->stde.pps_sb,This->offset.u.LowPart/BIGSIZE);
assert(blocknr>=0);
while (cb>0) {
/* we ensured that it is allocated above, so it better is */
/* read old block everytime, since we can have
* overlapping data at START and END of the write
*/
- if (!STORAGE_get_big_block(hf,blocknr,block))
+ if (!STORAGE_get_big_block(&This->str,blocknr,block))
return E_FAIL;
cc = BIGSIZE-(This->offset.u.LowPart&(BIGSIZE-1));
pbv+curoffset,
cc
);
- if (!STORAGE_put_big_block(hf,blocknr,block))
+ if (!STORAGE_put_big_block(&This->str,blocknr,block))
return E_FAIL;
cb -= cc;
curoffset += cc;
pbv += cc;
This->offset.u.LowPart += cc;
*byteswritten += cc;
- blocknr = STORAGE_get_next_big_blocknr(hf,blocknr);
+ blocknr = STORAGE_get_next_big_blocknr(&This->str,blocknr);
}
}
return S_OK;
lpst->lpVtbl = segstrvt16;
lpst->ref = 1;
lpst->thisptr = MapLS( lpst );
+ lpst->str.hf = NULL;
+ lpst->str.lockbytes = 0;
*str = (void*)lpst->thisptr;
}
/* IStream32 fields */
struct storage_pps_entry stde;
int ppsent;
- HANDLE hf;
+ HANDLE hf;
ULARGE_INTEGER offset;
} IStream32Impl;
return ref;
}
-/* --- IStorage16 implementation */
-
-typedef struct
-{
- /* IUnknown fields */
- const IStorage16Vtbl *lpVtbl;
- LONG ref;
- /* IStorage16 fields */
- SEGPTR thisptr; /* pointer to this struct as segmented */
- struct storage_pps_entry stde;
- int ppsent;
- HANDLE hf;
-} IStorage16Impl;
-
/******************************************************************************
* IStorage16_QueryInterface [STORAGE.500]
*/
int ppsent,x;
struct storage_pps_entry stde;
struct storage_header sth;
- HANDLE hf=This->hf;
BOOL ret;
int nPPSEntries;
- READ_HEADER;
-
+ READ_HEADER(&This->str);
TRACE("(%p)->(%s,0x%08lx,0x%08lx,0x%08lx,%p)\n",
This,pwcsName,grfMode,dwStgFormat,reserved2,ppstg
);
FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
_create_istorage16(ppstg);
lpstg = MapSL((SEGPTR)*ppstg);
- lpstg->hf = This->hf;
+ if (This->str.hf) {
+ DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
+ &lpstg->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ } else {
+ lpstg->str.lockbytes = This->str.lockbytes;
+ _ilockbytes16_addref(This->str.lockbytes);
+ }
- ppsent=STORAGE_get_free_pps_entry(lpstg->hf);
+ ppsent=STORAGE_get_free_pps_entry(&lpstg->str);
if (ppsent<0)
return E_FAIL;
stde=This->stde;
} else {
FIXME(" use prev chain too ?\n");
x=stde.pps_dir;
- if (1!=STORAGE_get_pps_entry(lpstg->hf,x,&stde))
+ if (1!=STORAGE_get_pps_entry(&lpstg->str,x,&stde))
return E_FAIL;
while (stde.pps_next!=-1) {
x=stde.pps_next;
- if (1!=STORAGE_get_pps_entry(lpstg->hf,x,&stde))
+ if (1!=STORAGE_get_pps_entry(&lpstg->str,x,&stde))
return E_FAIL;
}
stde.pps_next = ppsent;
}
- ret = STORAGE_put_pps_entry(lpstg->hf,x,&stde);
+ ret = STORAGE_put_pps_entry(&lpstg->str,x,&stde);
assert(ret);
- nPPSEntries = STORAGE_get_pps_entry(lpstg->hf,ppsent,&(lpstg->stde));
+ nPPSEntries = STORAGE_get_pps_entry(&lpstg->str,ppsent,&(lpstg->stde));
assert(nPPSEntries == 1);
MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, lpstg->stde.pps_rawname,
sizeof(lpstg->stde.pps_rawname)/sizeof(WCHAR));
lpstg->stde.pps_type = 1;
lpstg->ppsent = ppsent;
/* FIXME: timestamps? */
- if (!STORAGE_put_pps_entry(lpstg->hf,ppsent,&(lpstg->stde)))
+ if (!STORAGE_put_pps_entry(&lpstg->str,ppsent,&(lpstg->stde)))
return E_FAIL;
return S_OK;
}
FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
_create_istream16(ppstm);
lpstr = MapSL((SEGPTR)*ppstm);
- DuplicateHandle( GetCurrentProcess(), This->hf, GetCurrentProcess(),
- &lpstr->hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ if (This->str.hf) {
+ DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
+ &lpstr->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ } else {
+ lpstr->str.lockbytes = This->str.lockbytes;
+ _ilockbytes16_addref(This->str.lockbytes);
+ }
lpstr->offset.u.LowPart = 0;
- lpstr->offset.u.HighPart = 0;
+ lpstr->offset.u.HighPart= 0;
- ppsent=STORAGE_get_free_pps_entry(lpstr->hf);
+ ppsent=STORAGE_get_free_pps_entry(&lpstr->str);
if (ppsent<0)
return E_FAIL;
stde=This->stde;
else
while (stde.pps_next!=-1) {
x=stde.pps_next;
- if (1!=STORAGE_get_pps_entry(lpstr->hf,x,&stde))
+ if (1!=STORAGE_get_pps_entry(&lpstr->str,x,&stde))
return E_FAIL;
}
stde.pps_next = ppsent;
- ret = STORAGE_put_pps_entry(lpstr->hf,x,&stde);
+ ret = STORAGE_put_pps_entry(&lpstr->str,x,&stde);
assert(ret);
- nPPSEntries = STORAGE_get_pps_entry(lpstr->hf,ppsent,&(lpstr->stde));
+ nPPSEntries = STORAGE_get_pps_entry(&lpstr->str,ppsent,&(lpstr->stde));
assert(nPPSEntries == 1);
MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, lpstr->stde.pps_rawname,
sizeof(lpstr->stde.pps_rawname)/sizeof(WCHAR));
lpstr->stde.pps_size = 0;
lpstr->stde.pps_type = 2;
lpstr->ppsent = ppsent;
+
/* FIXME: timestamps? */
- if (!STORAGE_put_pps_entry(lpstr->hf,ppsent,&(lpstr->stde)))
+ if (!STORAGE_put_pps_entry(&lpstr->str,ppsent,&(lpstr->stde)))
return E_FAIL;
return S_OK;
}
WCHAR name[33];
int newpps;
- TRACE_(relay)("(%p)->(%s,%p,0x%08lx,%p,0x%08lx,%p)\n",
+ TRACE("(%p)->(%s,%p,0x%08lx,%p,0x%08lx,%p)\n",
This,pwcsName,pstgPrio,grfMode,snbExclude,reserved,ppstg
);
if (grfMode & STGM_TRANSACTED)
FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
_create_istorage16(ppstg);
lpstg = MapSL((SEGPTR)*ppstg);
- DuplicateHandle( GetCurrentProcess(), This->hf, GetCurrentProcess(),
- &lpstg->hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ if (This->str.hf) {
+ DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
+ &lpstg->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ } else {
+ lpstg->str.lockbytes = This->str.lockbytes;
+ _ilockbytes16_addref(This->str.lockbytes);
+ }
MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, name, sizeof(name)/sizeof(WCHAR));
- newpps = STORAGE_look_for_named_pps(lpstg->hf,This->stde.pps_dir,name);
+ newpps = STORAGE_look_for_named_pps(&lpstg->str,This->stde.pps_dir,name);
if (newpps==-1) {
IStream16_fnRelease((IStream16*)lpstg);
return E_FAIL;
}
- if (1!=STORAGE_get_pps_entry(lpstg->hf,newpps,&(lpstg->stde))) {
+ if (1!=STORAGE_get_pps_entry(&lpstg->str,newpps,&(lpstg->stde))) {
IStream16_fnRelease((IStream16*)lpstg);
return E_FAIL;
}
WCHAR name[33];
int newpps;
- TRACE_(relay)("(%p)->(%s,%p,0x%08lx,0x%08lx,%p)\n",
+ TRACE("(%p)->(%s,%p,0x%08lx,0x%08lx,%p)\n",
This,pwcsName,reserved1,grfMode,reserved2,ppstm
);
if (grfMode & STGM_TRANSACTED)
FIXME("We do not support transacted Compound Storage. Using direct mode.\n");
_create_istream16(ppstm);
lpstr = MapSL((SEGPTR)*ppstm);
- DuplicateHandle( GetCurrentProcess(), This->hf, GetCurrentProcess(),
- &lpstr->hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ if (This->str.hf) {
+ DuplicateHandle( GetCurrentProcess(), This->str.hf, GetCurrentProcess(),
+ &lpstr->str.hf, 0, TRUE, DUPLICATE_SAME_ACCESS );
+ } else {
+ lpstr->str.lockbytes = This->str.lockbytes;
+ _ilockbytes16_addref(This->str.lockbytes);
+ }
MultiByteToWideChar( CP_ACP, 0, pwcsName, -1, name, sizeof(name)/sizeof(WCHAR));
- newpps = STORAGE_look_for_named_pps(lpstr->hf,This->stde.pps_dir,name);
+ newpps = STORAGE_look_for_named_pps(&lpstr->str,This->stde.pps_dir,name);
if (newpps==-1) {
IStream16_fnRelease((IStream16*)lpstr);
return E_FAIL;
}
- if (1!=STORAGE_get_pps_entry(lpstr->hf,newpps,&(lpstr->stde))) {
+ if (1!=STORAGE_get_pps_entry(&lpstr->str,newpps,&(lpstr->stde))) {
IStream16_fnRelease((IStream16*)lpstr);
return E_FAIL;
}
- lpstr->offset.u.LowPart = 0;
+ lpstr->offset.u.LowPart = 0;
lpstr->offset.u.HighPart = 0;
- lpstr->ppsent = newpps;
+ lpstr->ppsent = newpps;
return S_OK;
}
}
lpst = HeapAlloc( GetProcessHeap(), 0, sizeof(*lpst) );
lpst->lpVtbl = segstvt16;
+ lpst->str.hf = NULL;
+ lpst->str.lockbytes = 0;
lpst->ref = 1;
lpst->thisptr = MapLS(lpst);
*stg = (void*)lpst->thisptr;
return E_FAIL;
}
lpstg = MapSL((SEGPTR)*ppstgOpen);
- lpstg->hf = hf;
+ lpstg->str.hf = hf;
+ lpstg->str.lockbytes = 0;
/* FIXME: check for existence before overwriting? */
- if (!STORAGE_init_storage(hf)) {
+ if (!STORAGE_init_storage(&lpstg->str)) {
CloseHandle(hf);
return E_FAIL;
}
i=0;ret=0;
while (!ret) { /* neither 1 nor <0 */
- ret=STORAGE_get_pps_entry(hf,i,&stde);
+ ret=STORAGE_get_pps_entry(&lpstg->str,i,&stde);
if ((ret==1) && (stde.pps_type==5)) {
lpstg->stde = stde;
lpstg->ppsent = i;
return E_FAIL;
}
lpstg = MapSL((SEGPTR)*ppstgOpen);
- lpstg->hf = hf;
+ lpstg->str.hf = hf;
i=0;ret=0;
while (!ret) { /* neither 1 nor <0 */
- ret=STORAGE_get_pps_entry(hf,i,&stde);
+ ret=STORAGE_get_pps_entry(&lpstg->str,i,&stde);
if ((ret==1) && (stde.pps_type==5)) {
lpstg->stde=stde;
break;
args[0] = (DWORD)plkbyt; /* iface */
args[1] = args[2] = 0; /* ULARGE_INTEGER offset */
- args[3] = (DWORD)K32WOWGlobalAllocLock16( 0, 8, &hsig ); /* sig */
+ args[3] = WOWGlobalAllocLock16( 0, 8, &hsig ); /* sig */
args[4] = 8;
args[5] = 0;
- if (!K32WOWCallback16Ex(
+ if (!WOWCallback16Ex(
(DWORD)((const ILockBytes16Vtbl*)MapSL(
(SEGPTR)((LPLOCKBYTES16)MapSL(plkbyt))->lpVtbl)
)->ReadAt,
return hres;
}
if (memcmp(MapSL(args[3]), STORAGE_magic, sizeof(STORAGE_magic)) == 0) {
- K32WOWGlobalUnlockFree16(args[3]);
+ WOWGlobalUnlockFree16(args[3]);
return S_OK;
}
- K32WOWGlobalUnlockFree16(args[3]);
+ WOWGlobalUnlockFree16(args[3]);
return S_FALSE;
}
* StgOpenStorageOnILockBytes [STORAGE.4]
*/
HRESULT WINAPI StgOpenStorageOnILockBytes16(
- ILockBytes16 *plkbyt,
- IStorage16 *pstgPriority,
- DWORD grfMode,
- SNB16 snbExclude,
- DWORD reserved,
- IStorage16 **ppstgOpen)
+ SEGPTR /*ILockBytes16 **/plkbyt,
+ IStorage16 *pstgPriority,
+ DWORD grfMode,
+ SNB16 snbExclude,
+ DWORD reserved,
+ IStorage16 **ppstgOpen)
{
- IStorage16Impl* lpstg;
+ IStorage16Impl* lpstg;
+ int i,ret;
+ struct storage_pps_entry stde;
+
+ FIXME("(%lx, %p, 0x%08lx, %d, %lx, %p)\n", plkbyt, pstgPriority, grfMode, (int)snbExclude, reserved, ppstgOpen);
+ if ((plkbyt == 0) || (ppstgOpen == 0))
+ return STG_E_INVALIDPOINTER;
+
+ *ppstgOpen = 0;
+
+ _create_istorage16(ppstgOpen);
+ lpstg = MapSL((SEGPTR)*ppstgOpen);
+ lpstg->str.hf = NULL;
+ lpstg->str.lockbytes = plkbyt;
+ i=0;ret=0;
+ while (!ret) { /* neither 1 nor <0 */
+ ret=STORAGE_get_pps_entry(&lpstg->str,i,&stde);
+ if ((ret==1) && (stde.pps_type==5)) {
+ lpstg->stde=stde;
+ break;
+ }
+ i++;
+ }
+ if (ret!=1) {
+ IStorage16_fnRelease((IStorage16*)lpstg); /* will remove it */
+ return E_FAIL;
+ }
+ return S_OK;
+}
- if ((plkbyt == 0) || (ppstgOpen == 0))
- return STG_E_INVALIDPOINTER;
+/***********************************************************************
+ * ReadClassStg (OLE2.18)
+ *
+ * This method reads the CLSID previously written to a storage object with
+ * the WriteClassStg.
+ *
+ * PARAMS
+ * pstg Segmented LPSTORAGE pointer.
+ */
+HRESULT WINAPI ReadClassStg16(SEGPTR pstg, CLSID *pclsid)
+{
+ STATSTG16 statstg;
+ HANDLE16 hstatstg;
+ HRESULT hres;
+ DWORD args[3];
- *ppstgOpen = 0;
+ TRACE("(%lx, %p)\n", pstg, pclsid);
- _create_istorage16(ppstgOpen);
- lpstg = MapSL((SEGPTR)*ppstgOpen);
+ if(pclsid==NULL)
+ return E_POINTER;
+ /*
+ * read a STATSTG structure (contains the clsid) from the storage
+ */
+ args[0] = (DWORD)pstg; /* iface */
+ args[1] = WOWGlobalAllocLock16( 0, sizeof(STATSTG16), &hstatstg );
+ args[2] = STATFLAG_DEFAULT;
+
+ if (!WOWCallback16Ex(
+ (DWORD)((const IStorage16Vtbl*)MapSL(
+ (SEGPTR)((LPSTORAGE16)MapSL(pstg))->lpVtbl)
+ )->Stat,
+ WCB16_PASCAL,
+ 3*sizeof(DWORD),
+ (LPVOID)args,
+ (LPDWORD)&hres
+ )) {
+ WOWGlobalUnlockFree16(args[1]);
+ ERR("CallTo16 IStorage16::Stat() failed, hres %lx\n",hres);
+ return hres;
+ }
+ memcpy(&statstg, MapSL(args[1]), sizeof(STATSTG16));
+ WOWGlobalUnlockFree16(args[1]);
- /* just teach it to use HANDLE instead of ilockbytes :/ */
+ if(SUCCEEDED(hres)) {
+ *pclsid=statstg.clsid;
+ TRACE("clsid is %s\n", debugstr_guid(&statstg.clsid));
+ }
+ return hres;
+}
- return S_OK;
+/***********************************************************************
+ * GetConvertStg (OLE2.82)
+ */
+HRESULT WINAPI GetConvertStg16(LPSTORAGE stg) {
+ FIXME("unimplemented stub!\n");
+ return E_FAIL;
}
2 stub StgCreateDocFileOnILockBytes
# 2 pascal StgCreateDocFileOnILockBytes(ptr long long ptr) StgCreateDocFileOnILockBytes16
3 pascal StgOpenStorage(str ptr long ptr long ptr) StgOpenStorage16
-4 pascal StgOpenStorageOnILockBytes(ptr ptr long long long ptr) StgOpenStorageOnILockBytes16
+4 pascal StgOpenStorageOnILockBytes(segptr ptr long long long ptr) StgOpenStorageOnILockBytes16
5 pascal StgIsStorageFile(str) StgIsStorageFile16
6 pascal StgIsStorageILockBytes(segptr) StgIsStorageILockBytes16
7 stub StgSetTimes
WINE_DEFAULT_DEBUG_CHANNEL(storage);
-#define FILE_BEGIN 0
-
/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
#define OLESTREAM_ID 0x501
#define OLESTREAM_MAX_STR_LEN 255
{
char strTemp[OLESTREAM_MAX_STR_LEN];
IStorageCompObj.dwCLSIDNameLength = OLESTREAM_MAX_STR_LEN;
- hErr = RegQueryValueA(hKey, NULL, strTemp, &(IStorageCompObj.dwCLSIDNameLength));
+ hErr = RegQueryValueA(hKey, NULL, strTemp, (LONG*) &(IStorageCompObj.dwCLSIDNameLength));
if(hErr == ERROR_SUCCESS)
{
strcpy(IStorageCompObj.strCLSIDName, strTemp);