Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/combase/apartment.c | 2 +- dlls/combase/combase.c | 39 ++++++++++++++++++++++++++++++++++ dlls/combase/combase.spec | 3 +-- dlls/combase/combase_private.h | 2 ++ dlls/ole32/compobj.c | 38 --------------------------------- dlls/ole32/compobj_private.h | 1 - dlls/ole32/ole32.spec | 2 +- 7 files changed, 44 insertions(+), 43 deletions(-)
diff --git a/dlls/combase/apartment.c b/dlls/combase/apartment.c index 1ce7021bef9..2d1f7a75744 100644 --- a/dlls/combase/apartment.c +++ b/dlls/combase/apartment.c @@ -627,7 +627,7 @@ static struct apartment *apartment_get_or_create(DWORD model) return apt; }
-struct apartment * WINAPI apartment_get_mta(void) +struct apartment * apartment_get_mta(void) { struct apartment *apt;
diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index 7d61faefa92..47e31ebad14 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -2422,6 +2422,45 @@ HRESULT WINAPI CoDecrementMTAUsage(CO_MTA_USAGE_COOKIE cookie) return S_OK; }
+/*********************************************************************** + * CoGetApartmentType (combase.@) + */ +HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) +{ + struct tlsdata *tlsdata; + struct apartment *apt; + HRESULT hr; + + TRACE("%p, %p\n", type, qualifier); + + if (!type || !qualifier) + return E_INVALIDARG; + + if (FAILED(hr = com_get_tlsdata(&tlsdata))) + return hr; + + if (!tlsdata->apt) + *type = APTTYPE_CURRENT; + else if (tlsdata->apt->multi_threaded) + *type = APTTYPE_MTA; + else if (tlsdata->apt->main) + *type = APTTYPE_MAINSTA; + else + *type = APTTYPE_STA; + + *qualifier = APTTYPEQUALIFIER_NONE; + + if (!tlsdata->apt && (apt = apartment_get_mta())) + { + apartment_release(apt); + *type = APTTYPE_MTA; + *qualifier = APTTYPEQUALIFIER_IMPLICIT_MTA; + return S_OK; + } + + return tlsdata->apt ? S_OK : CO_E_NOTINITIALIZED; +} + /*********************************************************************** * DllMain (combase.@) */ diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 52c4ef51b2e..143de28d7d6 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -96,7 +96,7 @@ @ stdcall CoFreeUnusedLibrariesEx(long long) @ stdcall CoGetActivationState(int128 long ptr) @ stub CoGetApartmentID -@ stdcall CoGetApartmentType(ptr ptr) ole32.CoGetApartmentType +@ stdcall CoGetApartmentType(ptr ptr) @ stdcall CoGetCallContext(ptr ptr) @ stdcall CoGetCallState(long ptr) @ stdcall CoGetCallerTID(ptr) ole32.CoGetCallerTID @@ -356,7 +356,6 @@ @ stdcall enter_apartment(ptr long) @ stdcall leave_apartment(ptr) @ stdcall apartment_get_inproc_class_object(ptr ptr ptr ptr long ptr) -@ stdcall apartment_get_mta() @ stdcall apartment_findfromoxid(int64) @ stdcall apartment_getwindow(ptr) @ stdcall apartment_global_cleanup() diff --git a/dlls/combase/combase_private.h b/dlls/combase/combase_private.h index 32ffba0df89..1f80f1a12be 100644 --- a/dlls/combase/combase_private.h +++ b/dlls/combase/combase_private.h @@ -133,8 +133,10 @@ struct stub_manager
HRESULT WINAPI enter_apartment(struct tlsdata *data, DWORD model); void WINAPI leave_apartment(struct tlsdata *data); +void WINAPI apartment_release(struct apartment *apt); HRESULT apartment_increment_mta_usage(CO_MTA_USAGE_COOKIE *cookie) DECLSPEC_HIDDEN; void apartment_decrement_mta_usage(CO_MTA_USAGE_COOKIE cookie) DECLSPEC_HIDDEN; +struct apartment * apartment_get_mta(void) DECLSPEC_HIDDEN;
/* Stub Manager */
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 5adcd94b2cd..975af46f854 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -1771,44 +1771,6 @@ HRESULT Handler_DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) return CLASS_E_CLASSNOTAVAILABLE; }
-/*********************************************************************** - * CoGetApartmentType [OLE32.@] - */ -HRESULT WINAPI CoGetApartmentType(APTTYPE *type, APTTYPEQUALIFIER *qualifier) -{ - struct oletls *info = COM_CurrentInfo(); - struct apartment *apt; - - TRACE("(%p, %p)\n", type, qualifier); - - if (!type || !qualifier) - return E_INVALIDARG; - - if (!info) - return E_OUTOFMEMORY; - - if (!info->apt) - *type = APTTYPE_CURRENT; - else if (info->apt->multi_threaded) - *type = APTTYPE_MTA; - else if (info->apt->main) - *type = APTTYPE_MAINSTA; - else - *type = APTTYPE_STA; - - *qualifier = APTTYPEQUALIFIER_NONE; - - if (!info->apt && (apt = apartment_get_mta())) - { - apartment_release(apt); - *type = APTTYPE_MTA; - *qualifier = APTTYPEQUALIFIER_IMPLICIT_MTA; - return S_OK; - } - - return info->apt ? S_OK : CO_E_NOTINITIALIZED; -} - /*********************************************************************** * CoDisableCallCancellation [OLE32.@] */ diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index 2c8c337c643..9d6a1d1b794 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -257,7 +257,6 @@ struct class_reg_data; extern HRESULT WINAPI apartment_get_inproc_class_object(struct apartment *apt, const struct class_reg_data *regdata, REFCLSID rclsid, REFIID riid, BOOL hostifnecessary, void **ppv) DECLSPEC_HIDDEN;
-extern struct apartment * WINAPI apartment_get_mta(void) DECLSPEC_HIDDEN; extern HRESULT WINAPI apartment_get_local_server_stream(struct apartment *apt, IStream **ret) DECLSPEC_HIDDEN; extern void WINAPI apartment_global_cleanup(void) DECLSPEC_HIDDEN;
diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index 7d3d1e2e6e3..0b38e74388a 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -26,7 +26,7 @@ @ stdcall CoFreeUnusedLibraries() combase.CoFreeUnusedLibraries @ stdcall CoFreeUnusedLibrariesEx(long long) combase.CoFreeUnusedLibrariesEx @ stdcall CoGetActivationState(int128 long ptr) combase.CoGetActivationState -@ stdcall CoGetApartmentType(ptr ptr) +@ stdcall CoGetApartmentType(ptr ptr) combase.CoGetApartmentType @ stdcall CoGetCallContext(ptr ptr) combase.CoGetCallContext @ stdcall CoGetCallState(long ptr) combase.CoGetCallState @ stdcall CoGetCallerTID(ptr)