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
a82238fa
Commit
a82238fa
authored
Jun 13, 2023
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Allocate 64-bit and kernel stacks in high memory.
parent
11cd5113
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
7 deletions
+11
-7
thread.c
dlls/ntdll/unix/thread.c
+4
-4
unix_private.h
dlls/ntdll/unix/unix_private.h
+4
-1
virtual.c
dlls/ntdll/unix/virtual.c
+3
-2
No files found.
dlls/ntdll/unix/thread.c
View file @
a82238fa
...
...
@@ -1180,7 +1180,7 @@ NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR limit, SIZE_T reserve_size, SIZE
NTSTATUS
status
;
/* kernel stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
0
,
kernel_stack_size
,
kernel_stack_size
,
FALSE
)))
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
limit_4g
,
0
,
kernel_stack_size
,
kernel_stack_size
,
FALSE
)))
return
status
;
thread_data
->
kernel_stack
=
stack
.
DeallocationStack
;
...
...
@@ -1191,7 +1191,7 @@ NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR limit, SIZE_T reserve_size, SIZE
((
get_machine_context_size
(
main_image_info
.
Machine
)
+
7
)
&
~
7
)
+
sizeof
(
ULONG64
);
/* 64-bit stack */
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
0
,
0x40000
,
0x40000
,
TRUE
)))
return
status
;
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
limit_4g
,
0
,
0x40000
,
0x40000
,
TRUE
)))
return
status
;
cpu
=
(
WOW64_CPURESERVED
*
)(((
ULONG_PTR
)
stack
.
StackBase
-
cpusize
)
&
~
15
);
cpu
->
Machine
=
main_image_info
.
Machine
;
...
...
@@ -1201,8 +1201,8 @@ NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR limit, SIZE_T reserve_size, SIZE
teb
->
DeallocationStack
=
stack
.
DeallocationStack
;
/* 32-bit stack */
if
(
(
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
limit
?
limit
:
0x7fffffff
,
reserve_size
,
commit_size
,
TRUE
)))
if
(
!
limit
||
limit
>=
limit_2g
)
limit
=
limit_2g
-
1
;
if
((
status
=
virtual_alloc_thread_stack
(
&
stack
,
0
,
limit
,
reserve_size
,
commit_size
,
TRUE
)))
return
status
;
wow_teb
->
Tib
.
StackBase
=
PtrToUlong
(
stack
.
StackBase
);
wow_teb
->
Tib
.
StackLimit
=
PtrToUlong
(
stack
.
StackLimit
);
...
...
dlls/ntdll/unix/unix_private.h
View file @
a82238fa
...
...
@@ -44,6 +44,9 @@ extern WORD native_machine DECLSPEC_HIDDEN;
static
const
BOOL
is_win64
=
(
sizeof
(
void
*
)
>
sizeof
(
int
));
static
const
ULONG_PTR
limit_2g
=
(
ULONG_PTR
)
1
<<
31
;
static
const
ULONG_PTR
limit_4g
=
(
ULONG_PTR
)((
ULONGLONG
)
1
<<
32
);
static
inline
BOOL
is_machine_64bit
(
WORD
machine
)
{
return
(
machine
==
IMAGE_FILE_MACHINE_AMD64
||
machine
==
IMAGE_FILE_MACHINE_ARM64
);
...
...
@@ -513,7 +516,7 @@ static inline NTSTATUS map_section( HANDLE mapping, void **ptr, SIZE_T *size, UL
{
*
ptr
=
NULL
;
*
size
=
0
;
return
NtMapViewOfSection
(
mapping
,
NtCurrentProcess
(),
ptr
,
is_win64
&&
wow_peb
?
0x7fffffff
:
0
,
return
NtMapViewOfSection
(
mapping
,
NtCurrentProcess
(),
ptr
,
is_win64
&&
wow_peb
?
limit_2g
-
1
:
0
,
0
,
NULL
,
size
,
ViewShare
,
0
,
protect
);
}
...
...
dlls/ntdll/unix/virtual.c
View file @
a82238fa
...
...
@@ -3352,7 +3352,7 @@ TEB *virtual_alloc_first_teb(void)
exit
(
1
);
}
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
teb_block
,
is_win64
?
0x7fffffff
:
0
,
&
total
,
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
teb_block
,
is_win64
?
limit_2g
-
1
:
0
,
&
total
,
MEM_RESERVE
|
MEM_TOP_DOWN
,
PAGE_READWRITE
);
teb_block_pos
=
30
;
ptr
=
(
char
*
)
teb_block
+
30
*
block_size
;
...
...
@@ -3390,7 +3390,8 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb )
{
SIZE_T
total
=
32
*
block_size
;
if
((
status
=
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
ptr
,
is_win64
&&
is_wow64
()
?
0x7fffffff
:
0
,
if
((
status
=
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
ptr
,
is_win64
&&
is_wow64
()
?
limit_2g
-
1
:
0
,
&
total
,
MEM_RESERVE
,
PAGE_READWRITE
)))
{
server_leave_uninterrupted_section
(
&
virtual_mutex
,
&
sigset
);
...
...
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