[PATCH v2] oleaut32: Retrieve funcdesc from TLB by memberid and invkind.
mo porot
porotmjp at gmail.com
Wed Jun 3 02:06:15 CDT 2020
This allows searching exact property access functions which
share same memberid.
Signed-off-by: Porot Mo <porotmjp at gmail.com>
---
v2: Add tests.
dlls/oleaut32/tests/test_reg.idl | 13 +++++++++++
dlls/oleaut32/tests/typelib.c | 49
++++++++++++++++++++++++++++++++++++++--
dlls/oleaut32/typelib.c | 15 +++++++++++-
3 files changed, 74 insertions(+), 3 deletions(-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20200603/2d6a7d2b/attachment.htm>
-------------- next part --------------
diff --git a/dlls/oleaut32/tests/test_reg.idl b/dlls/oleaut32/tests/test_reg.idl
index c9be76b..d41f4be 100644
--- a/dlls/oleaut32/tests/test_reg.idl
+++ b/dlls/oleaut32/tests/test_reg.idl
@@ -163,4 +163,17 @@ library register_test
UINT32 field;
HRESULT hr;
};
+
+ [
+ uuid(f073cd92-a199-11ea-bb37-0242ac130002),
+ dllname("test.dll")
+ ]
+ module TestGetDllEntry
+ {
+ [propget, entry(1)]
+ int test1([out] int *i);
+
+ [propput, entry(2)]
+ int test1([in] int i);
+ };
}
diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c
index 5e5b44a..23e73a8 100644
--- a/dlls/oleaut32/tests/typelib.c
+++ b/dlls/oleaut32/tests/typelib.c
@@ -837,12 +837,15 @@ static void test_TypeInfo(void)
DISPID dispidMember;
DISPPARAMS dispparams;
GUID bogusguid = {0x806afb4f,0x13f7,0x42d2,{0x89,0x2c,0x6c,0x97,0xc3,0x6a,0x36,0xc1}};
+ static const GUID moduleTestGetDllEntryGuid = {0xf073cd92,0xa199,0x11ea,{0xbb,0x37,0x02,0x42,0xac,0x13,0x00,0x02}};
VARIANT var, res, args[2];
UINT count, i;
TYPEKIND kind;
const WCHAR *filename;
TYPEATTR *attr;
LONG l;
+ WORD ordinal;
+ BSTR bstrDllName, bstrName;
hr = LoadTypeLib(wszStdOle2, &pTypeLib);
ok_ole_success(hr, LoadTypeLib);
@@ -1025,6 +1028,47 @@ static void test_TypeInfo(void)
hr = LoadTypeLib(filename, &pTypeLib);
ok(hr == S_OK, "got 0x%08x\n", hr);
+ /* test GetDllEntry */
+ hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &moduleTestGetDllEntryGuid, &pTypeInfo);
+ ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid);
+ ok(pTypeInfo != NULL, "got NULL typeinfo\n");
+
+ /* wrong memberid -- wrong invkind */
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x6000000d, INVOKE_FUNC, &bstrDllName, &bstrName, &ordinal);
+ ok(hr == TYPE_E_ELEMENTNOTFOUND, "ITypeInfo_GetDllEntry should have returned TYPE_E_ELEMENTNOTFOUND instead of 0x%08x\n", hr);
+
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x6000000d, INVOKE_PROPERTYPUTREF, &bstrDllName, &bstrName, &ordinal);
+ ok(hr == TYPE_E_ELEMENTNOTFOUND, "ITypeInfo_GetDllEntry should have returned TYPE_E_ELEMENTNOTFOUND instead of 0x%08x\n", hr);
+
+ /* wrong memberid -- correct invkind */
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x6000000d, INVOKE_PROPERTYGET, &bstrDllName, &bstrName, &ordinal);
+ ok(hr == TYPE_E_ELEMENTNOTFOUND, "ITypeInfo_GetDllEntry should have returned TYPE_E_ELEMENTNOTFOUND instead of 0x%08x\n", hr);
+
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x6000000d, INVOKE_PROPERTYPUT, &bstrDllName, &bstrName, &ordinal);
+ ok(hr == TYPE_E_ELEMENTNOTFOUND, "ITypeInfo_GetDllEntry should have returned TYPE_E_ELEMENTNOTFOUND instead of 0x%08x\n", hr);
+
+ /* correct memberid -- wrong invkind */
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x60000000, INVOKE_FUNC, &bstrDllName, &bstrName, &ordinal);
+ ok(hr == TYPE_E_ELEMENTNOTFOUND, "ITypeInfo_GetDllEntry should have returned TYPE_E_ELEMENTNOTFOUND instead of 0x%08x\n", hr);
+
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x60000000, INVOKE_PROPERTYPUTREF, &bstrDllName, &bstrName, &ordinal);
+ ok(hr == TYPE_E_ELEMENTNOTFOUND, "ITypeInfo_GetDllEntry should have returned TYPE_E_ELEMENTNOTFOUND instead of 0x%08x\n", hr);
+
+ /* correct memberid -- correct invkind */
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x60000000, INVOKE_PROPERTYGET, &bstrDllName, &bstrName, &ordinal);
+ ok_ole_success(hr, ITypeInfo_GetDllEntry);
+ ok(bstrDllName != NULL, "got NULL dllname\n");
+ ok(bstrName == NULL, "got funcname: %s\n", debugstr_w(bstrName));
+ ok(ordinal == 1, "got ordinal: %04x\n", ordinal);
+
+ hr = ITypeInfo_GetDllEntry(pTypeInfo, 0x60000000, INVOKE_PROPERTYPUT, &bstrDllName, &bstrName, &ordinal);
+ ok_ole_success(hr, ITypeInfo_GetDllEntry);
+ ok(bstrDllName != NULL, "got NULL dllname\n");
+ ok(bstrName == NULL, "got funcname: %s\n", debugstr_w(bstrName));
+ ok(ordinal == 2, "got ordinal: %04x\n", ordinal);
+
+ ITypeInfo_Release(pTypeInfo);
+
hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IInvokeTest, &pTypeInfo);
ok(hr == S_OK, "got 0x%08x\n", hr);
@@ -5092,7 +5136,8 @@ static void test_register_typelib(BOOL system_registration)
{ TKIND_DISPATCH, TYPEFLAG_FDISPATCHABLE },
{ TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
{ TKIND_INTERFACE, TYPEFLAG_FDISPATCHABLE },
- { TKIND_RECORD, 0 }
+ { TKIND_RECORD, 0 },
+ { TKIND_MODULE, 0 },
};
trace("Starting %s typelib registration tests\n",
@@ -5126,7 +5171,7 @@ static void test_register_typelib(BOOL system_registration)
ok(hr == S_OK, "got %08x\n", hr);
count = ITypeLib_GetTypeInfoCount(typelib);
- ok(count == 14, "got %d\n", count);
+ ok(count == 15, "got %d\n", count);
for(i = 0; i < count; i++)
{
diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c
index f8d7136..48de363 100644
--- a/dlls/oleaut32/typelib.c
+++ b/dlls/oleaut32/typelib.c
@@ -1701,6 +1701,19 @@ static inline TLBFuncDesc *TLB_get_funcdesc_by_memberid(ITypeInfoImpl *typeinfo,
return NULL;
}
+static inline TLBFuncDesc *TLB_get_funcdesc_by_memberid_invkind(ITypeInfoImpl *typeinfo, MEMBERID memid, INVOKEKIND invKind)
+{
+ int i;
+
+ for (i = 0; i < typeinfo->typeattr.cFuncs; ++i)
+ {
+ if (typeinfo->funcdescs[i].funcdesc.memid == memid && typeinfo->funcdescs[i].funcdesc.invkind == invKind)
+ return &typeinfo->funcdescs[i];
+ }
+
+ return NULL;
+}
+
static inline TLBVarDesc *TLB_get_vardesc_by_memberid(ITypeInfoImpl *typeinfo, MEMBERID memid)
{
int i;
@@ -7804,7 +7817,7 @@ static HRESULT WINAPI ITypeInfo_fnGetDllEntry( ITypeInfo2 *iface, MEMBERID memid
if (This->typeattr.typekind != TKIND_MODULE)
return TYPE_E_BADMODULEKIND;
- pFDesc = TLB_get_funcdesc_by_memberid(This, memid);
+ pFDesc = TLB_get_funcdesc_by_memberid_invkind(This, memid, invKind);
if(pFDesc){
dump_TypeInfo(This);
if (TRACE_ON(ole))
More information about the wine-devel
mailing list