2020-05-29 17:13:43 -07:00
|
|
|
From 3e86366ed3ab3aca555d2457e930cf7dbd08a105 Mon Sep 17 00:00:00 2001
|
2014-07-06 14:53:33 -07:00
|
|
|
From: Sebastian Lackner <sebastian@fds-team.de>
|
|
|
|
Date: Sun, 22 Jun 2014 19:04:38 +0200
|
2018-04-11 17:22:53 -07:00
|
|
|
Subject: [PATCH] wtsapi32: Partial implementation of WTSEnumerateProcessesW.
|
2014-07-06 14:53:33 -07:00
|
|
|
|
|
|
|
---
|
2018-04-11 17:22:53 -07:00
|
|
|
dlls/wtsapi32/tests/wtsapi.c | 1 -
|
2019-06-28 02:46:18 -07:00
|
|
|
dlls/wtsapi32/wtsapi32.c | 78 ++++++++++++++++++++++++++++++++++--
|
2018-04-11 17:22:53 -07:00
|
|
|
2 files changed, 74 insertions(+), 5 deletions(-)
|
2014-07-06 14:53:33 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c
|
2020-05-29 17:13:43 -07:00
|
|
|
index c9312cd97c5..72b57c16ffa 100644
|
2014-07-06 14:53:33 -07:00
|
|
|
--- a/dlls/wtsapi32/tests/wtsapi.c
|
|
|
|
+++ b/dlls/wtsapi32/tests/wtsapi.c
|
|
|
|
@@ -85,7 +85,6 @@ static void test_WTSEnumerateProcessesW(void)
|
|
|
|
{
|
|
|
|
found = found || !lstrcmpW(pname, info[i].pProcessName);
|
|
|
|
}
|
|
|
|
- todo_wine
|
|
|
|
ok(found || broken(!ret), "process name %s not found\n", wine_dbgstr_w(pname));
|
2018-04-11 17:22:53 -07:00
|
|
|
WTSFreeMemory(info);
|
2014-07-06 14:53:33 -07:00
|
|
|
}
|
|
|
|
diff --git a/dlls/wtsapi32/wtsapi32.c b/dlls/wtsapi32/wtsapi32.c
|
2020-05-29 17:13:43 -07:00
|
|
|
index ef3e0d10a0f..06ce384a337 100644
|
2014-07-06 14:53:33 -07:00
|
|
|
--- a/dlls/wtsapi32/wtsapi32.c
|
|
|
|
+++ b/dlls/wtsapi32/wtsapi32.c
|
2019-06-28 02:46:18 -07:00
|
|
|
@@ -17,8 +17,11 @@
|
|
|
|
|
2014-07-06 14:53:33 -07:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
+#include "ntstatus.h"
|
|
|
|
+#define WIN32_NO_STATUS
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
+#include "winternl.h"
|
2020-05-29 17:13:43 -07:00
|
|
|
#include "winnls.h"
|
2014-07-06 14:53:33 -07:00
|
|
|
#include "wtsapi32.h"
|
|
|
|
#include "wine/debug.h"
|
2020-05-29 17:13:43 -07:00
|
|
|
@@ -115,8 +118,13 @@ BOOL WINAPI WTSEnumerateProcessesA(HANDLE hServer, DWORD Reserved, DWORD Version
|
2014-07-06 14:53:33 -07:00
|
|
|
BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version,
|
|
|
|
PWTS_PROCESS_INFOW* ppProcessInfo, DWORD* pCount)
|
|
|
|
{
|
|
|
|
- FIXME("Stub %p 0x%08x 0x%08x %p %p\n", hServer, Reserved, Version,
|
|
|
|
- ppProcessInfo, pCount);
|
|
|
|
+ WTS_PROCESS_INFOW *processInfo;
|
|
|
|
+ SYSTEM_PROCESS_INFORMATION *spi;
|
|
|
|
+ ULONG size = 0x4000;
|
|
|
|
+ void *buf = NULL;
|
|
|
|
+ NTSTATUS status;
|
|
|
|
+ DWORD count;
|
|
|
|
+ WCHAR *name;
|
|
|
|
|
|
|
|
if (!ppProcessInfo || !pCount || Reserved != 0 || Version != 1)
|
|
|
|
{
|
2020-05-29 17:13:43 -07:00
|
|
|
@@ -124,9 +132,71 @@ BOOL WINAPI WTSEnumerateProcessesW(HANDLE hServer, DWORD Reserved, DWORD Version
|
2014-07-06 14:53:33 -07:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
- *pCount = 0;
|
|
|
|
- *ppProcessInfo = NULL;
|
|
|
|
+ if (hServer != WTS_CURRENT_SERVER_HANDLE)
|
|
|
|
+ {
|
|
|
|
+ SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ do
|
|
|
|
+ {
|
|
|
|
+ size *= 2;
|
|
|
|
+ HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
+ buf = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
+ if (!buf)
|
|
|
|
+ {
|
|
|
|
+ SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+ status = NtQuerySystemInformation(SystemProcessInformation, buf, size, NULL);
|
|
|
|
+ }
|
|
|
|
+ while (status == STATUS_INFO_LENGTH_MISMATCH);
|
|
|
|
+
|
|
|
|
+ if (status != STATUS_SUCCESS)
|
|
|
|
+ {
|
|
|
|
+ HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
+ SetLastError(RtlNtStatusToDosError(status));
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
2018-04-11 17:22:53 -07:00
|
|
|
+
|
2014-07-06 14:53:33 -07:00
|
|
|
+ spi = buf;
|
|
|
|
+ count = size = 0;
|
|
|
|
+ for (;;)
|
|
|
|
+ {
|
|
|
|
+ size += sizeof(WTS_PROCESS_INFOW) + spi->ProcessName.Length + sizeof(WCHAR);
|
|
|
|
+ count++;
|
|
|
|
+ if (spi->NextEntryOffset == 0) break;
|
|
|
|
+ spi = (SYSTEM_PROCESS_INFORMATION *)(((PCHAR)spi) + spi->NextEntryOffset);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ processInfo = HeapAlloc(GetProcessHeap(), 0, size);
|
|
|
|
+ if (!processInfo)
|
|
|
|
+ {
|
|
|
|
+ HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
+ SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+ name = (WCHAR *)&processInfo[count];
|
|
|
|
+
|
|
|
|
+ *ppProcessInfo = processInfo;
|
|
|
|
+ *pCount = count;
|
|
|
|
+
|
|
|
|
+ spi = buf;
|
|
|
|
+ while (count--)
|
|
|
|
+ {
|
|
|
|
+ processInfo->SessionId = 0;
|
|
|
|
+ processInfo->ProcessId = HandleToUlong(spi->UniqueProcessId);
|
|
|
|
+ processInfo->pProcessName = name;
|
|
|
|
+ processInfo->pUserSid = NULL;
|
|
|
|
+ memcpy( name, spi->ProcessName.Buffer, spi->ProcessName.Length );
|
|
|
|
+ name[ spi->ProcessName.Length/sizeof(WCHAR) ] = 0;
|
|
|
|
+
|
|
|
|
+ processInfo++;
|
|
|
|
+ name += (spi->ProcessName.Length + sizeof(WCHAR))/sizeof(WCHAR);
|
|
|
|
+ spi = (SYSTEM_PROCESS_INFORMATION *)(((PCHAR)spi) + spi->NextEntryOffset);
|
|
|
|
+ }
|
2018-04-11 17:22:53 -07:00
|
|
|
|
2014-07-06 14:53:33 -07:00
|
|
|
+ HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
--
|
2020-05-29 17:13:43 -07:00
|
|
|
2.26.2
|
2014-07-06 14:53:33 -07:00
|
|
|
|