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
20e73d73
Commit
20e73d73
authored
Oct 09, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved the constructor for the initial TEB to ntdll so that it runs as
early as possible on startup.
parent
36a6c740
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
63 deletions
+74
-63
process.c
dlls/kernel/process.c
+24
-30
thread.c
dlls/kernel/thread.c
+0
-31
thread.c
dlls/ntdll/thread.c
+49
-0
thread.h
include/thread.h
+1
-2
No files found.
dlls/kernel/process.c
View file @
20e73d73
...
...
@@ -96,9 +96,7 @@ typedef struct _PDB
LCID
locale
;
/* c4 Locale to be queried by GetThreadLocale (NT) */
}
PDB
;
PDB
current_process
;
static
PEB_LDR_DATA
process_ldr
;
static
PDB
*
current_process
;
static
HANDLE
main_exe_file
;
static
DWORD
shutdown_flags
=
0
;
...
...
@@ -660,11 +658,9 @@ static RTL_USER_PROCESS_PARAMETERS *init_user_process_params( size_t info_size )
*/
static
BOOL
process_init
(
char
*
argv
[]
)
{
static
RTL_USER_PROCESS_PARAMETERS
default_params
;
/* default parameters if no parent */
BOOL
ret
;
size_t
info_size
=
0
;
RTL_USER_PROCESS_PARAMETERS
*
params
=
&
default_params
;
RTL_USER_PROCESS_PARAMETERS
*
params
;
HANDLE
hstdin
,
hstdout
,
hstderr
;
setbuf
(
stdout
,
NULL
);
...
...
@@ -672,16 +668,13 @@ static BOOL process_init( char *argv[] )
setlocale
(
LC_CTYPE
,
""
);
/* Fill the initial process structure */
current_process
.
threads
=
1
;
current_process
.
running_threads
=
1
;
current_process
.
ring0_threads
=
1
;
current_process
.
group
=
&
current_process
;
current_process
.
priority
=
8
;
/* Normal */
current_process
.
ProcessParameters
=
&
default_params
;
current_process
.
LdrData
=
&
process_ldr
;
InitializeListHead
(
&
process_ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
process_ldr
.
InMemoryOrderModuleList
);
InitializeListHead
(
&
process_ldr
.
InInitializationOrderModuleList
);
current_process
=
(
PDB
*
)
NtCurrentTeb
()
->
Peb
;
/* FIXME: should be a PEB */
params
=
current_process
->
ProcessParameters
;
current_process
->
threads
=
1
;
current_process
->
running_threads
=
1
;
current_process
->
ring0_threads
=
1
;
current_process
->
group
=
current_process
;
current_process
->
priority
=
8
;
/* Normal */
/* Setup the server connection */
wine_server_init_thread
();
...
...
@@ -705,7 +698,7 @@ static BOOL process_init( char *argv[] )
if
(
!
ret
)
return
FALSE
;
/* Create the process heap */
current_process
.
heap
=
RtlCreateHeap
(
HEAP_GROWABLE
,
NULL
,
0
,
0
,
NULL
,
NULL
);
current_process
->
heap
=
RtlCreateHeap
(
HEAP_GROWABLE
,
NULL
,
0
,
0
,
NULL
,
NULL
);
if
(
info_size
==
0
)
{
...
...
@@ -730,7 +723,7 @@ static BOOL process_init( char *argv[] )
else
{
if
(
!
(
params
=
init_user_process_params
(
info_size
)))
return
FALSE
;
current_process
.
ProcessParameters
=
params
;
current_process
->
ProcessParameters
=
params
;
/* convert value from server:
* + 0 => INVALID_HANDLE_VALUE
...
...
@@ -813,13 +806,14 @@ void __wine_process_init( int argc, char *argv[] )
char
error
[
1024
];
DWORD
stack_size
=
0
;
int
file_exists
;
PEB
*
peb
=
NtCurrentTeb
()
->
Peb
;
/* Initialize everything */
if
(
!
process_init
(
argv
))
exit
(
1
);
argv
++
;
/* remove argv[0] (wine itself) */
if
(
!
(
main_exe_name
=
NtCurrentTeb
()
->
P
eb
->
ProcessParameters
->
ImagePathName
.
Buffer
))
if
(
!
(
main_exe_name
=
p
eb
->
ProcessParameters
->
ImagePathName
.
Buffer
))
{
WCHAR
buffer
[
MAX_PATH
];
WCHAR
exe_nameW
[
MAX_PATH
];
...
...
@@ -838,8 +832,8 @@ void __wine_process_init( int argc, char *argv[] )
MESSAGE
(
"wine: cannot open %s
\n
"
,
debugstr_w
(
main_exe_name
)
);
ExitProcess
(
1
);
}
RtlCreateUnicodeString
(
&
NtCurrentTeb
()
->
P
eb
->
ProcessParameters
->
ImagePathName
,
buffer
);
main_exe_name
=
NtCurrentTeb
()
->
P
eb
->
ProcessParameters
->
ImagePathName
.
Buffer
;
RtlCreateUnicodeString
(
&
p
eb
->
ProcessParameters
->
ImagePathName
,
buffer
);
main_exe_name
=
p
eb
->
ProcessParameters
->
ImagePathName
.
Buffer
;
}
TRACE
(
"starting process name=%s file=%p argv[0]=%s
\n
"
,
...
...
@@ -862,7 +856,8 @@ void __wine_process_init( int argc, char *argv[] )
{
case
BINARY_PE_EXE
:
TRACE
(
"starting Win32 binary %s
\n
"
,
debugstr_w
(
main_exe_name
)
);
if
((
current_process
.
module
=
load_pe_exe
(
main_exe_name
,
main_exe_file
)))
goto
found
;
if
((
peb
->
ImageBaseAddress
=
load_pe_exe
(
main_exe_name
,
main_exe_file
)))
goto
found
;
MESSAGE
(
"wine: could not load %s as Win32 binary
\n
"
,
debugstr_w
(
main_exe_name
)
);
ExitProcess
(
1
);
case
BINARY_PE_DLL
:
...
...
@@ -910,8 +905,7 @@ void __wine_process_init( int argc, char *argv[] )
{
*
p
=
0
;
/* update the unicode string */
RtlInitUnicodeString
(
&
NtCurrentTeb
()
->
Peb
->
ProcessParameters
->
ImagePathName
,
main_exe_name
);
RtlInitUnicodeString
(
&
peb
->
ProcessParameters
->
ImagePathName
,
main_exe_name
);
}
goto
found
;
}
...
...
@@ -926,9 +920,9 @@ void __wine_process_init( int argc, char *argv[] )
if
(
!
build_command_line
(
__wine_main_wargv
))
goto
error
;
/* create 32-bit module for main exe */
if
(
!
(
current_process
.
module
=
BUILTIN32_LoadExeModule
(
current_process
.
module
,
CreateFileW
)))
if
(
!
(
peb
->
ImageBaseAddress
=
BUILTIN32_LoadExeModule
(
peb
->
ImageBaseAddress
,
CreateFileW
)))
goto
error
;
stack_size
=
RtlImageNtHeader
(
current_process
.
module
)
->
OptionalHeader
.
SizeOfStackReserve
;
stack_size
=
RtlImageNtHeader
(
peb
->
ImageBaseAddress
)
->
OptionalHeader
.
SizeOfStackReserve
;
/* allocate main thread stack */
if
(
!
THREAD_InitStack
(
NtCurrentTeb
(),
stack_size
))
goto
error
;
...
...
@@ -1948,8 +1942,8 @@ BOOL WINAPI GetExitCodeProcess(
*/
UINT
WINAPI
SetErrorMode
(
UINT
mode
)
{
UINT
old
=
current_process
.
error_mode
;
current_process
.
error_mode
=
mode
;
UINT
old
=
current_process
->
error_mode
;
current_process
->
error_mode
=
mode
;
return
old
;
}
...
...
@@ -1966,7 +1960,7 @@ UINT WINAPI SetErrorMode( UINT mode )
DWORD
WINAPI
TlsAlloc
(
void
)
{
DWORD
i
,
mask
,
ret
=
0
;
DWORD
*
bits
=
current_process
.
tls_bits
;
DWORD
*
bits
=
current_process
->
tls_bits
;
RtlAcquirePebLock
();
if
(
*
bits
==
0xffffffff
)
{
...
...
@@ -2000,7 +1994,7 @@ BOOL WINAPI TlsFree(
DWORD
index
)
/* [in] TLS Index to free */
{
DWORD
mask
=
(
1
<<
(
index
&
31
));
DWORD
*
bits
=
current_process
.
tls_bits
;
DWORD
*
bits
=
current_process
->
tls_bits
;
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
...
...
dlls/kernel/thread.c
View file @
20e73d73
...
...
@@ -48,11 +48,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread);
WINE_DECLARE_DEBUG_CHANNEL
(
relay
);
/* TEB of the initial thread */
static
TEB
initial_teb
;
extern
struct
_PDB
current_process
;
/***********************************************************************
* THREAD_InitTEB
*
...
...
@@ -148,32 +143,6 @@ TEB *THREAD_InitStack( TEB *teb, DWORD stack_size )
/***********************************************************************
* THREAD_Init
*
* Setup the initial thread.
*
* NOTES: The first allocated TEB on NT is at 0x7ffde000.
*/
void
THREAD_Init
(
void
)
{
static
struct
debug_info
info
;
/* debug info for initial thread */
if
(
!
initial_teb
.
Tib
.
Self
)
/* do it only once */
{
THREAD_InitTEB
(
&
initial_teb
);
assert
(
initial_teb
.
teb_sel
);
info
.
str_pos
=
info
.
strings
;
info
.
out_pos
=
info
.
output
;
initial_teb
.
debug_info
=
&
info
;
initial_teb
.
Peb
=
(
PEB
*
)
&
current_process
;
/* FIXME */
SYSDEPS_SetCurThread
(
&
initial_teb
);
}
}
DECL_GLOBAL_CONSTRUCTOR
(
thread_init
)
{
THREAD_Init
();
}
/***********************************************************************
* THREAD_Start
*
* Start execution of a newly created thread. Does not return.
...
...
dlls/ntdll/thread.c
View file @
20e73d73
...
...
@@ -18,9 +18,13 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "wine/port.h"
#include "ntstatus.h"
#include "thread.h"
#include "winternl.h"
#include "wine/library.h"
#include "wine/server.h"
#include "wine/debug.h"
...
...
@@ -28,6 +32,51 @@ WINE_DEFAULT_DEBUG_CHANNEL(thread);
/***********************************************************************
* thread_init
*
* Setup the initial thread.
*
* NOTES: The first allocated TEB on NT is at 0x7ffde000.
*/
DECL_GLOBAL_CONSTRUCTOR
(
thread_init
)
{
static
TEB
teb
;
static
PEB
peb
;
static
PEB_LDR_DATA
ldr
;
static
RTL_USER_PROCESS_PARAMETERS
params
;
/* default parameters if no parent */
static
struct
debug_info
info
;
/* debug info for initial thread */
if
(
teb
.
Tib
.
Self
)
return
;
/* do it only once */
info
.
str_pos
=
info
.
strings
;
info
.
out_pos
=
info
.
output
;
teb
.
Tib
.
ExceptionList
=
(
void
*
)
~
0UL
;
teb
.
Tib
.
StackBase
=
(
void
*
)
~
0UL
;
teb
.
Tib
.
Self
=
&
teb
.
Tib
;
teb
.
Peb
=
&
peb
;
teb
.
tibflags
=
TEBF_WIN32
;
teb
.
request_fd
=
-
1
;
teb
.
reply_fd
=
-
1
;
teb
.
wait_fd
[
0
]
=
-
1
;
teb
.
wait_fd
[
1
]
=
-
1
;
teb
.
teb_sel
=
wine_ldt_alloc_fs
();
teb
.
debug_info
=
&
info
;
teb
.
StaticUnicodeString
.
MaximumLength
=
sizeof
(
teb
.
StaticUnicodeBuffer
);
teb
.
StaticUnicodeString
.
Buffer
=
teb
.
StaticUnicodeBuffer
;
InitializeListHead
(
&
teb
.
TlsLinks
);
peb
.
ProcessParameters
=
&
params
;
peb
.
LdrData
=
&
ldr
;
InitializeListHead
(
&
ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
ldr
.
InMemoryOrderModuleList
);
InitializeListHead
(
&
ldr
.
InInitializationOrderModuleList
);
SYSDEPS_SetCurThread
(
&
teb
);
}
/***********************************************************************
* NtOpenThread (NTDLL.@)
* ZwOpenThread (NTDLL.@)
*/
...
...
include/thread.h
View file @
20e73d73
...
...
@@ -125,7 +125,7 @@ typedef struct _TEB
/* the following are nt specific fields */
DWORD
pad6
[
624
];
/* --n 238 */
UNICODE_STRING
StaticUnicodeString
;
/* -2- bf8 used by advapi32 */
USHORT
StaticUnicodeBuffer
[
261
];
/* -2- c00 used by advapi32 */
WCHAR
StaticUnicodeBuffer
[
261
];
/* -2- c00 used by advapi32 */
PVOID
DeallocationStack
;
/* -2- e0c Base of the stack */
LPVOID
TlsSlots
[
64
];
/* -2- e10 Thread local storage */
LIST_ENTRY
TlsLinks
;
/* -2- f10 */
...
...
@@ -145,7 +145,6 @@ typedef struct _TEB
/* scheduler/thread.c */
extern
void
THREAD_Init
(
void
);
extern
TEB
*
THREAD_InitStack
(
TEB
*
teb
,
DWORD
stack_size
);
/* scheduler/sysdeps.c */
...
...
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