2012-11-21 11:09:45 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Stefan Leichter
|
2012-12-24 15:13:39 +01:00
|
|
|
* Copyright 2012 Jacek Caban for CodeWeavers
|
2012-11-21 11:09:45 +01:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2012-11-21 11:11:37 +01:00
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "atlbase.h"
|
2014-05-07 09:39:02 +02:00
|
|
|
#include "atlcom.h"
|
2012-11-21 11:09:45 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2013-10-16 20:42:27 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(atl);
|
2012-11-21 11:09:45 +01:00
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
#define ATLVer1Size FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer)
|
|
|
|
|
2013-01-25 13:12:02 +01:00
|
|
|
typedef unsigned char cpp_bool;
|
|
|
|
|
2012-12-24 15:13:39 +01:00
|
|
|
static ICatRegister *catreg;
|
|
|
|
|
2012-11-21 11:11:37 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlAdvise [atl100.@]
|
|
|
|
*/
|
2013-01-03 11:45:44 +01:00
|
|
|
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, DWORD *pdw)
|
2012-11-21 11:11:37 +01:00
|
|
|
{
|
2013-01-03 11:45:44 +01:00
|
|
|
IConnectionPointContainer *container;
|
|
|
|
IConnectionPoint *cp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
|
|
|
|
|
2013-05-25 14:56:43 +02:00
|
|
|
if(!pUnkCP)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-01-03 11:45:44 +01:00
|
|
|
hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IConnectionPointContainer_FindConnectionPoint(container, iid, &cp);
|
|
|
|
IConnectionPointContainer_Release(container);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IConnectionPoint_Advise(cp, pUnk, pdw);
|
|
|
|
IConnectionPoint_Release(cp);
|
|
|
|
return hres;
|
2012-11-21 11:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlUnadvise [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw)
|
|
|
|
{
|
2013-01-03 11:45:54 +01:00
|
|
|
IConnectionPointContainer *container;
|
|
|
|
IConnectionPoint *cp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("%p %p %ld\n", pUnkCP, iid, dw);
|
2013-01-03 11:45:54 +01:00
|
|
|
|
2013-05-25 14:56:43 +02:00
|
|
|
if(!pUnkCP)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2013-01-03 11:45:54 +01:00
|
|
|
hres = IUnknown_QueryInterface(pUnkCP, &IID_IConnectionPointContainer, (void**)&container);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IConnectionPointContainer_FindConnectionPoint(container, iid, &cp);
|
|
|
|
IConnectionPointContainer_Release(container);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IConnectionPoint_Unadvise(cp, dw);
|
|
|
|
IConnectionPoint_Release(cp);
|
|
|
|
return hres;
|
2012-11-21 11:11:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlFreeMarshalStream [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlFreeMarshalStream(IStream *stm)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", stm);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlMarshalPtrInProc [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **pstm)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", pUnk, iid, pstm);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlUnmarshalPtr [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", stm, iid, ppUnk);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlCreateTargetDC [atl100.@]
|
|
|
|
*/
|
|
|
|
HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
|
|
|
|
{
|
|
|
|
const WCHAR *driver = NULL, *device = NULL, *port = NULL;
|
|
|
|
DEVMODEW *devmode = NULL;
|
|
|
|
|
|
|
|
TRACE( "(%p, %p)\n", hdc, dv );
|
|
|
|
|
|
|
|
if (dv)
|
|
|
|
{
|
|
|
|
if (dv->tdDriverNameOffset) driver = (WCHAR *)((char *)dv + dv->tdDriverNameOffset);
|
|
|
|
if (dv->tdDeviceNameOffset) device = (WCHAR *)((char *)dv + dv->tdDeviceNameOffset);
|
|
|
|
if (dv->tdPortNameOffset) port = (WCHAR *)((char *)dv + dv->tdPortNameOffset);
|
|
|
|
if (dv->tdExtDevmodeOffset) devmode = (DEVMODEW *)((char *)dv + dv->tdExtDevmodeOffset);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hdc) return hdc;
|
2020-10-07 00:51:58 +02:00
|
|
|
driver = L"display";
|
2012-11-21 11:11:37 +01:00
|
|
|
}
|
|
|
|
return CreateDCW( driver, device, port, devmode );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlHiMetricToPixel [atl100.@]
|
|
|
|
*/
|
|
|
|
void WINAPI AtlHiMetricToPixel(const SIZEL* lpHiMetric, SIZEL* lpPix)
|
|
|
|
{
|
|
|
|
HDC dc = GetDC(NULL);
|
|
|
|
lpPix->cx = lpHiMetric->cx * GetDeviceCaps( dc, LOGPIXELSX ) / 100;
|
|
|
|
lpPix->cy = lpHiMetric->cy * GetDeviceCaps( dc, LOGPIXELSY ) / 100;
|
|
|
|
ReleaseDC( NULL, dc );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlPixelToHiMetric [atl100.@]
|
|
|
|
*/
|
|
|
|
void WINAPI AtlPixelToHiMetric(const SIZEL* lpPix, SIZEL* lpHiMetric)
|
|
|
|
{
|
|
|
|
HDC dc = GetDC(NULL);
|
|
|
|
lpHiMetric->cx = 100 * lpPix->cx / GetDeviceCaps( dc, LOGPIXELSX );
|
|
|
|
lpHiMetric->cy = 100 * lpPix->cy / GetDeviceCaps( dc, LOGPIXELSY );
|
|
|
|
ReleaseDC( NULL, dc );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlComPtrAssign [atl100.@]
|
|
|
|
*/
|
|
|
|
IUnknown* WINAPI AtlComPtrAssign(IUnknown** pp, IUnknown *p)
|
|
|
|
{
|
|
|
|
TRACE("(%p %p)\n", pp, p);
|
|
|
|
|
|
|
|
if (p) IUnknown_AddRef(p);
|
|
|
|
if (*pp) IUnknown_Release(*pp);
|
|
|
|
*pp = p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlComQIPtrAssign [atl100.@]
|
|
|
|
*/
|
|
|
|
IUnknown* WINAPI AtlComQIPtrAssign(IUnknown** pp, IUnknown *p, REFIID riid)
|
|
|
|
{
|
|
|
|
IUnknown *new_p = NULL;
|
|
|
|
|
|
|
|
TRACE("(%p %p %s)\n", pp, p, debugstr_guid(riid));
|
|
|
|
|
|
|
|
if (p) IUnknown_QueryInterface(p, riid, (void **)&new_p);
|
|
|
|
if (*pp) IUnknown_Release(*pp);
|
|
|
|
*pp = new_p;
|
|
|
|
return new_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlInternalQueryInterface [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
HRESULT rc = E_NOINTERFACE;
|
|
|
|
TRACE("(%p, %p, %s, %p)\n",this, pEntries, debugstr_guid(iid), ppvObject);
|
|
|
|
|
|
|
|
if (IsEqualGUID(iid,&IID_IUnknown))
|
|
|
|
{
|
|
|
|
TRACE("Returning IUnknown\n");
|
|
|
|
*ppvObject = ((LPSTR)this+pEntries[0].dw);
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (pEntries[i].pFunc != 0)
|
|
|
|
{
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("Trying entry %i (%s %Ix %p)\n",i,debugstr_guid(pEntries[i].piid),
|
2012-11-21 11:11:37 +01:00
|
|
|
pEntries[i].dw, pEntries[i].pFunc);
|
|
|
|
|
|
|
|
if (!pEntries[i].piid || IsEqualGUID(iid,pEntries[i].piid))
|
|
|
|
{
|
|
|
|
TRACE("MATCH\n");
|
|
|
|
if (pEntries[i].pFunc == (_ATL_CREATORARGFUNC*)1)
|
|
|
|
{
|
|
|
|
TRACE("Offset\n");
|
|
|
|
*ppvObject = ((LPSTR)this+pEntries[i].dw);
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Function\n");
|
|
|
|
rc = pEntries[i].pFunc(this, iid, ppvObject, pEntries[i].dw);
|
|
|
|
if(rc==S_OK || pEntries[i].piid)
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("Done returning (0x%lx)\n",rc);
|
2012-11-21 11:11:37 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlIPersistStreamInit_Load [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlIPersistStreamInit_Load( LPSTREAM pStm, ATL_PROPMAP_ENTRY *pMap,
|
|
|
|
void *pThis, IUnknown *pUnk)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %p)\n", pStm, pMap, pThis, pUnk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlIPersistStreamInit_Save [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlIPersistStreamInit_Save(LPSTREAM pStm, BOOL fClearDirty,
|
|
|
|
ATL_PROPMAP_ENTRY *pMap, void *pThis,
|
|
|
|
IUnknown *pUnk)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %p, %p, %p)\n", pStm, fClearDirty, pMap, pThis, pUnk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-24 18:43:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlIPersistPropertyBag_Load [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlIPersistPropertyBag_Load(LPPROPERTYBAG pPropBag, LPERRORLOG pErrorLog,
|
|
|
|
ATL_PROPMAP_ENTRY *pMap, void *pThis,
|
|
|
|
IUnknown *pUnk)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %p, %p, %p, %p)\n", pPropBag, pErrorLog, pMap, pThis, pUnk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-26 10:43:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlIPersistPropertyBag_Save [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlIPersistPropertyBag_Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty,
|
|
|
|
BOOL fSaveAll, ATL_PROPMAP_ENTRY *pMap,
|
|
|
|
void *pThis, IUnknown *pUnk)
|
|
|
|
{
|
|
|
|
FIXME("(%p, %d, %d, %p, %p, %p)\n", pPropBag, fClearDirty, fSaveAll, pMap, pThis, pUnk);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-10 12:27:29 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleAddTermFunc [atl100.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULE *pM, _ATL_TERMFUNC *pFunc, DWORD_PTR dw)
|
|
|
|
{
|
|
|
|
_ATL_TERMFUNC_ELEM *termfunc_elem;
|
|
|
|
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("version %04x (%p %p %Id)\n", _ATL_VER, pM, pFunc, dw);
|
2012-12-10 12:27:29 +01:00
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
if (_ATL_VER > _ATL_VER_30 || pM->cbSize > ATLVer1Size) {
|
2022-03-31 13:54:48 +02:00
|
|
|
termfunc_elem = malloc(sizeof(*termfunc_elem));
|
2014-02-13 16:00:27 +01:00
|
|
|
termfunc_elem->pFunc = pFunc;
|
|
|
|
termfunc_elem->dw = dw;
|
|
|
|
termfunc_elem->pNext = pM->m_pTermFuncs;
|
2012-12-10 12:27:29 +01:00
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
pM->m_pTermFuncs = termfunc_elem;
|
|
|
|
}
|
2012-12-10 12:27:29 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
#if _ATL_VER > _ATL_VER_30
|
|
|
|
|
2012-12-10 12:27:47 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlCallTermFunc [atl100.@]
|
|
|
|
*/
|
|
|
|
void WINAPI AtlCallTermFunc(_ATL_MODULE *pM)
|
|
|
|
{
|
|
|
|
_ATL_TERMFUNC_ELEM *iter = pM->m_pTermFuncs, *tmp;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pM);
|
|
|
|
|
|
|
|
while(iter) {
|
|
|
|
iter->pFunc(iter->dw);
|
|
|
|
tmp = iter;
|
|
|
|
iter = iter->pNext;
|
2022-03-31 13:54:48 +02:00
|
|
|
free(tmp);
|
2012-12-10 12:27:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pM->m_pTermFuncs = NULL;
|
|
|
|
}
|
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
#endif
|
|
|
|
|
2012-12-11 13:02:46 +01:00
|
|
|
/***********************************************************************
|
2012-12-28 14:23:07 +01:00
|
|
|
* AtlLoadTypeLib [atl100.56]
|
2012-12-11 13:02:46 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
|
|
|
|
BSTR *pbstrPath, ITypeLib **ppTypeLib)
|
|
|
|
{
|
2012-12-28 14:23:07 +01:00
|
|
|
size_t path_len, index_len;
|
|
|
|
ITypeLib *typelib = NULL;
|
|
|
|
WCHAR *path;
|
2012-12-11 13:02:46 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib);
|
|
|
|
|
2019-05-27 15:51:13 +02:00
|
|
|
index_len = lpszIndex ? lstrlenW(lpszIndex) : 0;
|
2022-03-31 13:54:48 +02:00
|
|
|
path = malloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(L".tlb"));
|
2012-12-28 14:23:07 +01:00
|
|
|
if(!path)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
path_len = GetModuleFileNameW(inst, path, MAX_PATH);
|
2013-01-05 00:20:57 +01:00
|
|
|
if(!path_len) {
|
2022-03-31 13:54:48 +02:00
|
|
|
free(path);
|
2012-12-28 14:23:07 +01:00
|
|
|
return HRESULT_FROM_WIN32(GetLastError());
|
2013-01-05 00:20:57 +01:00
|
|
|
}
|
2012-12-28 14:23:07 +01:00
|
|
|
|
|
|
|
if(index_len)
|
|
|
|
memcpy(path+path_len, lpszIndex, (index_len+1)*sizeof(WCHAR));
|
|
|
|
|
|
|
|
hres = LoadTypeLib(path, &typelib);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
WCHAR *ptr;
|
|
|
|
|
|
|
|
for(ptr = path+path_len-1; ptr > path && *ptr != '\\' && *ptr != '.'; ptr--);
|
|
|
|
if(*ptr != '.')
|
|
|
|
ptr = path+path_len;
|
2020-10-07 00:51:58 +02:00
|
|
|
lstrcpyW(ptr, L".tlb");
|
2012-12-28 14:23:07 +01:00
|
|
|
hres = LoadTypeLib(path, &typelib);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*pbstrPath = SysAllocString(path);
|
|
|
|
if(!*pbstrPath) {
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
hres = E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
}
|
2012-12-11 13:02:46 +01:00
|
|
|
|
2022-03-31 13:54:48 +02:00
|
|
|
free(path);
|
2012-12-11 13:02:46 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2012-12-28 14:23:07 +01:00
|
|
|
*ppTypeLib = typelib;
|
2012-12-11 13:02:46 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-13 16:00:42 +01:00
|
|
|
#if _ATL_VER <= _ATL_VER_80
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlRegisterTypeLib [atl80.19]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlRegisterTypeLib(HINSTANCE inst, const WCHAR *index)
|
|
|
|
{
|
|
|
|
ITypeLib *typelib;
|
|
|
|
BSTR path;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s)\n", inst, debugstr_w(index));
|
|
|
|
|
|
|
|
hres = AtlLoadTypeLib(inst, index, &path, &typelib);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = RegisterTypeLib(typelib, path, NULL); /* FIXME: pass help directory */
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
SysFreeString(path);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
#if _ATL_VER > _ATL_VER_30
|
|
|
|
|
2012-12-18 11:48:37 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlWinModuleInit [atl100.65]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlWinModuleInit(_ATL_WIN_MODULE *winmod)
|
|
|
|
{
|
2014-01-11 16:02:02 +01:00
|
|
|
TRACE("(%p)\n", winmod);
|
2012-12-18 11:48:37 +01:00
|
|
|
|
|
|
|
if(winmod->cbSize != sizeof(*winmod))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
InitializeCriticalSection(&winmod->m_csWindowCreate);
|
|
|
|
winmod->m_pCreateWndList = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2012-12-12 14:56:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlWinModuleAddCreateWndData [atl100.43]
|
|
|
|
*/
|
|
|
|
void WINAPI AtlWinModuleAddCreateWndData(_ATL_WIN_MODULE *pM, _AtlCreateWndData *pData, void *pvObject)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %p)\n", pM, pData, pvObject);
|
|
|
|
|
|
|
|
pData->m_pThis = pvObject;
|
|
|
|
pData->m_dwThreadID = GetCurrentThreadId();
|
|
|
|
|
|
|
|
EnterCriticalSection(&pM->m_csWindowCreate);
|
|
|
|
pData->m_pNext = pM->m_pCreateWndList;
|
|
|
|
pM->m_pCreateWndList = pData;
|
|
|
|
LeaveCriticalSection(&pM->m_csWindowCreate);
|
|
|
|
}
|
|
|
|
|
2012-12-19 14:16:57 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlWinModuleExtractCreateWndData [atl100.44]
|
|
|
|
*/
|
|
|
|
void* WINAPI AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE *winmod)
|
|
|
|
{
|
|
|
|
_AtlCreateWndData *iter, *prev = NULL;
|
|
|
|
DWORD thread_id;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", winmod);
|
|
|
|
|
|
|
|
thread_id = GetCurrentThreadId();
|
|
|
|
|
|
|
|
EnterCriticalSection(&winmod->m_csWindowCreate);
|
|
|
|
|
|
|
|
for(iter = winmod->m_pCreateWndList; iter && iter->m_dwThreadID != thread_id; iter = iter->m_pNext)
|
|
|
|
prev = iter;
|
|
|
|
if(iter) {
|
|
|
|
if(prev)
|
|
|
|
prev->m_pNext = iter->m_pNext;
|
|
|
|
else
|
|
|
|
winmod->m_pCreateWndList = iter->m_pNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&winmod->m_csWindowCreate);
|
|
|
|
|
|
|
|
return iter ? iter->m_pThis : NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-14 11:58:10 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlComModuleGetClassObject [atl100.15]
|
|
|
|
*/
|
2017-10-06 18:51:36 +02:00
|
|
|
#if _ATL_VER < _ATL_VER_110
|
2012-12-14 11:58:10 +01:00
|
|
|
HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pm, REFCLSID rclsid, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRY **iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s %s %p)\n", pm, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if(!pm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++) {
|
|
|
|
if(IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
|
|
|
|
if(!(*iter)->pCF)
|
|
|
|
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&(*iter)->pCF);
|
|
|
|
if((*iter)->pCF)
|
|
|
|
hres = IUnknown_QueryInterface((*iter)->pCF, riid, ppv);
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("returning %p (%08lx)\n", *ppv, hres);
|
2012-12-14 11:58:10 +01:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Class %s not found\n", debugstr_guid(rclsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
2017-10-06 18:51:36 +02:00
|
|
|
#else
|
|
|
|
HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pm, REFCLSID rclsid, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRY_EX **iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %s %s %p)\n", pm, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if(!pm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(iter = pm->m_ppAutoObjMapFirst; iter < pm->m_ppAutoObjMapLast; iter++) {
|
|
|
|
if(IsEqualCLSID((*iter)->pclsid, rclsid) && (*iter)->pfnGetClassObject) {
|
|
|
|
if(!(*iter)->pCache->pCF)
|
|
|
|
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&(*iter)->pCache->pCF);
|
|
|
|
if((*iter)->pCache->pCF)
|
|
|
|
hres = IUnknown_QueryInterface((*iter)->pCache->pCF, riid, ppv);
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("returning %p (%08lx)\n", *ppv, hres);
|
2017-10-06 18:51:36 +02:00
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Class %s not found\n", debugstr_guid(rclsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
|
|
|
#endif
|
2012-12-14 11:58:10 +01:00
|
|
|
|
2013-02-08 10:59:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlComModuleRegisterClassObjects [atl100.17]
|
|
|
|
*/
|
2017-10-06 18:51:36 +02:00
|
|
|
#if _ATL_VER < _ATL_VER_110
|
2013-02-08 10:59:19 +01:00
|
|
|
HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD context, DWORD flags)
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRY **iter;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("(%p %lx %lx)\n", module, context, flags);
|
2013-02-08 10:59:19 +01:00
|
|
|
|
|
|
|
if(!module)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
|
|
|
|
if(!(*iter)->pfnGetClassObject)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CoRegisterClassObject((*iter)->pclsid, unk, context, flags, &(*iter)->dwRegister);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2013-12-09 12:33:39 +01:00
|
|
|
}
|
2017-10-06 18:51:36 +02:00
|
|
|
#else
|
|
|
|
HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD context, DWORD flags)
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRY_EX **iter;
|
|
|
|
IUnknown *unk;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("(%p %lx %lx)\n", module, context, flags);
|
2017-10-06 18:51:36 +02:00
|
|
|
|
|
|
|
if(!module)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
|
|
|
|
if(!(*iter)->pfnGetClassObject)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
hres = (*iter)->pfnGetClassObject((*iter)->pfnCreateInstance, &IID_IUnknown, (void**)&unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = CoRegisterClassObject((*iter)->pclsid, unk, context, flags, &(*iter)->pCache->dwRegister);
|
|
|
|
IUnknown_Release(unk);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
#endif
|
2013-02-08 10:59:19 +01:00
|
|
|
|
2013-12-09 12:33:39 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlComModuleRevokeClassObjects [atl100.20]
|
|
|
|
*/
|
2017-10-06 18:51:36 +02:00
|
|
|
#if _ATL_VER < _ATL_VER_110
|
2013-12-09 12:33:39 +01:00
|
|
|
HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRY **iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", module);
|
|
|
|
|
|
|
|
if(!module)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
|
|
|
|
hres = CoRevokeClassObject((*iter)->dwRegister);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2013-02-08 10:59:19 +01:00
|
|
|
}
|
2017-10-06 18:51:36 +02:00
|
|
|
#else
|
|
|
|
HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRY_EX **iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", module);
|
|
|
|
|
|
|
|
if(!module)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
for(iter = module->m_ppAutoObjMapFirst; iter < module->m_ppAutoObjMapLast; iter++) {
|
|
|
|
hres = CoRevokeClassObject((*iter)->pCache->dwRegister);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
#endif
|
2013-02-08 10:59:19 +01:00
|
|
|
|
2013-01-14 13:03:13 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlComModuleUnregisterServer [atl100.22]
|
|
|
|
*/
|
2017-10-06 18:51:36 +02:00
|
|
|
#if _ATL_VER < _ATL_VER_110
|
2013-01-14 13:03:13 +01:00
|
|
|
HRESULT WINAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE *mod, BOOL bRegTypeLib, const CLSID *clsid)
|
|
|
|
{
|
|
|
|
const struct _ATL_CATMAP_ENTRY *catmap;
|
|
|
|
_ATL_OBJMAP_ENTRY **iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %x %s)\n", mod, bRegTypeLib, debugstr_guid(clsid));
|
|
|
|
|
|
|
|
for(iter = mod->m_ppAutoObjMapFirst; iter < mod->m_ppAutoObjMapLast; iter++) {
|
|
|
|
if(!*iter || (clsid && !IsEqualCLSID((*iter)->pclsid, clsid)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TRACE("Unregistering clsid %s\n", debugstr_guid((*iter)->pclsid));
|
|
|
|
|
|
|
|
catmap = (*iter)->pfnGetCategoryMap();
|
|
|
|
if(catmap) {
|
|
|
|
hres = AtlRegisterClassCategoriesHelper((*iter)->pclsid, catmap, FALSE);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = (*iter)->pfnUpdateRegistry(FALSE);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bRegTypeLib) {
|
|
|
|
ITypeLib *typelib;
|
|
|
|
TLIBATTR *attr;
|
|
|
|
BSTR path;
|
|
|
|
|
|
|
|
hres = AtlLoadTypeLib(mod->m_hInstTypeLib, NULL, &path, &typelib);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
SysFreeString(path);
|
|
|
|
hres = ITypeLib_GetLibAttr(typelib, &attr);
|
2013-01-15 12:46:06 +01:00
|
|
|
if(SUCCEEDED(hres)) {
|
2013-01-14 13:03:13 +01:00
|
|
|
hres = UnRegisterTypeLib(&attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, attr->lcid, attr->syskind);
|
2013-01-15 12:46:06 +01:00
|
|
|
ITypeLib_ReleaseTLibAttr(typelib, attr);
|
|
|
|
}
|
2013-01-14 13:03:13 +01:00
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2017-10-06 18:51:36 +02:00
|
|
|
#else
|
|
|
|
HRESULT WINAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE *mod, BOOL bRegTypeLib, const CLSID *clsid)
|
|
|
|
{
|
|
|
|
const struct _ATL_CATMAP_ENTRY *catmap;
|
|
|
|
_ATL_OBJMAP_ENTRY_EX **iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %x %s)\n", mod, bRegTypeLib, debugstr_guid(clsid));
|
|
|
|
|
|
|
|
for(iter = mod->m_ppAutoObjMapFirst; iter < mod->m_ppAutoObjMapLast; iter++) {
|
|
|
|
if(!*iter || (clsid && !IsEqualCLSID((*iter)->pclsid, clsid)))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TRACE("Unregistering clsid %s\n", debugstr_guid((*iter)->pclsid));
|
|
|
|
|
|
|
|
catmap = (*iter)->pfnGetCategoryMap();
|
|
|
|
if(catmap) {
|
|
|
|
hres = AtlRegisterClassCategoriesHelper((*iter)->pclsid, catmap, FALSE);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = (*iter)->pfnUpdateRegistry(FALSE);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(bRegTypeLib) {
|
|
|
|
ITypeLib *typelib;
|
|
|
|
TLIBATTR *attr;
|
|
|
|
BSTR path;
|
|
|
|
|
|
|
|
hres = AtlLoadTypeLib(mod->m_hInstTypeLib, NULL, &path, &typelib);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
SysFreeString(path);
|
|
|
|
hres = ITypeLib_GetLibAttr(typelib, &attr);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = UnRegisterTypeLib(&attr->guid, attr->wMajorVerNum, attr->wMinorVerNum, attr->lcid, attr->syskind);
|
|
|
|
ITypeLib_ReleaseTLibAttr(typelib, attr);
|
|
|
|
}
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
#endif
|
2013-01-14 13:03:13 +01:00
|
|
|
|
2014-02-13 16:00:27 +01:00
|
|
|
#endif
|
|
|
|
|
2012-12-13 12:00:23 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlRegisterClassCategoriesHelper [atl100.49]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlRegisterClassCategoriesHelper(REFCLSID clsid, const struct _ATL_CATMAP_ENTRY *catmap, BOOL reg)
|
|
|
|
{
|
2012-12-24 15:13:39 +01:00
|
|
|
const struct _ATL_CATMAP_ENTRY *iter;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%s %p %x)\n", debugstr_guid(clsid), catmap, reg);
|
|
|
|
|
2012-12-31 14:29:23 +01:00
|
|
|
if(!catmap)
|
|
|
|
return S_OK;
|
|
|
|
|
2012-12-24 15:13:39 +01:00
|
|
|
if(!catreg) {
|
|
|
|
ICatRegister *new_catreg;
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ICatRegister, (void**)&new_catreg);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(InterlockedCompareExchangePointer((void**)&catreg, new_catreg, NULL))
|
|
|
|
ICatRegister_Release(new_catreg);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(iter = catmap; iter->iType != _ATL_CATMAP_ENTRY_END; iter++) {
|
|
|
|
CATID catid = *iter->pcatid; /* For stupid lack of const in ICatRegister declaration. */
|
|
|
|
|
|
|
|
if(iter->iType == _ATL_CATMAP_ENTRY_IMPLEMENTED) {
|
|
|
|
if(reg)
|
|
|
|
hres = ICatRegister_RegisterClassImplCategories(catreg, clsid, 1, &catid);
|
|
|
|
else
|
|
|
|
hres = ICatRegister_UnRegisterClassImplCategories(catreg, clsid, 1, &catid);
|
|
|
|
}else {
|
|
|
|
if(reg)
|
|
|
|
hres = ICatRegister_RegisterClassReqCategories(catreg, clsid, 1, &catid);
|
|
|
|
else
|
|
|
|
hres = ICatRegister_UnRegisterClassReqCategories(catreg, clsid, 1, &catid);
|
|
|
|
}
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!reg) {
|
2020-10-07 00:51:58 +02:00
|
|
|
WCHAR reg_path[256] = L"CLSID\\", *ptr = reg_path+6;
|
2012-12-24 15:13:39 +01:00
|
|
|
|
|
|
|
ptr += StringFromGUID2(clsid, ptr, 64)-1;
|
|
|
|
*ptr++ = '\\';
|
|
|
|
|
2020-10-07 00:51:58 +02:00
|
|
|
lstrcpyW(ptr, L"Implemented Categories");
|
2012-12-24 15:13:39 +01:00
|
|
|
RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path);
|
|
|
|
|
2020-10-07 00:51:58 +02:00
|
|
|
lstrcpyW(ptr, L"Required Categories");
|
2012-12-24 15:13:39 +01:00
|
|
|
RegDeleteKeyW(HKEY_CLASSES_ROOT, reg_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2012-12-13 12:00:23 +01:00
|
|
|
}
|
|
|
|
|
2013-01-10 13:27:05 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlWaitWithMessageLoop [atl100.24]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI AtlWaitWithMessageLoop(HANDLE handle)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
DWORD res;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", handle);
|
|
|
|
|
|
|
|
while(1) {
|
|
|
|
res = MsgWaitForMultipleObjects(1, &handle, FALSE, INFINITE, QS_ALLINPUT);
|
|
|
|
switch(res) {
|
|
|
|
case WAIT_OBJECT_0:
|
|
|
|
return TRUE;
|
|
|
|
case WAIT_OBJECT_0+1:
|
|
|
|
if(GetMessageW(&msg, NULL, 0, 0) < 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessageW(&msg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-15 12:45:47 +01:00
|
|
|
static HRESULT get_default_source(ITypeLib *typelib, const CLSID *clsid, IID *iid)
|
|
|
|
{
|
|
|
|
ITypeInfo *typeinfo, *src_typeinfo = NULL;
|
|
|
|
TYPEATTR *attr;
|
|
|
|
int type_flags;
|
|
|
|
unsigned i;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = ITypeLib_GetTypeInfoOfGuid(typelib, clsid, &typeinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetTypeAttr(typeinfo, &attr);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0; i < attr->cImplTypes; i++) {
|
|
|
|
hres = ITypeInfo_GetImplTypeFlags(typeinfo, i, &type_flags);
|
|
|
|
if(SUCCEEDED(hres) && type_flags == (IMPLTYPEFLAG_FSOURCE|IMPLTYPEFLAG_FDEFAULT)) {
|
|
|
|
HREFTYPE ref;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetRefTypeOfImplType(typeinfo, i, &ref);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = ITypeInfo_GetRefTypeInfo(typeinfo, ref, &src_typeinfo);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ITypeInfo_ReleaseTypeAttr(typeinfo, attr);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
if(!src_typeinfo) {
|
|
|
|
*iid = IID_NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetTypeAttr(src_typeinfo, &attr);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*iid = attr->guid;
|
|
|
|
ITypeInfo_ReleaseTypeAttr(src_typeinfo, attr);
|
|
|
|
}
|
|
|
|
ITypeInfo_Release(src_typeinfo);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlGetObjectSourceInterface [atl100.54]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlGetObjectSourceInterface(IUnknown *unk, GUID *libid, IID *iid, unsigned short *major, unsigned short *minor)
|
|
|
|
{
|
|
|
|
IProvideClassInfo2 *classinfo;
|
|
|
|
ITypeInfo *typeinfo;
|
|
|
|
ITypeLib *typelib;
|
|
|
|
IPersist *persist;
|
|
|
|
IDispatch *disp;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p %p %p %p %p)\n", unk, libid, iid, major, minor);
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IDispatch, (void**)&disp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IDispatch_GetTypeInfo(disp, 0, 0, &typeinfo);
|
|
|
|
IDispatch_Release(disp);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = ITypeInfo_GetContainingTypeLib(typeinfo, &typelib, 0);
|
|
|
|
ITypeInfo_Release(typeinfo);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
TLIBATTR *attr;
|
|
|
|
|
|
|
|
hres = ITypeLib_GetLibAttr(typelib, &attr);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
*libid = attr->guid;
|
|
|
|
*major = attr->wMajorVerNum;
|
|
|
|
*minor = attr->wMinorVerNum;
|
|
|
|
ITypeLib_ReleaseTLibAttr(typelib, attr);
|
|
|
|
}else {
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IProvideClassInfo2, (void**)&classinfo);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
hres = IProvideClassInfo2_GetGUID(classinfo, GUIDKIND_DEFAULT_SOURCE_DISP_IID, iid);
|
|
|
|
IProvideClassInfo2_Release(classinfo);
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = IUnknown_QueryInterface(unk, &IID_IPersist, (void**)&persist);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
CLSID clsid;
|
|
|
|
|
|
|
|
hres = IPersist_GetClassID(persist, &clsid);
|
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
hres = get_default_source(typelib, &clsid, iid);
|
|
|
|
IPersist_Release(persist);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hres;
|
|
|
|
}
|
|
|
|
|
2014-01-29 10:24:44 +01:00
|
|
|
#if _ATL_VER >= _ATL_VER90
|
|
|
|
|
2013-03-13 17:36:14 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlSetPerUserRegistration [atl100.67]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlSetPerUserRegistration(cpp_bool bEnable)
|
|
|
|
{
|
|
|
|
FIXME("stub: bEnable: %d\n", bEnable);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2013-01-25 13:12:02 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlGetPerUserRegistration [atl100.68]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlGetPerUserRegistration(cpp_bool *pbEnabled)
|
|
|
|
{
|
|
|
|
FIXME("stub: returning false\n");
|
|
|
|
*pbEnabled = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-29 10:24:44 +01:00
|
|
|
#endif
|
|
|
|
|
2012-11-21 11:09:45 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlGetVersion [atl100.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI AtlGetVersion(void *pReserved)
|
|
|
|
{
|
2013-10-16 20:42:27 +02:00
|
|
|
TRACE("version %04x (%p)\n", _ATL_VER, pReserved);
|
|
|
|
return _ATL_VER;
|
2012-11-21 11:09:45 +01:00
|
|
|
}
|
2012-12-24 15:13:39 +01:00
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
2022-02-07 23:11:04 +01:00
|
|
|
TRACE("(0x%p, %ld, %p)\n", hinstDLL, fdwReason, lpvReserved);
|
2012-12-24 15:13:39 +01:00
|
|
|
|
|
|
|
switch(fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2013-05-16 12:50:07 +02:00
|
|
|
if (lpvReserved) break;
|
2012-12-24 15:13:39 +01:00
|
|
|
if(catreg)
|
|
|
|
ICatRegister_Release(catreg);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|