From e77306365b443dbac593fcc1379e00ca4f696963 Mon Sep 17 00:00:00 2001 From: Paul Vriens Date: Thu, 16 Jun 2005 09:44:39 +0000 Subject: [PATCH] ProcessName should be without the path. --- dlls/ntdll/nt.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/dlls/ntdll/nt.c b/dlls/ntdll/nt.c index c7362b35e56..9e6b791da28 100644 --- a/dlls/ntdll/nt.c +++ b/dlls/ntdll/nt.c @@ -27,6 +27,7 @@ #include #include #include "wine/debug.h" +#include "wine/unicode.h" #include "windef.h" #include "winbase.h" @@ -668,6 +669,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_PROCESS_INFORMATION* last = NULL; HANDLE hSnap = 0; WCHAR procname[1024]; + WCHAR* exename; DWORD wlen = 0; DWORD procstructlen = 0; @@ -686,11 +688,20 @@ NTSTATUS WINAPI NtQuerySystemInformation( { req->handle = hSnap; req->reset = (len == 0); - wine_server_set_reply( req, procname, sizeof(procname) ); + wine_server_set_reply( req, procname, sizeof(procname)-sizeof(WCHAR) ); if (!(ret = wine_server_call( req ))) { - wlen = wine_server_reply_size(reply) + sizeof(WCHAR); + /* Make sure procname is 0 terminated */ + procname[wine_server_reply_size(reply) / sizeof(WCHAR)] = 0; + + /* Get only the executable name, not the path */ + if ((exename = strrchrW(procname, '\\')) != NULL) exename++; + else exename = procname; + + wlen = (strlenW(exename) + 1) * sizeof(WCHAR); + procstructlen = sizeof(*spi) + wlen + ((reply->threads - 1) * sizeof(SYSTEM_THREAD_INFORMATION)); + if (Length >= len + procstructlen) { /* ftCreationTime, ftUserTime, ftKernelTime; @@ -762,8 +773,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( spi->ProcessName.Buffer = (WCHAR*)((char*)spi + spi->dwOffset); spi->ProcessName.Length = wlen - sizeof(WCHAR); spi->ProcessName.MaximumLength = wlen; - memcpy( spi->ProcessName.Buffer, procname, spi->ProcessName.Length ); - spi->ProcessName.Buffer[spi->ProcessName.Length / sizeof(WCHAR)] = 0; + memcpy( spi->ProcessName.Buffer, exename, wlen ); spi->dwOffset += wlen; last = spi;