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
f3dad37b
Commit
f3dad37b
authored
Dec 12, 2005
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TEB.StackLimit should not include the guard page.
parent
8a8a94ae
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
8 deletions
+11
-8
process.c
dlls/kernel/process.c
+3
-2
signal_i386.c
dlls/ntdll/signal_i386.c
+2
-2
thread.c
dlls/ntdll/thread.c
+5
-3
virtual.c
dlls/ntdll/virtual.c
+1
-1
No files found.
dlls/kernel/process.c
View file @
f3dad37b
...
@@ -978,7 +978,8 @@ static void *init_stack(void)
...
@@ -978,7 +978,8 @@ static void *init_stack(void)
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
NtCurrentTeb
()
->
Peb
->
ImageBaseAddress
);
IMAGE_NT_HEADERS
*
nt
=
RtlImageNtHeader
(
NtCurrentTeb
()
->
Peb
->
ImageBaseAddress
);
stack_size
=
max
(
nt
->
OptionalHeader
.
SizeOfStackReserve
,
nt
->
OptionalHeader
.
SizeOfStackCommit
);
stack_size
=
max
(
nt
->
OptionalHeader
.
SizeOfStackReserve
,
nt
->
OptionalHeader
.
SizeOfStackCommit
);
stack_size
=
(
stack_size
+
(
page_size
-
1
))
&
~
(
page_size
-
1
);
stack_size
+=
page_size
;
/* for the guard page */
stack_size
=
(
stack_size
+
0xffff
)
&
~
0xffff
;
/* round to 64K boundary */
if
(
stack_size
<
1024
*
1024
)
stack_size
=
1024
*
1024
;
/* Xlib needs a large stack */
if
(
stack_size
<
1024
*
1024
)
stack_size
=
1024
*
1024
;
/* Xlib needs a large stack */
if
(
!
(
base
=
VirtualAlloc
(
NULL
,
stack_size
,
MEM_COMMIT
,
PAGE_READWRITE
)))
if
(
!
(
base
=
VirtualAlloc
(
NULL
,
stack_size
,
MEM_COMMIT
,
PAGE_READWRITE
)))
...
@@ -990,7 +991,7 @@ static void *init_stack(void)
...
@@ -990,7 +991,7 @@ static void *init_stack(void)
/* note: limit is lower than base since the stack grows down */
/* note: limit is lower than base since the stack grows down */
NtCurrentTeb
()
->
DeallocationStack
=
base
;
NtCurrentTeb
()
->
DeallocationStack
=
base
;
NtCurrentTeb
()
->
Tib
.
StackBase
=
(
char
*
)
base
+
stack_size
;
NtCurrentTeb
()
->
Tib
.
StackBase
=
(
char
*
)
base
+
stack_size
;
NtCurrentTeb
()
->
Tib
.
StackLimit
=
bas
e
;
NtCurrentTeb
()
->
Tib
.
StackLimit
=
(
char
*
)
base
+
page_siz
e
;
/* setup guard page */
/* setup guard page */
VirtualProtect
(
base
,
1
,
PAGE_READWRITE
|
PAGE_GUARD
,
NULL
);
VirtualProtect
(
base
,
1
,
PAGE_READWRITE
|
PAGE_GUARD
,
NULL
);
...
...
dlls/ntdll/signal_i386.c
View file @
f3dad37b
...
@@ -830,10 +830,10 @@ static EXCEPTION_RECORD *setup_exception( SIGCONTEXT *sigcontext, raise_func fun
...
@@ -830,10 +830,10 @@ static EXCEPTION_RECORD *setup_exception( SIGCONTEXT *sigcontext, raise_func fun
}
}
if
(
stack
-
1
>
stack
||
/* check for overflow in subtraction */
if
(
stack
-
1
>
stack
||
/* check for overflow in subtraction */
(
char
*
)(
stack
-
1
)
<
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackLimit
+
4096
||
(
char
*
)(
stack
-
1
)
<
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackLimit
||
(
char
*
)
stack
>
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackBase
)
(
char
*
)
stack
>
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackBase
)
{
{
UINT
diff
=
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackLimit
+
4096
-
(
char
*
)
stack
;
UINT
diff
=
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackLimit
-
(
char
*
)
stack
;
if
(
diff
<
4096
)
if
(
diff
<
4096
)
{
{
ERR
(
"stack overflow %u bytes in thread %04lx eip %08lx esp %08lx stack %p-%p
\n
"
,
ERR
(
"stack overflow %u bytes in thread %04lx eip %08lx esp %08lx stack %p-%p
\n
"
,
...
...
dlls/ntdll/thread.c
View file @
f3dad37b
...
@@ -201,7 +201,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
...
@@ -201,7 +201,7 @@ static void start_thread( struct wine_pthread_thread_info *info )
PRTL_THREAD_START_ROUTINE
func
=
startup_info
->
entry_point
;
PRTL_THREAD_START_ROUTINE
func
=
startup_info
->
entry_point
;
void
*
arg
=
startup_info
->
entry_arg
;
void
*
arg
=
startup_info
->
entry_arg
;
struct
debug_info
debug_info
;
struct
debug_info
debug_info
;
SIZE_T
size
;
SIZE_T
size
,
page_size
=
getpagesize
()
;
debug_info
.
str_pos
=
debug_info
.
strings
;
debug_info
.
str_pos
=
debug_info
.
strings
;
debug_info
.
out_pos
=
debug_info
.
output
;
debug_info
.
out_pos
=
debug_info
.
output
;
...
@@ -219,10 +219,10 @@ static void start_thread( struct wine_pthread_thread_info *info )
...
@@ -219,10 +219,10 @@ static void start_thread( struct wine_pthread_thread_info *info )
&
size
,
MEM_SYSTEM
,
PAGE_READWRITE
);
&
size
,
MEM_SYSTEM
,
PAGE_READWRITE
);
/* limit is lower than base since the stack grows down */
/* limit is lower than base since the stack grows down */
teb
->
Tib
.
StackBase
=
(
char
*
)
info
->
stack_base
+
info
->
stack_size
;
teb
->
Tib
.
StackBase
=
(
char
*
)
info
->
stack_base
+
info
->
stack_size
;
teb
->
Tib
.
StackLimit
=
info
->
stack_bas
e
;
teb
->
Tib
.
StackLimit
=
(
char
*
)
info
->
stack_base
+
page_siz
e
;
/* setup the guard page */
/* setup the guard page */
size
=
1
;
size
=
page_size
;
NtProtectVirtualMemory
(
NtCurrentProcess
(),
&
teb
->
DeallocationStack
,
&
size
,
NtProtectVirtualMemory
(
NtCurrentProcess
(),
&
teb
->
DeallocationStack
,
&
size
,
PAGE_READWRITE
|
PAGE_GUARD
,
NULL
);
PAGE_READWRITE
|
PAGE_GUARD
,
NULL
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
info
);
RtlFreeHeap
(
GetProcessHeap
(),
0
,
info
);
...
@@ -252,6 +252,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
...
@@ -252,6 +252,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
DWORD
tid
=
0
;
DWORD
tid
=
0
;
int
request_pipe
[
2
];
int
request_pipe
[
2
];
NTSTATUS
status
;
NTSTATUS
status
;
SIZE_T
page_size
=
getpagesize
();
if
(
!
is_current_process
(
process
)
)
if
(
!
is_current_process
(
process
)
)
{
{
...
@@ -307,6 +308,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
...
@@ -307,6 +308,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
if
(
!
stack_commit
)
stack_commit
=
nt
->
OptionalHeader
.
SizeOfStackCommit
;
if
(
!
stack_commit
)
stack_commit
=
nt
->
OptionalHeader
.
SizeOfStackCommit
;
}
}
if
(
stack_reserve
<
stack_commit
)
stack_reserve
=
stack_commit
;
if
(
stack_reserve
<
stack_commit
)
stack_reserve
=
stack_commit
;
stack_reserve
+=
page_size
;
/* for the guard page */
stack_reserve
=
(
stack_reserve
+
0xffff
)
&
~
0xffff
;
/* round to 64K boundary */
stack_reserve
=
(
stack_reserve
+
0xffff
)
&
~
0xffff
;
/* round to 64K boundary */
if
(
stack_reserve
<
1024
*
1024
)
stack_reserve
=
1024
*
1024
;
/* Xlib needs a large stack */
if
(
stack_reserve
<
1024
*
1024
)
stack_reserve
=
1024
*
1024
;
/* Xlib needs a large stack */
...
...
dlls/ntdll/virtual.c
View file @
f3dad37b
...
@@ -1196,7 +1196,7 @@ NTSTATUS VIRTUAL_HandleFault( LPCVOID addr )
...
@@ -1196,7 +1196,7 @@ NTSTATUS VIRTUAL_HandleFault( LPCVOID addr )
ret
=
STATUS_GUARD_PAGE_VIOLATION
;
ret
=
STATUS_GUARD_PAGE_VIOLATION
;
}
}
/* is it inside the stack guard page? */
/* is it inside the stack guard page? */
if
(((
const
char
*
)
addr
>=
stack
)
&&
((
const
char
*
)
addr
<
stack
+
(
page_mask
+
1
)
))
if
(((
const
char
*
)
addr
>=
stack
-
(
page_mask
+
1
))
&&
((
const
char
*
)
addr
<
stack
))
ret
=
STATUS_STACK_OVERFLOW
;
ret
=
STATUS_STACK_OVERFLOW
;
}
}
RtlLeaveCriticalSection
(
&
csVirtual
);
RtlLeaveCriticalSection
(
&
csVirtual
);
...
...
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