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
7b4ca95a
Commit
7b4ca95a
authored
Jun 17, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add a helper to get the Wow64 TEB.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
bab4f293
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
35 deletions
+26
-35
thread.c
dlls/ntdll/unix/thread.c
+13
-21
unix_private.h
dlls/ntdll/unix/unix_private.h
+7
-0
virtual.c
dlls/ntdll/unix/virtual.c
+6
-14
No files found.
dlls/ntdll/unix/thread.c
View file @
7b4ca95a
...
...
@@ -761,19 +761,14 @@ static SIZE_T get_machine_context_size( USHORT machine )
*/
void
set_thread_id
(
TEB
*
teb
,
DWORD
pid
,
DWORD
tid
)
{
WOW_TEB
*
wow_teb
=
get_wow_teb
(
teb
);
teb
->
ClientId
.
UniqueProcess
=
ULongToHandle
(
pid
);
teb
->
ClientId
.
UniqueThread
=
ULongToHandle
(
tid
);
if
(
teb
->
WowTebOffset
)
if
(
wow_teb
)
{
#ifdef _WIN64
TEB32
*
teb32
=
(
TEB32
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
teb32
->
ClientId
.
UniqueProcess
=
pid
;
teb32
->
ClientId
.
UniqueThread
=
tid
;
#else
TEB64
*
teb64
=
(
TEB64
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
teb64
->
ClientId
.
UniqueProcess
=
pid
;
teb64
->
ClientId
.
UniqueThread
=
tid
;
#endif
wow_teb
->
ClientId
.
UniqueProcess
=
pid
;
wow_teb
->
ClientId
.
UniqueThread
=
tid
;
}
}
...
...
@@ -784,24 +779,23 @@ void set_thread_id( TEB *teb, DWORD pid, DWORD tid )
NTSTATUS
init_thread_stack
(
TEB
*
teb
,
ULONG_PTR
zero_bits
,
SIZE_T
reserve_size
,
SIZE_T
commit_size
)
{
struct
ntdll_thread_data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
&
teb
->
GdiTebBatch
;
WOW_TEB
*
wow_teb
=
get_wow_teb
(
teb
);
INITIAL_TEB
stack
;
NTSTATUS
status
;
if
(
teb
->
WowTebOffset
)
if
(
wow_teb
)
{
WOW64_CPURESERVED
*
cpu
;
SIZE_T
cpusize
=
sizeof
(
WOW64_CPURESERVED
)
+
((
get_machine_context_size
(
main_image_info
.
Machine
)
+
7
)
&
~
7
)
+
sizeof
(
ULONG64
);
#ifdef _WIN64
TEB32
*
teb32
=
(
TEB32
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
/* 32-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
zero_bits
,
reserve_size
,
commit_size
,
0
)))
return
status
;
teb32
->
Tib
.
StackBase
=
PtrToUlong
(
stack
.
StackBase
);
teb32
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
teb32
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
wow_teb
->
Tib
.
StackBase
=
PtrToUlong
(
stack
.
StackBase
);
wow_teb
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
wow_teb
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
/* 64-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
0x40000
,
0x40000
,
kernel_stack_size
)))
...
...
@@ -814,16 +808,14 @@ NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR zero_bits, SIZE_T reserve_size,
thread_data
->
kernel_stack
=
stack
.
StackBase
;
return
STATUS_SUCCESS
;
#else
TEB64
*
teb64
=
(
TEB64
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
/* 64-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
0x40000
,
0x40000
,
0
)))
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
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
teb64
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
wow_teb
->
Tib
.
StackBase
=
wow_teb
->
TlsSlots
[
WOW64_TLS_CPURESERVED
]
=
PtrToUlong
(
cpu
);
wow_teb
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
wow_teb
->
DeallocationStack
=
PtrToUlong
(
stack
.
DeallocationStack
);
#endif
}
...
...
dlls/ntdll/unix/unix_private.h
View file @
7b4ca95a
...
...
@@ -321,11 +321,18 @@ static inline void mutex_unlock( pthread_mutex_t *mutex )
}
#ifdef _WIN64
typedef
TEB32
WOW_TEB
;
static
inline
TEB64
*
NtCurrentTeb64
(
void
)
{
return
NULL
;
}
#else
typedef
TEB64
WOW_TEB
;
static
inline
TEB64
*
NtCurrentTeb64
(
void
)
{
return
(
TEB64
*
)
NtCurrentTeb
()
->
GdiBatchCount
;
}
#endif
static
inline
WOW_TEB
*
get_wow_teb
(
TEB
*
teb
)
{
return
teb
->
WowTebOffset
?
(
WOW_TEB
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
)
:
NULL
;
}
enum
loadorder
{
LO_INVALID
,
...
...
dlls/ntdll/unix/virtual.c
View file @
7b4ca95a
...
...
@@ -2985,9 +2985,10 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb )
void
virtual_free_teb
(
TEB
*
teb
)
{
struct
ntdll_thread_data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
&
teb
->
GdiTebBatch
;
void
*
ptr
=
teb
;
void
*
ptr
;
SIZE_T
size
;
sigset_t
sigset
;
WOW_TEB
*
wow_teb
=
get_wow_teb
(
teb
);
signal_free_thread
(
teb
);
if
(
teb
->
DeallocationStack
)
...
...
@@ -3000,24 +3001,15 @@ void virtual_free_teb( TEB *teb )
size
=
0
;
NtFreeVirtualMemory
(
GetCurrentProcess
(),
&
thread_data
->
kernel_stack
,
&
size
,
MEM_RELEASE
);
}
if
(
teb
->
WowTebOffset
)
if
(
wow_teb
&&
(
ptr
=
ULongToPtr
(
wow_teb
->
DeallocationStack
))
)
{
#ifdef _WIN64
TEB32
*
teb32
=
(
TEB32
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
void
*
addr
=
ULongToPtr
(
teb32
->
DeallocationStack
);
#else
TEB64
*
teb64
=
(
TEB64
*
)((
char
*
)
teb
+
teb
->
WowTebOffset
);
void
*
addr
=
ULongToPtr
(
teb64
->
DeallocationStack
);
#endif
if
(
addr
)
{
size
=
0
;
NtFreeVirtualMemory
(
GetCurrentProcess
(),
&
addr
,
&
size
,
MEM_RELEASE
);
}
size
=
0
;
NtFreeVirtualMemory
(
GetCurrentProcess
(),
&
ptr
,
&
size
,
MEM_RELEASE
);
}
server_enter_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
list_remove
(
&
thread_data
->
entry
);
ptr
=
teb
;
if
(
!
is_win64
)
ptr
=
(
char
*
)
ptr
-
teb_offset
;
*
(
void
**
)
ptr
=
next_free_teb
;
next_free_teb
=
ptr
;
...
...
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