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
118bd9fe
Commit
118bd9fe
authored
May 25, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Always put the pthread stack at the top of the 64-bit stack if there's one.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
5c1be1db
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
12 deletions
+43
-12
thread.c
dlls/ntdll/unix/thread.c
+43
-12
No files found.
dlls/ntdll/unix/thread.c
View file @
118bd9fe
...
@@ -787,36 +787,67 @@ void set_thread_id( TEB *teb, DWORD pid, DWORD tid )
...
@@ -787,36 +787,67 @@ void set_thread_id( TEB *teb, DWORD pid, DWORD tid )
NTSTATUS
init_thread_stack
(
TEB
*
teb
,
ULONG_PTR
zero_bits
,
SIZE_T
reserve_size
,
NTSTATUS
init_thread_stack
(
TEB
*
teb
,
ULONG_PTR
zero_bits
,
SIZE_T
reserve_size
,
SIZE_T
commit_size
,
SIZE_T
*
pthread_size
)
SIZE_T
commit_size
,
SIZE_T
*
pthread_size
)
{
{
INITIAL_TEB
stack
,
stack64
;
INITIAL_TEB
stack
;
NTSTATUS
status
;
NTSTATUS
status
;
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
zero_bits
,
reserve_size
,
commit_size
,
pthread_size
)))
if
(
teb
->
WowTebOffset
)
return
status
;
if
(
teb
->
WowTebOffset
&&
!
(
status
=
virtual_alloc_thread_stack
(
&
stack64
,
0
,
0x40000
,
0x40000
,
NULL
)))
{
{
WOW64_CPURESERVED
*
cpu
;
SIZE_T
cpusize
=
sizeof
(
WOW64_CPURESERVED
)
+
SIZE_T
cpusize
=
sizeof
(
WOW64_CPURESERVED
)
+
((
get_machine_context_size
(
main_image_info
.
Machine
)
+
7
)
&
~
7
)
+
sizeof
(
ULONG64
);
((
get_machine_context_size
(
main_image_info
.
Machine
)
+
7
)
&
~
7
)
+
sizeof
(
ULONG64
);
WOW64_CPURESERVED
*
cpu
=
(
WOW64_CPURESERVED
*
)(((
ULONG_PTR
)
stack64
.
StackBase
-
cpusize
)
&
~
15
);
#ifdef _WIN64
#ifdef _WIN64
TEB32
*
teb32
=
(
TEB32
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
TEB32
*
teb32
=
(
TEB32
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
/* 32-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
zero_bits
,
reserve_size
,
commit_size
,
NULL
)))
return
status
;
teb32
->
Tib
.
StackBase
=
PtrToUlong
(
stack
.
StackBase
);
teb32
->
Tib
.
StackBase
=
PtrToUlong
(
stack
.
StackBase
);
teb32
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
teb32
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
teb32
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
teb32
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
stack64
.
StackBase
=
teb
->
TlsSlots
[
WOW64_TLS_CPURESERVED
]
=
cpu
;
stack
=
stack64
;
/* 64-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
0x40000
,
0x40000
,
pthread_size
)))
return
status
;
cpu
=
(
WOW64_CPURESERVED
*
)(((
ULONG_PTR
)
stack
.
StackBase
-
cpusize
)
&
~
15
);
cpu
->
Machine
=
main_image_info
.
Machine
;
teb
->
Tib
.
StackBase
=
teb
->
TlsSlots
[
WOW64_TLS_CPURESERVED
]
=
cpu
;
teb
->
Tib
.
StackLimit
=
stack
.
StackLimit
;
teb
->
DeallocationStack
=
stack
.
DeallocationStack
;
if
(
pthread_size
)
{
struct
ntdll_thread_data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
&
teb
->
GdiTebBatch
;
thread_data
->
start_stack
=
stack
.
StackBase
;
*
pthread_size
+=
(
char
*
)
stack
.
StackBase
-
(
char
*
)
cpu
;
}
return
STATUS_SUCCESS
;
#else
#else
TEB64
*
teb64
=
(
TEB64
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
TEB64
*
teb64
=
(
TEB64
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
/* 64-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
0x40000
,
0x40000
,
NULL
)))
return
status
;
cpu
=
(
WOW64_CPURESERVED
*
)(((
ULONG_PTR
)
stack
.
StackBase
-
cpusize
)
&
~
15
);
cpu
->
Machine
=
main_image_info
.
Machine
;
teb64
->
Tib
.
StackBase
=
teb64
->
TlsSlots
[
WOW64_TLS_CPURESERVED
]
=
PtrToUlong
(
cpu
);
teb64
->
Tib
.
StackBase
=
teb64
->
TlsSlots
[
WOW64_TLS_CPURESERVED
]
=
PtrToUlong
(
cpu
);
teb64
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
64
.
StackLimit
);
teb64
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
teb64
->
DeallocationStack
=
PtrToUlong
(
stack
64
.
DeallocationStack
);
teb64
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
#endif
#endif
cpu
->
Machine
=
main_image_info
.
Machine
;
}
}
/* native stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
zero_bits
,
reserve_size
,
commit_size
,
pthread_size
)))
return
status
;
teb
->
Tib
.
StackBase
=
stack
.
StackBase
;
teb
->
Tib
.
StackBase
=
stack
.
StackBase
;
teb
->
Tib
.
StackLimit
=
stack
.
StackLimit
;
teb
->
Tib
.
StackLimit
=
stack
.
StackLimit
;
teb
->
DeallocationStack
=
stack
.
DeallocationStack
;
teb
->
DeallocationStack
=
stack
.
DeallocationStack
;
return
status
;
if
(
pthread_size
)
{
struct
ntdll_thread_data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
&
teb
->
GdiTebBatch
;
thread_data
->
start_stack
=
stack
.
StackBase
;
}
return
STATUS_SUCCESS
;
}
}
...
...
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