From 14db6a802c20fa162acc54505f28cc0ea7eb33b9 Mon Sep 17 00:00:00 2001 From: Alexandre Goujon Date: Sun, 18 Jul 2010 12:16:16 +0200 Subject: [PATCH] oleaut32/typelib: Fix ITypeInfo_Invoke with restricted keyword. --- dlls/oleaut32/tests/typelib.c | 92 ++++++++++++++++++++++++++++++----- dlls/oleaut32/typelib.c | 7 ++- 2 files changed, 85 insertions(+), 14 deletions(-) diff --git a/dlls/oleaut32/tests/typelib.c b/dlls/oleaut32/tests/typelib.c index 5487632a832..8a1fccb7705 100644 --- a/dlls/oleaut32/tests/typelib.c +++ b/dlls/oleaut32/tests/typelib.c @@ -488,32 +488,70 @@ static void test_TypeInfo(void) "ITypeInfo_GetIDsOfNames should have returned DISP_E_UNKNOWNNAME instead of 0x%08x\n", hr); - /* test invalid memberid */ - dispparams.cNamedArgs = 0; dispparams.cArgs = 0; dispparams.rgdispidNamedArgs = NULL; dispparams.rgvarg = NULL; + + /* test dispparams not NULL */ + + /* invalid member id -- wrong flags -- cNamedArgs not bigger than cArgs */ + dispparams.cNamedArgs = 0; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* invalid member id -- correct flags -- cNamedArgs not bigger than cArgs */ hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* invalid member id -- wrong flags -- cNamedArgs bigger than cArgs */ + dispparams.cNamedArgs = 1; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + /* invalid member id -- correct flags -- cNamedArgs bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, 0xdeadbeef, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + + hr = ITypeInfo_GetIDsOfNames(pTypeInfo, &pwszClone, 1, &dispidMember); ok_ole_success(hr, ITypeInfo_GetIDsOfNames); - /* test correct memberid, but wrong flags */ + /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */ + dispparams.cNamedArgs = 0; hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); + ok(hr == 0x8002000e, "ITypeInfo_Invoke should have returned 0x8002000e instead of 0x%08x\n", hr); */ - /* test NULL dispparams */ - hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL); - ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); - - /* test dispparams->cNamedArgs being bigger than dispparams->cArgs */ + /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */ dispparams.cNamedArgs = 1; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */ hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + + /* test NULL dispparams */ + + /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */ + dispparams.cNamedArgs = 0; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + + /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */ + dispparams.cNamedArgs = 1; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); + ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "ITypeInfo_Invoke should have returned E_INVALIDARG instead of 0x%08x\n", hr); ITypeInfo_Release(pTypeInfo); + + hr = ITypeLib_GetTypeInfoOfGuid(pTypeLib, &IID_IDispatch, &pTypeInfo); ok_ole_success(hr, ITypeLib_GetTypeInfoOfGuid); @@ -539,11 +577,41 @@ static void test_TypeInfo(void) VariantClear(&var); } - /* test invoking a method with a [restricted] keyword */ - hr = ITypeInfo_Invoke(pTypeInfo, NULL, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); - todo_wine { + /* test invoking a method with a [restricted] keyword */ + + /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */ + dispparams.cNamedArgs = 0; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + + /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */ + dispparams.cNamedArgs = 1; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, &dispparams, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, &dispparams, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + + /* test NULL dispparams */ + + /* correct member id -- wrong flags -- cNamedArgs not bigger than cArgs */ + dispparams.cNamedArgs = 0; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs not bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + + /* correct member id -- wrong flags -- cNamedArgs bigger than cArgs */ + dispparams.cNamedArgs = 1; + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_PROPERTYGET, NULL, NULL, NULL, NULL); + ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); + /* correct member id -- correct flags -- cNamedArgs bigger than cArgs */ + hr = ITypeInfo_Invoke(pTypeInfo, (void *)0xdeadbeef, dispidMember, DISPATCH_METHOD, NULL, NULL, NULL, NULL); ok(hr == DISP_E_MEMBERNOTFOUND, "ITypeInfo_Invoke should have returned DISP_E_MEMBERNOTFOUND instead of 0x%08x\n", hr); - } ITypeInfo_Release(pTypeInfo); ITypeLib_Release(pTypeLib); diff --git a/dlls/oleaut32/typelib.c b/dlls/oleaut32/typelib.c index b310a4b7551..7fac0398955 100644 --- a/dlls/oleaut32/typelib.c +++ b/dlls/oleaut32/typelib.c @@ -6017,12 +6017,15 @@ static HRESULT WINAPI ITypeInfo_fnInvoke( unsigned int var_index; TYPEKIND type_kind; HRESULT hres; - const TLBFuncDesc *pFuncInfo; + const TLBFuncDesc *pFuncInfo = This->funclist; TRACE("(%p)(%p,id=%d,flags=0x%08x,%p,%p,%p,%p)\n", This,pIUnk,memid,wFlags,pDispParams,pVarResult,pExcepInfo,pArgErr ); + if( pFuncInfo->funcdesc.wFuncFlags == FUNCFLAG_FRESTRICTED ) + return DISP_E_MEMBERNOTFOUND; + if (!pDispParams) { ERR("NULL pDispParams not allowed\n"); @@ -6491,7 +6494,7 @@ func_fail: WARN("Could not search inherited interface!\n"); } } - ERR("did not find member id %d, flags 0x%x!\n", memid, wFlags); + WARN("did not find member id %d, flags 0x%x!\n", memid, wFlags); return DISP_E_MEMBERNOTFOUND; }