All of lore.kernel.org
 help / color / mirror / Atom feed
From: Evgeny Kolmakov <randomjack94dev@gmail.com>
To: qemu-devel@nongnu.org
Cc: sw@weilnetz.de, Evgeny Kolmakov <randomjack94dev@gmail.com>
Subject: [PATCH] util/oslib-win32: Implement qemu_get_pid_name()
Date: Sun, 21 Jun 2026 16:06:26 +0300	[thread overview]
Message-ID: <20260621130626.19073-1-randomjack94dev@gmail.com> (raw)

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



                 reply	other threads:[~2026-06-21 13:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260621130626.19073-1-randomjack94dev@gmail.com \
    --to=randomjack94dev@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.