Roman Pišl : kernel32: Implement GetConsoleProcessList.
Alexandre Julliard
julliard at winehq.org
Tue Feb 15 16:07:20 CST 2022
Module: wine
Branch: master
Commit: 3a95a4a0120e231eb9054ca4632a7e05762928f6
URL: https://source.winehq.org/git/wine.git/?a=commit;h=3a95a4a0120e231eb9054ca4632a7e05762928f6
Author: Roman Pišl <rpisl at seznam.cz>
Date: Sat Feb 12 12:56:04 2022 +0100
kernel32: Implement GetConsoleProcessList.
Signed-off-by: Roman Pišl <rpisl at seznam.cz>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/console.c | 21 ++++++++++++++++++++-
dlls/kernel32/tests/console.c | 6 ------
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c
index 395d539a5dc..2aa59374c4f 100644
--- a/dlls/kernel32/console.c
+++ b/dlls/kernel32/console.c
@@ -252,7 +252,11 @@ DWORD WINAPI GetConsoleAliasW(LPWSTR lpSource, LPWSTR lpTargetBuffer,
*/
DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount)
{
- FIXME("(%p,%ld): stub\n", processlist, processcount);
+ DWORD saved;
+ NTSTATUS status;
+ IO_STATUS_BLOCK io;
+
+ TRACE("(%p,%ld)\n", processlist, processcount);
if (!processlist || processcount < 1)
{
@@ -260,6 +264,21 @@ DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount)
return 0;
}
+ saved = *processlist;
+ status = NtDeviceIoControlFile( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle,
+ NULL, NULL, NULL, &io, IOCTL_CONDRV_GET_PROCESS_LIST,
+ NULL, 0, processlist, processcount * sizeof(DWORD) );
+
+ if (!status) return io.Information / sizeof(DWORD);
+ if (status == STATUS_BUFFER_TOO_SMALL)
+ {
+ DWORD ret = *processlist;
+ *processlist = saved;
+ return ret;
+ }
+
+ *processlist = saved;
+ set_ntstatus( status );
return 0;
}
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c
index 5a399768d9e..5f5f0698040 100644
--- a/dlls/kernel32/tests/console.c
+++ b/dlls/kernel32/tests/console.c
@@ -1318,7 +1318,6 @@ static void test_GetConsoleProcessList(void)
SetLastError(0xdeadbeef);
ret = pGetConsoleProcessList(list, 1);
- todo_wine
ok(ret == 1, "Expected 1, got %d\n", ret);
HeapFree(GetProcessHeap(), 0, list);
@@ -1327,7 +1326,6 @@ static void test_GetConsoleProcessList(void)
SetLastError(0xdeadbeef);
ret = pGetConsoleProcessList(list, ret);
- todo_wine
ok(ret == 1, "Expected 1, got %d\n", ret);
if (ret == 1)
@@ -4361,16 +4359,12 @@ static void test_AttachConsole_child(DWORD console_pid)
SetLastError(0xdeadbeef);
len = pGetConsoleProcessList(list, 1);
- todo_wine
ok(len == 2, "Expected 2 processes, got %d\n", len);
ok(list[0] == 0xbabebabe, "Unexpected value in list %u\n", list[0]);
len = pGetConsoleProcessList(list, 2);
- todo_wine
ok(len == 2, "Expected 2 processes, got %d\n", len);
- todo_wine
ok(list[0] == console_pid || list[1] == console_pid, "Parent PID not in list\n");
- todo_wine
ok(list[0] == pid || list[1] == pid, "PID not in list\n");
ok(GetLastError() == 0xdeadbeef, "Unexpected last error: %u\n", GetLastError());
}
More information about the wine-cvs
mailing list