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
588d91ae
Commit
588d91ae
authored
Jun 15, 2021
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Store the current PEB in a global variable.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
09bb5d94
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
31 deletions
+25
-31
debug.c
dlls/ntdll/unix/debug.c
+1
-1
env.c
dlls/ntdll/unix/env.c
+1
-2
loader.c
dlls/ntdll/unix/loader.c
+2
-1
server.c
dlls/ntdll/unix/server.c
+1
-2
system.c
dlls/ntdll/unix/system.c
+8
-8
thread.c
dlls/ntdll/unix/thread.c
+4
-4
unix_private.h
dlls/ntdll/unix/unix_private.h
+1
-1
virtual.c
dlls/ntdll/unix/virtual.c
+7
-12
No files found.
dlls/ntdll/unix/debug.c
View file @
588d91ae
...
...
@@ -299,7 +299,7 @@ void dbg_init(void)
if
(
nb_debug_options
==
-
1
)
init_options
();
options
=
(
struct
__wine_debug_channel
*
)((
char
*
)
NtCurrentTeb
()
->
P
eb
+
(
is_win64
?
2
:
1
)
*
page_size
);
options
=
(
struct
__wine_debug_channel
*
)((
char
*
)
p
eb
+
(
is_win64
?
2
:
1
)
*
page_size
);
memcpy
(
options
,
debug_options
,
nb_debug_options
*
sizeof
(
*
options
)
);
free
(
debug_options
);
debug_options
=
options
;
...
...
dlls/ntdll/unix/env.c
View file @
588d91ae
...
...
@@ -62,6 +62,7 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
environ
);
PEB
*
peb
=
NULL
;
USHORT
*
uctable
=
NULL
,
*
lctable
=
NULL
;
SIZE_T
startup_info_size
=
0
;
BOOL
is_prefix_bootstrap
=
FALSE
;
...
...
@@ -1996,8 +1997,6 @@ static void *build_wow64_parameters( const RTL_USER_PROCESS_PARAMETERS *params )
*/
static
void
init_peb
(
RTL_USER_PROCESS_PARAMETERS
*
params
,
void
*
module
)
{
PEB
*
peb
=
NtCurrentTeb
()
->
Peb
;
peb
->
ImageBaseAddress
=
module
;
peb
->
ProcessParameters
=
params
;
peb
->
OSMajorVersion
=
6
;
...
...
dlls/ntdll/unix/loader.c
View file @
588d91ae
...
...
@@ -1772,7 +1772,7 @@ static void load_ntdll(void)
/***********************************************************************
* get_image_address
*/
ULONG_PTR
get_image_address
(
void
)
static
ULONG_PTR
get_image_address
(
void
)
{
#ifdef HAVE_GETAUXVAL
ULONG_PTR
size
,
num
,
phdr_addr
=
getauxval
(
AT_PHDR
);
...
...
@@ -1877,6 +1877,7 @@ static void start_main_thread(void)
if
(
p___wine_main_argc
)
*
p___wine_main_argc
=
main_argc
;
if
(
p___wine_main_argv
)
*
p___wine_main_argv
=
main_argv
;
if
(
p___wine_main_wargv
)
*
p___wine_main_wargv
=
main_wargv
;
*
(
ULONG_PTR
*
)
&
peb
->
CloudFileFlags
=
get_image_address
();
set_load_order_app_name
(
main_wargv
[
0
]
);
init_thread_stack
(
teb
,
is_win64
?
0x7fffffff
:
0
,
0
,
0
);
NtCreateKeyedEvent
(
&
keyed_event
,
GENERIC_READ
|
GENERIC_WRITE
,
NULL
,
0
);
...
...
dlls/ntdll/unix/server.c
View file @
588d91ae
...
...
@@ -1558,7 +1558,6 @@ size_t server_init_process(void)
*/
void
server_init_process_done
(
void
)
{
PEB
*
peb
=
NtCurrentTeb
()
->
Peb
;
void
*
entry
,
*
teb
;
NTSTATUS
status
;
int
suspend
,
needs_close
,
unixdir
;
...
...
@@ -1738,7 +1737,7 @@ NTSTATUS WINAPI NtClose( HANDLE handle )
if
(
fd
!=
-
1
)
close
(
fd
);
if
(
ret
!=
STATUS_INVALID_HANDLE
||
!
handle
)
return
ret
;
if
(
!
NtCurrentTeb
()
->
P
eb
->
BeingDebugged
)
return
ret
;
if
(
!
p
eb
->
BeingDebugged
)
return
ret
;
if
(
!
NtQueryInformationProcess
(
NtCurrentProcess
(),
ProcessDebugPort
,
&
port
,
sizeof
(
port
),
NULL
)
&&
port
)
{
NtCurrentTeb
()
->
ExceptionCode
=
ret
;
...
...
dlls/ntdll/unix/system.c
View file @
588d91ae
...
...
@@ -485,7 +485,7 @@ void init_cpu_info(void)
num
=
1
;
FIXME
(
"Detecting the number of processors is not supported.
\n
"
);
#endif
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
=
num
;
p
eb
->
NumberOfProcessors
=
num
;
get_cpuinfo
(
&
cpu_info
);
TRACE
(
"<- CPU arch %d, level %d, rev %d, features 0x%x
\n
"
,
cpu_info
.
ProcessorArchitecture
,
cpu_info
.
ProcessorLevel
,
cpu_info
.
ProcessorRevision
,
...
...
@@ -1033,7 +1033,7 @@ static NTSTATUS create_logical_proc_info( SYSTEM_LOGICAL_PROCESSOR_INFORMATION *
if
(
relation
!=
RelationAll
)
FIXME
(
"Relationship filtering not implemented: 0x%x
\n
"
,
relation
);
lcpu_no
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
lcpu_no
=
p
eb
->
NumberOfProcessors
;
size
=
sizeof
(
pkgs_no
);
if
(
sysctlbyname
(
"hw.packages"
,
&
pkgs_no
,
&
size
,
NULL
,
0
))
...
...
@@ -1180,7 +1180,7 @@ static NTSTATUS create_cpuset_info(SYSTEM_CPU_SET_INFORMATION *info)
ULONG64
cpu_mask
;
NTSTATUS
status
;
count
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
count
=
p
eb
->
NumberOfProcessors
;
cpu_info_size
=
3
*
sizeof
(
*
proc_info
);
if
(
!
(
proc_info_buffer
=
malloc
(
cpu_info_size
)))
...
...
@@ -2411,7 +2411,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
{
static
int
i
=
1
;
unsigned
int
n
;
cpus
=
min
(
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
,
out_cpus
);
cpus
=
min
(
p
eb
->
NumberOfProcessors
,
out_cpus
);
FIXME
(
"stub info_class SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION
\n
"
);
/* many programs expect these values to change so fake change */
for
(
n
=
0
;
n
<
cpus
;
n
++
)
...
...
@@ -2537,7 +2537,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
case
SystemInterruptInformation
:
/* 23 */
{
len
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
*
sizeof
(
SYSTEM_INTERRUPT_INFORMATION
);
len
=
p
eb
->
NumberOfProcessors
*
sizeof
(
SYSTEM_INTERRUPT_INFORMATION
);
if
(
size
>=
len
)
{
if
(
!
info
)
ret
=
STATUS_ACCESS_VIOLATION
;
...
...
@@ -2716,7 +2716,7 @@ NTSTATUS WINAPI NtQuerySystemInformation( SYSTEM_INFORMATION_CLASS class,
/* Each logical processor may use up to 7 entries in returned table:
* core, numa node, package, L1i, L1d, L2, L3 */
len
=
7
*
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
len
=
7
*
p
eb
->
NumberOfProcessors
;
buf
=
malloc
(
len
*
sizeof
(
*
buf
)
);
if
(
!
buf
)
{
...
...
@@ -2904,7 +2904,7 @@ NTSTATUS WINAPI NtQuerySystemInformationEx( SYSTEM_INFORMATION_CLASS class,
case
SystemCpuSetInformation
:
{
unsigned
int
cpu_count
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
unsigned
int
cpu_count
=
p
eb
->
NumberOfProcessors
;
PROCESS_BASIC_INFORMATION
pbi
;
HANDLE
process
;
...
...
@@ -3261,7 +3261,7 @@ NTSTATUS WINAPI NtPowerInformation( POWER_INFORMATION_LEVEL level, void *input,
int
i
,
out_cpus
;
if
((
output
==
NULL
)
||
(
out_size
==
0
))
return
STATUS_INVALID_PARAMETER
;
out_cpus
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
out_cpus
=
p
eb
->
NumberOfProcessors
;
if
((
out_size
/
sizeof
(
PROCESSOR_POWER_INFORMATION
))
<
out_cpus
)
return
STATUS_BUFFER_TOO_SMALL
;
#if defined(linux)
{
...
...
dlls/ntdll/unix/thread.c
View file @
588d91ae
...
...
@@ -1096,7 +1096,7 @@ NTSTATUS send_debug_event( EXCEPTION_RECORD *rec, CONTEXT *context, BOOL first_c
select_op_t
select_op
;
sigset_t
old_set
;
if
(
!
NtCurrentTeb
()
->
P
eb
->
BeingDebugged
)
return
0
;
/* no debugger present */
if
(
!
p
eb
->
BeingDebugged
)
return
0
;
/* no debugger present */
pthread_sigmask
(
SIG_BLOCK
,
&
server_block_set
,
&
old_set
);
...
...
@@ -1906,21 +1906,21 @@ ULONG WINAPI NtGetCurrentProcessorNumber(void)
if
(
res
!=
-
1
)
return
processor
;
#endif
if
(
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
>
1
)
if
(
p
eb
->
NumberOfProcessors
>
1
)
{
ULONG_PTR
thread_mask
,
processor_mask
;
if
(
!
NtQueryInformationThread
(
GetCurrentThread
(),
ThreadAffinityMask
,
&
thread_mask
,
sizeof
(
thread_mask
),
NULL
))
{
for
(
processor
=
0
;
processor
<
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
processor
++
)
for
(
processor
=
0
;
processor
<
p
eb
->
NumberOfProcessors
;
processor
++
)
{
processor_mask
=
(
1
<<
processor
);
if
(
thread_mask
&
processor_mask
)
{
if
(
thread_mask
!=
processor_mask
)
FIXME
(
"need multicore support (%d processors)
\n
"
,
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
);
p
eb
->
NumberOfProcessors
);
return
processor
;
}
}
...
...
dlls/ntdll/unix/unix_private.h
View file @
588d91ae
...
...
@@ -127,6 +127,7 @@ extern const char *build_dir DECLSPEC_HIDDEN;
extern
const
char
*
config_dir
DECLSPEC_HIDDEN
;
extern
const
char
*
user_name
DECLSPEC_HIDDEN
;
extern
const
char
**
dll_paths
DECLSPEC_HIDDEN
;
extern
PEB
*
peb
DECLSPEC_HIDDEN
;
extern
USHORT
*
uctable
DECLSPEC_HIDDEN
;
extern
USHORT
*
lctable
DECLSPEC_HIDDEN
;
extern
SIZE_T
startup_info_size
DECLSPEC_HIDDEN
;
...
...
@@ -167,7 +168,6 @@ extern NTSTATUS load_main_exe( const WCHAR *name, const char *unix_name, const W
void
**
module
)
DECLSPEC_HIDDEN
;
extern
NTSTATUS
load_start_exe
(
WCHAR
**
image
,
void
**
module
)
DECLSPEC_HIDDEN
;
extern
void
start_server
(
BOOL
debug
)
DECLSPEC_HIDDEN
;
extern
ULONG_PTR
get_image_address
(
void
)
DECLSPEC_HIDDEN
;
extern
unsigned
int
server_call_unlocked
(
void
*
req_ptr
)
DECLSPEC_HIDDEN
;
extern
void
server_enter_uninterrupted_section
(
pthread_mutex_t
*
mutex
,
sigset_t
*
sigset
)
DECLSPEC_HIDDEN
;
...
...
dlls/ntdll/unix/virtual.c
View file @
588d91ae
...
...
@@ -2688,7 +2688,7 @@ void virtual_init(void)
*/
ULONG_PTR
get_system_affinity_mask
(
void
)
{
ULONG
num_cpus
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
ULONG
num_cpus
=
p
eb
->
NumberOfProcessors
;
if
(
num_cpus
>=
sizeof
(
ULONG_PTR
)
*
8
)
return
~
(
ULONG_PTR
)
0
;
return
((
ULONG_PTR
)
1
<<
num_cpus
)
-
1
;
}
...
...
@@ -2723,7 +2723,7 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
info
->
LowestUserAddress
=
(
void
*
)
0x10000
;
info
->
HighestUserAddress
=
(
char
*
)
user_space_limit
-
1
;
info
->
ActiveProcessorsAffinityMask
=
get_system_affinity_mask
();
info
->
NumberOfProcessors
=
NtCurrentTeb
()
->
P
eb
->
NumberOfProcessors
;
info
->
NumberOfProcessors
=
p
eb
->
NumberOfProcessors
;
}
...
...
@@ -2840,7 +2840,7 @@ NTSTATUS virtual_create_builtin_view( void *module, const UNICODE_STRING *nt_nam
/* set some initial values in a new TEB */
static
TEB
*
init_teb
(
void
*
ptr
,
PEB
*
peb
,
BOOL
is_wow
)
static
TEB
*
init_teb
(
void
*
ptr
,
BOOL
is_wow
)
{
struct
ntdll_thread_data
*
thread_data
;
TEB
*
teb
;
...
...
@@ -2902,8 +2902,6 @@ static TEB *init_teb( void *ptr, PEB *peb, BOOL is_wow )
*/
TEB
*
virtual_alloc_first_teb
(
void
)
{
TEB
*
teb
;
PEB
*
peb
;
void
*
ptr
;
NTSTATUS
status
;
SIZE_T
data_size
=
page_size
;
...
...
@@ -2926,9 +2924,7 @@ TEB *virtual_alloc_first_teb(void)
data_size
=
2
*
block_size
;
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
(
void
**
)
&
ptr
,
0
,
&
data_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
peb
=
(
PEB
*
)((
char
*
)
teb_block
+
31
*
block_size
+
(
is_win64
?
0
:
page_size
));
teb
=
init_teb
(
ptr
,
peb
,
FALSE
);
*
(
ULONG_PTR
*
)
&
peb
->
CloudFileFlags
=
get_image_address
();
return
teb
;
return
init_teb
(
ptr
,
FALSE
);
}
...
...
@@ -2969,7 +2965,7 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb )
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
(
void
**
)
&
ptr
,
0
,
&
block_size
,
MEM_COMMIT
,
PAGE_READWRITE
);
}
*
ret_teb
=
teb
=
init_teb
(
ptr
,
NtCurrentTeb
()
->
Peb
,
!!
NtCurrentTeb
()
->
WowTebOffset
);
*
ret_teb
=
teb
=
init_teb
(
ptr
,
!!
NtCurrentTeb
()
->
WowTebOffset
);
server_leave_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
if
((
status
=
signal_alloc_thread
(
teb
)))
...
...
@@ -3050,8 +3046,7 @@ NTSTATUS virtual_clear_tls_index( ULONG index )
else
{
index
-=
TLS_MINIMUM_AVAILABLE
;
if
(
index
>=
8
*
sizeof
(
NtCurrentTeb
()
->
Peb
->
TlsExpansionBitmapBits
))
return
STATUS_INVALID_PARAMETER
;
if
(
index
>=
8
*
sizeof
(
peb
->
TlsExpansionBitmapBits
))
return
STATUS_INVALID_PARAMETER
;
server_enter_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
LIST_FOR_EACH_ENTRY
(
thread_data
,
&
teb_list
,
struct
ntdll_thread_data
,
entry
)
...
...
@@ -3655,7 +3650,7 @@ void CDECL virtual_release_address_space(void)
void
virtual_set_large_address_space
(
void
)
{
/* no large address space on win9x */
if
(
NtCurrentTeb
()
->
P
eb
->
OSPlatformId
!=
VER_PLATFORM_WIN32_NT
)
return
;
if
(
p
eb
->
OSPlatformId
!=
VER_PLATFORM_WIN32_NT
)
return
;
user_space_limit
=
working_set_limit
=
address_space_limit
;
}
...
...
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