From 31b2d81ea078ec03b240ae0b14fb7830da8b078f Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Fri, 30 Nov 2007 18:08:08 +0000 Subject: [PATCH] ole32: Ignore the threading model of the PSFactoryBuffer object created during standard marshaling. This is so that we don't try to host it. --- dlls/ole32/compobj.c | 76 ++++++++++++++++++++++++++------------------ dlls/ole32/compobj_private.h | 2 ++ dlls/ole32/marshal.c | 4 +-- 3 files changed, 49 insertions(+), 33 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 6cee5b976c6..7ef613ecbed 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -79,7 +79,7 @@ HINSTANCE OLE32_hInstance = 0; /* FIXME: make static ... */ static HRESULT COM_GetRegisteredClassObject(const struct apartment *apt, REFCLSID rclsid, DWORD dwClsContext, LPUNKNOWN* ppUnk); static void COM_RevokeAllClasses(const struct apartment *apt); -static HRESULT get_inproc_class_object(APARTMENT *apt, HKEY hkeydll, REFCLSID rclsid, REFIID riid, void **ppv); +static HRESULT get_inproc_class_object(APARTMENT *apt, HKEY hkeydll, REFCLSID rclsid, REFIID riid, BOOL hostifnecessary, void **ppv); static APARTMENT *MTA; /* protected by csApartment */ static APARTMENT *MainApartment; /* the first STA apartment */ @@ -2087,38 +2087,51 @@ static void get_threading_model(HKEY key, LPWSTR value, DWORD len) } static HRESULT get_inproc_class_object(APARTMENT *apt, HKEY hkeydll, - REFCLSID rclsid, REFIID riid, void **ppv) + REFCLSID rclsid, REFIID riid, + BOOL hostifnecessary, void **ppv) { - static const WCHAR wszApartment[] = {'A','p','a','r','t','m','e','n','t',0}; - static const WCHAR wszFree[] = {'F','r','e','e',0}; - static const WCHAR wszBoth[] = {'B','o','t','h',0}; WCHAR dllpath[MAX_PATH+1]; - WCHAR threading_model[10 /* strlenW(L"apartment")+1 */]; + BOOL apartment_threaded; - get_threading_model(hkeydll, threading_model, ARRAYSIZE(threading_model)); - /* "Apartment" */ - if (!strcmpiW(threading_model, wszApartment)) + if (hostifnecessary) { - if (apt->multi_threaded) - return apartment_hostobject_in_hostapt(apt, FALSE, FALSE, hkeydll, rclsid, riid, ppv); - } - /* "Free" */ - else if (!strcmpiW(threading_model, wszFree)) - { - if (!apt->multi_threaded) - return apartment_hostobject_in_hostapt(apt, TRUE, FALSE, hkeydll, rclsid, riid, ppv); - } - /* everything except "Apartment", "Free" and "Both" */ - else if (strcmpiW(threading_model, wszBoth)) - { - /* everything else is main-threaded */ - if (threading_model[0]) - FIXME("unrecognised threading model %s for object %s, should be main-threaded?\n", - debugstr_w(threading_model), debugstr_guid(rclsid)); + static const WCHAR wszApartment[] = {'A','p','a','r','t','m','e','n','t',0}; + static const WCHAR wszFree[] = {'F','r','e','e',0}; + static const WCHAR wszBoth[] = {'B','o','t','h',0}; + WCHAR threading_model[10 /* strlenW(L"apartment")+1 */]; - if (apt->multi_threaded || !apt->main) - return apartment_hostobject_in_hostapt(apt, FALSE, TRUE, hkeydll, rclsid, riid, ppv); + get_threading_model(hkeydll, threading_model, ARRAYSIZE(threading_model)); + /* "Apartment" */ + if (!strcmpiW(threading_model, wszApartment)) + { + apartment_threaded = TRUE; + if (apt->multi_threaded) + return apartment_hostobject_in_hostapt(apt, FALSE, FALSE, hkeydll, rclsid, riid, ppv); + } + /* "Free" */ + else if (!strcmpiW(threading_model, wszFree)) + { + apartment_threaded = FALSE; + if (!apt->multi_threaded) + return apartment_hostobject_in_hostapt(apt, TRUE, FALSE, hkeydll, rclsid, riid, ppv); + } + /* everything except "Apartment", "Free" and "Both" */ + else if (strcmpiW(threading_model, wszBoth)) + { + apartment_threaded = TRUE; + /* everything else is main-threaded */ + if (threading_model[0]) + FIXME("unrecognised threading model %s for object %s, should be main-threaded?\n", + debugstr_w(threading_model), debugstr_guid(rclsid)); + + if (apt->multi_threaded || !apt->main) + return apartment_hostobject_in_hostapt(apt, FALSE, TRUE, hkeydll, rclsid, riid, ppv); + } + else + apartment_threaded = FALSE; } + else + apartment_threaded = !apt->multi_threaded; if (COM_RegReadPath(hkeydll, NULL, NULL, dllpath, ARRAYSIZE(dllpath)) != ERROR_SUCCESS) { @@ -2127,8 +2140,7 @@ static HRESULT get_inproc_class_object(APARTMENT *apt, HKEY hkeydll, return REGDB_E_CLASSNOTREG; } - return apartment_getclassobject(apt, dllpath, - !strcmpiW(threading_model, wszApartment), + return apartment_getclassobject(apt, dllpath, apartment_threaded, rclsid, riid, ppv); } @@ -2228,7 +2240,8 @@ HRESULT WINAPI CoGetClassObject( if (SUCCEEDED(hres)) { - hres = get_inproc_class_object(apt, hkey, rclsid, iid, ppv); + hres = get_inproc_class_object(apt, hkey, rclsid, iid, + !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); RegCloseKey(hkey); } @@ -2258,7 +2271,8 @@ HRESULT WINAPI CoGetClassObject( if (SUCCEEDED(hres)) { - hres = get_inproc_class_object(apt, hkey, rclsid, iid, ppv); + hres = get_inproc_class_object(apt, hkey, rclsid, iid, + !(dwClsContext & WINE_CLSCTX_DONT_HOST), ppv); RegCloseKey(hkey); } diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index f99a89f3434..1c49956b6f8 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -307,6 +307,8 @@ extern HINSTANCE OLE32_hInstance; /* FIXME: make static */ #define CHARS_IN_GUID 39 /* including NULL */ +#define WINE_CLSCTX_DONT_HOST 0x80000000 + /* Exported non-interface Data Advise Holder functions */ HRESULT DataAdviseHolder_OnConnect(IDataAdviseHolder *iface, IDataObject *pDelegate); void DataAdviseHolder_OnDisconnect(IDataAdviseHolder *iface); diff --git a/dlls/ole32/marshal.c b/dlls/ole32/marshal.c index fde189a690f..32dadb1e308 100644 --- a/dlls/ole32/marshal.c +++ b/dlls/ole32/marshal.c @@ -76,8 +76,8 @@ static inline HRESULT get_facbuf_for_iid(REFIID riid, IPSFactoryBuffer **facbuf) if ((hr = CoGetPSClsid(riid, &clsid))) return hr; - return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, - &IID_IPSFactoryBuffer, (LPVOID*)facbuf); + return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER | WINE_CLSCTX_DONT_HOST, + NULL, &IID_IPSFactoryBuffer, (LPVOID*)facbuf); } /* marshals an object into a STDOBJREF structure */ -- 2.11.4.GIT