Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/kernel32/tests/console.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 5e35f101d5..207de684fb 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -1040,8 +1040,8 @@ static void test_GetConsoleProcessList(void) GetLastError());
/* We should only have 1 process but only for these specific unit tests as - * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS) would - * give us two processes for example. + * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS) + * gives us two processes - see test_AttachConsole. */ list = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD));
@@ -3232,6 +3232,20 @@ static void test_AttachConsole_child(DWORD console_pid) res = AttachConsole(ATTACH_PARENT_PROCESS); ok(res, "AttachConsole failed: %u\n", GetLastError());
+ if (pGetConsoleProcessList) + { + DWORD list[2]; + 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"); + } + ok(pipe_in != GetStdHandle(STD_INPUT_HANDLE), "std handle not set to console\n"); ok(pipe_out != GetStdHandle(STD_OUTPUT_HANDLE), "std handle not set to console\n");
Signed-off-by: Roman Pišl rpisl@seznam.cz --- include/wine/server_protocol.h | 18 ++++++++++++++ server/console.c | 45 ++++++++++++++++++++++++++++++++++ server/protocol.def | 9 +++++++ server/request.h | 6 +++++ server/trace.c | 14 +++++++++++ 5 files changed, 92 insertions(+)
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 9cdb9c765f..4d917199d6 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -1931,6 +1931,21 @@ struct attach_console_reply
+struct get_console_process_list_request +{ + struct request_header __header; + data_size_t count; +}; +struct get_console_process_list_reply +{ + struct reply_header __header; + data_size_t total; + /* VARARG(data,uints); */ + char __pad_12[4]; +}; + + + struct get_console_wait_event_request { struct request_header __header; @@ -5849,6 +5864,7 @@ enum request REQ_get_console_renderer_events, REQ_open_console, REQ_attach_console, + REQ_get_console_process_list, REQ_get_console_wait_event, REQ_get_console_mode, REQ_set_console_mode, @@ -6151,6 +6167,7 @@ union generic_request struct get_console_renderer_events_request get_console_renderer_events_request; struct open_console_request open_console_request; struct attach_console_request attach_console_request; + struct get_console_process_list_request get_console_process_list_request; struct get_console_wait_event_request get_console_wait_event_request; struct get_console_mode_request get_console_mode_request; struct set_console_mode_request set_console_mode_request; @@ -6451,6 +6468,7 @@ union generic_reply struct get_console_renderer_events_reply get_console_renderer_events_reply; struct open_console_reply open_console_reply; struct attach_console_reply attach_console_reply; + struct get_console_process_list_reply get_console_process_list_reply; struct get_console_wait_event_reply get_console_wait_event_reply; struct get_console_mode_reply get_console_mode_reply; struct set_console_mode_reply set_console_mode_reply; diff --git a/server/console.c b/server/console.c index 5feb1c2ba7..b94bb9c500 100644 --- a/server/console.c +++ b/server/console.c @@ -614,6 +614,25 @@ static void propagate_console_signal( struct console_input *console, enum_processes(propagate_console_signal_cb, &csi); }
+struct console_process_list +{ + DWORD* processes; + DWORD size; + DWORD count; +}; + +static int console_process_list_cb(struct process *process, void *user) +{ + if (process->console == current->process->console) + { + struct console_process_list* cpl = (struct console_process_list*)user; + if (cpl->count < cpl->size) cpl->processes[cpl->count] = process->id; + cpl->count++; + } + + return 0; +} + static int get_console_mode( obj_handle_t handle ) { struct object *obj; @@ -1617,6 +1636,32 @@ error: release_object( process ); }
+/* Get console process list */ +DECL_HANDLER(get_console_process_list) +{ + struct console_process_list cpl; + cpl.count = 0; + cpl.size = req->count; + cpl.processes = NULL; + reply->total = 0; + + if (cpl.size > 0) + { + cpl.processes = malloc(cpl.count * sizeof(DWORD)); + if (!cpl.processes) return; + } + + enum_processes(console_process_list_cb, &cpl); + + if (cpl.count > 0 && cpl.count <= req->count) + { + set_reply_data( cpl.processes, cpl.count * sizeof(DWORD) ); + } + + if (cpl.processes) free(cpl.processes); + reply->total = cpl.count; +} + /* set info about a console input */ DECL_HANDLER(set_console_input_info) { diff --git a/server/protocol.def b/server/protocol.def index 1413021a39..41c7d8a4e0 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1542,6 +1542,15 @@ struct console_renderer_event @END
+/* Get console process list */ +@REQ(get_console_process_list) + data_size_t count; /* maximum number of processes in list */ +@REPLY + data_size_t total; + VARARG(data,uints); /* PIDs attached to the console */ +@END + + /* Get the input queue wait event */ @REQ(get_console_wait_event) obj_handle_t handle; /* handle to the console */ diff --git a/server/request.h b/server/request.h index 0d4c083460..9ea4eedd02 100644 --- a/server/request.h +++ b/server/request.h @@ -185,6 +185,7 @@ DECL_HANDLER(free_console); DECL_HANDLER(get_console_renderer_events); DECL_HANDLER(open_console); DECL_HANDLER(attach_console); +DECL_HANDLER(get_console_process_list); DECL_HANDLER(get_console_wait_event); DECL_HANDLER(get_console_mode); DECL_HANDLER(set_console_mode); @@ -486,6 +487,7 @@ static const req_handler req_handlers[REQ_NB_REQUESTS] = (req_handler)req_get_console_renderer_events, (req_handler)req_open_console, (req_handler)req_attach_console, + (req_handler)req_get_console_process_list, (req_handler)req_get_console_wait_event, (req_handler)req_get_console_mode, (req_handler)req_set_console_mode, @@ -1148,6 +1150,10 @@ C_ASSERT( FIELD_OFFSET(struct attach_console_reply, std_in) == 8 ); C_ASSERT( FIELD_OFFSET(struct attach_console_reply, std_out) == 12 ); C_ASSERT( FIELD_OFFSET(struct attach_console_reply, std_err) == 16 ); C_ASSERT( sizeof(struct attach_console_reply) == 24 ); +C_ASSERT( FIELD_OFFSET(struct get_console_process_list_request, count) == 12 ); +C_ASSERT( sizeof(struct get_console_process_list_request) == 16 ); +C_ASSERT( FIELD_OFFSET(struct get_console_process_list_reply, total) == 8 ); +C_ASSERT( sizeof(struct get_console_process_list_reply) == 16 ); C_ASSERT( FIELD_OFFSET(struct get_console_wait_event_request, handle) == 12 ); C_ASSERT( sizeof(struct get_console_wait_event_request) == 16 ); C_ASSERT( FIELD_OFFSET(struct get_console_wait_event_reply, event) == 8 ); diff --git a/server/trace.c b/server/trace.c index dd63b166f3..729a5f2c38 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2037,6 +2037,17 @@ static void dump_attach_console_reply( const struct attach_console_reply *req ) fprintf( stderr, ", std_err=%04x", req->std_err ); }
+static void dump_get_console_process_list_request( const struct get_console_process_list_request *req ) +{ + fprintf( stderr, " count=%u", req->count ); +} + +static void dump_get_console_process_list_reply( const struct get_console_process_list_reply *req ) +{ + fprintf( stderr, " total=%u", req->total ); + dump_varargs_uints( ", data=", cur_size ); +} + static void dump_get_console_wait_event_request( const struct get_console_wait_event_request *req ) { fprintf( stderr, " handle=%04x", req->handle ); @@ -4663,6 +4674,7 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_get_console_renderer_events_request, (dump_func)dump_open_console_request, (dump_func)dump_attach_console_request, + (dump_func)dump_get_console_process_list_request, (dump_func)dump_get_console_wait_event_request, (dump_func)dump_get_console_mode_request, (dump_func)dump_set_console_mode_request, @@ -4961,6 +4973,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_get_console_renderer_events_reply, (dump_func)dump_open_console_reply, (dump_func)dump_attach_console_reply, + (dump_func)dump_get_console_process_list_reply, (dump_func)dump_get_console_wait_event_reply, (dump_func)dump_get_console_mode_reply, NULL, @@ -5259,6 +5272,7 @@ static const char * const req_names[REQ_NB_REQUESTS] = { "get_console_renderer_events", "open_console", "attach_console", + "get_console_process_list", "get_console_wait_event", "get_console_mode", "set_console_mode",
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48760 Signed-off-by: Roman Pišl rpisl@seznam.cz --- dlls/kernel32/console.c | 16 ++++++++++++++-- dlls/kernel32/tests/console.c | 5 ----- 2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 472d513990..27b22b5850 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -1493,7 +1493,8 @@ DWORD WINAPI GetConsoleAliasW(LPWSTR lpSource, LPWSTR lpTargetBuffer, */ DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount) { - FIXME("(%p,%d): stub\n", processlist, processcount); + DWORD ret = 0; + TRACE("(%p,%d)\n", processlist, processcount);
if (!processlist || processcount < 1) { @@ -1501,7 +1502,18 @@ DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount) return 0; }
- return 0; + SERVER_START_REQ(get_console_process_list) + { + req->count = processcount; + wine_server_set_reply( req, processlist, processcount * sizeof(DWORD) ); + if (!wine_server_call_err( req )) + { + ret = reply->total; + } + } + SERVER_END_REQ; + + return ret; }
BOOL CONSOLE_Init(RTL_USER_PROCESS_PARAMETERS *params) diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 207de684fb..e2c8388578 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -1054,7 +1054,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); @@ -1063,7 +1062,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) @@ -3238,11 +3236,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"); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=70217
Your paranoid android.
=== debiant (32 bit WoW report) ===
kernel32: debugger.c:1605: Test failed: unexpected instruction pointer AAAAAAAA expected 00340401