Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
54e11701
Commit
54e11701
authored
Sep 21, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Use conhost to handle Unix consoles.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0957f930
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
12 deletions
+77
-12
console.c
dlls/kernelbase/console.c
+54
-6
env.c
dlls/ntdll/unix/env.c
+23
-6
No files found.
dlls/kernelbase/console.c
View file @
54e11701
...
...
@@ -1656,11 +1656,18 @@ static HANDLE create_pseudo_console( COORD size, HANDLE input, HANDLE output, HA
si
.
StartupInfo
.
hStdError
=
output
;
si
.
StartupInfo
.
dwFlags
=
STARTF_USESTDHANDLES
;
swprintf
(
conhost_path
,
ARRAY_SIZE
(
conhost_path
),
L"%s
\\
conhost.exe"
,
system_dir
);
swprintf
(
cmd
,
ARRAY_SIZE
(
cmd
),
L"
\"
%s
\"
--headless %s--width %u --height %u --signal 0x%x --server 0x%x"
,
conhost_path
,
(
flags
&
PSEUDOCONSOLE_INHERIT_CURSOR
)
?
L"--inheritcursor "
:
L""
,
size
.
X
,
size
.
Y
,
signal
,
server
);
if
(
signal
)
{
swprintf
(
cmd
,
ARRAY_SIZE
(
cmd
),
L"
\"
%s
\"
--headless %s--width %u --height %u --signal 0x%x --server 0x%x"
,
conhost_path
,
(
flags
&
PSEUDOCONSOLE_INHERIT_CURSOR
)
?
L"--inheritcursor "
:
L""
,
size
.
X
,
size
.
Y
,
signal
,
server
);
}
else
{
swprintf
(
cmd
,
ARRAY_SIZE
(
cmd
),
L"
\"
%s
\"
--unix --width %u --height %u --server 0x%x"
,
conhost_path
,
size
.
X
,
size
.
Y
,
server
);
}
Wow64DisableWow64FsRedirection
(
&
redir
);
res
=
CreateProcessW
(
conhost_path
,
cmd
,
NULL
,
NULL
,
TRUE
,
DETACHED_PROCESS
,
NULL
,
NULL
,
&
si
.
StartupInfo
,
&
pi
);
...
...
@@ -1745,11 +1752,52 @@ HRESULT WINAPI ResizePseudoConsole( HPCON handle, COORD size )
return
E_NOTIMPL
;
}
static
BOOL
is_tty_handle
(
HANDLE
handle
)
{
return
((
UINT_PTR
)
handle
&
3
)
==
1
;
}
void
init_console
(
void
)
{
RTL_USER_PROCESS_PARAMETERS
*
params
=
RtlGetCurrentPeb
()
->
ProcessParameters
;
if
(
params
->
ConsoleHandle
==
CONSOLE_HANDLE_ALLOC
)
if
(
params
->
ConsoleHandle
==
CONSOLE_HANDLE_SHELL
)
{
HANDLE
tty_in
=
NULL
,
tty_out
=
NULL
,
process
=
NULL
;
COORD
size
;
if
(
is_tty_handle
(
params
->
hStdInput
))
{
tty_in
=
params
->
hStdInput
;
params
->
hStdInput
=
NULL
;
}
if
(
is_tty_handle
(
params
->
hStdOutput
))
{
tty_out
=
params
->
hStdOutput
;
params
->
hStdOutput
=
NULL
;
}
if
(
is_tty_handle
(
params
->
hStdError
))
{
if
(
tty_out
)
CloseHandle
(
params
->
hStdError
);
else
tty_out
=
params
->
hStdError
;
params
->
hStdError
=
NULL
;
}
size
.
X
=
params
->
dwXCountChars
;
size
.
Y
=
params
->
dwYCountChars
;
TRACE
(
"creating unix console (size %u %u)
\n
"
,
size
.
X
,
size
.
Y
);
params
->
ConsoleHandle
=
create_pseudo_console
(
size
,
tty_in
,
tty_out
,
NULL
,
0
,
&
process
);
CloseHandle
(
process
);
CloseHandle
(
tty_in
);
CloseHandle
(
tty_out
);
if
(
params
->
ConsoleHandle
&&
create_console_connection
(
params
->
ConsoleHandle
))
{
init_console_std_handles
(
FALSE
);
console_flags
=
0
;
}
}
else
if
(
params
->
ConsoleHandle
==
CONSOLE_HANDLE_ALLOC
)
{
HMODULE
mod
=
GetModuleHandleW
(
NULL
);
params
->
ConsoleHandle
=
NULL
;
...
...
dlls/ntdll/unix/env.c
View file @
54e11701
...
...
@@ -1156,12 +1156,29 @@ NTSTATUS CDECL get_dynamic_environment( WCHAR *env, SIZE_T *size )
void
CDECL
get_initial_console
(
RTL_USER_PROCESS_PARAMETERS
*
params
)
{
int
output_fd
=
-
1
;
if
(
isatty
(
0
)
||
isatty
(
1
)
||
isatty
(
2
))
params
->
ConsoleHandle
=
CONSOLE_HANDLE_SHELL
;
if
(
!
isatty
(
0
))
wine_server_fd_to_handle
(
0
,
GENERIC_READ
|
SYNCHRONIZE
,
OBJ_INHERIT
,
&
params
->
hStdInput
);
if
(
!
isatty
(
2
))
wine_server_fd_to_handle
(
2
,
GENERIC_WRITE
|
SYNCHRONIZE
,
OBJ_INHERIT
,
&
params
->
hStdError
);
else
output_fd
=
2
;
if
(
!
isatty
(
1
))
wine_server_fd_to_handle
(
1
,
GENERIC_WRITE
|
SYNCHRONIZE
,
OBJ_INHERIT
,
&
params
->
hStdOutput
);
else
output_fd
=
1
;
wine_server_fd_to_handle
(
0
,
GENERIC_READ
|
SYNCHRONIZE
,
OBJ_INHERIT
,
&
params
->
hStdInput
);
wine_server_fd_to_handle
(
1
,
GENERIC_WRITE
|
SYNCHRONIZE
,
OBJ_INHERIT
,
&
params
->
hStdOutput
);
wine_server_fd_to_handle
(
2
,
GENERIC_WRITE
|
SYNCHRONIZE
,
OBJ_INHERIT
,
&
params
->
hStdError
);
/* mark tty handles for kernelbase, see init_console */
if
(
params
->
hStdInput
&&
isatty
(
0
))
{
params
->
ConsoleHandle
=
CONSOLE_HANDLE_SHELL
;
params
->
hStdInput
=
(
HANDLE
)((
UINT_PTR
)
params
->
hStdInput
|
1
);
}
if
(
params
->
hStdError
&&
isatty
(
2
))
{
params
->
ConsoleHandle
=
CONSOLE_HANDLE_SHELL
;
params
->
hStdError
=
(
HANDLE
)((
UINT_PTR
)
params
->
hStdError
|
1
);
output_fd
=
2
;
}
if
(
params
->
hStdOutput
&&
isatty
(
1
))
{
params
->
ConsoleHandle
=
CONSOLE_HANDLE_SHELL
;
params
->
hStdOutput
=
(
HANDLE
)((
UINT_PTR
)
params
->
hStdOutput
|
1
);
output_fd
=
1
;
}
if
(
output_fd
!=
-
1
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment