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 );