Commit 878e15e2 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ole32: Allow more functions to use the implicit MTA.

parent 5e752db1
...@@ -1089,8 +1089,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject( ...@@ -1089,8 +1089,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(
TRACE("(%08x)\n",dwRegister); TRACE("(%08x)\n",dwRegister);
apt = COM_CurrentApt(); if (!(apt = apartment_get_current_or_mta()))
if (!apt)
{ {
ERR("COM was not initialized\n"); ERR("COM was not initialized\n");
return CO_E_NOTINITIALIZED; return CO_E_NOTINITIALIZED;
...@@ -1121,7 +1120,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject( ...@@ -1121,7 +1120,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoRevokeClassObject(
} }
LeaveCriticalSection( &csRegisteredClassList ); LeaveCriticalSection( &csRegisteredClassList );
apartment_release(apt);
return hr; return hr;
} }
...@@ -2072,9 +2071,11 @@ HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved ) ...@@ -2072,9 +2071,11 @@ HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
return hr; return hr;
} }
apt = COM_CurrentApt(); if (!(apt = apartment_get_current_or_mta()))
if (!apt) {
ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED; return CO_E_NOTINITIALIZED;
}
manager = get_stub_manager_from_object(apt, lpUnk, FALSE); manager = get_stub_manager_from_object(apt, lpUnk, FALSE);
if (manager) { if (manager) {
...@@ -2089,6 +2090,7 @@ HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved ) ...@@ -2089,6 +2090,7 @@ HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
* not found, making apps think that the object was disconnected, when * not found, making apps think that the object was disconnected, when
* it actually wasn't */ * it actually wasn't */
apartment_release(apt);
return S_OK; return S_OK;
} }
...@@ -2596,7 +2598,7 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid) ...@@ -2596,7 +2598,7 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid)
static const WCHAR wszInterface[] = {'I','n','t','e','r','f','a','c','e','\\',0}; static const WCHAR wszInterface[] = {'I','n','t','e','r','f','a','c','e','\\',0};
static const WCHAR wszPSC[] = {'\\','P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0}; static const WCHAR wszPSC[] = {'\\','P','r','o','x','y','S','t','u','b','C','l','s','i','d','3','2',0};
WCHAR path[ARRAYSIZE(wszInterface) - 1 + CHARS_IN_GUID - 1 + ARRAYSIZE(wszPSC)]; WCHAR path[ARRAYSIZE(wszInterface) - 1 + CHARS_IN_GUID - 1 + ARRAYSIZE(wszPSC)];
APARTMENT *apt = COM_CurrentApt(); APARTMENT *apt;
struct registered_psclsid *registered_psclsid; struct registered_psclsid *registered_psclsid;
ACTCTX_SECTION_KEYED_DATA data; ACTCTX_SECTION_KEYED_DATA data;
HRESULT hr; HRESULT hr;
...@@ -2605,11 +2607,12 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid) ...@@ -2605,11 +2607,12 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid)
TRACE("() riid=%s, pclsid=%p\n", debugstr_guid(riid), pclsid); TRACE("() riid=%s, pclsid=%p\n", debugstr_guid(riid), pclsid);
if (!apt) if (!(apt = apartment_get_current_or_mta()))
{ {
ERR("apartment not initialised\n"); ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED; return CO_E_NOTINITIALIZED;
} }
apartment_release(apt);
if (!pclsid) if (!pclsid)
return E_INVALIDARG; return E_INVALIDARG;
...@@ -2680,16 +2683,17 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid) ...@@ -2680,16 +2683,17 @@ HRESULT WINAPI CoGetPSClsid(REFIID riid, CLSID *pclsid)
*/ */
HRESULT WINAPI CoRegisterPSClsid(REFIID riid, REFCLSID rclsid) HRESULT WINAPI CoRegisterPSClsid(REFIID riid, REFCLSID rclsid)
{ {
APARTMENT *apt = COM_CurrentApt(); APARTMENT *apt;
struct registered_psclsid *registered_psclsid; struct registered_psclsid *registered_psclsid;
TRACE("(%s, %s)\n", debugstr_guid(riid), debugstr_guid(rclsid)); TRACE("(%s, %s)\n", debugstr_guid(riid), debugstr_guid(rclsid));
if (!apt) if (!(apt = apartment_get_current_or_mta()))
{ {
ERR("apartment not initialised\n"); ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED; return CO_E_NOTINITIALIZED;
} }
apartment_release(apt);
EnterCriticalSection(&cs_registered_psclsid_list); EnterCriticalSection(&cs_registered_psclsid_list);
...@@ -2815,8 +2819,7 @@ HRESULT WINAPI CoRegisterClassObject( ...@@ -2815,8 +2819,7 @@ HRESULT WINAPI CoRegisterClassObject(
if ( (lpdwRegister==0) || (pUnk==0) ) if ( (lpdwRegister==0) || (pUnk==0) )
return E_INVALIDARG; return E_INVALIDARG;
apt = COM_CurrentApt(); if (!(apt = apartment_get_current_or_mta()))
if (!apt)
{ {
ERR("COM was not initialized\n"); ERR("COM was not initialized\n");
return CO_E_NOTINITIALIZED; return CO_E_NOTINITIALIZED;
...@@ -2839,16 +2842,21 @@ HRESULT WINAPI CoRegisterClassObject( ...@@ -2839,16 +2842,21 @@ HRESULT WINAPI CoRegisterClassObject(
if (dwClsContext & CLSCTX_LOCAL_SERVER) if (dwClsContext & CLSCTX_LOCAL_SERVER)
hr = CoLockObjectExternal(foundObject, TRUE, FALSE); hr = CoLockObjectExternal(foundObject, TRUE, FALSE);
IUnknown_Release(foundObject); IUnknown_Release(foundObject);
apartment_release(apt);
return hr; return hr;
} }
IUnknown_Release(foundObject); IUnknown_Release(foundObject);
ERR("object already registered for class %s\n", debugstr_guid(rclsid)); ERR("object already registered for class %s\n", debugstr_guid(rclsid));
apartment_release(apt);
return CO_E_OBJISREG; return CO_E_OBJISREG;
} }
newClass = HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass)); newClass = HeapAlloc(GetProcessHeap(), 0, sizeof(RegisteredClass));
if ( newClass == NULL ) if ( newClass == NULL )
{
apartment_release(apt);
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
}
newClass->classIdentifier = *rclsid; newClass->classIdentifier = *rclsid;
newClass->apartment_id = apt->oxid; newClass->apartment_id = apt->oxid;
...@@ -2877,7 +2885,10 @@ HRESULT WINAPI CoRegisterClassObject( ...@@ -2877,7 +2885,10 @@ HRESULT WINAPI CoRegisterClassObject(
hr = get_local_server_stream(apt, &marshal_stream); hr = get_local_server_stream(apt, &marshal_stream);
if(FAILED(hr)) if(FAILED(hr))
{
apartment_release(apt);
return hr; return hr;
}
hr = RPC_StartLocalServer(&newClass->classIdentifier, hr = RPC_StartLocalServer(&newClass->classIdentifier,
marshal_stream, marshal_stream,
...@@ -2885,6 +2896,7 @@ HRESULT WINAPI CoRegisterClassObject( ...@@ -2885,6 +2896,7 @@ HRESULT WINAPI CoRegisterClassObject(
&newClass->RpcRegistration); &newClass->RpcRegistration);
IStream_Release(marshal_stream); IStream_Release(marshal_stream);
} }
apartment_release(apt);
return S_OK; return S_OK;
} }
...@@ -3645,8 +3657,11 @@ HRESULT WINAPI CoLockObjectExternal( ...@@ -3645,8 +3657,11 @@ HRESULT WINAPI CoLockObjectExternal(
TRACE("pUnk=%p, fLock=%s, fLastUnlockReleases=%s\n", TRACE("pUnk=%p, fLock=%s, fLastUnlockReleases=%s\n",
pUnk, fLock ? "TRUE" : "FALSE", fLastUnlockReleases ? "TRUE" : "FALSE"); pUnk, fLock ? "TRUE" : "FALSE", fLastUnlockReleases ? "TRUE" : "FALSE");
apt = COM_CurrentApt(); if (!(apt = apartment_get_current_or_mta()))
if (!apt) return CO_E_NOTINITIALIZED; {
ERR("apartment not initialised\n");
return CO_E_NOTINITIALIZED;
}
stubmgr = get_stub_manager_from_object(apt, pUnk, fLock); stubmgr = get_stub_manager_from_object(apt, pUnk, fLock);
if (!stubmgr) if (!stubmgr)
...@@ -3655,6 +3670,7 @@ HRESULT WINAPI CoLockObjectExternal( ...@@ -3655,6 +3670,7 @@ HRESULT WINAPI CoLockObjectExternal(
/* Note: native is pretty broken here because it just silently /* Note: native is pretty broken here because it just silently
* fails, without returning an appropriate error code, making apps * fails, without returning an appropriate error code, making apps
* think that the object was disconnected, when it actually wasn't */ * think that the object was disconnected, when it actually wasn't */
apartment_release(apt);
return S_OK; return S_OK;
} }
...@@ -3664,6 +3680,7 @@ HRESULT WINAPI CoLockObjectExternal( ...@@ -3664,6 +3680,7 @@ HRESULT WINAPI CoLockObjectExternal(
stub_manager_ext_release(stubmgr, 1, FALSE, fLastUnlockReleases); stub_manager_ext_release(stubmgr, 1, FALSE, fLastUnlockReleases);
stub_manager_int_release(stubmgr); stub_manager_int_release(stubmgr);
apartment_release(apt);
return S_OK; return S_OK;
} }
......
...@@ -3701,6 +3701,8 @@ static DWORD CALLBACK implicit_mta_proc(void *param) ...@@ -3701,6 +3701,8 @@ static DWORD CALLBACK implicit_mta_proc(void *param)
IComThreadingInfo *threading_info; IComThreadingInfo *threading_info;
ULONG_PTR token; ULONG_PTR token;
IUnknown *unk; IUnknown *unk;
DWORD cookie;
CLSID clsid;
HRESULT hr; HRESULT hr;
test_apt_type(APTTYPE_MTA, APTTYPEQUALIFIER_IMPLICIT_MTA, TRUE, TRUE); test_apt_type(APTTYPE_MTA, APTTYPEQUALIFIER_IMPLICIT_MTA, TRUE, TRUE);
...@@ -3720,6 +3722,28 @@ static DWORD CALLBACK implicit_mta_proc(void *param) ...@@ -3720,6 +3722,28 @@ static DWORD CALLBACK implicit_mta_proc(void *param)
hr = CoGetContextToken(&token); hr = CoGetContextToken(&token);
ok_ole_success(hr, "CoGetContextToken"); ok_ole_success(hr, "CoGetContextToken");
hr = CoRegisterPSClsid(&IID_IWineTest, &CLSID_WineTestPSFactoryBuffer);
ok_ole_success(hr, "CoRegisterPSClsid");
hr = CoGetPSClsid(&IID_IClassFactory, &clsid);
ok_ole_success(hr, "CoGetPSClsid");
hr = CoRegisterClassObject(&CLSID_WineOOPTest, (IUnknown *)&Test_ClassFactory,
CLSCTX_INPROC_SERVER, REGCLS_SINGLEUSE, &cookie);
ok_ole_success(hr, "CoRegisterClassObject");
hr = CoRevokeClassObject(cookie);
ok_ole_success(hr, "CoRevokeClassObject");
hr = CoRegisterMessageFilter(NULL, NULL);
ok(hr == CO_E_NOT_SUPPORTED, "got %#x\n", hr);
hr = CoLockObjectExternal((IUnknown *)&Test_Unknown, TRUE, TRUE);
ok_ole_success(hr, "CoLockObjectExternal");
hr = CoDisconnectObject((IUnknown *)&Test_Unknown, 0);
ok_ole_success(hr, "CoDisconnectObject");
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment