Signed-off-by: Roman Pišl rpisl@seznam.cz --- 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..4999b9a760e 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; + SetLastError(RtlNtStatusToDosError(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()); }