-- v4: wbemprox: Add property "ExecutablePath" to Win32_Process wbemprox/tests: Add test for Win32_Process querying "ExecutablePath" propery
From: Fabian Maurer dark.shadow4@web.de
--- dlls/wbemprox/tests/query.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index ea108e31e49..63c92f8e60c 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -549,6 +549,7 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) IWbemClassObject *process, *sig_in, *sig_out, *out, *params; WCHAR cmdlineW[MAX_PATH + 64 + 1]; IWbemQualifierSet *qualifiers; + WCHAR executable_path[255]; VARIANT retval, val; SAFEARRAY *names; LONG bound, i; @@ -718,7 +719,6 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) hr = IWbemServices_ExecMethod( services, class, method, 0, NULL, NULL, &out, NULL ); ok( hr == S_OK, "failed to execute method %#lx\n", hr ); SysFreeString( method ); - SysFreeString( class );
type = 0xdeadbeef; VariantInit( &retval ); @@ -765,8 +765,29 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) hr = IWbemQualifierSet_Get( qualifiers, L"ID", 0, &val, &flavor ); ok( hr == WBEM_E_NOT_FOUND, "got %#lx\n", hr );
+ /* Test instance properties */ + + hr = IWbemServices_GetObject( services, class, 0, NULL, &process, NULL ); + ok( hr == S_OK, "got %#lx\n", hr ); + + type = 0xdeadbeef; + VariantInit( &val ); + hr = IWbemClassObject_Get( process, L"ExecutablePath", 0, &val, &type, NULL ); + todo_wine + ok( hr == S_OK, "IWbemClassObject_Get failed with %#lx\n", hr ); + todo_wine + ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); + todo_wine + ok( type == CIM_STRING, "unexpected type %#lx\n", type ); + GetModuleFileNameW( NULL, executable_path, ARRAY_SIZE(executable_path) ); + todo_wine + ok( !lstrcmpiW( V_BSTR( &val ), executable_path ), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&val)), wine_dbgstr_w(executable_path) ); + VariantClear( &val ); + IWbemClassObject_Release( process ); + IWbemQualifierSet_Release( qualifiers ); IWbemClassObject_Release( out ); + SysFreeString( class ); }
static void test_Win32_ComputerSystem( IWbemServices *services )
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57314 --- dlls/wbemprox/builtin.c | 21 +++++++++++++++++++++ dlls/wbemprox/tests/query.c | 4 ---- 2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 80434e5f19f..50fdcf03fc5 100644 --- a/dlls/wbemprox/builtin.c +++ b/dlls/wbemprox/builtin.c @@ -323,6 +323,7 @@ static const struct column col_process[] = { L"Caption", CIM_STRING|COL_FLAG_DYNAMIC }, { L"CommandLine", CIM_STRING|COL_FLAG_DYNAMIC }, { L"Description", CIM_STRING|COL_FLAG_DYNAMIC }, + { L"ExecutablePath", CIM_STRING|COL_FLAG_DYNAMIC }, { L"Handle", CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY }, { L"Name", CIM_STRING|COL_FLAG_DYNAMIC }, { L"ParentProcessID", CIM_UINT32 }, @@ -815,6 +816,7 @@ struct record_process const WCHAR *caption; const WCHAR *commandline; const WCHAR *description; + const WCHAR *executablepath; const WCHAR *handle; const WCHAR *name; UINT32 pprocess_id; @@ -3360,6 +3362,24 @@ static WCHAR *get_cmdline( DWORD process_id ) return NULL; /* FIXME handle different process case */ }
+static WCHAR *get_executablepath( DWORD process_id ) +{ + DWORD size = MAX_PATH; + HANDLE process = OpenProcess( PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_id ); + WCHAR *executable_path = calloc(sizeof(WCHAR), size + 1); + if (!process) + return NULL; + + while (!QueryFullProcessImageNameW( process, 0, executable_path, &size ) && GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + size *= 2; + executable_path = realloc(executable_path, (size + 1) * sizeof(WCHAR)); + } + + CloseHandle( process ); + return executable_path; +} + static enum fill_status fill_process( struct table *table, const struct expr *cond ) { WCHAR handle[11]; @@ -3388,6 +3408,7 @@ static enum fill_status fill_process( struct table *table, const struct expr *co rec->caption = wcsdup( entry.szExeFile ); rec->commandline = get_cmdline( entry.th32ProcessID ); rec->description = wcsdup( entry.szExeFile ); + rec->executablepath = get_executablepath( entry.th32ProcessID ); swprintf( handle, ARRAY_SIZE( handle ), L"%u", entry.th32ProcessID ); rec->handle = wcsdup( handle ); rec->name = wcsdup( entry.szExeFile ); diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 63c92f8e60c..21c9a704e78 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -773,14 +773,10 @@ static void test_Win32_Process( IWbemServices *services, BOOL use_full_path ) type = 0xdeadbeef; VariantInit( &val ); hr = IWbemClassObject_Get( process, L"ExecutablePath", 0, &val, &type, NULL ); - todo_wine ok( hr == S_OK, "IWbemClassObject_Get failed with %#lx\n", hr ); - todo_wine ok( V_VT( &val ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &val ) ); - todo_wine ok( type == CIM_STRING, "unexpected type %#lx\n", type ); GetModuleFileNameW( NULL, executable_path, ARRAY_SIZE(executable_path) ); - todo_wine ok( !lstrcmpiW( V_BSTR( &val ), executable_path ), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&val)), wine_dbgstr_w(executable_path) ); VariantClear( &val ); IWbemClassObject_Release( process );
On Fri Nov 1 06:15:16 2024 +0000, Fabian Maurer wrote:
changed this line in [version 4 of the diff](/wine/wine/-/merge_requests/6734/diffs?diff_id=140895&start_sha=9f8821de9462f72b2f8b171e5f197168ff0fc1c7#38386f740b0689e89d38acb18360b6b790541752_3373_3371)
Fixed
On Thu Oct 31 13:46:13 2024 +0000, Hans Leidekker wrote:
[wbemprox_test.diff](/uploads/b7cf630004b8c4e9b5fd0e35a2fe6230/wbemprox_test.diff) How about this?
I wasn't sure how to properly get the object, so a query seemed like the safer choice. Thanks, updated.
This merge request was approved by Hans Leidekker.