Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
e7550069
Commit
e7550069
authored
Jul 30, 2020
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernelbase: Lock console critical section when changing current console.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
fa2b372e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
1 deletion
+14
-1
console.c
dlls/kernelbase/console.c
+14
-1
No files found.
dlls/kernelbase/console.c
View file @
e7550069
...
@@ -178,6 +178,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid )
...
@@ -178,6 +178,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid )
TRACE
(
"(%x)
\n
"
,
pid
);
TRACE
(
"(%x)
\n
"
,
pid
);
RtlEnterCriticalSection
(
&
console_section
);
SERVER_START_REQ
(
attach_console
)
SERVER_START_REQ
(
attach_console
)
{
{
req
->
pid
=
pid
;
req
->
pid
=
pid
;
...
@@ -189,6 +191,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid )
...
@@ -189,6 +191,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH AttachConsole( DWORD pid )
}
}
}
}
SERVER_END_REQ
;
SERVER_END_REQ
;
RtlLeaveCriticalSection
(
&
console_section
);
return
ret
;
return
ret
;
}
}
...
@@ -211,11 +215,14 @@ BOOL WINAPI AllocConsole(void)
...
@@ -211,11 +215,14 @@ BOOL WINAPI AllocConsole(void)
TRACE
(
"()
\n
"
);
TRACE
(
"()
\n
"
);
RtlEnterCriticalSection
(
&
console_section
);
std_in
=
CreateFileW
(
L"CONIN$"
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
std_in
=
CreateFileW
(
L"CONIN$"
,
GENERIC_READ
|
GENERIC_WRITE
|
SYNCHRONIZE
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
0
);
if
(
GetConsoleMode
(
std_in
,
&
mode
))
if
(
GetConsoleMode
(
std_in
,
&
mode
))
{
{
/* we already have a console opened on this process, don't create a new one */
/* we already have a console opened on this process, don't create a new one */
CloseHandle
(
std_in
);
CloseHandle
(
std_in
);
RtlLeaveCriticalSection
(
&
console_section
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -248,7 +255,7 @@ BOOL WINAPI AllocConsole(void)
...
@@ -248,7 +255,7 @@ BOOL WINAPI AllocConsole(void)
console_si
.
lpTitle
=
buffer
;
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
);
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
)))
if
((
ret
=
CreateProcessW
(
NULL
,
cmd
,
NULL
,
NULL
,
TRUE
,
DETACHED_PROCESS
,
NULL
,
NULL
,
&
console_si
,
&
pi
)))
...
@@ -286,6 +293,7 @@ BOOL WINAPI AllocConsole(void)
...
@@ -286,6 +293,7 @@ BOOL WINAPI AllocConsole(void)
SetStdHandle
(
STD_INPUT_HANDLE
,
std_in
);
SetStdHandle
(
STD_INPUT_HANDLE
,
std_in
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
std_out
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
std_out
);
SetStdHandle
(
STD_ERROR_HANDLE
,
std_err
);
SetStdHandle
(
STD_ERROR_HANDLE
,
std_err
);
RtlLeaveCriticalSection
(
&
console_section
);
SetLastError
(
ERROR_SUCCESS
);
SetLastError
(
ERROR_SUCCESS
);
return
TRUE
;
return
TRUE
;
...
@@ -295,6 +303,7 @@ error:
...
@@ -295,6 +303,7 @@ error:
if
(
std_out
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
std_out
);
if
(
std_out
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
std_out
);
if
(
std_err
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
std_err
);
if
(
std_err
!=
INVALID_HANDLE_VALUE
)
CloseHandle
(
std_err
);
FreeConsole
();
FreeConsole
();
RtlLeaveCriticalSection
(
&
console_section
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -468,12 +477,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
...
@@ -468,12 +477,16 @@ BOOL WINAPI DECLSPEC_HOTPATCH FreeConsole(void)
HANDLE
event
;
HANDLE
event
;
BOOL
ret
;
BOOL
ret
;
RtlEnterCriticalSection
(
&
console_section
);
SERVER_START_REQ
(
free_console
)
SERVER_START_REQ
(
free_console
)
{
{
ret
=
!
wine_server_call_err
(
req
);
ret
=
!
wine_server_call_err
(
req
);
}
}
SERVER_END_REQ
;
SERVER_END_REQ
;
if
((
event
=
InterlockedExchangePointer
(
&
console_wait_event
,
NULL
)))
NtClose
(
event
);
if
((
event
=
InterlockedExchangePointer
(
&
console_wait_event
,
NULL
)))
NtClose
(
event
);
RtlLeaveCriticalSection
(
&
console_section
);
return
ret
;
return
ret
;
}
}
...
...
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