Signed-off-by: Jactry Zeng jzeng@codeweavers.com --- dlls/comsvcs/Makefile.in | 2 +- dlls/comsvcs/comsvcs_private.h | 15 ++++++++ dlls/comsvcs/main.c | 68 ++++++++++++++++++++++++++++++++++ dlls/comsvcs/property.c | 46 +++++++++++++++++++---- dlls/comsvcs/tests/property.c | 56 ++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 9 deletions(-)
diff --git a/dlls/comsvcs/Makefile.in b/dlls/comsvcs/Makefile.in index b4a4244bce..82a496ea9c 100644 --- a/dlls/comsvcs/Makefile.in +++ b/dlls/comsvcs/Makefile.in @@ -1,6 +1,6 @@ MODULE = comsvcs.dll IMPORTLIB = comsvcs -IMPORTS = ole32 uuid +IMPORTS = ole32 oleaut32 uuid
EXTRADLLFLAGS = -mno-cygwin
diff --git a/dlls/comsvcs/comsvcs_private.h b/dlls/comsvcs/comsvcs_private.h index 6d299d3a88..8a67bcffd8 100644 --- a/dlls/comsvcs/comsvcs_private.h +++ b/dlls/comsvcs/comsvcs_private.h @@ -33,6 +33,21 @@ #include "wine/heap.h" #include "wine/debug.h"
+enum tid_t +{ + NULL_tid, + ISharedPropertyGroupManager_tid, + LAST_tid +}; + +static REFIID tid_ids[] = +{ + &IID_NULL, + &IID_ISharedPropertyGroupManager, +}; + +HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo); + HRESULT WINAPI group_manager_create(IClassFactory *iface, IUnknown *outer, REFIID riid, void **out);
#endif diff --git a/dlls/comsvcs/main.c b/dlls/comsvcs/main.c index 1d3f7db174..9f1deb7155 100644 --- a/dlls/comsvcs/main.c +++ b/dlls/comsvcs/main.c @@ -361,6 +361,71 @@ static HRESULT WINAPI dispenser_manager_cf_CreateInstance(IClassFactory *iface, return ret; }
+static ITypeLib *typelib; +static ITypeInfo *typeinfos[LAST_tid]; + +static HRESULT load_typelib(void) +{ + ITypeLib *tl; + HRESULT hr; + + if (typelib) + return S_OK; + + hr = LoadRegTypeLib(&LIBID_COMSVCSLib, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl); + if (FAILED(hr)) + { + ERR("LoadRegTypeLib failed: %#x.\n", hr); + return hr; + } + + if (InterlockedCompareExchangePointer((void**)&typelib, tl, NULL)) + ITypeLib_Release(tl); + return hr; +} + +HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) +{ + HRESULT hr; + + hr = load_typelib(); + if (FAILED(hr)) + return hr; + + if (!typeinfos[tid]) + { + ITypeInfo *ti; + + hr = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti); + if (FAILED(hr)) + { + ERR("GetTypeInfoOfGuid(%s) failed: %#x.\n", debugstr_guid(tid_ids[tid]), hr); + return hr; + } + + if (InterlockedCompareExchangePointer((void**)(typeinfos + tid), ti, NULL)) + ITypeInfo_Release(ti); + } + + *typeinfo = typeinfos[tid]; + ITypeInfo_AddRef(typeinfos[tid]); + return S_OK; +} + +static void release_typelib(void) +{ + unsigned i; + + if (!typelib) + return; + + for (i = 0; i < ARRAY_SIZE(typeinfos); i++) + if (typeinfos[i]) + ITypeInfo_Release(typeinfos[i]); + + ITypeLib_Release(typelib); +} + BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID lpv) { switch(reason) @@ -371,6 +436,9 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID lpv) COMSVCS_hInstance = hinst; DisableThreadLibraryCalls(hinst); break; + case DLL_PROCESS_DETACH: + release_typelib(); + break; } return TRUE; } diff --git a/dlls/comsvcs/property.c b/dlls/comsvcs/property.c index 0d81ac60c8..e4aeab924d 100644 --- a/dlls/comsvcs/property.c +++ b/dlls/comsvcs/property.c @@ -85,31 +85,61 @@ static ULONG WINAPI group_manager_Release(ISharedPropertyGroupManager *iface)
static HRESULT WINAPI group_manager_GetTypeInfoCount(ISharedPropertyGroupManager *iface, UINT *info) { - FIXME("iface %p, info %p: stub.\n", iface, info); - return E_NOTIMPL; + TRACE("iface %p, info %p.\n", iface, info); + + if (!info) + return E_INVALIDARG; + *info = 1; + return S_OK; }
static HRESULT WINAPI group_manager_GetTypeInfo(ISharedPropertyGroupManager *iface, UINT index, LCID lcid, ITypeInfo **info) { - FIXME("iface %p, index %u, lcid %u, info %p: stub.\n", iface, index, lcid, info); - return E_NOTIMPL; + HRESULT hr; + + TRACE("iface %p, index %u, lcid %u, info %p.\n", iface, index, lcid, info); + + if (index) + return DISP_E_BADINDEX; + + hr = get_typeinfo(ISharedPropertyGroupManager_tid, info); + if (SUCCEEDED(hr)) + ITypeInfo_AddRef(*info); + return hr; }
static HRESULT WINAPI group_manager_GetIDsOfNames(ISharedPropertyGroupManager *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *dispid) { - FIXME("iface %p, riid %s, names %p, count %u, lcid %u, dispid %p: stub.\n", + ITypeInfo *typeinfo; + HRESULT hr; + + TRACE("iface %p, riid %s, names %p, count %u, lcid %u, dispid %p.\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
- return E_NOTIMPL; + hr = get_typeinfo(ISharedPropertyGroupManager_tid, &typeinfo); + if (SUCCEEDED(hr)) + { + hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid); + ITypeInfo_Release(typeinfo); + } + + return hr; }
static HRESULT WINAPI group_manager_Invoke(ISharedPropertyGroupManager *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *except, UINT *argerr) { - FIXME("iface %p, member %u, riid %s, lcid %u, flags %x, params %p, result %p, except %p, argerr %p: stub.\n", + ITypeInfo *typeinfo; + HRESULT hr; + + TRACE("iface %p, member %u, riid %s, lcid %u, flags %x, params %p, result %p, except %p, argerr %p.\n", iface, member, debugstr_guid(riid), lcid, flags, params, result, except, argerr); - return E_NOTIMPL; + + hr = get_typeinfo(ISharedPropertyGroupManager_tid, &typeinfo); + if (SUCCEEDED(hr)) + hr = ITypeInfo_Invoke(typeinfo, iface, member, flags, params, result, except, argerr); + return hr; }
static HRESULT WINAPI group_manager_CreatePropertyGroup(ISharedPropertyGroupManager *iface, BSTR name, LONG *isolation, diff --git a/dlls/comsvcs/tests/property.c b/dlls/comsvcs/tests/property.c index e857bf11e6..140f62dfc0 100644 --- a/dlls/comsvcs/tests/property.c +++ b/dlls/comsvcs/tests/property.c @@ -60,6 +60,54 @@ static const IUnknownVtbl outer_vtbl =
static IUnknown test_outer = {&outer_vtbl};
+struct test_name_id +{ + const WCHAR *name; + DISPID id; +}; + +#define TEST_TYPEINFO(dispatch,test_name_ids,id_count,riid) _test_typeinfo(dispatch, test_name_ids, id_count, riid, __LINE__) +static void _test_typeinfo(IDispatch *dispatch, struct test_name_id *test_name_ids, UINT id_count, REFIID riid, int line) +{ + static const LCID english = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT); + ITypeInfo *typeinfo; + TYPEATTR *typeattr; + DISPID dispid; + UINT count; + BSTR names; + HRESULT hr; + int i; + + hr = IDispatch_GetTypeInfoCount(dispatch, NULL); + ok_(__FILE__,line)(hr == E_INVALIDARG, "GetTypeInfoCount got hr %#x.\n", hr); + + count = 0xdeadbeef; + hr = IDispatch_GetTypeInfoCount(dispatch, &count); + ok_(__FILE__,line)(hr == S_OK, "GetTypeInfoCount got hr %#x.\n", hr); + ok_(__FILE__,line)(count == 1, "Got unexpected count: %d.\n", count); + + hr = IDispatch_GetTypeInfo(dispatch, 1, english, &typeinfo); + ok_(__FILE__,line)(hr == DISP_E_BADINDEX, "GetTypeInfo got hr %#x.\n", hr); + + hr = IDispatch_GetTypeInfo(dispatch, 0, english, &typeinfo); + ok_(__FILE__,line)(hr == S_OK, "GetTypeInfo failed %#x.\n", hr); + hr = ITypeInfo_GetTypeAttr(typeinfo, &typeattr); + ok_(__FILE__,line)(hr == S_OK, "GetTypeAttr got hr %#x.\n", hr); + ok_(__FILE__,line)(IsEqualGUID(&typeattr->guid, riid), + "Got unexpected type guid: %s.\n", wine_dbgstr_guid(&typeattr->guid)); + ITypeInfo_Release(typeinfo); + + for (i = 0; i < id_count; i++) + { + names = SysAllocString(test_name_ids[i].name); + dispid = 0xdeadbeef; + hr = IDispatch_GetIDsOfNames(dispatch, &IID_NULL, &names, 1, english, &dispid); + SysFreeString(names); + ok_(__FILE__,line)(hr == S_OK, "tests[%d] got hr %#x.\n", i, hr); + ok_(__FILE__,line)(dispid == test_name_ids[i].id, "tests[%d] got wrong dispid %x.\n", i, dispid); + } +} + static void test_interfaces(void) { ISharedPropertyGroupManager *manager, *manager1; @@ -67,6 +115,12 @@ static void test_interfaces(void) IDispatch *dispatch; IUnknown *unk; HRESULT hr; + struct test_name_id test_name_ids[] = + { + {L"CreatePropertyGroup", 0x1}, + {L"Group", 0x2}, + {L"_NewEnum", DISPID_NEWENUM}, + };
hr = CoCreateInstance(&CLSID_SharedPropertyGroupManager, &test_outer, CLSCTX_INPROC_SERVER, &IID_ISharedPropertyGroupManager, (void **)&manager); @@ -100,6 +154,8 @@ static void test_interfaces(void) refcount = get_refcount(manager); ok(refcount == expected_refcount, "Got refcount: %d, expected %d.\n", refcount, expected_refcount);
+ TEST_TYPEINFO(dispatch, test_name_ids, ARRAY_SIZE(test_name_ids), &IID_ISharedPropertyGroupManager); + IDispatch_Release(dispatch); IUnknown_Release(unk); ISharedPropertyGroupManager_Release(manager);
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=77312
Your paranoid android.
=== debiant (32 bit report) ===
comsvcs: property.c:127: Test failed: Got hr 0x80040154. property.c:131: Test failed: Got hr 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00403757).
Report validation errors: comsvcs:property crashed (c0000005)
=== debiant (32 bit French report) ===
comsvcs: property.c:127: Test failed: Got hr 0x80040154. property.c:131: Test failed: Got hr 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00403757).
Report validation errors: comsvcs:property crashed (c0000005)
=== debiant (32 bit Japanese:Japan report) ===
comsvcs: property.c:127: Test failed: Got hr 0x80040154. property.c:131: Test failed: Got hr 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00403757).
Report validation errors: comsvcs:property crashed (c0000005)
=== debiant (32 bit Chinese:China report) ===
comsvcs: property.c:127: Test failed: Got hr 0x80040154. property.c:131: Test failed: Got hr 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00403757).
Report validation errors: comsvcs:property crashed (c0000005)
=== debiant (32 bit WoW report) ===
comsvcs: property.c:127: Test failed: Got hr 0x80040154. property.c:131: Test failed: Got hr 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00403757).
Report validation errors: comsvcs:property crashed (c0000005)
=== debiant (64 bit WoW report) ===
comsvcs: property.c:127: Test failed: Got hr 0x80040154. property.c:131: Test failed: Got hr 0x80040154. Unhandled exception: page fault on read access to 0x00000000 in 32-bit code (0x00403757).
Report validation errors: comsvcs:property crashed (c0000005)
On 8/19/20 10:48 AM, Jactry Zeng wrote:
static HRESULT WINAPI group_manager_GetTypeInfo(ISharedPropertyGroupManager *iface, UINT index, LCID lcid, ITypeInfo **info) {
- FIXME("iface %p, index %u, lcid %u, info %p: stub.\n", iface, index, lcid, info);
- return E_NOTIMPL;
- HRESULT hr;
- TRACE("iface %p, index %u, lcid %u, info %p.\n", iface, index, lcid, info);
- if (index)
return DISP_E_BADINDEX;
- hr = get_typeinfo(ISharedPropertyGroupManager_tid, info);
- if (SUCCEEDED(hr))
ITypeInfo_AddRef(*info);
- return hr;
}
get_typeinfo() already addref's, so this will leak.
static HRESULT WINAPI group_manager_GetIDsOfNames(ISharedPropertyGroupManager *iface, REFIID riid, LPOLESTR *names, UINT count, LCID lcid, DISPID *dispid) {
- FIXME("iface %p, riid %s, names %p, count %u, lcid %u, dispid %p: stub.\n",
- ITypeInfo *typeinfo;
- HRESULT hr;
- TRACE("iface %p, riid %s, names %p, count %u, lcid %u, dispid %p.\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
- return E_NOTIMPL;
- hr = get_typeinfo(ISharedPropertyGroupManager_tid, &typeinfo);
- if (SUCCEEDED(hr))
- {
hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid);
ITypeInfo_Release(typeinfo);
- }
- return hr;
}
This one is fine.
static HRESULT WINAPI group_manager_Invoke(ISharedPropertyGroupManager *iface, DISPID member, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *except, UINT *argerr) {
- FIXME("iface %p, member %u, riid %s, lcid %u, flags %x, params %p, result %p, except %p, argerr %p: stub.\n",
- ITypeInfo *typeinfo;
- HRESULT hr;
- TRACE("iface %p, member %u, riid %s, lcid %u, flags %x, params %p, result %p, except %p, argerr %p.\n", iface, member, debugstr_guid(riid), lcid, flags, params, result, except, argerr);
- return E_NOTIMPL;
- hr = get_typeinfo(ISharedPropertyGroupManager_tid, &typeinfo);
- if (SUCCEEDED(hr))
hr = ITypeInfo_Invoke(typeinfo, iface, member, flags, params, result, except, argerr);
- return hr;
}
This one is not.