wineconsole: Use NtCreateFile to create renderer object.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
c4789b08f3
commit
919a94aa95
|
@ -46,6 +46,13 @@
|
||||||
/* console handle type */
|
/* console handle type */
|
||||||
typedef unsigned int condrv_handle_t;
|
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 */
|
/* structure for console char/attribute info */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -637,10 +637,18 @@ static struct inner_data* WINECON_Init(HINSTANCE hInst, DWORD pid, LPCWSTR appna
|
||||||
enum init_return (*backend)(struct inner_data*),
|
enum init_return (*backend)(struct inner_data*),
|
||||||
INT nCmdShow)
|
INT nCmdShow)
|
||||||
{
|
{
|
||||||
|
OBJECT_ATTRIBUTES attr = {sizeof(attr)};
|
||||||
struct inner_data* data = NULL;
|
struct inner_data* data = NULL;
|
||||||
DWORD ret;
|
DWORD ret;
|
||||||
struct config_data cfg;
|
struct config_data cfg;
|
||||||
STARTUPINFOW si;
|
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));
|
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
|
||||||
if (!data) return 0;
|
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 );
|
ret = !wine_server_call_err( req );
|
||||||
data->hConIn = wine_server_ptr_handle( reply->handle_in );
|
data->hConIn = wine_server_ptr_handle( reply->handle_in );
|
||||||
data->hSynchro = wine_server_ptr_handle( reply->event );
|
|
||||||
}
|
}
|
||||||
SERVER_END_REQ;
|
SERVER_END_REQ;
|
||||||
if (!ret) goto error;
|
if (!ret) goto error;
|
||||||
WINE_TRACE("using hConIn %p, hSynchro event %p\n", data->hConIn, data->hSynchro);
|
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)
|
SERVER_START_REQ(create_console_output)
|
||||||
{
|
{
|
||||||
req->handle_in = wine_server_obj_handle( data->hConIn );
|
req->handle_in = wine_server_obj_handle( data->hConIn );
|
||||||
|
|
|
@ -1847,7 +1847,6 @@ DECL_HANDLER(alloc_console)
|
||||||
obj_handle_t in = 0;
|
obj_handle_t in = 0;
|
||||||
obj_handle_t evt = 0;
|
obj_handle_t evt = 0;
|
||||||
struct process *process;
|
struct process *process;
|
||||||
struct thread *renderer;
|
|
||||||
struct console_input *console;
|
struct console_input *console;
|
||||||
int fd;
|
int fd;
|
||||||
int attach = 0;
|
int attach = 0;
|
||||||
|
@ -1865,8 +1864,7 @@ DECL_HANDLER(alloc_console)
|
||||||
switch (req->pid)
|
switch (req->pid)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
/* renderer is current, console to be attached to parent process */
|
/* console to be attached to parent process */
|
||||||
renderer = current;
|
|
||||||
if (!(process = get_process_from_id( current->process->parent_id )))
|
if (!(process = get_process_from_id( current->process->parent_id )))
|
||||||
{
|
{
|
||||||
if (fd != -1) close( fd );
|
if (fd != -1) close( fd );
|
||||||
|
@ -1876,15 +1874,13 @@ DECL_HANDLER(alloc_console)
|
||||||
attach = 1;
|
attach = 1;
|
||||||
break;
|
break;
|
||||||
case 0xffffffff:
|
case 0xffffffff:
|
||||||
/* no renderer, console to be attached to current process */
|
/* console to be attached to current process */
|
||||||
renderer = NULL;
|
|
||||||
process = current->process;
|
process = current->process;
|
||||||
grab_object( process );
|
grab_object( process );
|
||||||
attach = 1;
|
attach = 1;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* renderer is current, console to be attached to req->pid */
|
/* console to be attached to req->pid */
|
||||||
renderer = current;
|
|
||||||
if (!(process = get_process_from_id( req->pid )))
|
if (!(process = get_process_from_id( req->pid )))
|
||||||
{
|
{
|
||||||
if (fd != -1) close( fd );
|
if (fd != -1) close( fd );
|
||||||
|
@ -1899,7 +1895,7 @@ DECL_HANDLER(alloc_console)
|
||||||
goto the_end;
|
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 )))
|
if ((in = alloc_handle( current->process, console, req->access, req->attributes )))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue