wbemprox: Check for method existence in class_object_GetMethod().

Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Paul Gofman 2021-05-18 09:49:44 +02:00 committed by Alexandre Julliard
parent f47a09b917
commit 09b0154ac1
2 changed files with 26 additions and 2 deletions

View File

@ -875,10 +875,27 @@ static HRESULT WINAPI class_object_GetMethod(
{ {
struct class_object *co = impl_from_IWbemClassObject( iface ); struct class_object *co = impl_from_IWbemClassObject( iface );
IWbemClassObject *in, *out; IWbemClassObject *in, *out;
struct table *table;
unsigned int i;
HRESULT hr; HRESULT hr;
TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, ppInSignature, ppOutSignature); TRACE("%p, %s, %08x, %p, %p\n", iface, debugstr_w(wszName), lFlags, ppInSignature, ppOutSignature);
if (ppInSignature) *ppInSignature = NULL;
if (ppOutSignature) *ppOutSignature = NULL;
table = get_view_table( impl_from_IEnumWbemClassObject( co->iter )->query->view, co->index );
for (i = 0; i < table->num_cols; ++i)
{
if (is_method( table, i ) && !lstrcmpiW( table->columns[i].name, wszName )) break;
}
if (i == table->num_cols)
{
FIXME("Method %s not found in class %s.\n", debugstr_w(wszName), debugstr_w(co->name));
return WBEM_E_NOT_FOUND;
}
hr = create_signature( co->name, wszName, PARAM_IN, &in ); hr = create_signature( co->name, wszName, PARAM_IN, &in );
if (hr != S_OK) return hr; if (hr != S_OK) return hr;

View File

@ -460,7 +460,7 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
WBEM_FLAVOR_ORIGIN_PROPAGATED; WBEM_FLAVOR_ORIGIN_PROPAGATED;
WCHAR full_path[MAX_COMPUTERNAME_LENGTH + ARRAY_SIZE( L"\\\\%s\\ROOT\\CIMV2:" )]; WCHAR full_path[MAX_COMPUTERNAME_LENGTH + ARRAY_SIZE( L"\\\\%s\\ROOT\\CIMV2:" )];
BSTR class, method; BSTR class, method;
IWbemClassObject *process, *sig_in, *out; IWbemClassObject *process, *sig_in, *sig_out, *out;
IWbemQualifierSet *qualifiers; IWbemQualifierSet *qualifiers;
VARIANT retval, val; VARIANT retval, val;
SAFEARRAY *names; SAFEARRAY *names;
@ -504,8 +504,15 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path )
} }
SafeArrayDestroy( names ); SafeArrayDestroy( names );
sig_in = (void *)0xdeadbeef;
sig_out = (void *)0xdeadbeef;
hr = IWbemClassObject_GetMethod( process, L"unknown", 0, &sig_in, &sig_out );
ok( hr == WBEM_E_NOT_FOUND, "Got unexpected hr %#x\n", hr );
ok( !sig_in, "Got unexpected sig_in %p.\n", sig_in );
ok( !sig_out, "Got unexpected sig_out %p.\n", sig_out );
sig_in = (void*)0xdeadbeef; sig_in = (void*)0xdeadbeef;
hr = IWbemClassObject_GetMethod( process, L"GetOwner", 0, &sig_in, NULL ); hr = IWbemClassObject_GetMethod( process, L"getowner", 0, &sig_in, NULL );
ok( hr == S_OK, "failed to get GetOwner method %08x\n", hr ); ok( hr == S_OK, "failed to get GetOwner method %08x\n", hr );
ok( !sig_in, "sig_in != NULL\n"); ok( !sig_in, "sig_in != NULL\n");
IWbemClassObject_Release( process ); IWbemClassObject_Release( process );