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
f1e4c541
Commit
f1e4c541
authored
Jul 15, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add a helper function to grow the stack on guard page faults.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
432d5041
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
18 deletions
+28
-18
virtual.c
dlls/ntdll/unix/virtual.c
+28
-18
No files found.
dlls/ntdll/unix/virtual.c
View file @
f1e4c541
...
@@ -2845,6 +2845,33 @@ void virtual_map_user_shared_data(void)
...
@@ -2845,6 +2845,33 @@ void virtual_map_user_shared_data(void)
/***********************************************************************
/***********************************************************************
* grow_thread_stack
*/
static
NTSTATUS
grow_thread_stack
(
char
*
page
)
{
NTSTATUS
ret
=
0
;
size_t
guaranteed
=
max
(
NtCurrentTeb
()
->
GuaranteedStackBytes
,
page_size
*
(
is_win64
?
2
:
1
)
);
set_page_vprot_bits
(
page
,
page_size
,
0
,
VPROT_GUARD
);
mprotect_range
(
page
,
page_size
,
0
,
0
);
if
(
page
>=
(
char
*
)
NtCurrentTeb
()
->
DeallocationStack
+
page_size
+
guaranteed
)
{
set_page_vprot_bits
(
page
-
page_size
,
page_size
,
VPROT_COMMITTED
|
VPROT_GUARD
,
0
);
mprotect_range
(
page
-
page_size
,
page_size
,
0
,
0
);
}
else
/* inside guaranteed space -> overflow exception */
{
page
=
(
char
*
)
NtCurrentTeb
()
->
DeallocationStack
+
page_size
;
set_page_vprot_bits
(
page
,
guaranteed
,
VPROT_COMMITTED
,
VPROT_GUARD
);
mprotect_range
(
page
,
guaranteed
,
0
,
0
);
ret
=
STATUS_STACK_OVERFLOW
;
}
NtCurrentTeb
()
->
Tib
.
StackLimit
=
page
;
return
ret
;
}
/***********************************************************************
* virtual_handle_fault
* virtual_handle_fault
*/
*/
NTSTATUS
virtual_handle_fault
(
void
*
addr
,
DWORD
err
,
void
*
stack
)
NTSTATUS
virtual_handle_fault
(
void
*
addr
,
DWORD
err
,
void
*
stack
)
...
@@ -3045,24 +3072,7 @@ int virtual_handle_stack_fault( void *addr )
...
@@ -3045,24 +3072,7 @@ int virtual_handle_stack_fault( void *addr )
pthread_mutex_lock
(
&
virtual_mutex
);
/* no need for signal masking inside signal handler */
pthread_mutex_lock
(
&
virtual_mutex
);
/* no need for signal masking inside signal handler */
if
(
get_page_vprot
(
addr
)
&
VPROT_GUARD
)
if
(
get_page_vprot
(
addr
)
&
VPROT_GUARD
)
{
{
size_t
guaranteed
=
max
(
NtCurrentTeb
()
->
GuaranteedStackBytes
,
page_size
*
(
is_win64
?
2
:
1
)
);
ret
=
grow_thread_stack
(
ROUND_ADDR
(
addr
,
page_mask
))
?
-
1
:
1
;
char
*
page
=
ROUND_ADDR
(
addr
,
page_mask
);
set_page_vprot_bits
(
page
,
page_size
,
0
,
VPROT_GUARD
);
mprotect_range
(
page
,
page_size
,
0
,
0
);
if
(
page
>=
(
char
*
)
NtCurrentTeb
()
->
DeallocationStack
+
page_size
+
guaranteed
)
{
set_page_vprot_bits
(
page
-
page_size
,
page_size
,
VPROT_COMMITTED
|
VPROT_GUARD
,
0
);
mprotect_range
(
page
-
page_size
,
page_size
,
0
,
0
);
ret
=
1
;
}
else
/* inside guaranteed space -> overflow exception */
{
page
=
(
char
*
)
NtCurrentTeb
()
->
DeallocationStack
+
page_size
;
set_page_vprot_bits
(
page
,
guaranteed
,
VPROT_COMMITTED
,
VPROT_GUARD
);
mprotect_range
(
page
,
guaranteed
,
0
,
0
);
ret
=
-
1
;
}
NtCurrentTeb
()
->
Tib
.
StackLimit
=
page
;
}
}
pthread_mutex_unlock
(
&
virtual_mutex
);
pthread_mutex_unlock
(
&
virtual_mutex
);
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