Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
CoGetClassObject() moved to helper to make it easier to get flags validation right later - CLSCTX_APPCONTAINER can't be used with it, and should return E_INVALIDARG, while it's usable for CoCreateInstance*.
.../api-ms-win-core-com-l1-1-0.spec | 2 +- .../api-ms-win-core-com-l1-1-1.spec | 2 +- dlls/combase/combase.c | 110 +++++++++------- dlls/combase/combase.spec | 2 +- dlls/ole32/ole32.spec | 1 + dlls/ole32/tests/compobj.c | 122 ++++++++++++++++++ include/objbase.h | 2 + include/wtypes.idl | 41 +++--- 8 files changed, 217 insertions(+), 65 deletions(-)
diff --git a/dlls/api-ms-win-core-com-l1-1-0/api-ms-win-core-com-l1-1-0.spec b/dlls/api-ms-win-core-com-l1-1-0/api-ms-win-core-com-l1-1-0.spec index eb81d238550..f5be6d88c75 100644 --- a/dlls/api-ms-win-core-com-l1-1-0/api-ms-win-core-com-l1-1-0.spec +++ b/dlls/api-ms-win-core-com-l1-1-0/api-ms-win-core-com-l1-1-0.spec @@ -8,7 +8,7 @@ @ stdcall CoCreateGuid(ptr) ole32.CoCreateGuid @ stdcall CoCreateInstance(ptr ptr long ptr ptr) ole32.CoCreateInstance @ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) ole32.CoCreateInstanceEx -@ stub CoCreateInstanceFromApp +@ stdcall CoCreateInstanceFromApp(ptr ptr long ptr long ptr) ole32.CoCreateInstanceFromApp @ stub CoDecodeProxy @ stdcall CoDecrementMTAUsage(ptr) ole32.CoDecrementMTAUsage @ stdcall CoDisableCallCancellation(ptr) ole32.CoDisableCallCancellation diff --git a/dlls/api-ms-win-core-com-l1-1-1/api-ms-win-core-com-l1-1-1.spec b/dlls/api-ms-win-core-com-l1-1-1/api-ms-win-core-com-l1-1-1.spec index 6c3115d6007..f443592db3b 100644 --- a/dlls/api-ms-win-core-com-l1-1-1/api-ms-win-core-com-l1-1-1.spec +++ b/dlls/api-ms-win-core-com-l1-1-1/api-ms-win-core-com-l1-1-1.spec @@ -8,7 +8,7 @@ @ stdcall CoCreateGuid(ptr) ole32.CoCreateGuid @ stdcall CoCreateInstance(ptr ptr long ptr ptr) ole32.CoCreateInstance @ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) ole32.CoCreateInstanceEx -@ stub CoCreateInstanceFromApp +@ stdcall CoCreateInstanceFromApp(ptr ptr long ptr long ptr) ole32.CoCreateInstanceFromApp @ stub CoDecodeProxy @ stdcall CoDecrementMTAUsage(ptr) ole32.CoDecrementMTAUsage @ stdcall CoDisableCallCancellation(ptr) ole32.CoDisableCallCancellation diff --git a/dlls/combase/combase.c b/dlls/combase/combase.c index c90cba6185c..66c99b53523 100644 --- a/dlls/combase/combase.c +++ b/dlls/combase/combase.c @@ -1527,53 +1527,19 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, IUnknown *out }
/*********************************************************************** - * CoCreateInstanceEx (combase.@) + * CoCreateInstanceFromApp (combase.@) */ -HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, - COSERVERINFO *server_info, ULONG count, MULTI_QI *results) +HRESULT WINAPI CoCreateInstanceFromApp(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, + void *server_info, ULONG count, MULTI_QI *results) { - IClassFactory *factory; - IUnknown *unk = NULL; - CLSID clsid; - HRESULT hr; - - TRACE("%s, %p, %#x, %p, %u, %p\n", debugstr_guid(rclsid), outer, cls_context, server_info, count, results); - - if (!count || !results) - return E_INVALIDARG; - - if (server_info) - FIXME("Server info is not supported.\n"); - - init_multi_qi(count, results, E_NOINTERFACE); - - hr = CoGetTreatAsClass(rclsid, &clsid); - if (FAILED(hr)) - clsid = *rclsid; - - hr = CoGetClassObject(&clsid, cls_context, NULL, &IID_IClassFactory, (void **)&factory); - if (FAILED(hr)) - return hr; + TRACE("%s, %p, %#x, %p, %u, %p\n", debugstr_guid(rclsid), outer, cls_context, server_info, + count, results);
- hr = IClassFactory_CreateInstance(factory, outer, results[0].pIID, (void **)&unk); - IClassFactory_Release(factory); - if (FAILED(hr)) - { - if (hr == CLASS_E_NOAGGREGATION && outer) - FIXME("Class %s does not support aggregation\n", debugstr_guid(&clsid)); - else - FIXME("no instance created for interface %s of class %s, hr %#x.\n", - debugstr_guid(results[0].pIID), debugstr_guid(&clsid), hr); - return hr; - } - - return return_multi_qi(unk, count, results, TRUE); + return CoCreateInstanceEx(rclsid, outer, cls_context | CLSCTX_APPCONTAINER, server_info, + count, results); }
-/*********************************************************************** - * CoGetClassObject (combase.@) - */ -HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscontext, +static HRESULT com_get_class_object(REFCLSID rclsid, DWORD clscontext, COSERVERINFO *server_info, REFIID riid, void **obj) { struct class_reg_data clsreg = { 0 }; @@ -1581,8 +1547,6 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscont IUnknown *registered_obj; struct apartment *apt;
- TRACE("%s, %s\n", debugstr_guid(rclsid), debugstr_guid(riid)); - if (!obj) return E_INVALIDARG;
@@ -1601,7 +1565,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscont { if (IsEqualCLSID(rclsid, &CLSID_InProcFreeMarshaler) || IsEqualCLSID(rclsid, &CLSID_GlobalOptions) || - IsEqualCLSID(rclsid, &CLSID_ManualResetEvent) || + (!(clscontext & CLSCTX_APPCONTAINER) && IsEqualCLSID(rclsid, &CLSID_ManualResetEvent)) || IsEqualCLSID(rclsid, &CLSID_StdGlobalInterfaceTable)) { apartment_release(apt); @@ -1637,7 +1601,7 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscont * First, try and see if we can't match the class ID with one of the * registered classes. */ - if ((registered_obj = com_get_registered_class_object(apt, rclsid, clscontext))) + if (!(clscontext & CLSCTX_APPCONTAINER) && (registered_obj = com_get_registered_class_object(apt, rclsid, clscontext))) { hr = IUnknown_QueryInterface(registered_obj, riid, obj); IUnknown_Release(registered_obj); @@ -1737,6 +1701,60 @@ HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscont return hr; }
+/*********************************************************************** + * CoCreateInstanceEx (combase.@) + */ +HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstanceEx(REFCLSID rclsid, IUnknown *outer, DWORD cls_context, + COSERVERINFO *server_info, ULONG count, MULTI_QI *results) +{ + IClassFactory *factory; + IUnknown *unk = NULL; + CLSID clsid; + HRESULT hr; + + TRACE("%s, %p, %#x, %p, %u, %p\n", debugstr_guid(rclsid), outer, cls_context, server_info, count, results); + + if (!count || !results) + return E_INVALIDARG; + + if (server_info) + FIXME("Server info is not supported.\n"); + + init_multi_qi(count, results, E_NOINTERFACE); + + clsid = *rclsid; + if (!(cls_context & CLSCTX_APPCONTAINER)) + CoGetTreatAsClass(rclsid, &clsid); + + if (FAILED(hr = com_get_class_object(&clsid, cls_context, NULL, &IID_IClassFactory, (void **)&factory))) + return hr; + + hr = IClassFactory_CreateInstance(factory, outer, results[0].pIID, (void **)&unk); + IClassFactory_Release(factory); + if (FAILED(hr)) + { + if (hr == CLASS_E_NOAGGREGATION && outer) + FIXME("Class %s does not support aggregation\n", debugstr_guid(&clsid)); + else + FIXME("no instance created for interface %s of class %s, hr %#x.\n", + debugstr_guid(results[0].pIID), debugstr_guid(&clsid), hr); + return hr; + } + + return return_multi_qi(unk, count, results, TRUE); +} + +/*********************************************************************** + * CoGetClassObject (combase.@) + */ +HRESULT WINAPI DECLSPEC_HOTPATCH CoGetClassObject(REFCLSID rclsid, DWORD clscontext, + COSERVERINFO *server_info, REFIID riid, void **obj) +{ + TRACE("%s, %#x, %s\n", debugstr_guid(rclsid), clscontext, debugstr_guid(riid)); + + return com_get_class_object(rclsid, clscontext, server_info, riid, obj); +} + /*********************************************************************** * CoFreeUnusedLibraries (combase.@) */ diff --git a/dlls/combase/combase.spec b/dlls/combase/combase.spec index 9d9b34640be..6e74cca1f24 100644 --- a/dlls/combase/combase.spec +++ b/dlls/combase/combase.spec @@ -82,7 +82,7 @@ @ stdcall CoCreateGuid(ptr) @ stdcall CoCreateInstance(ptr ptr long ptr ptr) @ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) -@ stub CoCreateInstanceFromApp +@ stdcall CoCreateInstanceFromApp(ptr ptr long ptr long ptr) @ stub CoCreateObjectInContext @ stub CoDeactivateObject @ stub CoDecodeProxy diff --git a/dlls/ole32/ole32.spec b/dlls/ole32/ole32.spec index a6f62ebfa99..8e73fdd16b4 100644 --- a/dlls/ole32/ole32.spec +++ b/dlls/ole32/ole32.spec @@ -14,6 +14,7 @@ @ stdcall CoCreateGuid(ptr) combase.CoCreateGuid @ stdcall CoCreateInstance(ptr ptr long ptr ptr) combase.CoCreateInstance @ stdcall CoCreateInstanceEx(ptr ptr long ptr long ptr) combase.CoCreateInstanceEx +@ stdcall CoCreateInstanceFromApp(ptr ptr long ptr long ptr) combase.CoCreateInstanceFromApp @ stdcall CoDecrementMTAUsage(ptr) combase.CoDecrementMTAUsage @ stdcall CoDisableCallCancellation(ptr) combase.CoDisableCallCancellation @ stdcall CoDisconnectObject(ptr long) combase.CoDisconnectObject diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index eb172aac28d..98b3ef642b8 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -80,6 +80,8 @@ static HRESULT (WINAPI * pCoIncrementMTAUsage)(CO_MTA_USAGE_COOKIE *cookie); static HRESULT (WINAPI * pCoDecrementMTAUsage)(CO_MTA_USAGE_COOKIE cookie); static LONG (WINAPI * pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD); static LONG (WINAPI * pRegOverridePredefKey)(HKEY key, HKEY override); +static HRESULT (WINAPI * pCoCreateInstanceFromApp)(REFCLSID clsid, IUnknown *outer, DWORD clscontext, + void *reserved, DWORD count, MULTI_QI *results);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, LPBOOL);
@@ -2244,6 +2246,23 @@ static void test_TreatAsClass(void) pIP = NULL; }
+ if (pCoCreateInstanceFromApp) + { + MULTI_QI mqi = { 0 }; + + mqi.pIID = &IID_IInternetProtocol; + hr = pCoCreateInstanceFromApp(&deadbeef, NULL, CLSCTX_INPROC_SERVER, NULL, 1, &mqi); + ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(&deadbeef, NULL, CLSCTX_INPROC_SERVER | CLSCTX_APPCONTAINER, &IID_IInternetProtocol, + (void **)&pIP); + ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(&deadbeef, NULL, CLSCTX_INPROC_SERVER, &IID_IInternetProtocol, (void **)&pIP); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IUnknown_Release(pIP); + } + hr = pCoTreatAsClass(&deadbeef, &CLSID_NULL); ok(hr == S_OK, "CoTreatAsClass failed: %08x\n", hr);
@@ -3943,6 +3962,7 @@ static void init_funcs(void) pCoGetApartmentType = (void*)GetProcAddress(hOle32, "CoGetApartmentType"); pCoIncrementMTAUsage = (void*)GetProcAddress(hOle32, "CoIncrementMTAUsage"); pCoDecrementMTAUsage = (void*)GetProcAddress(hOle32, "CoDecrementMTAUsage"); + pCoCreateInstanceFromApp = (void*)GetProcAddress(hOle32, "CoCreateInstanceFromApp"); pRegDeleteKeyExA = (void*)GetProcAddress(hAdvapi32, "RegDeleteKeyExA"); pRegOverridePredefKey = (void*)GetProcAddress(hAdvapi32, "RegOverridePredefKey");
@@ -4075,6 +4095,107 @@ static void test_mta_usage(void) test_apt_type(APTTYPE_CURRENT, APTTYPEQUALIFIER_NONE); }
+static void test_CoCreateInstanceFromApp(void) +{ + static const CLSID *supported_classes[] = + { + &CLSID_InProcFreeMarshaler, + &CLSID_GlobalOptions, + &CLSID_StdGlobalInterfaceTable, + }; + static const CLSID *unsupported_classes[] = + { + &CLSID_ManualResetEvent, + }; + unsigned int i; + IUnknown *unk; + DWORD cookie; + MULTI_QI mqi; + HRESULT hr; + HANDLE handle; + ULONG_PTR actctx_cookie; + + if (!pCoCreateInstanceFromApp) + { + win_skip("CoCreateInstanceFromApp() is not available.\n"); + return; + } + + CoInitialize(NULL); + + for (i = 0; i < ARRAY_SIZE(supported_classes); ++i) + { + memset(&mqi, 0, sizeof(mqi)); + mqi.pIID = &IID_IUnknown; + hr = pCoCreateInstanceFromApp(supported_classes[i], NULL, CLSCTX_INPROC_SERVER, NULL, 1, &mqi); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IUnknown_Release(mqi.pItf); + + hr = CoCreateInstance(supported_classes[i], NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IUnknown_Release(unk); + } + + for (i = 0; i < ARRAY_SIZE(unsupported_classes); ++i) + { + memset(&mqi, 0, sizeof(mqi)); + mqi.pIID = &IID_IUnknown; + hr = pCoCreateInstanceFromApp(unsupported_classes[i], NULL, CLSCTX_INPROC_SERVER, NULL, 1, &mqi); + ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(unsupported_classes[i], NULL, CLSCTX_INPROC_SERVER | CLSCTX_APPCONTAINER, + &IID_IUnknown, (void **)&unk); + ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(unsupported_classes[i], NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + IUnknown_Release(unk); + } + + /* Locally registered classes are filtered out. */ + hr = CoRegisterClassObject(&CLSID_WineOOPTest, (IUnknown *)&Test_ClassFactory, CLSCTX_INPROC_SERVER, + REGCLS_MULTIPLEUSE, &cookie); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER, NULL, &IID_IClassFactory, (void **)&unk); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = CoGetClassObject(&CLSID_WineOOPTest, CLSCTX_INPROC_SERVER | CLSCTX_APPCONTAINER, NULL, + &IID_IClassFactory, (void **)&unk); +todo_wine + ok(hr == E_INVALIDARG, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); + ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_WineOOPTest, NULL, CLSCTX_INPROC_SERVER | CLSCTX_APPCONTAINER, + &IID_IUnknown, (void **)&unk); + ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr); + + memset(&mqi, 0, sizeof(mqi)); + mqi.pIID = &IID_IUnknown; + hr = pCoCreateInstanceFromApp(&CLSID_WineOOPTest, NULL, CLSCTX_INPROC_SERVER, NULL, 1, &mqi); + ok(hr == REGDB_E_CLASSNOTREG, "Unexpected hr %#x.\n", hr); + + hr = CoRevokeClassObject(cookie); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + /* Activation context */ + if ((handle = activate_context(actctx_manifest, &actctx_cookie))) + { + hr = CoCreateInstance(&IID_Testiface7, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk); + ok(hr == 0x80001235, "Unexpected hr %#x.\n", hr); + + hr = CoCreateInstance(&IID_Testiface7, NULL, CLSCTX_INPROC_SERVER | CLSCTX_APPCONTAINER, + &IID_IUnknown, (void **)&unk); + ok(hr == 0x80001235, "Unexpected hr %#x.\n", hr); + + deactivate_context(handle, actctx_cookie); + } + + CoUninitialize(); +} + START_TEST(compobj) { init_funcs(); @@ -4124,6 +4245,7 @@ START_TEST(compobj) test_implicit_mta(); test_CoGetCurrentProcess(); test_mta_usage(); + test_CoCreateInstanceFromApp();
DeleteFileA( testlib ); } diff --git a/include/objbase.h b/include/objbase.h index e5a6b2a9faf..0a50d28e9d2 100644 --- a/include/objbase.h +++ b/include/objbase.h @@ -319,6 +319,8 @@ HRESULT WINAPI CoCreateInstanceEx(REFCLSID rclsid, COSERVERINFO* pServerInfo, ULONG cmq, MULTI_QI* pResults); +HRESULT WINAPI CoCreateInstanceFromApp(REFCLSID clsid, IUnknown *outer, DWORD clscontext, void *reserved, + DWORD count, MULTI_QI *results);
HRESULT WINAPI CoGetInstanceFromFile(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, DWORD grfMode, OLECHAR* pwszName, DWORD dwCount, MULTI_QI* pResults); HRESULT WINAPI CoGetInstanceFromIStorage(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, IStorage* pstg, DWORD dwCount, MULTI_QI* pResults); diff --git a/include/wtypes.idl b/include/wtypes.idl index a6682212b5b..754258839d7 100644 --- a/include/wtypes.idl +++ b/include/wtypes.idl @@ -336,22 +336,31 @@ cpp_quote("#define ROTFLAGS_ALLOWANYCLIENT 0x2") cpp_quote("#endif")
typedef enum tagCLSCTX { - CLSCTX_INPROC_SERVER = 0x1, - CLSCTX_INPROC_HANDLER = 0x2, - CLSCTX_LOCAL_SERVER = 0x4, - CLSCTX_INPROC_SERVER16 = 0x8, - CLSCTX_REMOTE_SERVER = 0x10, - CLSCTX_INPROC_HANDLER16 = 0x20, - CLSCTX_INPROC_SERVERX86 = 0x40, - CLSCTX_INPROC_HANDLERX86 = 0x80, - CLSCTX_ESERVER_HANDLER = 0x100, - CLSCTX_NO_CODE_DOWNLOAD = 0x400, - CLSCTX_NO_CUSTOM_MARSHAL = 0x1000, - CLSCTX_ENABLE_CODE_DOWNLOAD = 0x2000, - CLSCTX_NO_FAILURE_LOG = 0x4000, - CLSCTX_DISABLE_AAA = 0x8000, - CLSCTX_ENABLE_AAA = 0x10000, - CLSCTX_FROM_DEFAULT_CONTEXT = 0x20000 + CLSCTX_INPROC_SERVER = 0x00000001, + CLSCTX_INPROC_HANDLER = 0x00000002, + CLSCTX_LOCAL_SERVER = 0x00000004, + CLSCTX_INPROC_SERVER16 = 0x00000008, + CLSCTX_REMOTE_SERVER = 0x00000010, + CLSCTX_INPROC_HANDLER16 = 0x00000020, + CLSCTX_INPROC_SERVERX86 = 0x00000040, + CLSCTX_INPROC_HANDLERX86 = 0x00000080, + CLSCTX_ESERVER_HANDLER = 0x00000100, + CLSCTX_NO_CODE_DOWNLOAD = 0x00000400, + CLSCTX_NO_CUSTOM_MARSHAL = 0x00001000, + CLSCTX_ENABLE_CODE_DOWNLOAD = 0x00002000, + CLSCTX_NO_FAILURE_LOG = 0x00004000, + CLSCTX_DISABLE_AAA = 0x00008000, + CLSCTX_ENABLE_AAA = 0x00010000, + CLSCTX_FROM_DEFAULT_CONTEXT = 0x00020000, + CLSCTX_ACTIVATE_X86_SERVER = 0x00040000, + CLSCTX_ACTIVATE_32_BIT_SERVER = CLSCTX_ACTIVATE_X86_SERVER, + CLSCTX_ACTIVATE_64_BIT_SERVER = 0x00080000, + CLSCTX_ENABLE_CLOAKING = 0x00100000, + CLSCTX_APPCONTAINER = 0x00400000, + CLSCTX_ACTIVATE_AAA_AS_IU = 0x00800000, + CLSCTX_RESERVED6 = 0x01000000, + CLSCTX_ACTIVATE_ARM32_SERVER = 0x02000000, + CLSCTX_PS_DLL = 0x80000000, } CLSCTX;
cpp_quote("#define CLSCTX_INPROC (CLSCTX_INPROC_SERVER | CLSCTX_INPROC_HANDLER)")
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
These are available on XP, but likely were available before that as well.
dlls/ole32/tests/compobj.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/dlls/ole32/tests/compobj.c b/dlls/ole32/tests/compobj.c index 98b3ef642b8..e627521fa59 100644 --- a/dlls/ole32/tests/compobj.c +++ b/dlls/ole32/tests/compobj.c @@ -72,8 +72,6 @@ DEFINE_EXPECT(PostUninitialize); /* functions that are not present on all versions of Windows */ static HRESULT (WINAPI * pCoGetObjectContext)(REFIID riid, LPVOID *ppv); static HRESULT (WINAPI * pCoSwitchCallContext)(IUnknown *pObject, IUnknown **ppOldObject); -static HRESULT (WINAPI * pCoGetTreatAsClass)(REFCLSID clsidOld, LPCLSID pClsidNew); -static HRESULT (WINAPI * pCoTreatAsClass)(REFCLSID clsidOld, REFCLSID pClsidNew); static HRESULT (WINAPI * pCoGetContextToken)(ULONG_PTR *token); static HRESULT (WINAPI * pCoGetApartmentType)(APTTYPE *type, APTTYPEQUALIFIER *qualifier); static HRESULT (WINAPI * pCoIncrementMTAUsage)(CO_MTA_USAGE_COOKIE *cookie); @@ -2190,21 +2188,15 @@ static void test_TreatAsClass(void) HKEY clsidkey, deadbeefkey; LONG lr;
- if (!pCoGetTreatAsClass) - { - win_skip("CoGetTreatAsClass not present\n"); - return; - } - - hr = pCoGetTreatAsClass(&deadbeef,&out); + hr = CoGetTreatAsClass(&deadbeef,&out); ok (hr == S_FALSE, "expected S_FALSE got %x\n",hr); ok (IsEqualGUID(&out,&deadbeef), "expected to get same clsid back\n");
- hr = pCoGetTreatAsClass(NULL, &out); + hr = CoGetTreatAsClass(NULL, &out); ok(hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr); ok(IsEqualGUID(&out, &deadbeef), "expected no change to the clsid\n");
- hr = pCoGetTreatAsClass(&deadbeef, NULL); + hr = CoGetTreatAsClass(&deadbeef, NULL); ok(hr == E_INVALIDARG, "expected E_INVALIDARG got %08x\n", hr);
lr = RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &clsidkey); @@ -2217,17 +2209,17 @@ static void test_TreatAsClass(void) return; }
- hr = pCoTreatAsClass(&deadbeef, &deadbeef); + hr = CoTreatAsClass(&deadbeef, &deadbeef); ok(hr == REGDB_E_WRITEREGDB, "CoTreatAsClass gave wrong error: %08x\n", hr);
- hr = pCoTreatAsClass(&deadbeef, &CLSID_FileProtocol); + hr = CoTreatAsClass(&deadbeef, &CLSID_FileProtocol); if(hr == REGDB_E_WRITEREGDB){ win_skip("Insufficient privileges to use CoTreatAsClass\n"); goto exit; } ok(hr == S_OK, "CoTreatAsClass failed: %08x\n", hr);
- hr = pCoGetTreatAsClass(&deadbeef, &out); + hr = CoGetTreatAsClass(&deadbeef, &out); ok(hr == S_OK, "CoGetTreatAsClass failed: %08x\n",hr); ok(IsEqualGUID(&out, &CLSID_FileProtocol), "expected to get substituted clsid\n");
@@ -2263,10 +2255,10 @@ static void test_TreatAsClass(void) IUnknown_Release(pIP); }
- hr = pCoTreatAsClass(&deadbeef, &CLSID_NULL); + hr = CoTreatAsClass(&deadbeef, &CLSID_NULL); ok(hr == S_OK, "CoTreatAsClass failed: %08x\n", hr);
- hr = pCoGetTreatAsClass(&deadbeef, &out); + hr = CoGetTreatAsClass(&deadbeef, &out); ok(hr == S_FALSE, "expected S_FALSE got %08x\n", hr); ok(IsEqualGUID(&out, &deadbeef), "expected to get same clsid back\n");
@@ -3956,8 +3948,6 @@ static void init_funcs(void)
pCoGetObjectContext = (void*)GetProcAddress(hOle32, "CoGetObjectContext"); pCoSwitchCallContext = (void*)GetProcAddress(hOle32, "CoSwitchCallContext"); - pCoGetTreatAsClass = (void*)GetProcAddress(hOle32,"CoGetTreatAsClass"); - pCoTreatAsClass = (void*)GetProcAddress(hOle32,"CoTreatAsClass"); pCoGetContextToken = (void*)GetProcAddress(hOle32, "CoGetContextToken"); pCoGetApartmentType = (void*)GetProcAddress(hOle32, "CoGetApartmentType"); pCoIncrementMTAUsage = (void*)GetProcAddress(hOle32, "CoIncrementMTAUsage");
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/ole32/tests/stg_prop.c | 95 +++++++++--------------------------- dlls/ole32/tests/storage32.c | 19 +------- 2 files changed, 26 insertions(+), 88 deletions(-)
diff --git a/dlls/ole32/tests/stg_prop.c b/dlls/ole32/tests/stg_prop.c index 0184693f2a5..ea58e8bda3e 100644 --- a/dlls/ole32/tests/stg_prop.c +++ b/dlls/ole32/tests/stg_prop.c @@ -24,22 +24,6 @@ #define PID_BEHAVIOR 0x80000003 #endif
-static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR); -static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *); -static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **); -static HRESULT (WINAPI *pStgCreatePropStg)(IUnknown *, REFFMTID, const CLSID *, DWORD, DWORD, IPropertyStorage **); -static HRESULT (WINAPI *pStgOpenPropStg)(IUnknown *, REFFMTID, DWORD, DWORD, IPropertyStorage **); - -static void init_function_pointers(void) -{ - HMODULE hmod = GetModuleHandleA("ole32.dll"); - pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName"); - pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId"); - pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg"); - pStgCreatePropStg = (void*)GetProcAddress(hmod, "StgCreatePropStg"); - pStgOpenPropStg = (void*)GetProcAddress(hmod, "StgOpenPropStg"); -} - /* FIXME: this creates an ANSI storage, try to find conditions under which * Unicode translation fails */ @@ -79,13 +63,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage)
if(propSetStorage) { - if(!pStgCreatePropSetStg) - { - IStorage_Release(storage); - DeleteFileW(filename); - return; - } - hr = pStgCreatePropSetStg(storage, 0, propSetStorage); + hr = StgCreatePropSetStg(storage, 0, propSetStorage); ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(*propSetStorage, @@ -100,14 +78,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage) STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream); ok(hr == S_OK, "IStorage_CreateStream failed: 0x%08x\n", hr);
- if(!pStgCreatePropStg) - { - IStorage_Release(storage); - IUnknown_Release(stream); - DeleteFileW(filename); - return; - } - hr = pStgCreatePropStg((IUnknown *)stream, &FMTID_SummaryInformation, + hr = StgCreatePropStg((IUnknown *)stream, &FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI, 0, &propertyStorage); ok(hr == S_OK, "StgCreatePropStg failed: 0x%08x\n", hr); } @@ -289,7 +260,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage)
if(propSetStorage) { - hr = pStgCreatePropSetStg(storage, 0, propSetStorage); + hr = StgCreatePropSetStg(storage, 0, propSetStorage); ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Open(*propSetStorage, &FMTID_SummaryInformation, @@ -302,14 +273,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage) 0, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream); ok(hr == S_OK, "IStorage_OpenStream failed: 0x%08x\n", hr);
- if(!pStgOpenPropStg) - { - IStorage_Release(storage); - IUnknown_Release(stream); - DeleteFileW(filename); - return; - } - hr = pStgOpenPropStg((IUnknown *)stream, &FMTID_SummaryInformation, + hr = StgOpenPropStg((IUnknown *)stream, &FMTID_SummaryInformation, PROPSETFLAG_DEFAULT, 0, &propertyStorage); ok(hr == S_OK, "StgOpenPropStg failed: 0x%08x\n", hr); } @@ -345,7 +309,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage)
if(propSetStorage) { - hr = pStgCreatePropSetStg(storage, 0, propSetStorage); + hr = StgCreatePropSetStg(storage, 0, propSetStorage); ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(*propSetStorage, @@ -360,7 +324,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage) STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream); ok(hr == S_OK, "IStorage_CreateStream failed: 0x%08x\n", hr);
- hr = pStgCreatePropStg((IUnknown *)stream, &anyOldGuid, NULL, + hr = StgCreatePropStg((IUnknown *)stream, &anyOldGuid, NULL, PROPSETFLAG_DEFAULT, 0, &propertyStorage); ok(hr == S_OK, "StgCreatePropStg failed: 0x%08x\n", hr); } @@ -387,7 +351,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage)
if(propSetStorage) { - hr = pStgCreatePropSetStg(storage, 0, propSetStorage); + hr = StgCreatePropSetStg(storage, 0, propSetStorage); ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Open(*propSetStorage, &anyOldGuid, @@ -400,7 +364,7 @@ static void testPropsHelper(IPropertySetStorage **propSetStorage) 0, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream); ok(hr == S_OK, "IStorage_OpenStream failed: 0x%08x\n", hr);
- hr = pStgOpenPropStg((IUnknown *)stream, &anyOldGuid, + hr = StgOpenPropStg((IUnknown *)stream, &anyOldGuid, PROPSETFLAG_DEFAULT, 0, &propertyStorage); ok(hr == S_OK, "StgOpenPropStg failed: 0x%08x\n", hr); } @@ -451,13 +415,7 @@ static void testCodepage(void) STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage); ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
- if(!pStgCreatePropSetStg) - { - IStorage_Release(storage); - DeleteFileW(fileName); - return; - } - hr = pStgCreatePropSetStg(storage, 0, &propSetStorage); + hr = StgCreatePropSetStg(storage, 0, &propSetStorage); ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(propSetStorage, @@ -540,7 +498,7 @@ static void testCodepage(void) STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage); ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
- hr = pStgCreatePropSetStg(storage, 0, &propSetStorage); + hr = StgCreatePropSetStg(storage, 0, &propSetStorage); ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
hr = IPropertySetStorage_Create(propSetStorage, @@ -609,64 +567,60 @@ static void testFmtId(void) FMTID fmtid; HRESULT hr;
- if (pFmtIdToPropStgName) { - hr = pFmtIdToPropStgName(NULL, name); + hr = FmtIdToPropStgName(NULL, name); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr); - hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL); + hr = FmtIdToPropStgName(&FMTID_SummaryInformation, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr); - hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name); + hr = FmtIdToPropStgName(&FMTID_SummaryInformation, name); ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr); ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) * sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n"); - hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name); + hr = FmtIdToPropStgName(&FMTID_DocSummaryInformation, name); ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr); ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) * sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n"); - hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name); + hr = FmtIdToPropStgName(&FMTID_UserDefinedProperties, name); ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr); ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) * sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n"); - hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name); + hr = FmtIdToPropStgName(&IID_IPropertySetStorage, name); ok(hr == S_OK, "FmtIdToPropStgName failed: 0x%08x\n", hr); ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) * sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n"); - }
- if(pPropStgNameToFmtId) { /* test args first */ - hr = pPropStgNameToFmtId(NULL, NULL); + hr = PropStgNameToFmtId(NULL, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr); - hr = pPropStgNameToFmtId(NULL, &fmtid); + hr = PropStgNameToFmtId(NULL, &fmtid); ok(hr == STG_E_INVALIDNAME, "Expected STG_E_INVALIDNAME, got 0x%08x\n", hr); - hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL); + hr = PropStgNameToFmtId(szDocSummaryInfo, NULL); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08x\n", hr); /* test the known format IDs */ - hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid); + hr = PropStgNameToFmtId(szSummaryInfo, &fmtid); ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr); ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)), "Got unexpected FMTID, expected FMTID_SummaryInformation\n"); - hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid); + hr = PropStgNameToFmtId(szDocSummaryInfo, &fmtid); ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr); ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)), "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n"); /* test another GUID */ - hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid); + hr = PropStgNameToFmtId(szIID_IPropSetStg, &fmtid); ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr); ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)), "Got unexpected FMTID, expected IID_IPropertySetStorage\n"); /* now check case matching */ CharUpperW(szDocSummaryInfo + 1); - hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid); + hr = PropStgNameToFmtId(szDocSummaryInfo, &fmtid); ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr); ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)), "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n"); CharUpperW(szIID_IPropSetStg + 1); - hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid); + hr = PropStgNameToFmtId(szIID_IPropSetStg, &fmtid); ok(hr == S_OK, "PropStgNameToFmtId failed: 0x%08x\n", hr); ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)), "Got unexpected FMTID, expected IID_IPropertySetStorage\n"); - } }
static void test_propertyset_storage_enum(void) @@ -785,7 +739,6 @@ todo_wine {
START_TEST(stg_prop) { - init_function_pointers(); testProps(); testCodepage(); testFmtId(); diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 9d2c970e867..eea78c6d3fe 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -446,23 +446,14 @@ static void test_create_storage_modes(void)
static void test_stgcreatestorageex(void) { - HRESULT (WINAPI *pStgCreateStorageEx)(const WCHAR* pwcsName, DWORD grfMode, DWORD stgfmt, DWORD grfAttrs, STGOPTIONS* pStgOptions, void* reserved, REFIID riid, void** ppObjectOpen); - HMODULE hOle32 = GetModuleHandleA("ole32"); IStorage *stg = NULL; STGOPTIONS stgoptions = {1, 0, 4096}; HRESULT r;
- pStgCreateStorageEx = (void *) GetProcAddress(hOle32, "StgCreateStorageEx"); - if (!pStgCreateStorageEx) - { - win_skip("skipping test on NT4\n"); - return; - } - DeleteFileA(filenameA);
/* Verify that StgCreateStorageEx can accept an options param */ - r = pStgCreateStorageEx( filename, + r = StgCreateStorageEx( filename, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, STGFMT_DOCFILE, 0, @@ -471,19 +462,13 @@ static void test_stgcreatestorageex(void) &IID_IStorage, (void **) &stg); ok(r==S_OK || r==STG_E_UNIMPLEMENTEDFUNCTION, "StgCreateStorageEx with options failed\n"); - if (r==STG_E_UNIMPLEMENTEDFUNCTION) - { - /* We're on win98 which means all bets are off. Let's get out of here. */ - win_skip("skipping test on win9x\n"); - return; - }
r = IStorage_Release(stg); ok(r == 0, "storage not released\n"); ok(DeleteFileA(filenameA), "failed to delete file\n");
/* Verify that StgCreateStorageEx can accept a NULL pStgOptions */ - r = pStgCreateStorageEx( filename, + r = StgCreateStorageEx( filename, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, STGFMT_STORAGE, 0,
Signed-off-by: Huw Davies huw@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com ---
For now to unblock remaining tests.
dlls/ole32/tests/marshal.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c index a6811b9d241..891df59c54b 100644 --- a/dlls/ole32/tests/marshal.c +++ b/dlls/ole32/tests/marshal.c @@ -3529,13 +3529,17 @@ static void test_client_security(void) hr = IClassFactory_QueryInterface(pProxy, &IID_IUnknown, (LPVOID*)&pUnknown1); ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown");
- hr = IClassFactory_QueryInterface(pProxy, &IID_IRemUnknown, (LPVOID*)&pProxy2); - ok_ole_success(hr, "IUnknown_QueryInterface IID_IStream"); + /* Does not work on Windows 10 19xx+ */ + if (SUCCEEDED(IClassFactory_QueryInterface(pProxy, &IID_IRemUnknown, (void **)&pProxy2))) + { + hr = IUnknown_QueryInterface(pProxy2, &IID_IUnknown, (void **)&pUnknown2); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
- hr = IUnknown_QueryInterface(pProxy2, &IID_IUnknown, (LPVOID*)&pUnknown2); - ok_ole_success(hr, "IUnknown_QueryInterface IID_IUnknown"); + ok(pUnknown1 == pUnknown2, "both proxy's IUnknowns should be the same - %p, %p\n", pUnknown1, pUnknown2); + IUnknown_Release(pUnknown2);
- ok(pUnknown1 == pUnknown2, "both proxy's IUnknowns should be the same - %p, %p\n", pUnknown1, pUnknown2); + IUnknown_Release(pProxy2); + }
hr = IClassFactory_QueryInterface(pProxy, &IID_IMarshal, (LPVOID*)&pMarshal); ok_ole_success(hr, "IUnknown_QueryInterface IID_IMarshal"); @@ -3572,9 +3576,7 @@ static void test_client_security(void) CoTaskMemFree(pServerPrincName);
IClassFactory_Release(pProxy); - IUnknown_Release(pProxy2); IUnknown_Release(pUnknown1); - IUnknown_Release(pUnknown2); IMarshal_Release(pMarshal); IClientSecurity_Release(pCliSec);
Signed-off-by: Huw Davies huw@codeweavers.com
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=78380
Your paranoid android.
=== w8 (32 bit report) ===
ole32: compobj.c:832: Test failed: Section not found. compobj.c:842: Test failed: Unexpected return value. compobj.c:851: Test failed: Unexpected return value. compobj.c:857: Test failed: Unexpected module name L"testlib.dll".