Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48760 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/kernel32/console.c | 18 ++++++++++++++++-- dlls/kernel32/tests/console.c | 5 ----- 2 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 80f3419cd7a..621103978fa 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -252,7 +252,10 @@ DWORD WINAPI GetConsoleAliasW(LPWSTR lpSource, LPWSTR lpTargetBuffer, */ DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount) { - FIXME("(%p,%d): stub\n", processlist, processcount); + NTSTATUS status; + IO_STATUS_BLOCK io; + + TRACE("(%p,%d)\n", processlist, processcount);
if (!processlist || processcount < 1) { @@ -260,7 +263,18 @@ DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount) return 0; }
- return 0; + status = NtDeviceIoControlFile( RtlGetCurrentPeb()->ProcessParameters->ConsoleHandle, + NULL, NULL, NULL, &io, IOCTL_CONDRV_GET_PROCESS_LIST, + NULL, 0, processlist, processcount * sizeof(DWORD) ); + + if (status == STATUS_BUFFER_TOO_SMALL) return *processlist; + if (status) + { + SetLastError(RtlNtStatusToDosError(status)); + return 0; + } + + return io.Information / sizeof(DWORD); }
/* Undocumented, called by native doskey.exe */ diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 94a0a370462..ef28debb6ff 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) @@ -4360,11 +4358,8 @@ static void test_AttachConsole_child(DWORD console_pid) DWORD pid = GetCurrentProcessId(); SetLastError(0xdeadbeef); len = pGetConsoleProcessList(list, 2); - todo_wine ok(len == 2, "Expected 2, 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"); }