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
711bde7c
Commit
711bde7c
authored
May 17, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add a helper function to set the thread id.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
cf02b0bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
33 deletions
+36
-33
server.c
dlls/ntdll/unix/server.c
+10
-28
thread.c
dlls/ntdll/unix/thread.c
+25
-5
unix_private.h
dlls/ntdll/unix/unix_private.h
+1
-0
No files found.
dlls/ntdll/unix/server.c
View file @
711bde7c
...
...
@@ -1447,22 +1447,6 @@ static int init_thread_pipe(void)
/***********************************************************************
* init_teb64
*
* Initialize the 64-bit part of the TEB for WoW64 threads.
*/
static
void
init_teb64
(
TEB
*
teb
)
{
#ifndef _WIN64
TEB64
*
teb64
=
(
TEB64
*
)((
char
*
)
teb
-
teb_offset
);
if
(
!
is_wow64
)
return
;
teb64
->
ClientId
.
UniqueProcess
=
PtrToUlong
(
teb
->
ClientId
.
UniqueProcess
);
teb64
->
ClientId
.
UniqueThread
=
PtrToUlong
(
teb
->
ClientId
.
UniqueThread
);
#endif
}
/***********************************************************************
* process_exit_wrapper
*
* Close server socket and exit process normally.
...
...
@@ -1488,6 +1472,7 @@ size_t server_init_process(void)
int
ret
,
reply_pipe
;
struct
sigaction
sig_act
;
size_t
info_size
;
DWORD
pid
,
tid
;
server_pid
=
-
1
;
if
(
env_socket
)
...
...
@@ -1558,8 +1543,8 @@ size_t server_init_process(void)
req
->
debug_level
=
(
TRACE_ON
(
server
)
!=
0
);
wine_server_set_reply
(
req
,
supported_machines
,
sizeof
(
supported_machines
)
);
ret
=
wine_server_call
(
req
);
NtCurrentTeb
()
->
ClientId
.
UniqueProcess
=
ULongToHandle
(
reply
->
pid
)
;
NtCurrentTeb
()
->
ClientId
.
UniqueThread
=
ULongToHandle
(
reply
->
tid
)
;
pid
=
reply
->
pid
;
tid
=
reply
->
tid
;
info_size
=
reply
->
info_size
;
server_start_time
=
reply
->
server_start
;
supported_machines_count
=
wine_server_reply_size
(
reply
)
/
sizeof
(
*
supported_machines
);
...
...
@@ -1578,13 +1563,11 @@ size_t server_init_process(void)
{
if
(
arch
&&
!
strcmp
(
arch
,
"win32"
))
fatal_error
(
"WINEARCH set to win32 but '%s' is a 64-bit installation.
\n
"
,
config_dir
);
if
(
!
is_win64
)
{
is_wow64
=
TRUE
;
NtCurrentTeb
()
->
GdiBatchCount
=
PtrToUlong
(
(
char
*
)
NtCurrentTeb
()
-
teb_offset
);
NtCurrentTeb
()
->
WowTebOffset
=
-
teb_offset
;
init_teb64
(
NtCurrentTeb
()
);
}
#ifndef _WIN64
is_wow64
=
TRUE
;
NtCurrentTeb
()
->
GdiBatchCount
=
PtrToUlong
(
(
char
*
)
NtCurrentTeb
()
-
teb_offset
);
NtCurrentTeb
()
->
WowTebOffset
=
-
teb_offset
;
#endif
}
else
{
...
...
@@ -1594,6 +1577,8 @@ size_t server_init_process(void)
fatal_error
(
"WINEARCH set to win64 but '%s' is a 32-bit installation.
\n
"
,
config_dir
);
}
set_thread_id
(
NtCurrentTeb
(),
pid
,
tid
);
for
(
i
=
0
;
i
<
supported_machines_count
;
i
++
)
if
(
supported_machines
[
i
]
==
current_machine
)
return
info_size
;
...
...
@@ -1675,12 +1660,9 @@ void server_init_thread( void *entry_point, BOOL *suspend )
req
->
wait_fd
=
ntdll_get_thread_data
()
->
wait_fd
[
1
];
wine_server_call
(
req
);
*
suspend
=
reply
->
suspend
;
NtCurrentTeb
()
->
ClientId
.
UniqueProcess
=
ULongToHandle
(
reply
->
pid
);
NtCurrentTeb
()
->
ClientId
.
UniqueThread
=
ULongToHandle
(
reply
->
tid
);
}
SERVER_END_REQ
;
close
(
reply_pipe
);
init_teb64
(
NtCurrentTeb
()
);
}
...
...
dlls/ntdll/unix/thread.c
View file @
711bde7c
...
...
@@ -120,6 +120,28 @@ static void start_thread( TEB *teb )
/***********************************************************************
* set_thread_id
*/
void
set_thread_id
(
TEB
*
teb
,
DWORD
pid
,
DWORD
tid
)
{
teb
->
ClientId
.
UniqueProcess
=
ULongToHandle
(
pid
);
teb
->
ClientId
.
UniqueThread
=
ULongToHandle
(
tid
);
if
(
teb
->
WowTebOffset
)
{
#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
}
}
/***********************************************************************
* update_attr_list
*
* Update the output attributes.
...
...
@@ -173,7 +195,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
DWORD
tid
=
0
;
int
request_pipe
[
2
];
SIZE_T
extra_stack
=
PTHREAD_STACK_MIN
;
CLIENT_ID
client_id
;
TEB
*
teb
;
INITIAL_TEB
stack
;
NTSTATUS
status
;
...
...
@@ -200,6 +221,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
if
(
result
.
create_thread
.
status
==
STATUS_SUCCESS
)
{
CLIENT_ID
client_id
;
TEB
*
teb
=
wine_server_get_ptr
(
result
.
create_thread
.
teb
);
*
handle
=
wine_server_ptr_handle
(
result
.
create_thread
.
handle
);
client_id
.
UniqueProcess
=
ULongToHandle
(
result
.
create_thread
.
pid
);
...
...
@@ -253,9 +275,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
goto
done
;
}
client_id
.
UniqueProcess
=
ULongToHandle
(
GetCurrentProcessId
()
);
client_id
.
UniqueThread
=
ULongToHandle
(
tid
);
teb
->
ClientId
=
client_id
;
set_thread_id
(
teb
,
GetCurrentProcessId
(),
tid
);
teb
->
Tib
.
StackBase
=
stack
.
StackBase
;
teb
->
Tib
.
StackLimit
=
stack
.
StackLimit
;
...
...
@@ -289,7 +309,7 @@ done:
close
(
request_pipe
[
1
]
);
return
status
;
}
if
(
attr_list
)
update_attr_list
(
attr_list
,
&
client_i
d
,
teb
);
if
(
attr_list
)
update_attr_list
(
attr_list
,
&
teb
->
ClientI
d
,
teb
);
return
STATUS_SUCCESS
;
}
...
...
dlls/ntdll/unix/unix_private.h
View file @
711bde7c
...
...
@@ -172,6 +172,7 @@ extern void server_init_process_done(void) DECLSPEC_HIDDEN;
extern
void
server_init_thread
(
void
*
entry_point
,
BOOL
*
suspend
)
DECLSPEC_HIDDEN
;
extern
int
server_pipe
(
int
fd
[
2
]
)
DECLSPEC_HIDDEN
;
extern
void
set_thread_id
(
TEB
*
teb
,
DWORD
pid
,
DWORD
tid
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
context_to_server
(
context_t
*
to
,
const
CONTEXT
*
from
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
context_from_server
(
CONTEXT
*
to
,
const
context_t
*
from
)
DECLSPEC_HIDDEN
;
extern
void
DECLSPEC_NORETURN
abort_thread
(
int
status
)
DECLSPEC_HIDDEN
;
...
...
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