winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
July 2020
----- 2025 -----
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
1 participants
826 discussions
Start a n
N
ew thread
Jacek Caban : kernelbase: Use init_console_std_handles in AttachConsole.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: ed8358393413d52096c56e96b44ee73f15053f91 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=ed8358393413d52096c56e96…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:16:42 2020 +0200 kernelbase: Use init_console_std_handles in AttachConsole. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/console.c | 9 +++------ include/wine/server_protocol.h | 6 +----- server/console.c | 14 -------------- server/protocol.def | 4 ---- server/request.h | 4 ---- server/trace.c | 9 +-------- 6 files changed, 5 insertions(+), 41 deletions(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index be05a535c5..93ab29d6f1 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -246,15 +246,12 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid ) SERVER_START_REQ( attach_console ) { req->pid = pid; - if ((ret = !wine_server_call_err( req ))) - { - SetStdHandle( STD_INPUT_HANDLE, wine_server_ptr_handle( reply->std_in )); - SetStdHandle( STD_OUTPUT_HANDLE, wine_server_ptr_handle( reply->std_out )); - SetStdHandle( STD_ERROR_HANDLE, wine_server_ptr_handle( reply->std_err )); - } + ret = !wine_server_call_err( req ); } SERVER_END_REQ; + if (ret && !(ret = init_console_std_handles())) FreeConsole(); + RtlLeaveCriticalSection( &console_section ); return ret; } diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index 7753d24877..587b2391ce 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -1858,10 +1858,6 @@ struct attach_console_request struct attach_console_reply { struct reply_header __header; - obj_handle_t std_in; - obj_handle_t std_out; - obj_handle_t std_err; - char __pad_20[4]; }; @@ -6355,7 +6351,7 @@ union generic_reply /* ### protocol_version begin ### */ -#define SERVER_PROTOCOL_VERSION 633 +#define SERVER_PROTOCOL_VERSION 634 /* ### protocol_version end ### */ diff --git a/server/console.c b/server/console.c index 0060f7cb65..53910b3f46 100644 --- a/server/console.c +++ b/server/console.c @@ -2108,15 +2108,6 @@ DECL_HANDLER(attach_console) if (process->console && process->console->active) { - reply->std_in = alloc_handle( current->process, process->console, GENERIC_READ, 0 ); - if (!reply->std_in) goto error; - - reply->std_out = alloc_handle( current->process, process->console->active, GENERIC_WRITE, 0 ); - if (!reply->std_out) goto error; - - reply->std_err = alloc_handle( current->process, process->console->active, GENERIC_WRITE, 0 ); - if (!reply->std_err) goto error; - current->process->console = (struct console_input *)grab_object( process->console ); current->process->console->num_proc++; } @@ -2127,11 +2118,6 @@ DECL_HANDLER(attach_console) release_object( process ); return; - -error: - if (reply->std_in) close_handle( current->process, reply->std_in ); - if (reply->std_out) close_handle( current->process, reply->std_out ); - release_object( process ); } /* set info about a console input */ diff --git a/server/protocol.def b/server/protocol.def index c2773307a4..1bbc8c5008 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -1475,10 +1475,6 @@ enum server_fd_type /* Attach to a other process's console */ @REQ(attach_console) process_id_t pid; /* pid of attached console process */ -@REPLY - obj_handle_t std_in; /* attached stdin */ - obj_handle_t std_out; /* attached stdout */ - obj_handle_t std_err; /* attached stderr */ @END diff --git a/server/request.h b/server/request.h index 190581332b..cd0799f2c1 100644 --- a/server/request.h +++ b/server/request.h @@ -1112,10 +1112,6 @@ C_ASSERT( sizeof(struct alloc_console_reply) == 16 ); C_ASSERT( sizeof(struct free_console_request) == 16 ); C_ASSERT( FIELD_OFFSET(struct attach_console_request, pid) == 12 ); C_ASSERT( sizeof(struct attach_console_request) == 16 ); -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_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 15a769fb59..51bd490fe2 100644 --- a/server/trace.c +++ b/server/trace.c @@ -2046,13 +2046,6 @@ static void dump_attach_console_request( const struct attach_console_request *re fprintf( stderr, " pid=%04x", req->pid ); } -static void dump_attach_console_reply( const struct attach_console_reply *req ) -{ - fprintf( stderr, " std_in=%04x", req->std_in ); - fprintf( stderr, ", std_out=%04x", req->std_out ); - fprintf( stderr, ", std_err=%04x", req->std_err ); -} - static void dump_get_console_wait_event_request( const struct get_console_wait_event_request *req ) { fprintf( stderr, " handle=%04x", req->handle ); @@ -4793,7 +4786,7 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { NULL, (dump_func)dump_alloc_console_reply, NULL, - (dump_func)dump_attach_console_reply, + NULL, (dump_func)dump_get_console_wait_event_reply, NULL, (dump_func)dump_get_console_input_info_reply,
1
0
0
0
Jacek Caban : kernel32/tests: Add more AllocConsole tests.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: a09a268faeb29fb6cffd6e422843659793f09ced URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a09a268faeb29fb6cffd6e42…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:16:30 2020 +0200 kernel32/tests: Add more AllocConsole tests. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernel32/tests/console.c | 106 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 47bfb8dbd3..c9b30e3b50 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3770,6 +3770,105 @@ static void test_AttachConsole(HANDLE console) ok(!memcmp(buf, "Child", 5), "Unexpected console output\n"); } +static void test_AllocConsole_child(void) +{ + HANDLE unbound_output; + HANDLE prev_output, prev_error; + STARTUPINFOW si; + DWORD mode; + BOOL res; + + GetStartupInfoW(&si); + + prev_output = GetStdHandle(STD_OUTPUT_HANDLE); + res = DuplicateHandle(GetCurrentProcess(), prev_output, GetCurrentProcess(), &unbound_output, + 0, FALSE, DUPLICATE_SAME_ACCESS); + ok(res, "DuplicateHandle failed: %u\n", GetLastError()); + + res = GetConsoleMode(unbound_output, &mode); + ok(res, "GetConsoleMode failed: %u\n", GetLastError()); + + prev_error = GetStdHandle(STD_ERROR_HANDLE); + if (si.dwFlags & STARTF_USESTDHANDLES) + { + res = GetConsoleMode(prev_error, &mode); + ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %u\n", GetLastError()); + } + + FreeConsole(); + + ok(GetStdHandle(STD_OUTPUT_HANDLE) == prev_output, "GetStdHandle(STD_OUTPUT_HANDLE) = %p\n", GetStdHandle(STD_OUTPUT_HANDLE)); + ok(GetStdHandle(STD_ERROR_HANDLE) == prev_error, "GetStdHandle(STD_ERROR_HANDLE) = %p\n", GetStdHandle(STD_ERROR_HANDLE)); + res = GetConsoleMode(unbound_output, &mode); + todo_wine + ok(!res && GetLastError() == ERROR_INVALID_HANDLE, "GetConsoleMode failed: %u\n", GetLastError()); + + res = AllocConsole(); + ok(res, "AllocConsole failed: %u\n", GetLastError()); + + if (si.dwFlags & STARTF_USESTDHANDLES) + { + ok(GetStdHandle(STD_OUTPUT_HANDLE) == prev_output, "GetStdHandle(STD_OUTPUT_HANDLE) = %p\n", GetStdHandle(STD_OUTPUT_HANDLE)); + ok(GetStdHandle(STD_ERROR_HANDLE) == prev_error, "GetStdHandle(STD_ERROR_HANDLE) = %p\n", GetStdHandle(STD_ERROR_HANDLE)); + } + + res = GetConsoleMode(unbound_output, &mode); + ok(res, "GetConsoleMode failed: %u\n", GetLastError()); + + FreeConsole(); + SetStdHandle(STD_OUTPUT_HANDLE, NULL); + SetStdHandle(STD_ERROR_HANDLE, NULL); + res = AllocConsole(); + ok(res, "AllocConsole failed: %u\n", GetLastError()); + + ok(GetStdHandle(STD_OUTPUT_HANDLE) != NULL, "GetStdHandle(STD_OUTPUT_HANDLE) = %p\n", GetStdHandle(STD_OUTPUT_HANDLE)); + ok(GetStdHandle(STD_ERROR_HANDLE) != NULL, "GetStdHandle(STD_ERROR_HANDLE) = %p\n", GetStdHandle(STD_ERROR_HANDLE)); + + res = GetConsoleMode(unbound_output, &mode); + ok(res, "GetConsoleMode failed: %u\n", GetLastError()); + res = GetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), &mode); + ok(res, "GetConsoleMode failed: %u\n", GetLastError()); + res = GetConsoleMode(GetStdHandle(STD_ERROR_HANDLE), &mode); + ok(res, "GetConsoleMode failed: %u\n", GetLastError()); + + res = CloseHandle(unbound_output); + ok(res, "CloseHandle failed: %u\n", GetLastError()); +} + +static void test_AllocConsole(void) +{ + SECURITY_ATTRIBUTES inheritable_attr = { sizeof(inheritable_attr), NULL, TRUE }; + STARTUPINFOA si = { sizeof(si) }; + PROCESS_INFORMATION info; + char **argv, buf[MAX_PATH]; + HANDLE pipe_read, pipe_write; + BOOL res; + + if (skip_nt) return; + + winetest_get_mainargs(&argv); + sprintf(buf, "\"%s\" console alloc_console", argv[0], GetCurrentProcessId()); + res = CreateProcessA(NULL, buf, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); + ok(res, "CreateProcess failed: %u\n", GetLastError()); + CloseHandle(info.hThread); + wait_child_process(info.hProcess); + CloseHandle(info.hProcess); + + res = CreatePipe(&pipe_read, &pipe_write, &inheritable_attr, 0); + ok(res, "CreatePipe failed: %u\n", GetLastError()); + + si.dwFlags = STARTF_USESTDHANDLES; + si.hStdError = pipe_write; + res = CreateProcessA(NULL, buf, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &info); + ok(res, "CreateProcess failed: %u\n", GetLastError()); + CloseHandle(info.hThread); + wait_child_process(info.hProcess); + CloseHandle(info.hProcess); + + CloseHandle(pipe_read); + CloseHandle(pipe_write); +} + START_TEST(console) { static const char font_name[] = "Lucida Console"; @@ -3796,6 +3895,12 @@ START_TEST(console) return; } + if (argc == 3 && !strcmp(argv[2], "alloc_console")) + { + test_AllocConsole_child(); + return; + } + /* be sure we have a clean console (and that's our own) * FIXME: this will make the test fail (currently) if we don't run * under X11 @@ -3938,5 +4043,6 @@ START_TEST(console) test_GetConsoleScreenBufferInfoEx(hConOut); test_SetConsoleScreenBufferInfoEx(hConOut); test_AttachConsole(hConOut); + test_AllocConsole(); test_FreeConsole(); }
1
0
0
0
Jacek Caban : kernelbase: Close handles allocated by AllocConsole in FreeConsole.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: 53f17314aa97d4aba8d37d76ae878cbae20818bf URL:
https://source.winehq.org/git/wine.git/?a=commit;h=53f17314aa97d4aba8d37d76…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:16:13 2020 +0200 kernelbase: Close handles allocated by AllocConsole in FreeConsole. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/console.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index d326901eac..be05a535c5 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -55,6 +55,11 @@ static CRITICAL_SECTION_DEBUG critsect_debug = static CRITICAL_SECTION console_section = { &critsect_debug, -1, 0, 0, 0, 0 }; static HANDLE console_wait_event; +static unsigned int console_flags; + +#define CONSOLE_INPUT_HANDLE 0x01 +#define CONSOLE_OUTPUT_HANDLE 0x02 +#define CONSOLE_ERROR_HANDLE 0x04 static WCHAR input_exe[MAX_PATH + 1]; @@ -191,6 +196,7 @@ static BOOL init_console_std_handles(void) FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_CREATE, FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); if (!set_ntstatus( status )) return FALSE; + console_flags |= CONSOLE_INPUT_HANDLE; SetStdHandle( STD_INPUT_HANDLE, console_handle_map( handle )); } @@ -210,6 +216,7 @@ static BOOL init_console_std_handles(void) if (!set_ntstatus( status )) return FALSE; if (!std_out) { + console_flags |= CONSOLE_OUTPUT_HANDLE; SetStdHandle( STD_OUTPUT_HANDLE, console_handle_map( handle )); } @@ -218,6 +225,7 @@ static BOOL init_console_std_handles(void) if (!std_out && !DuplicateHandle( GetCurrentProcess(), handle, GetCurrentProcess(), &handle, 0, TRUE, DUPLICATE_SAME_ACCESS )) return FALSE; + console_flags |= CONSOLE_ERROR_HANDLE; SetStdHandle( STD_ERROR_HANDLE, console_handle_map( handle )); } @@ -504,6 +512,11 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void) RtlEnterCriticalSection( &console_section ); + if (console_flags & CONSOLE_INPUT_HANDLE) NtClose( GetStdHandle( STD_INPUT_HANDLE )); + if (console_flags & CONSOLE_OUTPUT_HANDLE) NtClose( GetStdHandle( STD_OUTPUT_HANDLE )); + if (console_flags & CONSOLE_ERROR_HANDLE) NtClose( GetStdHandle( STD_ERROR_HANDLE )); + console_flags = 0; + SERVER_START_REQ( free_console ) { ret = !wine_server_call_err( req );
1
0
0
0
Jacek Caban : kernelbase: Fix handling processes using STARTF_USESTDHANDLES when setting standard handles in AllocConsole.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: bd54f39766e53f92909bc208e5746497c0dc5d69 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=bd54f39766e53f92909bc208…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:16:01 2020 +0200 kernelbase: Fix handling processes using STARTF_USESTDHANDLES when setting standard handles in AllocConsole. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/console.c | 89 ++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index c3634c792f..d326901eac 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -169,6 +169,61 @@ static COORD get_largest_console_window_size( HANDLE handle ) return c; } +static BOOL init_console_std_handles(void) +{ + HANDLE std_out = NULL, std_err = NULL, handle; + OBJECT_ATTRIBUTES attr = {sizeof(attr)}; + IO_STATUS_BLOCK iosb; + UNICODE_STRING name; + STARTUPINFOW si; + NTSTATUS status; + + GetStartupInfoW( &si ); + attr.ObjectName = &name; + attr.Attributes = OBJ_INHERIT; + + if (!(si.dwFlags & STARTF_USESTDHANDLES) || !GetStdHandle( STD_INPUT_HANDLE )) + { + /* FIXME: Use unbound console handle */ + RtlInitUnicodeString( &name, L"\\Device\\ConDrv\\CurrentIn" ); + status = NtCreateFile( &handle, FILE_READ_DATA | FILE_WRITE_DATA | SYNCHRONIZE | FILE_READ_ATTRIBUTES | + FILE_WRITE_ATTRIBUTES, &attr, &iosb, NULL, FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_CREATE, + FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); + if (!set_ntstatus( status )) return FALSE; + SetStdHandle( STD_INPUT_HANDLE, console_handle_map( handle )); + } + + if (si.dwFlags & STARTF_USESTDHANDLES) + { + std_out = GetStdHandle( STD_OUTPUT_HANDLE ); + std_err = GetStdHandle( STD_ERROR_HANDLE ); + if (std_out && std_err) return TRUE; + } + + /* FIXME: Use unbound console handle */ + RtlInitUnicodeString( &name, L"\\Device\\ConDrv\\CurrentOut" ); + status = NtCreateFile( &handle, FILE_READ_DATA | FILE_WRITE_DATA | SYNCHRONIZE | FILE_READ_ATTRIBUTES | + FILE_WRITE_ATTRIBUTES, &attr, &iosb, NULL, FILE_ATTRIBUTE_NORMAL, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, FILE_CREATE, + FILE_NON_DIRECTORY_FILE | FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0 ); + if (!set_ntstatus( status )) return FALSE; + if (!std_out) + { + SetStdHandle( STD_OUTPUT_HANDLE, console_handle_map( handle )); + } + + if (!std_err) + { + if (!std_out && !DuplicateHandle( GetCurrentProcess(), handle, GetCurrentProcess(), + &handle, 0, TRUE, DUPLICATE_SAME_ACCESS )) + return FALSE; + SetStdHandle( STD_ERROR_HANDLE, console_handle_map( handle )); + } + + return TRUE; +} + /****************************************************************** * AttachConsole (kernelbase.@) */ @@ -203,13 +258,10 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid ) BOOL WINAPI AllocConsole(void) { SECURITY_ATTRIBUTES inheritable_attr = { sizeof(inheritable_attr), NULL, TRUE }; - HANDLE std_in = INVALID_HANDLE_VALUE; - HANDLE std_out = INVALID_HANDLE_VALUE; - HANDLE std_err = INVALID_HANDLE_VALUE; STARTUPINFOW app_si, console_si; WCHAR buffer[1024], cmd[256]; PROCESS_INFORMATION pi; - HANDLE event; + HANDLE event, std_in; DWORD mode; BOOL ret; @@ -266,42 +318,15 @@ BOOL WINAPI AllocConsole(void) CloseHandle( pi.hProcess ); } CloseHandle( event ); - if (!ret) goto error; + if (!ret || !init_console_std_handles()) goto error; TRACE( "Started wineconsole pid=%08x tid=%08x\n", pi.dwProcessId, pi.dwThreadId ); - if (!(app_si.dwFlags & STARTF_USESTDHANDLES)) - { - - std_in = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 0, &inheritable_attr, - OPEN_EXISTING, 0, 0); - if (std_in == INVALID_HANDLE_VALUE) goto error; - - std_out = CreateFileW( L"CONOUT$", GENERIC_READ | GENERIC_WRITE, 0, &inheritable_attr, OPEN_EXISTING, 0, 0); - if (std_out == INVALID_HANDLE_VALUE) goto error; - - if (!DuplicateHandle( GetCurrentProcess(), std_out, GetCurrentProcess(), - &std_err, 0, TRUE, DUPLICATE_SAME_ACCESS) ) - goto error; - } - else - { - std_in = app_si.hStdInput; - std_out = app_si.hStdOutput; - std_err = app_si.hStdError; - } - - SetStdHandle( STD_INPUT_HANDLE, std_in ); - SetStdHandle( STD_OUTPUT_HANDLE, std_out ); - SetStdHandle( STD_ERROR_HANDLE, std_err ); RtlLeaveCriticalSection( &console_section ); SetLastError( ERROR_SUCCESS ); return TRUE; error: ERR("Can't allocate console\n"); - if (std_in != INVALID_HANDLE_VALUE) CloseHandle(std_in); - if (std_out != INVALID_HANDLE_VALUE) CloseHandle(std_out); - if (std_err != INVALID_HANDLE_VALUE) CloseHandle(std_err); FreeConsole(); RtlLeaveCriticalSection( &console_section ); return FALSE;
1
0
0
0
Jacek Caban : kernelbase: Lock console critical section when changing current console.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: e7550069ded02c1f8503a15e155127e1e2c26f6a URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e7550069ded02c1f8503a15e…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:15:45 2020 +0200 kernelbase: Lock console critical section when changing current console. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/kernelbase/console.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/dlls/kernelbase/console.c b/dlls/kernelbase/console.c index 10b52df4e9..c3634c792f 100644 --- a/dlls/kernelbase/console.c +++ b/dlls/kernelbase/console.c @@ -178,6 +178,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid ) TRACE( "(%x)\n", pid ); + RtlEnterCriticalSection( &console_section ); + SERVER_START_REQ( attach_console ) { req->pid = pid; @@ -189,6 +191,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid ) } } SERVER_END_REQ; + + RtlLeaveCriticalSection( &console_section ); return ret; } @@ -211,11 +215,14 @@ BOOL WINAPI AllocConsole(void) TRACE("()\n"); + RtlEnterCriticalSection( &console_section ); + std_in = CreateFileW( L"CONIN$", GENERIC_READ | GENERIC_WRITE | SYNCHRONIZE, 0, NULL, OPEN_EXISTING, 0, 0 ); if (GetConsoleMode( std_in, &mode )) { /* we already have a console opened on this process, don't create a new one */ CloseHandle( std_in ); + RtlLeaveCriticalSection( &console_section ); return FALSE; } @@ -248,7 +255,7 @@ BOOL WINAPI AllocConsole(void) console_si.lpTitle = buffer; } - if (!(event = CreateEventW( &inheritable_attr, TRUE, FALSE, NULL ))) return FALSE; + if (!(event = CreateEventW( &inheritable_attr, TRUE, FALSE, NULL ))) goto error; swprintf( cmd, ARRAY_SIZE(cmd), L"wineconsole --use-event=%ld", (DWORD_PTR)event ); if ((ret = CreateProcessW( NULL, cmd, NULL, NULL, TRUE, DETACHED_PROCESS, NULL, NULL, &console_si, &pi ))) @@ -286,6 +293,7 @@ BOOL WINAPI AllocConsole(void) SetStdHandle( STD_INPUT_HANDLE, std_in ); SetStdHandle( STD_OUTPUT_HANDLE, std_out ); SetStdHandle( STD_ERROR_HANDLE, std_err ); + RtlLeaveCriticalSection( &console_section ); SetLastError( ERROR_SUCCESS ); return TRUE; @@ -295,6 +303,7 @@ error: if (std_out != INVALID_HANDLE_VALUE) CloseHandle(std_out); if (std_err != INVALID_HANDLE_VALUE) CloseHandle(std_err); FreeConsole(); + RtlLeaveCriticalSection( &console_section ); return FALSE; } @@ -468,12 +477,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void) HANDLE event; BOOL ret; + RtlEnterCriticalSection( &console_section ); + SERVER_START_REQ( free_console ) { ret = !wine_server_call_err( req ); } SERVER_END_REQ; if ((event = InterlockedExchangePointer( &console_wait_event, NULL ))) NtClose( event ); + + RtlLeaveCriticalSection( &console_section ); return ret; }
1
0
0
0
Jacek Caban : wineconsole: Use console in/out handles only in WINECON_Init.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: fa2b372ec02d3755ce892612750238f41b39ad85 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=fa2b372ec02d3755ce892612…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:15:35 2020 +0200 wineconsole: Use console in/out handles only in WINECON_Init. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/wineconsole/winecon_private.h | 2 -- programs/wineconsole/wineconsole.c | 29 ++++++++++++++++------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/programs/wineconsole/winecon_private.h b/programs/wineconsole/winecon_private.h index d78502a260..736cf7824e 100644 --- a/programs/wineconsole/winecon_private.h +++ b/programs/wineconsole/winecon_private.h @@ -60,8 +60,6 @@ struct inner_data { COORD cursor; /* position in cells of cursor */ - HANDLE hConIn; /* console input handle */ - HANDLE hConOut; /* screen buffer handle: has to be changed when active sb changes */ HANDLE console; /* console renderer handle */ HANDLE hProcess; /* handle to the child process or NULL */ HWND hWnd; /* handle of 'user' window or NULL for 'curses' */ diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index c78a7f814b..1104963f0f 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -530,8 +530,6 @@ static void WINECON_Delete(struct inner_data* data) if (!data) return; if (data->fnDeleteBackend) data->fnDeleteBackend(data); - if (data->hConIn) CloseHandle(data->hConIn); - if (data->hConOut) CloseHandle(data->hConOut); if (data->console) CloseHandle(data->console); if (data->hProcess) CloseHandle(data->hProcess); if (data->overlapped.hEvent) CloseHandle(data->overlapped.hEvent); @@ -584,7 +582,7 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data) * * Spawn the child process when invoked with wineconsole foo bar */ -static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine) +static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine, HANDLE con_in, HANDLE con_out) { PROCESS_INFORMATION info; STARTUPINFOW startup; @@ -598,11 +596,11 @@ static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine) /* the attributes of wineconsole's handles are not adequate for inheritance, so * get them with the correct attributes before process creation */ - if (!DuplicateHandle(GetCurrentProcess(), data->hConIn, GetCurrentProcess(), + if (!DuplicateHandle(GetCurrentProcess(), con_in, GetCurrentProcess(), &startup.hStdInput, GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, TRUE, 0) || - !DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), + !DuplicateHandle(GetCurrentProcess(), con_out, GetCurrentProcess(), &startup.hStdOutput, GENERIC_READ|GENERIC_WRITE, TRUE, 0) || - !DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), + !DuplicateHandle(GetCurrentProcess(), con_out, GetCurrentProcess(), &startup.hStdError, GENERIC_READ|GENERIC_WRITE, TRUE, 0)) { WINE_ERR("Can't dup handles\n"); @@ -645,6 +643,8 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna UNICODE_STRING string; IO_STATUS_BLOCK io; condrv_handle_t h; + HANDLE con_in; + HANDLE con_out; NTSTATUS status; static const WCHAR renderer_pathW[] = {'\\','D','e','v','i','c','e','\\','C','o','n','D','r','v', @@ -689,11 +689,11 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna req->input_fd = -1; ret = !wine_server_call_err( req ); - data->hConIn = wine_server_ptr_handle( reply->handle_in ); + con_in = wine_server_ptr_handle( reply->handle_in ); } SERVER_END_REQ; if (!ret) goto error; - WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->console); + WINE_TRACE("using con_in %p, renderer %p\n", con_in, data->console); RtlInitUnicodeString(&string, renderer_pathW); attr.ObjectName = &string; @@ -702,23 +702,23 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna 0, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0); if (status) goto error; - h = condrv_handle(data->hConIn); + h = condrv_handle(con_in); if (!DeviceIoControl(data->console, IOCTL_CONDRV_ATTACH_RENDERER, &h, sizeof(h), NULL, 0, NULL, NULL)) goto error; SERVER_START_REQ(create_console_output) { - req->handle_in = wine_server_obj_handle( data->hConIn ); + req->handle_in = wine_server_obj_handle( con_in ); req->access = GENERIC_WRITE|GENERIC_READ; req->attributes = 0; req->share = FILE_SHARE_READ|FILE_SHARE_WRITE; req->fd = -1; ret = !wine_server_call_err( req ); - data->hConOut = wine_server_ptr_handle( reply->handle_out ); + con_out = wine_server_ptr_handle( reply->handle_out ); } SERVER_END_REQ; if (!ret) goto error; - WINE_TRACE("using hConOut %p\n", data->hConOut); + WINE_TRACE("using con_out %p\n", con_out); /* filling data->curcfg from cfg */ switch ((*backend)(data)) @@ -755,7 +755,10 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna lstrlenW(appname) * sizeof(WCHAR), NULL, 0, NULL, NULL); if (!ret) goto error; - if (cmdline && !WINECON_Spawn(data, cmdline)) goto error; + if (cmdline && !WINECON_Spawn(data, cmdline, con_in, con_out)) goto error; + + CloseHandle(con_in); + CloseHandle(con_out); return data; case init_failed:
1
0
0
0
Jacek Caban : wineconsole: Move WINECON_Spawn call to WINECON_Init.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: 504d6eaa9a0642e6c71aa320cb5ac1e88dc44a01 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=504d6eaa9a0642e6c71aa320…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:15:19 2020 +0200 wineconsole: Move WINECON_Spawn call to WINECON_Init. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/wineconsole/wineconsole.c | 113 +++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 60 deletions(-) diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 8752ec6b13..c78a7f814b 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -579,6 +579,53 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data) return TRUE; } +/****************************************************************** + * WINECON_Spawn + * + * Spawn the child process when invoked with wineconsole foo bar + */ +static BOOL WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine) +{ + PROCESS_INFORMATION info; + STARTUPINFOW startup; + BOOL done; + + /* we're in the case wineconsole <exe> <options>... spawn the new process */ + memset(&startup, 0, sizeof(startup)); + startup.cb = sizeof(startup); + startup.dwFlags = STARTF_USESTDHANDLES; + + /* the attributes of wineconsole's handles are not adequate for inheritance, so + * get them with the correct attributes before process creation + */ + if (!DuplicateHandle(GetCurrentProcess(), data->hConIn, GetCurrentProcess(), + &startup.hStdInput, GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, TRUE, 0) || + !DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), + &startup.hStdOutput, GENERIC_READ|GENERIC_WRITE, TRUE, 0) || + !DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), + &startup.hStdError, GENERIC_READ|GENERIC_WRITE, TRUE, 0)) + { + WINE_ERR("Can't dup handles\n"); + /* no need to delete handles, we're exiting the program anyway */ + return FALSE; + } + + done = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info); + if (done) + { + data->hProcess = info.hProcess; + CloseHandle(info.hThread); + } + else printf_res(IDS_CMD_LAUNCH_FAILED, wine_dbgstr_w(cmdLine)); + + /* we no longer need the handles passed to the child for the console */ + CloseHandle(startup.hStdInput); + CloseHandle(startup.hStdOutput); + CloseHandle(startup.hStdError); + + return done; +} + /****************************************************************** * WINECON_Init * @@ -587,7 +634,7 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data) */ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appname, enum init_return (*backend)(struct inner_data*), - INT nCmdShow) + INT nCmdShow, WCHAR *cmdline) { struct condrv_input_info_params input_params; OBJECT_ATTRIBUTES attr = {sizeof(attr)}; @@ -708,7 +755,9 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna lstrlenW(appname) * sizeof(WCHAR), NULL, 0, NULL, NULL); if (!ret) goto error; + if (cmdline && !WINECON_Spawn(data, cmdline)) goto error; return data; + case init_failed: break; } @@ -720,52 +769,6 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna return NULL; } -/****************************************************************** - * WINECON_Spawn - * - * Spawn the child process when invoked with wineconsole foo bar - */ -static int WINECON_Spawn(struct inner_data* data, LPWSTR cmdLine) -{ - PROCESS_INFORMATION info; - STARTUPINFOW startup; - BOOL done; - - /* we're in the case wineconsole <exe> <options>... spawn the new process */ - memset(&startup, 0, sizeof(startup)); - startup.cb = sizeof(startup); - startup.dwFlags = STARTF_USESTDHANDLES; - - /* the attributes of wineconsole's handles are not adequate for inheritance, so - * get them with the correct attributes before process creation - */ - if (!DuplicateHandle(GetCurrentProcess(), data->hConIn, GetCurrentProcess(), - &startup.hStdInput, GENERIC_READ|GENERIC_WRITE|SYNCHRONIZE, TRUE, 0) || - !DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), - &startup.hStdOutput, GENERIC_READ|GENERIC_WRITE, TRUE, 0) || - !DuplicateHandle(GetCurrentProcess(), data->hConOut, GetCurrentProcess(), - &startup.hStdError, GENERIC_READ|GENERIC_WRITE, TRUE, 0)) - { - WINE_ERR("Can't dup handles\n"); - /* no need to delete handles, we're exiting the program anyway */ - return 1; - } - - done = CreateProcessW(NULL, cmdLine, NULL, NULL, TRUE, 0L, NULL, NULL, &startup, &info); - if (done) - { - data->hProcess = info.hProcess; - CloseHandle(info.hThread); - } - - /* we no longer need the handles passed to the child for the console */ - CloseHandle(startup.hStdInput); - CloseHandle(startup.hStdOutput); - CloseHandle(startup.hStdError); - - return !done; -} - struct wc_init { LPCSTR ptr; enum {from_event, from_process_name} mode; @@ -859,7 +862,7 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh { case from_event: /* case of wineconsole <evt>, signal process that created us that we're up and running */ - if (!(data = WINECON_Init(hInst, 0, NULL, wci.backend, nCmdShow))) return 1; + if (!(data = WINECON_Init(hInst, 0, NULL, wci.backend, nCmdShow, NULL))) return 1; ret = !SetEvent(wci.event); if (ret != 0) WINE_ERR("SetEvent failed.\n"); break; @@ -876,19 +879,9 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh MultiByteToWideChar(CP_ACP, 0, wci.ptr, -1, buffer, len); - if (!(data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend, nCmdShow))) - { - HeapFree(GetProcessHeap(), 0, buffer); - return 1; - } - ret = WINECON_Spawn(data, buffer); + data = WINECON_Init(hInst, GetCurrentProcessId(), buffer, wci.backend, nCmdShow, buffer); HeapFree(GetProcessHeap(), 0, buffer); - if (ret != 0) - { - WINECON_Delete(data); - printf_res(IDS_CMD_LAUNCH_FAILED, wine_dbgstr_a(wci.ptr)); - return ret; - } + if (!data) return 1; } break; default:
1
0
0
0
Jacek Caban : wineconsole: Use renderer handle instead of hConIn where possible.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: 78831ae9d044ffb824e72cb8952f3eb25140c7c9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=78831ae9d044ffb824e72cb8…
Author: Jacek Caban <jacek(a)codeweavers.com> Date: Thu Jul 30 17:15:08 2020 +0200 wineconsole: Use renderer handle instead of hConIn where possible. Signed-off-by: Jacek Caban <jacek(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- programs/wineconsole/curses.c | 4 ++-- programs/wineconsole/user.c | 10 +++++----- programs/wineconsole/wineconsole.c | 16 ++++++++-------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/programs/wineconsole/curses.c b/programs/wineconsole/curses.c index 3f56bdb0ca..3ddd22387f 100644 --- a/programs/wineconsole/curses.c +++ b/programs/wineconsole/curses.c @@ -339,7 +339,7 @@ static void WCCURSES_SetTitle(const struct inner_data* data) { WCHAR wbuf[256]; - if (WINECON_GetConsoleTitle(data->hConIn, wbuf, ARRAY_SIZE(wbuf))) + if (WINECON_GetConsoleTitle(data->console, wbuf, ARRAY_SIZE(wbuf))) { char buffer[256]; @@ -965,7 +965,7 @@ static DWORD CALLBACK input_thread( void *arg ) else numEvent = WCCURSES_FillSimpleChar(ir, inchar); - if (numEvent) WriteConsoleInputW(data->hConIn, ir, numEvent, &n); + if (numEvent) WriteConsoleInputW(data->console, ir, numEvent, &n); } LeaveCriticalSection(&PRIVATE(data)->lock); } diff --git a/programs/wineconsole/user.c b/programs/wineconsole/user.c index 4476845154..bbaffd3c2a 100644 --- a/programs/wineconsole/user.c +++ b/programs/wineconsole/user.c @@ -267,7 +267,7 @@ static void WCUSER_SetTitle(const struct inner_data* data) { WCHAR buffer[256]; - if (WINECON_GetConsoleTitle(data->hConIn, buffer, sizeof(buffer))) + if (WINECON_GetConsoleTitle(data->console, buffer, sizeof(buffer))) SetWindowTextW(data->hWnd, buffer); } @@ -738,7 +738,7 @@ static void WCUSER_PasteFromClipboard(struct inner_data* data) ir[1] = ir[0]; ir[1].Event.KeyEvent.bKeyDown = FALSE; - WriteConsoleInputW(data->hConIn, ir, 2, &n); + WriteConsoleInputW(data->console, ir, 2, &n); } GlobalUnlock(h); } @@ -1052,7 +1052,7 @@ static void WCUSER_GenerateKeyInputRecord(struct inner_data* data, BOOL down, ir.Event.KeyEvent.uChar.UnicodeChar = last; /* FIXME: HACKY... and buggy because it should be a stack, not a single value */ if (!down) last = 0; - WriteConsoleInputW(data->hConIn, &ir, 1, &n); + WriteConsoleInputW(data->console, &ir, 1, &n); } /****************************************************************** @@ -1068,7 +1068,7 @@ static void WCUSER_GenerateMouseInputRecord(struct inner_data* data, COORD c, DWORD mode, n; /* MOUSE_EVENTs shouldn't be sent unless ENABLE_MOUSE_INPUT is active */ - if (!GetConsoleMode(data->hConIn, &mode) || !(mode & ENABLE_MOUSE_INPUT)) + if (!GetConsoleMode(data->console, &mode) || !(mode & ENABLE_MOUSE_INPUT)) return; ir.EventType = MOUSE_EVENT; @@ -1083,7 +1083,7 @@ static void WCUSER_GenerateMouseInputRecord(struct inner_data* data, COORD c, ir.Event.MouseEvent.dwControlKeyState = WCUSER_GetCtrlKeyState(keyState); ir.Event.MouseEvent.dwEventFlags = event; - WriteConsoleInputW(data->hConIn, &ir, 1, &n); + WriteConsoleInputW(data->console, &ir, 1, &n); } /****************************************************************** diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index a61aad5293..8752ec6b13 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -374,17 +374,17 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf if (data->curcfg.history_size != cfg->history_size) { data->curcfg.history_size = cfg->history_size; - WINECON_SetHistorySize(data->hConIn, cfg->history_size); + WINECON_SetHistorySize(data->console, cfg->history_size); } if (data->curcfg.history_nodup != cfg->history_nodup) { data->curcfg.history_nodup = cfg->history_nodup; - WINECON_SetHistoryMode(data->hConIn, cfg->history_nodup); + WINECON_SetHistoryMode(data->console, cfg->history_nodup); } if (data->curcfg.insert_mode != cfg->insert_mode) { data->curcfg.insert_mode = cfg->insert_mode; - WINECON_SetInsertMode(data->hConIn, cfg->insert_mode); + WINECON_SetInsertMode(data->console, cfg->insert_mode); } data->curcfg.menu_mask = cfg->menu_mask; data->curcfg.quick_edit = cfg->quick_edit; @@ -511,7 +511,7 @@ void WINECON_SetConfig(struct inner_data* data, const struct config_data* cf if (data->curcfg.edition_mode != cfg->edition_mode) { data->curcfg.edition_mode = cfg->edition_mode; - WINECON_SetEditionMode(data->hConIn, cfg->edition_mode); + WINECON_SetEditionMode(data->console, cfg->edition_mode); } /* we now need to gather all events we got from the operations above, * in order to get data correctly updated @@ -553,14 +553,14 @@ static BOOL WINECON_GetServerConfig(struct inner_data* data) struct condrv_output_info output_info; DWORD mode; - if (!DeviceIoControl(data->hConIn, IOCTL_CONDRV_GET_INPUT_INFO, NULL, 0, + if (!DeviceIoControl(data->console, IOCTL_CONDRV_GET_INPUT_INFO, NULL, 0, &input_info, sizeof(input_info), NULL, NULL)) return FALSE; data->curcfg.history_size = input_info.history_size; data->curcfg.history_nodup = input_info.history_mode; data->curcfg.edition_mode = input_info.edition_mode; - GetConsoleMode(data->hConIn, &mode); + GetConsoleMode(data->console, &mode); data->curcfg.insert_mode = (mode & (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS)) == (ENABLE_INSERT_MODE|ENABLE_EXTENDED_FLAGS); @@ -700,11 +700,11 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna memset(&input_params, 0, sizeof(input_params)); input_params.mask = SET_CONSOLE_INPUT_INFO_WIN; input_params.info.win = condrv_handle(data->hWnd); - ret = DeviceIoControl(data->hConIn, IOCTL_CONDRV_SET_INPUT_INFO, &input_params, sizeof(input_params), + ret = DeviceIoControl(data->console, IOCTL_CONDRV_SET_INPUT_INFO, &input_params, sizeof(input_params), NULL, 0, NULL, NULL); if (!ret) goto error; - ret = DeviceIoControl(data->hConIn, IOCTL_CONDRV_SET_TITLE, (void *)appname, + ret = DeviceIoControl(data->console, IOCTL_CONDRV_SET_TITLE, (void *)appname, lstrlenW(appname) * sizeof(WCHAR), NULL, 0, NULL, NULL); if (!ret) goto error;
1
0
0
0
Zhiyi Zhang : winex11.drv: Remove the old display settings handler interface.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: b45c04f4c352ef81df5312684008839f4eeee03d URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b45c04f4c352ef81df531268…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Mon Jul 27 16:02:17 2020 +0800 winex11.drv: Remove the old display settings handler interface. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/settings.c | 228 -------------------------------------------- dlls/winex11.drv/x11drv.h | 16 ---- 2 files changed, 244 deletions(-) Diff:
https://source.winehq.org/git/wine.git/?a=commitdiff;h=b45c04f4c352ef81df53…
1
0
0
0
Zhiyi Zhang : winex11.drv: Migrate NoRes display settings handler to a new interface.
by Alexandre Julliard
30 Jul '20
30 Jul '20
Module: wine Branch: master Commit: 9c99d9bceba34559a32f1e5906a6fcbcf91b0004 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9c99d9bceba34559a32f1e59…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Mon Jul 27 16:01:55 2020 +0800 winex11.drv: Migrate NoRes display settings handler to a new interface. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winex11.drv/settings.c | 93 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/dlls/winex11.drv/settings.c b/dlls/winex11.drv/settings.c index 7c7d950718..57b7faba8e 100644 --- a/dlls/winex11.drv/settings.c +++ b/dlls/winex11.drv/settings.c @@ -169,30 +169,99 @@ void X11DRV_Settings_SetHandler(const struct x11drv_settings_handler *new_handle * Default handlers if resolution switching is not enabled * */ -static int X11DRV_nores_GetCurrentMode(void) +static BOOL nores_get_id(const WCHAR *device_name, ULONG_PTR *id) { - return 0; + WCHAR primary_adapter[CCHDEVICENAME]; + + if (!get_primary_adapter( primary_adapter )) + return FALSE; + + *id = !lstrcmpiW( device_name, primary_adapter ) ? 1 : 0; + return TRUE; +} + +static BOOL nores_get_modes(ULONG_PTR id, DWORD flags, DEVMODEW **new_modes, UINT *mode_count) +{ + RECT primary = get_host_primary_monitor_rect(); + DEVMODEW *modes; + + modes = heap_calloc(1, sizeof(*modes)); + if (!modes) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + modes[0].dmSize = sizeof(*modes); + modes[0].dmDriverExtra = 0; + modes[0].dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | + DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY; + modes[0].u1.s2.dmDisplayOrientation = DMDO_DEFAULT; + modes[0].dmBitsPerPel = screen_bpp; + modes[0].dmPelsWidth = primary.right; + modes[0].dmPelsHeight = primary.bottom; + modes[0].u2.dmDisplayFlags = 0; + modes[0].dmDisplayFrequency = 60; + + *new_modes = modes; + *mode_count = 1; + return TRUE; } -static LONG X11DRV_nores_SetCurrentMode(int mode) +static void nores_free_modes(DEVMODEW *modes) { - if (mode == 0) return DISP_CHANGE_SUCCESSFUL; - TRACE("Ignoring mode change request mode=%d\n", mode); - return DISP_CHANGE_FAILED; + heap_free(modes); +} + +static BOOL nores_get_current_mode(ULONG_PTR id, DEVMODEW *mode) +{ + RECT primary = get_host_primary_monitor_rect(); + + mode->dmFields = DM_DISPLAYORIENTATION | DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | + DM_DISPLAYFLAGS | DM_DISPLAYFREQUENCY | DM_POSITION; + mode->u1.s2.dmDisplayOrientation = DMDO_DEFAULT; + mode->u2.dmDisplayFlags = 0; + mode->u1.s2.dmPosition.x = 0; + mode->u1.s2.dmPosition.y = 0; + + if (id != 1) + { + FIXME("Non-primary adapters are unsupported.\n"); + mode->dmBitsPerPel = 0; + mode->dmPelsWidth = 0; + mode->dmPelsHeight = 0; + mode->dmDisplayFrequency = 0; + return TRUE; + } + + mode->dmBitsPerPel = screen_bpp; + mode->dmPelsWidth = primary.right; + mode->dmPelsHeight = primary.bottom; + mode->dmDisplayFrequency = 60; + return TRUE; +} + +static LONG nores_set_current_mode(ULONG_PTR id, DEVMODEW *mode) +{ + WARN("NoRes settings handler, ignoring mode change request.\n"); + return DISP_CHANGE_SUCCESSFUL; } /* default handler only gets the current X desktop resolution */ void X11DRV_Settings_Init(void) { - RECT primary = get_host_primary_monitor_rect(); + struct x11drv_settings_handler nores_handler; depths = screen_bpp == 32 ? depths_32 : depths_24; - X11DRV_Settings_SetHandlers("NoRes", - X11DRV_nores_GetCurrentMode, - X11DRV_nores_SetCurrentMode, - 1, 0); - X11DRV_Settings_AddOneMode( primary.right - primary.left, primary.bottom - primary.top, 0, 60); + nores_handler.name = "NoRes"; + nores_handler.priority = 0; + nores_handler.get_id = nores_get_id; + nores_handler.get_modes = nores_get_modes; + nores_handler.free_modes = nores_free_modes; + nores_handler.get_current_mode = nores_get_current_mode; + nores_handler.set_current_mode = nores_set_current_mode; + X11DRV_Settings_SetHandler(&nores_handler); } static BOOL get_display_device_reg_key(const WCHAR *device_name, WCHAR *key, unsigned len)
1
0
0
0
← Newer
1
2
3
4
...
83
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Results per page:
10
25
50
100
200