From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57314 --- dlls/wbemprox/builtin.c | 17 +++++++++++++++++ dlls/wbemprox/tests/query.c | 4 ---- 2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c index 80434e5f19f..d628070dc0b 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; @@ -3368,6 +3370,9 @@ static enum fill_status fill_process( struct table *table, const struct expr *co HANDLE snap; enum fill_status status = FILL_STATUS_FAILED; UINT row = 0, offset = 0; + HANDLE process; + WCHAR executable_path[MAX_PATH]; + DWORD size;
snap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); if (snap == INVALID_HANDLE_VALUE) return FILL_STATUS_FAILED; @@ -3384,10 +3389,21 @@ static enum fill_status fill_process( struct table *table, const struct expr *co goto done; }
+ process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, entry.th32ProcessID); + if (!process) + { + ERR("Failed to open process\n"); + status = FILL_STATUS_FAILED; + goto done; + } + size = ARRAY_SIZE(executable_path); + QueryFullProcessImageNameW(process, 0, executable_path, &size); + rec = (struct record_process *)(table->data + offset); rec->caption = wcsdup( entry.szExeFile ); rec->commandline = get_cmdline( entry.th32ProcessID ); rec->description = wcsdup( entry.szExeFile ); + rec->executablepath = wcsdup( executable_path ); swprintf( handle, ARRAY_SIZE( handle ), L"%u", entry.th32ProcessID ); rec->handle = wcsdup( handle ); rec->name = wcsdup( entry.szExeFile ); @@ -3397,6 +3413,7 @@ static enum fill_status fill_process( struct table *table, const struct expr *co /* methods */ rec->create = process_create; rec->get_owner = process_get_owner; + CloseHandle(process); if (!match_row( table, row, cond, &status )) { free_row_values( table, row ); diff --git a/dlls/wbemprox/tests/query.c b/dlls/wbemprox/tests/query.c index 4b3b8f544a8..f99daaceae9 100644 --- a/dlls/wbemprox/tests/query.c +++ b/dlls/wbemprox/tests/query.c @@ -799,13 +799,9 @@ static void test_Win32_Process_query( IWbemServices *services ) type = 0xdeadbeef; VariantInit( &value ); hr = IWbemClassObject_Get( obj, L"ExecutablePath", 0, &value, &type, NULL ); - todo_wine ok( hr == S_OK, "IWbemClassObject_Get failed with %#lx\n", hr ); - todo_wine ok( V_VT( &value ) == VT_BSTR, "unexpected variant type 0x%x\n", V_VT( &value ) ); - todo_wine ok( type == CIM_STRING, "unexpected type %#lx\n", type ); - todo_wine ok( !lstrcmpiW( V_BSTR( &value ), executable_path), "got %s, expected %s\n", wine_dbgstr_w(V_BSTR(&value)), wine_dbgstr_w(executable_path) ); VariantClear( &value );