2009-01-21 14:10:09 +00:00
|
|
|
/*
|
|
|
|
* ITSS Class Factory
|
|
|
|
*
|
|
|
|
* Copyright 2002 Lionel Ulmer
|
|
|
|
* Copyright 2004 Mike McCormack
|
|
|
|
*
|
|
|
|
* see http://bonedaddy.net/pabs3/hhm/#chmspec
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-01-24 23:00:42 +00:00
|
|
|
|
2018-03-17 12:10:01 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "rpcproxy.h"
|
|
|
|
#include "advpub.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "itsstor.h"
|
|
|
|
|
|
|
|
#include "initguid.h"
|
|
|
|
#include "wine/itss.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(itss);
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj);
|
|
|
|
|
|
|
|
LONG dll_count = 0;
|
|
|
|
static HINSTANCE hInst;
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
|
|
|
|
{
|
|
|
|
switch(fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hInstDLL);
|
|
|
|
hInst = hInstDLL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* ITSS ClassFactory
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2012-01-27 17:05:33 +00:00
|
|
|
IClassFactory IClassFactory_iface;
|
2009-01-21 14:10:09 +00:00
|
|
|
HRESULT (*pfnCreateInstance)(IUnknown *pUnkOuter, LPVOID *ppObj);
|
|
|
|
} IClassFactoryImpl;
|
|
|
|
|
2012-01-27 17:05:33 +00:00
|
|
|
static inline IClassFactoryImpl *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2009-01-21 14:10:09 +00:00
|
|
|
static HRESULT WINAPI
|
|
|
|
ITSSCF_QueryInterface(LPCLASSFACTORY iface,REFIID riid,LPVOID *ppobj)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualGUID(riid, &IID_IClassFactory))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
2017-02-26 17:36:06 +00:00
|
|
|
*ppobj = &This->IClassFactory_iface;
|
2009-01-21 14:10:09 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppobj);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ITSSCF_AddRef(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
ITSS_LockModule();
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ITSSCF_Release(LPCLASSFACTORY iface)
|
|
|
|
{
|
|
|
|
ITSS_UnlockModule();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-06-04 02:37:18 +00:00
|
|
|
static HRESULT WINAPI ITSSCF_CreateInstance(IClassFactory *iface, IUnknown *outer,
|
|
|
|
REFIID riid, void **ppv)
|
2009-01-21 14:10:09 +00:00
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
IClassFactoryImpl *This = impl_from_IClassFactory(iface);
|
2018-06-04 02:37:18 +00:00
|
|
|
IUnknown *unk;
|
2009-01-21 14:10:09 +00:00
|
|
|
HRESULT hres;
|
|
|
|
|
2018-06-04 02:37:18 +00:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", This, outer, debugstr_guid(riid), ppv);
|
2009-01-21 14:10:09 +00:00
|
|
|
|
2018-06-04 02:37:18 +00:00
|
|
|
if(outer && !IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
*ppv = NULL;
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = This->pfnCreateInstance(outer, (void**)&unk);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
*ppv = NULL;
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
hres = IUnknown_QueryInterface(unk, riid, ppv);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
}else {
|
|
|
|
*ppv = unk;
|
2009-01-21 14:10:09 +00:00
|
|
|
}
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITSSCF_LockServer(LPCLASSFACTORY iface, BOOL dolock)
|
|
|
|
{
|
|
|
|
TRACE("(%p)->(%d)\n", iface, dolock);
|
|
|
|
|
|
|
|
if (dolock)
|
|
|
|
ITSS_LockModule();
|
|
|
|
else
|
|
|
|
ITSS_UnlockModule();
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ITSSCF_Vtbl =
|
|
|
|
{
|
|
|
|
ITSSCF_QueryInterface,
|
|
|
|
ITSSCF_AddRef,
|
|
|
|
ITSSCF_Release,
|
|
|
|
ITSSCF_CreateInstance,
|
|
|
|
ITSSCF_LockServer
|
|
|
|
};
|
|
|
|
|
2012-01-27 17:05:33 +00:00
|
|
|
static const IClassFactoryImpl ITStorage_factory = { { &ITSSCF_Vtbl }, ITSS_create };
|
|
|
|
static const IClassFactoryImpl MSITStore_factory = { { &ITSSCF_Vtbl }, ITS_IParseDisplayName_create };
|
|
|
|
static const IClassFactoryImpl ITSProtocol_factory = { { &ITSSCF_Vtbl }, ITSProtocol_create };
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (ITSS.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
|
|
|
|
{
|
|
|
|
const IClassFactoryImpl *factory;
|
|
|
|
|
|
|
|
TRACE("%s %s %p\n", debugstr_guid(rclsid), debugstr_guid(iid), ppv);
|
|
|
|
|
|
|
|
if (IsEqualGUID(&CLSID_ITStorage, rclsid))
|
|
|
|
factory = &ITStorage_factory;
|
|
|
|
else if (IsEqualGUID(&CLSID_MSITStore, rclsid))
|
|
|
|
factory = &MSITStore_factory;
|
|
|
|
else if (IsEqualGUID(&CLSID_ITSProtocol, rclsid))
|
|
|
|
factory = &ITSProtocol_factory;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("%s: no class found.\n", debugstr_guid(rclsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IUnknown_QueryInterface( (IUnknown*) factory, iid, ppv );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
typedef struct {
|
2012-01-27 17:05:33 +00:00
|
|
|
IITStorage IITStorage_iface;
|
2009-01-21 14:10:09 +00:00
|
|
|
LONG ref;
|
|
|
|
} ITStorageImpl;
|
|
|
|
|
2012-01-27 17:05:33 +00:00
|
|
|
static inline ITStorageImpl *impl_from_IITStorage(IITStorage *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ITStorageImpl, IITStorage_iface);
|
|
|
|
}
|
|
|
|
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_QueryInterface(
|
|
|
|
IITStorage* iface,
|
|
|
|
REFIID riid,
|
|
|
|
void** ppvObject)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IITStorage))
|
|
|
|
{
|
2013-09-20 10:53:58 +00:00
|
|
|
IITStorage_AddRef(iface);
|
|
|
|
*ppvObject = iface;
|
2009-01-21 14:10:09 +00:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ITStorageImpl_AddRef(
|
|
|
|
IITStorage* iface)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
TRACE("%p\n", This);
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ITStorageImpl_Release(
|
|
|
|
IITStorage* iface)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if (ref == 0) {
|
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
ITSS_UnlockModule();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgCreateDocfile(
|
|
|
|
IITStorage* iface,
|
|
|
|
const WCHAR* pwcsName,
|
|
|
|
DWORD grfMode,
|
|
|
|
DWORD reserved,
|
|
|
|
IStorage** ppstgOpen)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
TRACE("%p %s %u %u %p\n", This,
|
|
|
|
debugstr_w(pwcsName), grfMode, reserved, ppstgOpen );
|
|
|
|
|
|
|
|
return ITSS_StgOpenStorage( pwcsName, NULL, grfMode,
|
|
|
|
0, reserved, ppstgOpen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgCreateDocfileOnILockBytes(
|
|
|
|
IITStorage* iface,
|
|
|
|
ILockBytes* plkbyt,
|
|
|
|
DWORD grfMode,
|
|
|
|
DWORD reserved,
|
|
|
|
IStorage** ppstgOpen)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgIsStorageFile(
|
|
|
|
IITStorage* iface,
|
|
|
|
const WCHAR* pwcsName)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgIsStorageILockBytes(
|
|
|
|
IITStorage* iface,
|
|
|
|
ILockBytes* plkbyt)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgOpenStorage(
|
|
|
|
IITStorage* iface,
|
|
|
|
const WCHAR* pwcsName,
|
|
|
|
IStorage* pstgPriority,
|
|
|
|
DWORD grfMode,
|
|
|
|
SNB snbExclude,
|
|
|
|
DWORD reserved,
|
|
|
|
IStorage** ppstgOpen)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
TRACE("%p %s %p %d %p\n", This, debugstr_w( pwcsName ),
|
|
|
|
pstgPriority, grfMode, snbExclude );
|
|
|
|
|
|
|
|
return ITSS_StgOpenStorage( pwcsName, pstgPriority, grfMode,
|
|
|
|
snbExclude, reserved, ppstgOpen);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgOpenStorageOnILockBytes(
|
|
|
|
IITStorage* iface,
|
|
|
|
ILockBytes* plkbyt,
|
|
|
|
IStorage* pStgPriority,
|
|
|
|
DWORD grfMode,
|
|
|
|
SNB snbExclude,
|
|
|
|
DWORD reserved,
|
|
|
|
IStorage** ppstgOpen)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_StgSetTimes(
|
|
|
|
IITStorage* iface,
|
|
|
|
const WCHAR* lpszName,
|
|
|
|
const FILETIME* pctime,
|
|
|
|
const FILETIME* patime,
|
|
|
|
const FILETIME* pmtime)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_SetControlData(
|
|
|
|
IITStorage* iface,
|
|
|
|
PITS_Control_Data pControlData)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_DefaultControlData(
|
|
|
|
IITStorage* iface,
|
|
|
|
PITS_Control_Data* ppControlData)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ITStorageImpl_Compact(
|
|
|
|
IITStorage* iface,
|
|
|
|
const WCHAR* pwcsName,
|
|
|
|
ECompactionLev iLev)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
ITStorageImpl *This = impl_from_IITStorage(iface);
|
2009-01-21 14:10:09 +00:00
|
|
|
FIXME("%p\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IITStorageVtbl ITStorageImpl_Vtbl =
|
|
|
|
{
|
|
|
|
ITStorageImpl_QueryInterface,
|
|
|
|
ITStorageImpl_AddRef,
|
|
|
|
ITStorageImpl_Release,
|
|
|
|
ITStorageImpl_StgCreateDocfile,
|
|
|
|
ITStorageImpl_StgCreateDocfileOnILockBytes,
|
|
|
|
ITStorageImpl_StgIsStorageFile,
|
|
|
|
ITStorageImpl_StgIsStorageILockBytes,
|
|
|
|
ITStorageImpl_StgOpenStorage,
|
|
|
|
ITStorageImpl_StgOpenStorageOnILockBytes,
|
|
|
|
ITStorageImpl_StgSetTimes,
|
|
|
|
ITStorageImpl_SetControlData,
|
|
|
|
ITStorageImpl_DefaultControlData,
|
|
|
|
ITStorageImpl_Compact,
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT ITSS_create(IUnknown *pUnkOuter, LPVOID *ppObj)
|
|
|
|
{
|
|
|
|
ITStorageImpl *its;
|
|
|
|
|
|
|
|
if( pUnkOuter )
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
|
|
|
its = HeapAlloc( GetProcessHeap(), 0, sizeof(ITStorageImpl) );
|
2012-01-27 17:05:33 +00:00
|
|
|
its->IITStorage_iface.lpVtbl = &ITStorageImpl_Vtbl;
|
2009-01-21 14:10:09 +00:00
|
|
|
its->ref = 1;
|
|
|
|
|
|
|
|
TRACE("-> %p\n", its);
|
2009-02-26 10:34:15 +00:00
|
|
|
*ppObj = its;
|
2009-01-21 14:10:09 +00:00
|
|
|
|
|
|
|
ITSS_LockModule();
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
|
|
{
|
|
|
|
TRACE("dll_count = %u\n", dll_count);
|
|
|
|
return dll_count ? S_FALSE : S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (ITSS.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
return __wine_register_resources( hInst );
|
2009-01-21 14:10:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (ITSS.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
2012-01-27 17:05:33 +00:00
|
|
|
return __wine_unregister_resources( hInst );
|
2009-01-21 14:10:09 +00:00
|
|
|
}
|