atl110: Fix _ATL_COM_MODULE structure layout.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2017-10-06 18:51:36 +02:00 committed by Alexandre Julliard
parent 6d0d955ac0
commit ffed1a5f9f
2 changed files with 157 additions and 0 deletions

View File

@ -486,6 +486,7 @@ void* WINAPI AtlWinModuleExtractCreateWndData(_ATL_WIN_MODULE *winmod)
/***********************************************************************
* AtlComModuleGetClassObject [atl100.15]
*/
#if _ATL_VER < _ATL_VER_110
HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pm, REFCLSID rclsid, REFIID riid, void **ppv)
{
_ATL_OBJMAP_ENTRY **iter;
@ -510,10 +511,37 @@ HRESULT WINAPI AtlComModuleGetClassObject(_ATL_COM_MODULE *pm, REFCLSID rclsid,
WARN("Class %s not found\n", debugstr_guid(rclsid));
return CLASS_E_CLASSNOTAVAILABLE;
}
#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);
TRACE("returning %p (%08x)\n", *ppv, hres);
return hres;
}
}
WARN("Class %s not found\n", debugstr_guid(rclsid));
return CLASS_E_CLASSNOTAVAILABLE;
}
#endif
/***********************************************************************
* AtlComModuleRegisterClassObjects [atl100.17]
*/
#if _ATL_VER < _ATL_VER_110
HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD context, DWORD flags)
{
_ATL_OBJMAP_ENTRY **iter;
@ -541,10 +569,40 @@ HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD c
return S_OK;
}
#else
HRESULT WINAPI AtlComModuleRegisterClassObjects(_ATL_COM_MODULE *module, DWORD context, DWORD flags)
{
_ATL_OBJMAP_ENTRY_EX **iter;
IUnknown *unk;
HRESULT hres;
TRACE("(%p %x %x)\n", module, context, flags);
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
/***********************************************************************
* AtlComModuleRevokeClassObjects [atl100.20]
*/
#if _ATL_VER < _ATL_VER_110
HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
{
_ATL_OBJMAP_ENTRY **iter;
@ -563,10 +621,31 @@ HRESULT WINAPI AtlComModuleRevokeClassObjects(_ATL_COM_MODULE *module)
return S_OK;
}
#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
/***********************************************************************
* AtlComModuleUnregisterServer [atl100.22]
*/
#if _ATL_VER < _ATL_VER_110
HRESULT WINAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE *mod, BOOL bRegTypeLib, const CLSID *clsid)
{
const struct _ATL_CATMAP_ENTRY *catmap;
@ -615,6 +694,56 @@ HRESULT WINAPI AtlComModuleUnregisterServer(_ATL_COM_MODULE *mod, BOOL bRegTypeL
return S_OK;
}
#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
#endif

View File

@ -94,6 +94,23 @@ typedef struct _ATL_OBJMAP_ENTRYW_TAG
void (WINAPI *pfnObjectMain)(BOOL bStarting);
} _ATL_OBJMAP_ENTRYW, _ATL_OBJMAP_ENTRY30, _ATL_OBJMAP_ENTRY;
typedef struct _ATL_OBJMAP_CACHE
{
IUnknown *pCF;
DWORD dwRegister;
} _ATL_OBJMAP_CACHE;
typedef struct _ATL_OBJMAP_ENTRY110
{
const CLSID* pclsid;
HRESULT (WINAPI *pfnUpdateRegistry)(BOOL bRegister);
_ATL_CREATORFUNC* pfnGetClassObject;
_ATL_CREATORFUNC* pfnCreateInstance;
_ATL_OBJMAP_CACHE* pCache;
_ATL_DESCRIPTIONFUNCW* pfnGetObjectDescription;
_ATL_CATMAPFUNC* pfnGetCategoryMap;
void (WINAPI *pfnObjectMain)(BOOL bStarting);
} _ATL_OBJMAP_ENTRY110, _ATL_OBJMAP_ENTRY_EX;
typedef struct _ATL_TERMFUNC_ELEM_TAG
{
@ -186,6 +203,16 @@ typedef struct _ATL_WIN_MODULE70
CSimpleArray /* <ATOM> */ m_rgWindowClassAtoms;
} _ATL_WIN_MODULE70;
#if _ATL_VER >= _ATL_VER_110
typedef struct _ATL_COM_MODULE70
{
UINT cbSize;
HINSTANCE m_hInstTypeLib;
_ATL_OBJMAP_ENTRY_EX **m_ppAutoObjMapFirst;
_ATL_OBJMAP_ENTRY_EX **m_ppAutoObjMapLast;
CComCriticalSection m_csObjMap;
} _ATL_COM_MODULE70, _ATL_COM_MODULE;
#else
typedef struct _ATL_COM_MODULE70
{
UINT cbSize;
@ -194,6 +221,7 @@ typedef struct _ATL_COM_MODULE70
_ATL_OBJMAP_ENTRY **m_ppAutoObjMapLast;
CComCriticalSection m_csObjMap;
} _ATL_COM_MODULE70, _ATL_COM_MODULE;
#endif
#if _ATL_VER >= _ATL_VER_70
typedef _ATL_MODULE70 _ATL_MODULE;