Module: wine Branch: master Commit: 919a94aa954f543b49728f1750ea23aab21cc41c URL: https://source.winehq.org/git/wine.git/?a=commit;h=919a94aa954f543b49728f175...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Jul 16 17:50:33 2020 +0200
wineconsole: Use NtCreateFile to create renderer object.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
include/wine/condrv.h | 7 +++++++ programs/wineconsole/wineconsole.c | 20 +++++++++++++++++++- server/console.c | 12 ++++-------- 3 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/include/wine/condrv.h b/include/wine/condrv.h index 80613d6b7f..bf00262d70 100644 --- a/include/wine/condrv.h +++ b/include/wine/condrv.h @@ -46,6 +46,13 @@ /* console handle type */ typedef unsigned int condrv_handle_t;
+/* convert an object handle to a server handle */ +static inline condrv_handle_t condrv_handle( HANDLE handle ) +{ + if ((int)(INT_PTR)handle != (INT_PTR)handle) return 0xfffffff0; /* some invalid handle */ + return (INT_PTR)handle; +} + /* structure for console char/attribute info */ typedef struct { diff --git a/programs/wineconsole/wineconsole.c b/programs/wineconsole/wineconsole.c index 5040800946..4e0309f18b 100644 --- a/programs/wineconsole/wineconsole.c +++ b/programs/wineconsole/wineconsole.c @@ -637,10 +637,18 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna enum init_return (*backend)(struct inner_data*), INT nCmdShow) { + OBJECT_ATTRIBUTES attr = {sizeof(attr)}; struct inner_data* data = NULL; DWORD ret; struct config_data cfg; STARTUPINFOW si; + UNICODE_STRING string; + IO_STATUS_BLOCK io; + condrv_handle_t h; + NTSTATUS status; + + static const WCHAR renderer_pathW[] = {'\','D','e','v','i','c','e','\','C','o','n','D','r','v', + '\','R','e','n','d','e','r','e','r',0};
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data)); if (!data) return 0; @@ -682,12 +690,22 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
ret = !wine_server_call_err( req ); data->hConIn = wine_server_ptr_handle( reply->handle_in ); - data->hSynchro = wine_server_ptr_handle( reply->event ); } SERVER_END_REQ; if (!ret) goto error; WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSynchro);
+ RtlInitUnicodeString(&string, renderer_pathW); + attr.ObjectName = &string; + status = NtCreateFile(&data->hSynchro, FILE_READ_DATA | FILE_WRITE_DATA | FILE_WRITE_PROPERTIES + | FILE_READ_PROPERTIES | SYNCHRONIZE, &attr, &io, NULL, FILE_ATTRIBUTE_NORMAL, + 0, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0); + if (status) goto error; + + h = condrv_handle(data->hConIn); + if (!DeviceIoControl(data->hSynchro, 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 ); diff --git a/server/console.c b/server/console.c index f56d4ba380..4ff433be4e 100644 --- a/server/console.c +++ b/server/console.c @@ -1847,7 +1847,6 @@ DECL_HANDLER(alloc_console) obj_handle_t in = 0; obj_handle_t evt = 0; struct process *process; - struct thread *renderer; struct console_input *console; int fd; int attach = 0; @@ -1865,8 +1864,7 @@ DECL_HANDLER(alloc_console) switch (req->pid) { case 0: - /* renderer is current, console to be attached to parent process */ - renderer = current; + /* console to be attached to parent process */ if (!(process = get_process_from_id( current->process->parent_id ))) { if (fd != -1) close( fd ); @@ -1876,15 +1874,13 @@ DECL_HANDLER(alloc_console) attach = 1; break; case 0xffffffff: - /* no renderer, console to be attached to current process */ - renderer = NULL; + /* console to be attached to current process */ process = current->process; grab_object( process ); attach = 1; break; default: - /* renderer is current, console to be attached to req->pid */ - renderer = current; + /* console to be attached to req->pid */ if (!(process = get_process_from_id( req->pid ))) { if (fd != -1) close( fd ); @@ -1899,7 +1895,7 @@ DECL_HANDLER(alloc_console) goto the_end; }
- if ((console = (struct console_input*)create_console_input( renderer, fd ))) + if ((console = (struct console_input*)create_console_input( NULL, fd ))) { if ((in = alloc_handle( current->process, console, req->access, req->attributes ))) {