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
a19e3eeb
Commit
a19e3eeb
authored
Jan 20, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Move the TEB register to the ntdll_thread_regs structure.
parent
53e634be
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
15 deletions
+25
-15
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+3
-3
signal_i386.c
dlls/ntdll/signal_i386.c
+2
-2
thread.c
dlls/ntdll/thread.c
+20
-10
No files found.
dlls/ntdll/ntdll_misc.h
View file @
a19e3eeb
...
...
@@ -119,14 +119,13 @@ struct debug_info
struct
ntdll_thread_data
{
DWORD
teb_sel
;
/* selector to TEB */
struct
debug_info
*
debug_info
;
/* info for debugstr functions */
int
request_fd
;
/* fd for sending server requests */
int
reply_fd
;
/* fd for receiving server replies */
int
wait_fd
[
2
];
/* fd for sleeping server requests */
void
*
vm86_ptr
;
/* data for vm86 mode */
void
*
pad
[
3
];
/* change this if you add fields! */
void
*
pad
[
4
];
/* change this if you add fields! */
};
static
inline
struct
ntdll_thread_data
*
ntdll_get_thread_data
(
void
)
...
...
@@ -137,13 +136,14 @@ static inline struct ntdll_thread_data *ntdll_get_thread_data(void)
/* thread registers, stored in NtCurrentTeb()->SpareBytes1 */
struct
ntdll_thread_regs
{
DWORD
fs
;
/* TEB selector */
DWORD
dr0
;
/* debug registers */
DWORD
dr1
;
DWORD
dr2
;
DWORD
dr3
;
DWORD
dr6
;
DWORD
dr7
;
DWORD
spare
[
4
];
/* change this if you add fields! */
DWORD
spare
[
3
];
/* change this if you add fields! */
};
static
inline
struct
ntdll_thread_regs
*
ntdll_get_thread_regs
(
void
)
...
...
dlls/ntdll/signal_i386.c
View file @
a19e3eeb
...
...
@@ -648,7 +648,7 @@ inline static void *init_handler( const SIGCONTEXT *sigcontext, WORD *fs, WORD *
{
void
*
stack
=
(
void
*
)
ESP_sig
(
sigcontext
);
TEB
*
teb
=
get_current_teb
();
struct
ntdll_thread_
data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
struct
ntdll_thread_
regs
*
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
/* get %fs and %gs at time of the fault */
#ifdef FS_sig
...
...
@@ -662,7 +662,7 @@ inline static void *init_handler( const SIGCONTEXT *sigcontext, WORD *fs, WORD *
*
gs
=
wine_get_gs
();
#endif
wine_set_fs
(
thread_
data
->
teb_sel
);
wine_set_fs
(
thread_
regs
->
fs
);
/* now restore a proper %gs for the fault handler */
if
(
!
wine_ldt_is_system
(
CS_sig
(
sigcontext
))
||
...
...
dlls/ntdll/thread.c
View file @
a19e3eeb
...
...
@@ -67,6 +67,7 @@ struct wine_pthread_functions pthread_functions = { NULL };
static
inline
NTSTATUS
init_teb
(
TEB
*
teb
)
{
struct
ntdll_thread_data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
struct
ntdll_thread_regs
*
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
teb
->
Tib
.
ExceptionList
=
(
void
*
)
~
0UL
;
teb
->
Tib
.
StackBase
=
(
void
*
)
~
0UL
;
...
...
@@ -75,7 +76,7 @@ static inline NTSTATUS init_teb( TEB *teb )
teb
->
StaticUnicodeString
.
Buffer
=
teb
->
StaticUnicodeBuffer
;
teb
->
StaticUnicodeString
.
MaximumLength
=
sizeof
(
teb
->
StaticUnicodeBuffer
);
if
(
!
(
thread_
data
->
teb_sel
=
wine_ldt_alloc_fs
()))
return
STATUS_TOO_MANY_THREADS
;
if
(
!
(
thread_
regs
->
fs
=
wine_ldt_alloc_fs
()))
return
STATUS_TOO_MANY_THREADS
;
thread_data
->
request_fd
=
-
1
;
thread_data
->
reply_fd
=
-
1
;
thread_data
->
wait_fd
[
0
]
=
-
1
;
...
...
@@ -92,10 +93,10 @@ static inline void free_teb( TEB *teb )
{
SIZE_T
size
=
0
;
void
*
addr
=
teb
;
struct
ntdll_thread_
data
*
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
struct
ntdll_thread_
regs
*
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
NtFreeVirtualMemory
(
NtCurrentProcess
(),
&
addr
,
&
size
,
MEM_RELEASE
);
wine_ldt_free_fs
(
thread_
data
->
teb_sel
);
wine_ldt_free_fs
(
thread_
regs
->
fs
);
munmap
(
teb
,
sigstack_total_size
);
}
...
...
@@ -113,6 +114,7 @@ void thread_init(void)
void
*
addr
;
SIZE_T
info_size
;
struct
ntdll_thread_data
*
thread_data
;
struct
ntdll_thread_regs
*
thread_regs
;
struct
wine_pthread_thread_info
thread_info
;
static
struct
debug_info
debug_info
;
/* debug info for initial thread */
...
...
@@ -138,13 +140,14 @@ void thread_init(void)
teb
=
addr
;
init_teb
(
teb
);
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
thread_data
->
debug_info
=
&
debug_info
;
InsertHeadList
(
&
tls_links
,
&
teb
->
TlsLinks
);
thread_info
.
stack_base
=
NULL
;
thread_info
.
stack_size
=
0
;
thread_info
.
teb_base
=
teb
;
thread_info
.
teb_sel
=
thread_
data
->
teb_sel
;
thread_info
.
teb_sel
=
thread_
regs
->
fs
;
wine_pthread_get_functions
(
&
pthread_functions
,
sizeof
(
pthread_functions
)
);
pthread_functions
.
init_current_teb
(
&
thread_info
);
pthread_functions
.
init_thread
(
&
thread_info
);
...
...
@@ -243,7 +246,8 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
PRTL_THREAD_START_ROUTINE
start
,
void
*
param
,
HANDLE
*
handle_ptr
,
CLIENT_ID
*
id
)
{
struct
ntdll_thread_data
*
thread_data
=
NULL
;
struct
ntdll_thread_data
*
thread_data
;
struct
ntdll_thread_regs
*
thread_regs
=
NULL
;
struct
startup_info
*
info
=
NULL
;
void
*
addr
;
HANDLE
handle
=
0
;
...
...
@@ -294,14 +298,20 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
teb
->
ClientId
.
UniqueProcess
=
(
HANDLE
)
GetCurrentProcessId
();
teb
->
ClientId
.
UniqueThread
=
(
HANDLE
)
tid
;
/* inherit registers from parent thread */
memcpy
(
teb
->
SpareBytes1
,
ntdll_get_thread_regs
(),
sizeof
(
teb
->
SpareBytes1
)
);
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
thread_data
->
request_fd
=
request_pipe
[
1
];
info
->
pthread_info
.
teb_base
=
teb
;
info
->
pthread_info
.
teb_sel
=
thread_data
->
teb_sel
;
info
->
pthread_info
.
teb_sel
=
thread_regs
->
fs
;
/* inherit debug registers from parent thread */
thread_regs
->
dr0
=
ntdll_get_thread_regs
()
->
dr0
;
thread_regs
->
dr1
=
ntdll_get_thread_regs
()
->
dr1
;
thread_regs
->
dr2
=
ntdll_get_thread_regs
()
->
dr2
;
thread_regs
->
dr3
=
ntdll_get_thread_regs
()
->
dr3
;
thread_regs
->
dr6
=
ntdll_get_thread_regs
()
->
dr6
;
thread_regs
->
dr7
=
ntdll_get_thread_regs
()
->
dr7
;
if
(
!
stack_reserve
||
!
stack_commit
)
{
...
...
@@ -333,7 +343,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
return
STATUS_SUCCESS
;
error:
if
(
thread_
data
)
wine_ldt_free_fs
(
thread_data
->
teb_sel
);
if
(
thread_
regs
)
wine_ldt_free_fs
(
thread_regs
->
fs
);
if
(
addr
)
{
SIZE_T
size
=
0
;
...
...
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