mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
ole32: Add Co*InitializeSpy functions.
This commit is contained in:
parent
1482006fb5
commit
92dca953d9
3 changed files with 78 additions and 2 deletions
|
@ -1013,6 +1013,64 @@ DWORD WINAPI CoBuildVersion(void)
|
||||||
return (rmm<<16)+rup;
|
return (rmm<<16)+rup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* CoRegisterInitializeSpy [OLE32.@]
|
||||||
|
*
|
||||||
|
* Add a Spy that watches CoInitializeEx calls
|
||||||
|
*
|
||||||
|
* PARAMS
|
||||||
|
* spy [I] Pointer to IUnknown interface that will be QueryInterface'd.
|
||||||
|
* cookie [II] cookie receiver
|
||||||
|
*
|
||||||
|
* RETURNS
|
||||||
|
* Success: S_OK if not already initialized, S_FALSE otherwise.
|
||||||
|
* Failure: HRESULT code.
|
||||||
|
*
|
||||||
|
* SEE ALSO
|
||||||
|
* CoInitializeEx
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI CoRegisterInitializeSpy(IInitializeSpy *spy, ULARGE_INTEGER *cookie)
|
||||||
|
{
|
||||||
|
struct oletls *info = COM_CurrentInfo();
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
TRACE("(%p, %p)\n", spy, cookie);
|
||||||
|
|
||||||
|
if (!spy || !cookie || !info)
|
||||||
|
{
|
||||||
|
if (!info)
|
||||||
|
WARN("Could not allocate tls\n");
|
||||||
|
return E_INVALIDARG;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info->spy)
|
||||||
|
{
|
||||||
|
FIXME("Already registered?\n");
|
||||||
|
return E_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IUnknown_QueryInterface(spy, &IID_IInitializeSpy, (void **) &info->spy);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
cookie->QuadPart = (DWORD_PTR)spy;
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
return hr;
|
||||||
|
}
|
||||||
|
|
||||||
|
HRESULT WINAPI CoRevokeInitializeSpy(ULARGE_INTEGER cookie)
|
||||||
|
{
|
||||||
|
struct oletls *info = COM_CurrentInfo();
|
||||||
|
TRACE("(%s)\n", wine_dbgstr_longlong(cookie.QuadPart));
|
||||||
|
|
||||||
|
if (!info || !info->spy || cookie.QuadPart != (DWORD_PTR)info->spy)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
IUnknown_Release(info->spy);
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* CoInitialize [OLE32.@]
|
* CoInitialize [OLE32.@]
|
||||||
*
|
*
|
||||||
|
@ -1069,6 +1127,7 @@ HRESULT WINAPI CoInitialize(LPVOID lpReserved)
|
||||||
*/
|
*/
|
||||||
HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
|
HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
|
||||||
{
|
{
|
||||||
|
struct oletls *info = COM_CurrentInfo();
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
APARTMENT *apt;
|
APARTMENT *apt;
|
||||||
|
|
||||||
|
@ -1096,7 +1155,10 @@ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
|
||||||
RunningObjectTableImpl_Initialize();
|
RunningObjectTableImpl_Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(apt = COM_CurrentInfo()->apt))
|
if (info->spy)
|
||||||
|
IInitializeSpy_PreInitialize(info->spy, dwCoInit, info->inits);
|
||||||
|
|
||||||
|
if (!(apt = info->apt))
|
||||||
{
|
{
|
||||||
apt = apartment_get_or_create(dwCoInit);
|
apt = apartment_get_or_create(dwCoInit);
|
||||||
if (!apt) return E_OUTOFMEMORY;
|
if (!apt) return E_OUTOFMEMORY;
|
||||||
|
@ -1113,7 +1175,10 @@ HRESULT WINAPI CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
|
||||||
else
|
else
|
||||||
hr = S_FALSE;
|
hr = S_FALSE;
|
||||||
|
|
||||||
COM_CurrentInfo()->inits++;
|
info->inits++;
|
||||||
|
|
||||||
|
if (info->spy)
|
||||||
|
IInitializeSpy_PostInitialize(info->spy, hr, dwCoInit, info->inits);
|
||||||
|
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
@ -1144,10 +1209,16 @@ void WINAPI CoUninitialize(void)
|
||||||
/* will only happen on OOM */
|
/* will only happen on OOM */
|
||||||
if (!info) return;
|
if (!info) return;
|
||||||
|
|
||||||
|
if (info->spy)
|
||||||
|
IInitializeSpy_PreUninitialize(info->spy, info->inits);
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (!info->inits)
|
if (!info->inits)
|
||||||
{
|
{
|
||||||
ERR("Mismatched CoUninitialize\n");
|
ERR("Mismatched CoUninitialize\n");
|
||||||
|
|
||||||
|
if (info->spy)
|
||||||
|
IInitializeSpy_PostUninitialize(info->spy, info->inits);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1173,6 +1244,8 @@ void WINAPI CoUninitialize(void)
|
||||||
ERR( "CoUninitialize() - not CoInitialized.\n" );
|
ERR( "CoUninitialize() - not CoInitialized.\n" );
|
||||||
InterlockedExchangeAdd(&s_COMLockCount,1); /* restore the lock count. */
|
InterlockedExchangeAdd(&s_COMLockCount,1); /* restore the lock count. */
|
||||||
}
|
}
|
||||||
|
if (info->spy)
|
||||||
|
IInitializeSpy_PostUninitialize(info->spy, info->inits);
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
|
|
@ -175,6 +175,7 @@ struct oletls
|
||||||
struct apartment *apt;
|
struct apartment *apt;
|
||||||
IErrorInfo *errorinfo; /* see errorinfo.c */
|
IErrorInfo *errorinfo; /* see errorinfo.c */
|
||||||
IUnknown *state; /* see CoSetState */
|
IUnknown *state; /* see CoSetState */
|
||||||
|
IInitializeSpy *spy; /* The "SPY" from CoInitializeSpy */
|
||||||
DWORD inits; /* number of times CoInitializeEx called */
|
DWORD inits; /* number of times CoInitializeEx called */
|
||||||
DWORD ole_inits; /* number of times OleInitialize called */
|
DWORD ole_inits; /* number of times OleInitialize called */
|
||||||
GUID causality_id; /* unique identifier for each COM call */
|
GUID causality_id; /* unique identifier for each COM call */
|
||||||
|
|
|
@ -57,6 +57,7 @@
|
||||||
@ stub CoQueryReleaseObject
|
@ stub CoQueryReleaseObject
|
||||||
@ stdcall CoRegisterChannelHook(ptr ptr)
|
@ stdcall CoRegisterChannelHook(ptr ptr)
|
||||||
@ stdcall CoRegisterClassObject(ptr ptr long long ptr)
|
@ stdcall CoRegisterClassObject(ptr ptr long long ptr)
|
||||||
|
@ stdcall CoRegisterInitializeSpy(ptr ptr)
|
||||||
@ stdcall CoRegisterMallocSpy (ptr)
|
@ stdcall CoRegisterMallocSpy (ptr)
|
||||||
@ stdcall CoRegisterMessageFilter(ptr ptr)
|
@ stdcall CoRegisterMessageFilter(ptr ptr)
|
||||||
@ stdcall CoRegisterPSClsid(ptr ptr)
|
@ stdcall CoRegisterPSClsid(ptr ptr)
|
||||||
|
@ -67,6 +68,7 @@
|
||||||
@ stdcall CoResumeClassObjects()
|
@ stdcall CoResumeClassObjects()
|
||||||
@ stdcall CoRevertToSelf()
|
@ stdcall CoRevertToSelf()
|
||||||
@ stdcall CoRevokeClassObject(long)
|
@ stdcall CoRevokeClassObject(long)
|
||||||
|
@ stdcall CoRevokeInitializeSpy(double)
|
||||||
@ stdcall CoRevokeMallocSpy()
|
@ stdcall CoRevokeMallocSpy()
|
||||||
@ stdcall CoSetProxyBlanket(ptr long long wstr long long ptr long)
|
@ stdcall CoSetProxyBlanket(ptr long long wstr long long ptr long)
|
||||||
@ stdcall CoSetState(ptr)
|
@ stdcall CoSetState(ptr)
|
||||||
|
|
Loading…
Reference in a new issue