All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] util/oslib-win32: Implement qemu_get_pid_name()
@ 2026-06-21 13:06 Evgeny Kolmakov
  0 siblings, 0 replies; only message in thread
From: Evgeny Kolmakov @ 2026-06-21 13:06 UTC (permalink / raw)
  To: qemu-devel; +Cc: sw, Evgeny Kolmakov

Replace the abort() stub with a proper implementation using
QueryFullProcessImageNameW() and g_utf16_to_utf8() to retrieve
the process executable name on Windows. Returns NULL on error
to match POSIX behavior.

Signed-off-by: Evgeny Kolmakov <randomjack94dev@gmail.com>
---
 util/oslib-win32.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index 5f3e8f4d98..2b083b5d7a 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -287,8 +287,23 @@ bool qemu_finish_async_prealloc_mem(Error **errp)
 
 char *qemu_get_pid_name(pid_t pid)
 {
-    /* XXX Implement me */
-    abort();
+    HANDLE hProcess;
+    WCHAR path[4096];
+    DWORD size = G_N_ELEMENTS(path);
+    char *name = NULL;
+
+    hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, (DWORD)pid);
+    if (!hProcess) {
+        return NULL;
+    }
+
+    if (QueryFullProcessImageNameW(hProcess, 0, path, &size)) {
+        const WCHAR *base = wcsrchr(path, L'\\');
+        name = g_utf16_to_utf8(base ? base + 1 : path, -1, NULL, NULL, NULL);
+    }
+
+    CloseHandle(hProcess);
+    return name;
 }
 
 
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-21 13:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-21 13:06 [PATCH] util/oslib-win32: Implement qemu_get_pid_name() Evgeny Kolmakov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.