wbemprox: Add property "ExecutablePath" to Win32_Process.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57314
This commit is contained in:
Fabian Maurer 2024-10-25 22:01:56 +02:00 committed by Alexandre Julliard
parent c159055e65
commit adc82d8d59
Notes: Alexandre Julliard 2024-11-05 22:27:57 +01:00
Approved-by: Hans Leidekker (@hans)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6734
2 changed files with 25 additions and 4 deletions

View file

@ -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,28 @@ 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;
if (!process) return NULL;
for (;;)
{
if (!(executable_path = malloc( (size + 1) * sizeof(WCHAR) ))) break;
executable_path[0] = 0;
if (QueryFullProcessImageNameW( process, 0, executable_path, &size )) break;
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) break;
free( executable_path );
size *= 2;
}
CloseHandle( process );
return executable_path;
}
static enum fill_status fill_process( struct table *table, const struct expr *cond )
{
WCHAR handle[11];
@ -3388,6 +3412,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 );

View file

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