2004-07-06 23:01:18 +02:00
|
|
|
/*
|
|
|
|
* Implementation of Active Template Library (atl.dll)
|
|
|
|
*
|
|
|
|
* Copyright 2004 Aric Stewart for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-07-06 23:01:18 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2004-07-06 23:01:18 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winerror.h"
|
2006-10-30 16:57:48 +01:00
|
|
|
#include "wingdi.h"
|
2004-07-06 23:01:18 +02:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "objidl.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
#include "atlbase.h"
|
2005-04-22 21:04:18 +02:00
|
|
|
#include "atliface.h"
|
2006-06-14 03:37:43 +02:00
|
|
|
#include "atlwin.h"
|
2004-07-06 23:01:18 +02:00
|
|
|
|
2006-06-14 14:20:41 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2004-07-06 23:01:18 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(atl);
|
|
|
|
|
2005-03-16 20:53:41 +01:00
|
|
|
HINSTANCE hInst;
|
|
|
|
|
2004-07-06 23:01:18 +02:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
|
|
|
{
|
2006-10-06 23:02:28 +02:00
|
|
|
TRACE("(0x%p, %d, %p)\n",hinstDLL,fdwReason,lpvReserved);
|
2004-07-06 23:01:18 +02:00
|
|
|
|
2005-03-16 20:53:41 +01:00
|
|
|
if (fdwReason == DLL_PROCESS_ATTACH) {
|
|
|
|
DisableThreadLibraryCalls(hinstDLL);
|
|
|
|
hInst = hinstDLL;
|
|
|
|
}
|
2004-07-06 23:01:18 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-06-15 11:04:33 +02:00
|
|
|
#define ATLVer1Size FIELD_OFFSET(_ATL_MODULEW, dwAtlBuildVer)
|
2005-08-24 20:13:24 +02:00
|
|
|
|
2006-11-10 22:06:10 +01:00
|
|
|
HRESULT WINAPI AtlModuleInit(_ATL_MODULEW* pM, _ATL_OBJMAP_ENTRYW* p, HINSTANCE h)
|
2004-07-06 23:01:18 +02:00
|
|
|
{
|
|
|
|
INT i;
|
2005-08-24 20:13:24 +02:00
|
|
|
UINT size;
|
2004-07-06 23:01:18 +02:00
|
|
|
|
|
|
|
FIXME("SEMI-STUB (%p %p %p)\n",pM,p,h);
|
|
|
|
|
2005-08-24 20:13:24 +02:00
|
|
|
size = pM->cbSize;
|
2010-06-15 11:04:33 +02:00
|
|
|
switch (size)
|
2005-08-24 20:13:24 +02:00
|
|
|
{
|
2010-06-15 11:04:33 +02:00
|
|
|
case ATLVer1Size:
|
|
|
|
case sizeof(_ATL_MODULEW):
|
|
|
|
#ifdef _WIN64
|
|
|
|
case sizeof(_ATL_MODULEW) + sizeof(void *):
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Unknown structure version (size %i)\n",size);
|
2005-08-24 20:13:24 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
2006-11-10 22:06:53 +01:00
|
|
|
|
2005-08-24 20:13:24 +02:00
|
|
|
memset(pM,0,pM->cbSize);
|
|
|
|
pM->cbSize = size;
|
2004-07-06 23:01:18 +02:00
|
|
|
pM->m_hInst = h;
|
|
|
|
pM->m_hInstResource = h;
|
|
|
|
pM->m_hInstTypeLib = h;
|
|
|
|
pM->m_pObjMap = p;
|
|
|
|
pM->m_hHeap = GetProcessHeap();
|
|
|
|
|
2005-12-26 12:55:22 +01:00
|
|
|
InitializeCriticalSection(&pM->u.m_csTypeInfoHolder);
|
|
|
|
InitializeCriticalSection(&pM->m_csWindowCreate);
|
|
|
|
InitializeCriticalSection(&pM->m_csObjMap);
|
|
|
|
|
2004-07-06 23:01:18 +02:00
|
|
|
/* call mains */
|
|
|
|
i = 0;
|
2005-08-24 20:13:24 +02:00
|
|
|
if (pM->m_pObjMap != NULL && size > ATLVer1Size)
|
2004-07-06 23:01:18 +02:00
|
|
|
{
|
2005-08-19 11:58:02 +02:00
|
|
|
while (pM->m_pObjMap[i].pclsid != NULL)
|
|
|
|
{
|
|
|
|
TRACE("Initializing object %i %p\n",i,p[i].pfnObjectMain);
|
|
|
|
if (p[i].pfnObjectMain)
|
|
|
|
p[i].pfnObjectMain(TRUE);
|
|
|
|
i++;
|
|
|
|
}
|
2004-07-06 23:01:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-02 20:13:56 +01:00
|
|
|
static _ATL_OBJMAP_ENTRYW_V1 *get_objmap_entry( _ATL_MODULEW *mod, unsigned int index )
|
|
|
|
{
|
|
|
|
_ATL_OBJMAP_ENTRYW_V1 *ret;
|
|
|
|
|
|
|
|
if (mod->cbSize == ATLVer1Size)
|
|
|
|
ret = (_ATL_OBJMAP_ENTRYW_V1 *)mod->m_pObjMap + index;
|
|
|
|
else
|
|
|
|
ret = (_ATL_OBJMAP_ENTRYW_V1 *)(mod->m_pObjMap + index);
|
|
|
|
|
|
|
|
if (!ret->pclsid) ret = NULL;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-11-10 22:06:53 +01:00
|
|
|
HRESULT WINAPI AtlModuleLoadTypeLib(_ATL_MODULEW *pM, LPCOLESTR lpszIndex,
|
2006-06-21 20:49:50 +02:00
|
|
|
BSTR *pbstrPath, ITypeLib **ppTypeLib)
|
|
|
|
{
|
2006-11-10 22:06:53 +01:00
|
|
|
HRESULT hRes;
|
|
|
|
OLECHAR path[MAX_PATH+8]; /* leave some space for index */
|
|
|
|
|
|
|
|
TRACE("(%p, %s, %p, %p)\n", pM, debugstr_w(lpszIndex), pbstrPath, ppTypeLib);
|
|
|
|
|
|
|
|
if (!pM)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
GetModuleFileNameW(pM->m_hInstTypeLib, path, MAX_PATH);
|
|
|
|
if (lpszIndex)
|
|
|
|
lstrcatW(path, lpszIndex);
|
|
|
|
|
|
|
|
hRes = LoadTypeLib(path, ppTypeLib);
|
|
|
|
if (FAILED(hRes))
|
|
|
|
return hRes;
|
|
|
|
|
|
|
|
*pbstrPath = SysAllocString(path);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-06-21 20:49:50 +02:00
|
|
|
}
|
|
|
|
|
2006-11-10 22:06:10 +01:00
|
|
|
HRESULT WINAPI AtlModuleTerm(_ATL_MODULEW* pM)
|
2004-08-11 20:47:52 +02:00
|
|
|
{
|
2005-10-06 14:29:02 +02:00
|
|
|
_ATL_TERMFUNC_ELEM *iter = pM->m_pTermFuncs, *tmp;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pM);
|
|
|
|
|
|
|
|
while(iter) {
|
|
|
|
iter->pFunc(iter->dw);
|
|
|
|
tmp = iter;
|
|
|
|
iter = iter->pNext;
|
|
|
|
HeapFree(GetProcessHeap(), 0, tmp);
|
|
|
|
}
|
|
|
|
|
2004-08-11 20:47:52 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, pM);
|
2005-10-06 14:29:02 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-10-18 12:34:21 +02:00
|
|
|
HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULEW *pM, _ATL_TERMFUNC *pFunc, DWORD_PTR dw)
|
2005-10-06 14:29:02 +02:00
|
|
|
{
|
|
|
|
_ATL_TERMFUNC_ELEM *termfunc_elem;
|
|
|
|
|
|
|
|
TRACE("(%p %p %ld)\n", pM, pFunc, dw);
|
|
|
|
|
|
|
|
termfunc_elem = HeapAlloc(GetProcessHeap(), 0, sizeof(_ATL_TERMFUNC_ELEM));
|
|
|
|
termfunc_elem->pFunc = pFunc;
|
|
|
|
termfunc_elem->dw = dw;
|
|
|
|
termfunc_elem->pNext = pM->m_pTermFuncs;
|
|
|
|
|
|
|
|
pM->m_pTermFuncs = termfunc_elem;
|
|
|
|
|
2004-08-11 20:47:52 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-11-10 22:06:10 +01:00
|
|
|
HRESULT WINAPI AtlModuleRegisterClassObjects(_ATL_MODULEW *pM, DWORD dwClsContext,
|
2004-07-06 23:01:18 +02:00
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
2010-02-02 20:13:56 +01:00
|
|
|
_ATL_OBJMAP_ENTRYW_V1 *obj;
|
2004-07-06 23:01:18 +02:00
|
|
|
HRESULT hRes = S_OK;
|
|
|
|
int i=0;
|
|
|
|
|
2006-10-06 23:02:28 +02:00
|
|
|
TRACE("(%p %i %i)\n",pM, dwClsContext, dwFlags);
|
2004-07-06 23:01:18 +02:00
|
|
|
|
|
|
|
if (pM == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-02-02 20:13:56 +01:00
|
|
|
while ((obj = get_objmap_entry( pM, i++ )))
|
2004-07-06 23:01:18 +02:00
|
|
|
{
|
|
|
|
IUnknown* pUnknown;
|
|
|
|
HRESULT rc;
|
|
|
|
|
|
|
|
TRACE("Registering object %i\n",i);
|
|
|
|
if (obj->pfnGetClassObject)
|
|
|
|
{
|
|
|
|
rc = obj->pfnGetClassObject(obj->pfnCreateInstance, &IID_IUnknown,
|
|
|
|
(LPVOID*)&pUnknown);
|
|
|
|
if (SUCCEEDED (rc) )
|
|
|
|
{
|
|
|
|
CoRegisterClassObject(obj->pclsid, pUnknown, dwClsContext,
|
|
|
|
dwFlags, &obj->dwRegister);
|
|
|
|
if (pUnknown)
|
|
|
|
IUnknown_Release(pUnknown);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return hRes;
|
|
|
|
}
|
|
|
|
|
2006-11-10 22:06:10 +01:00
|
|
|
HRESULT WINAPI AtlModuleUnregisterServerEx(_ATL_MODULEW* pM, BOOL bUnRegTypeLib, const CLSID* pCLSID)
|
2004-09-28 05:14:11 +02:00
|
|
|
{
|
|
|
|
FIXME("(%p, %i, %p) stub\n", pM, bUnRegTypeLib, pCLSID);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-11-07 17:38:31 +01:00
|
|
|
|
2005-12-26 12:55:22 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2007-04-29 18:46:50 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2005-12-26 12:55:22 +01:00
|
|
|
|
2007-02-07 16:22:55 +01:00
|
|
|
HRESULT WINAPI AtlInternalQueryInterface(void* this, const _ATL_INTMAP_ENTRY* pEntries, REFIID iid, void** ppvObject)
|
2004-07-06 23:01:18 +02:00
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
HRESULT rc = E_NOINTERFACE;
|
2007-04-25 12:21:03 +02:00
|
|
|
TRACE("(%p, %p, %s, %p)\n",this, pEntries, debugstr_guid(iid), ppvObject);
|
2004-07-06 23:01:18 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(iid,&IID_IUnknown))
|
|
|
|
{
|
|
|
|
TRACE("Returning IUnknown\n");
|
2007-04-25 12:21:03 +02:00
|
|
|
*ppvObject = ((LPSTR)this+pEntries[0].dw);
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
2004-07-06 23:01:18 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (pEntries[i].pFunc != 0)
|
|
|
|
{
|
2007-04-25 12:21:03 +02:00
|
|
|
TRACE("Trying entry %i (%s %i %p)\n",i,debugstr_guid(pEntries[i].piid),
|
2004-07-06 23:01:18 +02:00
|
|
|
pEntries[i].dw, pEntries[i].pFunc);
|
|
|
|
|
2004-09-01 19:28:19 +02:00
|
|
|
if (pEntries[i].piid && IsEqualGUID(iid,pEntries[i].piid))
|
2004-07-06 23:01:18 +02:00
|
|
|
{
|
|
|
|
TRACE("MATCH\n");
|
|
|
|
if (pEntries[i].pFunc == (_ATL_CREATORARGFUNC*)1)
|
|
|
|
{
|
|
|
|
TRACE("Offset\n");
|
|
|
|
*ppvObject = ((LPSTR)this+pEntries[i].dw);
|
2007-04-03 19:14:22 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObject);
|
2004-07-06 23:01:18 +02:00
|
|
|
rc = S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Function\n");
|
2010-06-17 12:53:48 +02:00
|
|
|
rc = pEntries[i].pFunc(this, iid, ppvObject, pEntries[i].dw);
|
2004-07-06 23:01:18 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
2006-10-06 23:02:28 +02:00
|
|
|
TRACE("Done returning (0x%x)\n",rc);
|
2004-07-06 23:01:18 +02:00
|
|
|
return rc;
|
|
|
|
}
|
2004-09-02 22:06:39 +02:00
|
|
|
|
2004-12-27 18:08:08 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleRegisterServer [ATL.@]
|
|
|
|
*
|
|
|
|
*/
|
2006-11-10 22:06:53 +01:00
|
|
|
HRESULT WINAPI AtlModuleRegisterServer(_ATL_MODULEW* pM, BOOL bRegTypeLib, const CLSID* clsid)
|
2004-12-27 18:08:08 +01:00
|
|
|
{
|
2010-02-02 20:13:56 +01:00
|
|
|
const _ATL_OBJMAP_ENTRYW_V1 *obj;
|
2006-11-10 22:08:11 +01:00
|
|
|
int i;
|
|
|
|
HRESULT hRes;
|
|
|
|
|
|
|
|
TRACE("%p %d %s\n", pM, bRegTypeLib, debugstr_guid(clsid));
|
|
|
|
|
|
|
|
if (pM == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-02-02 20:13:56 +01:00
|
|
|
for (i = 0; (obj = get_objmap_entry( pM, i )) != NULL; i++) /* register CLSIDs */
|
2006-11-10 22:08:11 +01:00
|
|
|
{
|
2010-02-02 20:13:56 +01:00
|
|
|
if (!clsid || IsEqualCLSID(obj->pclsid, clsid))
|
2006-11-10 22:08:11 +01:00
|
|
|
{
|
|
|
|
TRACE("Registering clsid %s\n", debugstr_guid(obj->pclsid));
|
|
|
|
hRes = obj->pfnUpdateRegistry(TRUE); /* register */
|
|
|
|
if (FAILED(hRes))
|
|
|
|
return hRes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bRegTypeLib)
|
|
|
|
{
|
|
|
|
hRes = AtlModuleRegisterTypeLib(pM, NULL);
|
|
|
|
if (FAILED(hRes))
|
|
|
|
return hRes;
|
|
|
|
}
|
|
|
|
|
2004-12-27 18:08:08 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2005-01-19 18:00:32 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlAdvise [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlAdvise(IUnknown *pUnkCP, IUnknown *pUnk, const IID *iid, LPDWORD pdw)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p %p\n", pUnkCP, pUnk, iid, pdw);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlUnadvise [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlUnadvise(IUnknown *pUnkCP, const IID *iid, DWORD dw)
|
|
|
|
{
|
2006-10-06 23:02:28 +02:00
|
|
|
FIXME("%p %p %d\n", pUnkCP, iid, dw);
|
2005-01-19 18:00:32 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlFreeMarshalStream [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlFreeMarshalStream(IStream *stm)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", stm);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlMarshalPtrInProc [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlMarshalPtrInProc(IUnknown *pUnk, const IID *iid, IStream **pstm)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", pUnk, iid, pstm);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlUnmarshalPtr [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlUnmarshalPtr(IStream *stm, const IID *iid, IUnknown **ppUnk)
|
|
|
|
{
|
|
|
|
FIXME("%p %p %p\n", stm, iid, ppUnk);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleGetClassObject [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlModuleGetClassObject(_ATL_MODULEW *pm, REFCLSID rclsid,
|
|
|
|
REFIID riid, LPVOID *ppv)
|
|
|
|
{
|
2010-02-02 20:13:56 +01:00
|
|
|
_ATL_OBJMAP_ENTRYW_V1 *obj;
|
2006-06-12 02:34:53 +02:00
|
|
|
int i;
|
2007-04-25 12:21:48 +02:00
|
|
|
HRESULT hres = CLASS_E_CLASSNOTAVAILABLE;
|
2006-06-12 02:34:53 +02:00
|
|
|
|
|
|
|
TRACE("%p %s %s %p\n", pm, debugstr_guid(rclsid), debugstr_guid(riid), ppv);
|
|
|
|
|
|
|
|
if (pm == NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2010-02-02 20:13:56 +01:00
|
|
|
for (i = 0; (obj = get_objmap_entry( pm, i )) != NULL; i++)
|
2006-06-12 02:34:53 +02:00
|
|
|
{
|
2010-02-02 20:13:56 +01:00
|
|
|
if (IsEqualCLSID(obj->pclsid, rclsid))
|
2006-06-12 02:34:53 +02:00
|
|
|
{
|
|
|
|
TRACE("found object %i\n", i);
|
|
|
|
if (obj->pfnGetClassObject)
|
2007-04-25 12:21:48 +02:00
|
|
|
{
|
|
|
|
if (!obj->pCF)
|
|
|
|
hres = obj->pfnGetClassObject(obj->pfnCreateInstance,
|
|
|
|
&IID_IUnknown,
|
|
|
|
(void **)&obj->pCF);
|
|
|
|
if (obj->pCF)
|
|
|
|
hres = IUnknown_QueryInterface(obj->pCF, riid, ppv);
|
|
|
|
break;
|
|
|
|
}
|
2006-06-12 02:34:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("no class object found for %s\n", debugstr_guid(rclsid));
|
|
|
|
|
2007-04-25 12:21:48 +02:00
|
|
|
return hres;
|
2005-01-19 18:00:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleGetClassObject [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlModuleRegisterTypeLib(_ATL_MODULEW *pm, LPCOLESTR lpszIndex)
|
|
|
|
{
|
2006-11-10 22:07:29 +01:00
|
|
|
HRESULT hRes;
|
|
|
|
BSTR path;
|
|
|
|
ITypeLib *typelib;
|
|
|
|
|
|
|
|
TRACE("%p %s\n", pm, debugstr_w(lpszIndex));
|
|
|
|
|
|
|
|
if (!pm)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
hRes = AtlModuleLoadTypeLib(pm, lpszIndex, &path, &typelib);
|
|
|
|
|
|
|
|
if (SUCCEEDED(hRes))
|
|
|
|
{
|
|
|
|
hRes = RegisterTypeLib(typelib, path, NULL); /* FIXME: pass help directory */
|
|
|
|
ITypeLib_Release(typelib);
|
|
|
|
SysFreeString(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
return hRes;
|
2005-01-19 18:00:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleRevokeClassObjects [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlModuleRevokeClassObjects(_ATL_MODULEW *pm)
|
|
|
|
{
|
|
|
|
FIXME("%p\n", pm);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleUnregisterServer [ATL.@]
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI AtlModuleUnregisterServer(_ATL_MODULEW *pm, const CLSID *clsid)
|
|
|
|
{
|
|
|
|
FIXME("%p %s\n", pm, debugstr_guid(clsid));
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-11-28 11:28:19 +01:00
|
|
|
|
2010-05-25 16:51:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleRegisterWndClassInfoA [ATL.@]
|
|
|
|
*
|
|
|
|
* See AtlModuleRegisterWndClassInfoW.
|
|
|
|
*/
|
|
|
|
ATOM WINAPI AtlModuleRegisterWndClassInfoA(_ATL_MODULEA *pm, _ATL_WNDCLASSINFOA *wci, WNDPROC *pProc)
|
|
|
|
{
|
|
|
|
ATOM atom;
|
|
|
|
|
|
|
|
FIXME("%p %p %p semi-stub\n", pm, wci, pProc);
|
|
|
|
|
|
|
|
atom = wci->m_atom;
|
|
|
|
if (!atom)
|
|
|
|
{
|
|
|
|
WNDCLASSEXA wc;
|
|
|
|
|
|
|
|
TRACE("wci->m_wc.lpszClassName = %s\n", wci->m_wc.lpszClassName);
|
|
|
|
|
|
|
|
if (!wci->m_wc.lpszClassName)
|
|
|
|
{
|
2010-05-25 17:03:35 +02:00
|
|
|
sprintf(wci->m_szAutoName, "ATL%08lx", (UINT_PTR)wci);
|
2010-05-25 16:51:00 +02:00
|
|
|
TRACE("auto-generated class name %s\n", wci->m_szAutoName);
|
|
|
|
wci->m_wc.lpszClassName = wci->m_szAutoName;
|
|
|
|
}
|
|
|
|
|
|
|
|
atom = GetClassInfoExA(pm->m_hInst, wci->m_wc.lpszClassName, &wc);
|
|
|
|
if (!atom)
|
|
|
|
atom = RegisterClassExA(&wci->m_wc);
|
|
|
|
|
|
|
|
wci->pWndProc = wci->m_wc.lpfnWndProc;
|
|
|
|
wci->m_atom = atom;
|
|
|
|
}
|
|
|
|
*pProc = wci->pWndProc;
|
|
|
|
|
|
|
|
TRACE("returning 0x%04x\n", atom);
|
|
|
|
return atom;
|
|
|
|
}
|
|
|
|
|
2006-06-14 03:37:43 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleRegisterWndClassInfoW [ATL.@]
|
2006-06-14 14:20:41 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pm [IO] Information about the module registering the window.
|
|
|
|
* wci [IO] Information about the window being registered.
|
|
|
|
* pProc [O] Window procedure of the registered class.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Atom representing the registered class.
|
|
|
|
*
|
|
|
|
* NOTES
|
|
|
|
* Can be called multiple times without error, unlike RegisterClassEx().
|
|
|
|
*
|
2007-02-14 16:22:07 +01:00
|
|
|
* If the class name is NULL, then a class with a name of "ATLxxxxxxxx" is
|
|
|
|
* registered, where the 'x's represent a unique value.
|
2006-11-10 22:06:53 +01:00
|
|
|
*
|
2006-06-14 03:37:43 +02:00
|
|
|
*/
|
|
|
|
ATOM WINAPI AtlModuleRegisterWndClassInfoW(_ATL_MODULEW *pm, _ATL_WNDCLASSINFOW *wci, WNDPROC *pProc)
|
|
|
|
{
|
2006-06-14 14:20:41 +02:00
|
|
|
ATOM atom;
|
|
|
|
|
|
|
|
FIXME("%p %p %p semi-stub\n", pm, wci, pProc);
|
|
|
|
|
|
|
|
atom = wci->m_atom;
|
|
|
|
if (!atom)
|
|
|
|
{
|
|
|
|
WNDCLASSEXW wc;
|
|
|
|
|
|
|
|
TRACE("wci->m_wc.lpszClassName = %s\n", debugstr_w(wci->m_wc.lpszClassName));
|
|
|
|
|
|
|
|
if (!wci->m_wc.lpszClassName)
|
|
|
|
{
|
2010-05-25 17:03:35 +02:00
|
|
|
static const WCHAR szFormat[] = {'A','T','L','%','0','8','l','x',0};
|
|
|
|
sprintfW(wci->m_szAutoName, szFormat, (UINT_PTR)wci);
|
2006-06-14 14:20:41 +02:00
|
|
|
TRACE("auto-generated class name %s\n", debugstr_w(wci->m_szAutoName));
|
|
|
|
wci->m_wc.lpszClassName = wci->m_szAutoName;
|
|
|
|
}
|
|
|
|
|
|
|
|
atom = GetClassInfoExW(pm->m_hInst, wci->m_wc.lpszClassName, &wc);
|
|
|
|
if (!atom)
|
|
|
|
atom = RegisterClassExW(&wci->m_wc);
|
|
|
|
|
|
|
|
wci->pWndProc = wci->m_wc.lpfnWndProc;
|
|
|
|
wci->m_atom = atom;
|
|
|
|
}
|
|
|
|
*pProc = wci->pWndProc;
|
|
|
|
|
|
|
|
TRACE("returning 0x%04x\n", atom);
|
|
|
|
return atom;
|
2006-06-14 03:37:43 +02:00
|
|
|
}
|
2006-10-30 16:57:48 +01:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|
2006-10-30 16:55:05 +01:00
|
|
|
|
2010-06-14 14:13:52 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlCreateTargetDC [ATL.@]
|
|
|
|
*/
|
|
|
|
HDC WINAPI AtlCreateTargetDC( HDC hdc, DVTARGETDEVICE *dv )
|
|
|
|
{
|
|
|
|
static const WCHAR displayW[] = {'d','i','s','p','l','a','y',0};
|
|
|
|
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;
|
|
|
|
driver = displayW;
|
|
|
|
}
|
|
|
|
return CreateDCW( driver, device, port, devmode );
|
|
|
|
}
|
|
|
|
|
2006-10-30 16:55:05 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleAddCreateWndData [ATL.@]
|
|
|
|
*/
|
2007-02-07 16:22:55 +01:00
|
|
|
void WINAPI AtlModuleAddCreateWndData(_ATL_MODULEW *pM, _AtlCreateWndData *pData, void* pvObject)
|
2006-10-30 16:55:05 +01:00
|
|
|
{
|
|
|
|
TRACE("(%p, %p, %p)\n", pM, pData, pvObject);
|
|
|
|
|
|
|
|
pData->m_pThis = pvObject;
|
|
|
|
pData->m_dwThreadID = GetCurrentThreadId();
|
|
|
|
pData->m_pNext = pM->m_pCreateWndList;
|
|
|
|
pM->m_pCreateWndList = pData;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* AtlModuleExtractCreateWndData [ATL.@]
|
|
|
|
*
|
|
|
|
* NOTE: I failed to find any good description of this function.
|
|
|
|
* Tests show that this function extracts one of _AtlCreateWndData
|
2006-11-10 22:06:53 +01:00
|
|
|
* records from the current thread from a list
|
|
|
|
*
|
2006-10-30 16:55:05 +01:00
|
|
|
*/
|
2007-02-07 16:22:55 +01:00
|
|
|
void* WINAPI AtlModuleExtractCreateWndData(_ATL_MODULEW *pM)
|
2006-10-30 16:55:05 +01:00
|
|
|
{
|
|
|
|
_AtlCreateWndData **ppData;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", pM);
|
|
|
|
|
|
|
|
for(ppData = &pM->m_pCreateWndList; *ppData!=NULL; ppData = &(*ppData)->m_pNext)
|
|
|
|
{
|
|
|
|
if ((*ppData)->m_dwThreadID == GetCurrentThreadId())
|
|
|
|
{
|
|
|
|
_AtlCreateWndData *pData = *ppData;
|
|
|
|
*ppData = pData->m_pNext;
|
|
|
|
return pData->m_pThis;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2007-04-29 18:48:07 +02:00
|
|
|
|
|
|
|
/* FIXME: should be in a header file */
|
|
|
|
typedef struct ATL_PROPMAP_ENTRY
|
|
|
|
{
|
|
|
|
LPCOLESTR szDesc;
|
|
|
|
DISPID dispid;
|
|
|
|
const CLSID* pclsidPropPage;
|
|
|
|
const IID* piidDispatch;
|
|
|
|
DWORD dwOffsetData;
|
|
|
|
DWORD dwSizeData;
|
|
|
|
VARTYPE vt;
|
|
|
|
} ATL_PROPMAP_ENTRY;
|
|
|
|
|
2007-06-12 17:51:53 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* AtlIPersistStreamInit_Load [ATL.@]
|
|
|
|
*/
|
2007-04-29 18:48:07 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|