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
b526a48a
Commit
b526a48a
authored
Dec 04, 2017
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Pass the stack pointer to virtual_clear_thread_stack().
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
23ec3ce2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
56 deletions
+47
-56
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+1
-1
signal_i386.c
dlls/ntdll/signal_i386.c
+30
-33
signal_x86_64.c
dlls/ntdll/signal_x86_64.c
+12
-18
virtual.c
dlls/ntdll/virtual.c
+4
-4
No files found.
dlls/ntdll/ntdll_misc.h
View file @
b526a48a
...
...
@@ -168,7 +168,7 @@ extern void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info ) DECLSPEC_H
extern
NTSTATUS
virtual_create_builtin_view
(
void
*
base
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
virtual_alloc_thread_stack
(
TEB
*
teb
,
SIZE_T
reserve_size
,
SIZE_T
commit_size
,
SIZE_T
extra_size
)
DECLSPEC_HIDDEN
;
extern
void
virtual_clear_thread_stack
(
void
)
DECLSPEC_HIDDEN
;
extern
void
virtual_clear_thread_stack
(
void
*
stack_end
)
DECLSPEC_HIDDEN
;
extern
BOOL
virtual_handle_stack_fault
(
void
*
addr
)
DECLSPEC_HIDDEN
;
extern
BOOL
virtual_is_valid_code_address
(
const
void
*
addr
,
SIZE_T
size
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
virtual_handle_fault
(
LPCVOID
addr
,
DWORD
err
,
BOOL
on_signal_stack
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/signal_i386.c
View file @
b526a48a
...
...
@@ -1312,7 +1312,7 @@ __ASM_GLOBAL_FUNC( set_full_cpu_context,
*
* Set the new CPU context. Used by NtSetContextThread.
*/
static
void
set_cpu_context
(
const
CONTEXT
*
context
)
void
DECLSPEC_HIDDEN
set_cpu_context
(
const
CONTEXT
*
context
)
{
DWORD
flags
=
context
->
ContextFlags
&
~
CONTEXT_i386
;
...
...
@@ -2867,28 +2867,37 @@ __ASM_GLOBAL_FUNC( start_thread,
"movl %ebp,(%eax)
\n\t
"
/* build initial context on thread stack */
"movl %fs:4,%eax
\n\t
"
/* NtCurrentTeb()->StackBase */
"leal -0x2dc(%eax),%e
cx
\n\t
"
/* sizeof(context) + 16 */
"movl $0x10007,(%e
cx
)
\n\t
"
/* context->ContextFlags = CONTEXT_FULL */
"movw %cs,0xbc(%e
cx
)
\n\t
"
/* context->SegCs */
"movw %ds,0x98(%e
cx
)
\n\t
"
/* context->SegDs */
"movw %es,0x94(%e
cx
)
\n\t
"
/* context->SegEs */
"movw %fs,0x90(%e
cx
)
\n\t
"
/* context->SegFs */
"movw %gs,0x8c(%e
cx
)
\n\t
"
/* context->SegGs */
"movw %ss,0xc8(%e
cx
)
\n\t
"
/* context->SegSs */
"leal -0x2dc(%eax),%e
si
\n\t
"
/* sizeof(context) + 16 */
"movl $0x10007,(%e
si
)
\n\t
"
/* context->ContextFlags = CONTEXT_FULL */
"movw %cs,0xbc(%e
si
)
\n\t
"
/* context->SegCs */
"movw %ds,0x98(%e
si
)
\n\t
"
/* context->SegDs */
"movw %es,0x94(%e
si
)
\n\t
"
/* context->SegEs */
"movw %fs,0x90(%e
si
)
\n\t
"
/* context->SegFs */
"movw %gs,0x8c(%e
si
)
\n\t
"
/* context->SegGs */
"movw %ss,0xc8(%e
si
)
\n\t
"
/* context->SegSs */
"movl 8(%ebp),%eax
\n\t
"
"movl %eax,0xb0(%e
cx
)
\n\t
"
/* context->Eax = entry */
"movl %eax,0xb0(%e
si
)
\n\t
"
/* context->Eax = entry */
"movl 12(%ebp),%eax
\n\t
"
"movl %eax,0xa4(%e
cx
)
\n\t
"
/* context->Ebx = arg */
"movl %eax,0xa4(%e
si
)
\n\t
"
/* context->Ebx = arg */
"movl 20(%ebp),%eax
\n\t
"
"movl %eax,0xb8(%ecx)
\n\t
"
/* context->Eip = relay */
"leal 0x2cc(%ecx),%eax
\n\t
"
"movl %eax,0xc4(%ecx)
\n\t
"
/* context->Esp */
/* switch to thread stack and call thread_startup() */
"leal -12(%ecx),%esp
\n\t
"
"movl %eax,0xb8(%esi)
\n\t
"
/* context->Eip = relay */
"leal 0x2cc(%esi),%eax
\n\t
"
"movl %eax,0xc4(%esi)
\n\t
"
/* context->Esp */
/* switch to thread stack */
"leal -12(%esi),%esp
\n\t
"
/* attach dlls */
"pushl 16(%ebp)
\n\t
"
/* suspend */
"pushl %e
cx
\n\t
"
/* context */
"pushl %e
si
\n\t
"
/* context */
"xorl %ebp,%ebp
\n\t
"
"call "
__ASM_NAME
(
"thread_startup"
)
)
"call "
__ASM_NAME
(
"attach_dlls"
)
"
\n\t
"
"addl $20,%esp
\n\t
"
/* clear the stack */
"leal -0xd24(%esi),%eax
\n\t
"
/* round down to page size */
"pushl %eax
\n\t
"
"call "
__ASM_NAME
(
"virtual_clear_thread_stack"
)
"
\n\t
"
/* switch to the initial context */
"movl %esi,(%esp)
\n\t
"
"call "
__ASM_NAME
(
"set_cpu_context"
)
)
extern
void
DECLSPEC_NORETURN
call_thread_exit_func
(
int
status
,
void
(
*
func
)(
int
),
void
*
frame
);
__ASM_GLOBAL_FUNC
(
call_thread_exit_func
,
...
...
@@ -2951,24 +2960,13 @@ void DECLSPEC_HIDDEN call_thread_func( LPTHREAD_START_ROUTINE entry, void *arg )
/***********************************************************************
* thread_startup
*/
void
DECLSPEC_HIDDEN
thread_startup
(
CONTEXT
*
context
,
BOOL
suspend
)
{
attach_dlls
(
context
,
suspend
);
virtual_clear_thread_stack
();
set_cpu_context
(
context
);
}
/***********************************************************************
* signal_start_thread
*
* Thread startup sequence:
* signal_start_thread()
* -> start_thread()
* -> thread_startup()
* -> call_thread_entry()
* -> call_thread_func()
* -> call_thread_entry()
* -> call_thread_func()
*/
void
signal_start_thread
(
LPTHREAD_START_ROUTINE
entry
,
void
*
arg
,
BOOL
suspend
)
{
...
...
@@ -2981,8 +2979,7 @@ void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend
* Process startup sequence:
* signal_start_process()
* -> start_thread()
* -> thread_startup()
* -> kernel32_start_process()
* -> kernel32_start_process()
*/
void
signal_start_process
(
LPTHREAD_START_ROUTINE
entry
,
BOOL
suspend
)
{
...
...
dlls/ntdll/signal_x86_64.c
View file @
b526a48a
...
...
@@ -1889,7 +1889,7 @@ __ASM_GLOBAL_FUNC( set_full_cpu_context,
*
* Set the new CPU context. Used by NtSetContextThread.
*/
static
void
set_cpu_context
(
const
CONTEXT
*
context
)
void
DECLSPEC_HIDDEN
set_cpu_context
(
const
CONTEXT
*
context
)
{
DWORD
flags
=
context
->
ContextFlags
&
~
CONTEXT_AMD64
;
...
...
@@ -4103,11 +4103,18 @@ __ASM_GLOBAL_FUNC( start_thread,
"movq %rax,0x98(%r10)
\n\t
"
/* context->Rsp */
"movq %rcx,0xf8(%r10)
\n\t
"
/* context->Rip = relay */
"fxsave 0x100(%r10)
\n\t
"
/* context->FtlSave */
/* switch to thread stack
and call thread_startup()
*/
/* switch to thread stack */
"movq %r10,%rsp
\n\t
"
/* attach dlls */
"movq %r10,%rdi
\n\t
"
/* context */
"movq %rdx,%rsi
\n\t
"
/* suspend */
"call "
__ASM_NAME
(
"thread_startup"
)
)
"call "
__ASM_NAME
(
"attach_dlls"
)
"
\n\t
"
/* clear the stack */
"leaq -0xb00(%rsp),%rdi
\n\t
"
/* round down to page size */
"call "
__ASM_NAME
(
"virtual_clear_thread_stack"
)
"
\n\t
"
/* switch to the initial context */
"movq %rsp,%rdi
\n\t
"
"call "
__ASM_NAME
(
"set_cpu_context"
)
)
extern
void
DECLSPEC_NORETURN
call_thread_exit_func
(
int
status
,
void
(
*
func
)(
int
),
void
*
frame
);
__ASM_GLOBAL_FUNC
(
call_thread_exit_func
,
...
...
@@ -4123,24 +4130,12 @@ __ASM_GLOBAL_FUNC( call_thread_exit_func,
/***********************************************************************
* thread_startup
*/
void
DECLSPEC_HIDDEN
thread_startup
(
CONTEXT
*
context
,
BOOL
suspend
)
{
attach_dlls
(
context
,
suspend
);
virtual_clear_thread_stack
();
set_cpu_context
(
context
);
}
/***********************************************************************
* signal_start_thread
*
* Thread startup sequence:
* signal_start_thread()
* -> start_thread()
* -> thread_startup()
* -> call_thread_func()
* -> call_thread_func()
*/
void
signal_start_thread
(
LPTHREAD_START_ROUTINE
entry
,
void
*
arg
,
BOOL
suspend
)
{
...
...
@@ -4155,8 +4150,7 @@ void signal_start_thread( LPTHREAD_START_ROUTINE entry, void *arg, BOOL suspend
* Process startup sequence:
* signal_start_process()
* -> start_thread()
* -> thread_startup()
* -> kernel32_start_process()
* -> kernel32_start_process()
*/
void
signal_start_process
(
LPTHREAD_START_ROUTINE
entry
,
BOOL
suspend
)
{
...
...
dlls/ntdll/virtual.c
View file @
b526a48a
...
...
@@ -1825,13 +1825,13 @@ done:
*
* Clear the stack contents before calling the main entry point, some broken apps need that.
*/
void
virtual_clear_thread_stack
(
void
)
void
virtual_clear_thread_stack
(
void
*
stack_end
)
{
void
*
stack
=
NtCurrentTeb
()
->
Tib
.
StackLimit
;
size_t
size
=
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackBase
-
(
char
*
)
NtCurrentTeb
()
->
Tib
.
StackLimit
;
size_t
size
=
(
char
*
)
stack_end
-
(
char
*
)
stack
;
wine_anon_mmap
(
stack
,
size
-
page_size
,
PROT_READ
|
PROT_WRITE
,
MAP_FIXED
);
if
(
force_exec_prot
)
mprotect
(
stack
,
size
-
page_size
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
);
wine_anon_mmap
(
stack
,
size
,
PROT_READ
|
PROT_WRITE
,
MAP_FIXED
);
if
(
force_exec_prot
)
mprotect
(
stack
,
size
,
PROT_READ
|
PROT_WRITE
|
PROT_EXEC
);
}
...
...
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