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
6c9ade05
Commit
6c9ade05
authored
Jul 24, 2006
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Allocate the PEB with NtAllocateVirtualMemory too.
parent
cc297050
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
36 deletions
+48
-36
ntdll_misc.h
dlls/ntdll/ntdll_misc.h
+2
-1
thread.c
dlls/ntdll/thread.c
+39
-14
virtual.c
dlls/ntdll/virtual.c
+7
-21
No files found.
dlls/ntdll/ntdll_misc.h
View file @
6c9ade05
...
@@ -50,6 +50,8 @@ extern size_t get_signal_stack_total_size(void);
...
@@ -50,6 +50,8 @@ extern size_t get_signal_stack_total_size(void);
extern
void
version_init
(
const
WCHAR
*
appname
);
extern
void
version_init
(
const
WCHAR
*
appname
);
extern
void
debug_init
(
void
);
extern
void
debug_init
(
void
);
extern
HANDLE
thread_init
(
void
);
extern
HANDLE
thread_init
(
void
);
extern
void
virtual_init
(
void
);
extern
void
virtual_init_threading
(
void
);
/* server support */
/* server support */
extern
time_t
server_start_time
;
extern
time_t
server_start_time
;
...
@@ -106,7 +108,6 @@ extern NTSTATUS DIR_unmount_device( HANDLE handle );
...
@@ -106,7 +108,6 @@ extern NTSTATUS DIR_unmount_device( HANDLE handle );
extern
NTSTATUS
DIR_get_unix_cwd
(
char
**
cwd
);
extern
NTSTATUS
DIR_get_unix_cwd
(
char
**
cwd
);
/* virtual memory */
/* virtual memory */
extern
NTSTATUS
VIRTUAL_alloc_teb
(
void
**
ret
,
size_t
size
);
extern
NTSTATUS
VIRTUAL_HandleFault
(
LPCVOID
addr
);
extern
NTSTATUS
VIRTUAL_HandleFault
(
LPCVOID
addr
);
extern
BOOL
VIRTUAL_HasMapping
(
LPCVOID
addr
);
extern
BOOL
VIRTUAL_HasMapping
(
LPCVOID
addr
);
extern
void
VIRTUAL_UseLargeAddressSpace
(
void
);
extern
void
VIRTUAL_UseLargeAddressSpace
(
void
);
...
...
dlls/ntdll/thread.c
View file @
6c9ade05
...
@@ -52,7 +52,6 @@ struct startup_info
...
@@ -52,7 +52,6 @@ struct startup_info
void
*
entry_arg
;
void
*
entry_arg
;
};
};
static
PEB
peb
;
static
PEB_LDR_DATA
ldr
;
static
PEB_LDR_DATA
ldr
;
static
RTL_USER_PROCESS_PARAMETERS
params
;
/* default parameters if no parent */
static
RTL_USER_PROCESS_PARAMETERS
params
;
/* default parameters if no parent */
static
WCHAR
current_dir
[
MAX_NT_PATH_LENGTH
];
static
WCHAR
current_dir
[
MAX_NT_PATH_LENGTH
];
...
@@ -75,7 +74,6 @@ static inline NTSTATUS init_teb( TEB *teb )
...
@@ -75,7 +74,6 @@ static inline NTSTATUS init_teb( TEB *teb )
teb
->
Tib
.
ExceptionList
=
(
void
*
)
~
0UL
;
teb
->
Tib
.
ExceptionList
=
(
void
*
)
~
0UL
;
teb
->
Tib
.
StackBase
=
(
void
*
)
~
0UL
;
teb
->
Tib
.
StackBase
=
(
void
*
)
~
0UL
;
teb
->
Tib
.
Self
=
&
teb
->
Tib
;
teb
->
Tib
.
Self
=
&
teb
->
Tib
;
teb
->
Peb
=
&
peb
;
teb
->
StaticUnicodeString
.
Buffer
=
teb
->
StaticUnicodeBuffer
;
teb
->
StaticUnicodeString
.
Buffer
=
teb
->
StaticUnicodeBuffer
;
teb
->
StaticUnicodeString
.
MaximumLength
=
sizeof
(
teb
->
StaticUnicodeBuffer
);
teb
->
StaticUnicodeString
.
MaximumLength
=
sizeof
(
teb
->
StaticUnicodeBuffer
);
...
@@ -148,7 +146,7 @@ static NTSTATUS init_user_process_params( SIZE_T info_size, HANDLE *exe_file )
...
@@ -148,7 +146,7 @@ static NTSTATUS init_user_process_params( SIZE_T info_size, HANDLE *exe_file )
if
(
status
!=
STATUS_SUCCESS
)
return
status
;
if
(
status
!=
STATUS_SUCCESS
)
return
status
;
params
->
AllocationSize
=
info_size
;
params
->
AllocationSize
=
info_size
;
peb
.
ProcessParameters
=
params
;
NtCurrentTeb
()
->
Peb
->
ProcessParameters
=
params
;
SERVER_START_REQ
(
get_startup_info
)
SERVER_START_REQ
(
get_startup_info
)
{
{
...
@@ -201,37 +199,62 @@ static NTSTATUS init_user_process_params( SIZE_T info_size, HANDLE *exe_file )
...
@@ -201,37 +199,62 @@ static NTSTATUS init_user_process_params( SIZE_T info_size, HANDLE *exe_file )
*/
*/
HANDLE
thread_init
(
void
)
HANDLE
thread_init
(
void
)
{
{
PEB
*
peb
;
TEB
*
teb
;
TEB
*
teb
;
void
*
addr
;
void
*
addr
;
SIZE_T
info_size
;
SIZE_T
size
,
info_size
;
HANDLE
exe_file
=
0
;
HANDLE
exe_file
=
0
;
struct
ntdll_thread_data
*
thread_data
;
struct
ntdll_thread_data
*
thread_data
;
struct
ntdll_thread_regs
*
thread_regs
;
struct
ntdll_thread_regs
*
thread_regs
;
struct
wine_pthread_thread_info
thread_info
;
struct
wine_pthread_thread_info
thread_info
;
static
struct
debug_info
debug_info
;
/* debug info for initial thread */
static
struct
debug_info
debug_info
;
/* debug info for initial thread */
peb
.
NumberOfProcessors
=
1
;
virtual_init
();
peb
.
ProcessParameters
=
&
params
;
peb
.
TlsBitmap
=
&
tls_bitmap
;
/* reserve space for shared user data */
peb
.
TlsExpansionBitmap
=
&
tls_expansion_bitmap
;
peb
.
LdrData
=
&
ldr
;
addr
=
(
void
*
)
0x7ffe0000
;
size
=
0x10000
;
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
addr
,
0
,
&
size
,
MEM_RESERVE
,
PAGE_READONLY
);
/* allocate and initialize the PEB */
addr
=
NULL
;
size
=
sizeof
(
*
peb
);
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
addr
,
1
,
&
size
,
MEM_COMMIT
|
MEM_TOP_DOWN
,
PAGE_READWRITE
);
peb
=
addr
;
peb
->
NumberOfProcessors
=
1
;
peb
->
ProcessParameters
=
&
params
;
peb
->
TlsBitmap
=
&
tls_bitmap
;
peb
->
TlsExpansionBitmap
=
&
tls_expansion_bitmap
;
peb
->
LdrData
=
&
ldr
;
params
.
CurrentDirectory
.
DosPath
.
Buffer
=
current_dir
;
params
.
CurrentDirectory
.
DosPath
.
Buffer
=
current_dir
;
params
.
CurrentDirectory
.
DosPath
.
MaximumLength
=
sizeof
(
current_dir
);
params
.
CurrentDirectory
.
DosPath
.
MaximumLength
=
sizeof
(
current_dir
);
params
.
wShowWindow
=
1
;
/* SW_SHOWNORMAL */
params
.
wShowWindow
=
1
;
/* SW_SHOWNORMAL */
RtlInitializeBitMap
(
&
tls_bitmap
,
peb
.
TlsBitmapBits
,
sizeof
(
peb
.
TlsBitmapBits
)
*
8
);
RtlInitializeBitMap
(
&
tls_bitmap
,
peb
->
TlsBitmapBits
,
sizeof
(
peb
->
TlsBitmapBits
)
*
8
);
RtlInitializeBitMap
(
&
tls_expansion_bitmap
,
peb
.
TlsExpansionBitmapBits
,
RtlInitializeBitMap
(
&
tls_expansion_bitmap
,
peb
->
TlsExpansionBitmapBits
,
sizeof
(
peb
.
TlsExpansionBitmapBits
)
*
8
);
sizeof
(
peb
->
TlsExpansionBitmapBits
)
*
8
);
InitializeListHead
(
&
ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
ldr
.
InMemoryOrderModuleList
);
InitializeListHead
(
&
ldr
.
InMemoryOrderModuleList
);
InitializeListHead
(
&
ldr
.
InInitializationOrderModuleList
);
InitializeListHead
(
&
ldr
.
InInitializationOrderModuleList
);
InitializeListHead
(
&
tls_links
);
InitializeListHead
(
&
tls_links
);
/* allocate and initialize the initial TEB */
sigstack_total_size
=
get_signal_stack_total_size
();
sigstack_total_size
=
get_signal_stack_total_size
();
while
(
1
<<
sigstack_zero_bits
<
sigstack_total_size
)
sigstack_zero_bits
++
;
while
(
1
<<
sigstack_zero_bits
<
sigstack_total_size
)
sigstack_zero_bits
++
;
assert
(
1
<<
sigstack_zero_bits
==
sigstack_total_size
);
/* must be a power of 2 */
assert
(
1
<<
sigstack_zero_bits
==
sigstack_total_size
);
/* must be a power of 2 */
thread_info
.
teb_size
=
sigstack_total_size
;
thread_info
.
teb_size
=
sigstack_total_size
;
VIRTUAL_alloc_teb
(
&
addr
,
thread_info
.
teb_size
);
addr
=
NULL
;
size
=
sigstack_total_size
;
NtAllocateVirtualMemory
(
NtCurrentProcess
(),
&
addr
,
sigstack_zero_bits
,
&
size
,
MEM_COMMIT
|
MEM_TOP_DOWN
,
PAGE_READWRITE
);
teb
=
addr
;
teb
=
addr
;
teb
->
Peb
=
peb
;
thread_info
.
teb_size
=
size
;
init_teb
(
teb
);
init_teb
(
teb
);
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
thread_data
=
(
struct
ntdll_thread_data
*
)
teb
->
SystemReserved2
;
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
thread_regs
=
(
struct
ntdll_thread_regs
*
)
teb
->
SpareBytes1
;
...
@@ -245,6 +268,7 @@ HANDLE thread_init(void)
...
@@ -245,6 +268,7 @@ HANDLE thread_init(void)
wine_pthread_get_functions
(
&
pthread_functions
,
sizeof
(
pthread_functions
)
);
wine_pthread_get_functions
(
&
pthread_functions
,
sizeof
(
pthread_functions
)
);
pthread_functions
.
init_current_teb
(
&
thread_info
);
pthread_functions
.
init_current_teb
(
&
thread_info
);
pthread_functions
.
init_thread
(
&
thread_info
);
pthread_functions
.
init_thread
(
&
thread_info
);
virtual_init_threading
();
debug_info
.
str_pos
=
debug_info
.
strings
;
debug_info
.
str_pos
=
debug_info
.
strings
;
debug_info
.
out_pos
=
debug_info
.
output
;
debug_info
.
out_pos
=
debug_info
.
output
;
...
@@ -255,7 +279,7 @@ HANDLE thread_init(void)
...
@@ -255,7 +279,7 @@ HANDLE thread_init(void)
info_size
=
server_init_thread
(
thread_info
.
pid
,
thread_info
.
tid
,
NULL
);
info_size
=
server_init_thread
(
thread_info
.
pid
,
thread_info
.
tid
,
NULL
);
/* create the process heap */
/* create the process heap */
if
(
!
(
peb
.
ProcessHeap
=
RtlCreateHeap
(
HEAP_GROWABLE
,
NULL
,
0
,
0
,
NULL
,
NULL
)))
if
(
!
(
peb
->
ProcessHeap
=
RtlCreateHeap
(
HEAP_GROWABLE
,
NULL
,
0
,
0
,
NULL
,
NULL
)))
{
{
MESSAGE
(
"wine: failed to create the process heap
\n
"
);
MESSAGE
(
"wine: failed to create the process heap
\n
"
);
exit
(
1
);
exit
(
1
);
...
@@ -421,6 +445,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
...
@@ -421,6 +445,7 @@ NTSTATUS WINAPI RtlCreateUserThread( HANDLE process, const SECURITY_DESCRIPTOR *
&
size
,
MEM_COMMIT
|
MEM_TOP_DOWN
,
PAGE_READWRITE
)))
&
size
,
MEM_COMMIT
|
MEM_TOP_DOWN
,
PAGE_READWRITE
)))
goto
error
;
goto
error
;
teb
=
addr
;
teb
=
addr
;
teb
->
Peb
=
NtCurrentTeb
()
->
Peb
;
info
->
pthread_info
.
teb_size
=
size
;
info
->
pthread_info
.
teb_size
=
size
;
if
((
status
=
init_teb
(
teb
)))
goto
error
;
if
((
status
=
init_teb
(
teb
)))
goto
error
;
...
...
dlls/ntdll/virtual.c
View file @
6c9ade05
...
@@ -142,6 +142,7 @@ static UINT_PTR page_mask;
...
@@ -142,6 +142,7 @@ static UINT_PTR page_mask;
static
void
*
user_space_limit
=
USER_SPACE_LIMIT
;
static
void
*
user_space_limit
=
USER_SPACE_LIMIT
;
static
void
*
preload_reserve_start
;
static
void
*
preload_reserve_start
;
static
void
*
preload_reserve_end
;
static
void
*
preload_reserve_end
;
static
int
use_locks
;
/***********************************************************************
/***********************************************************************
...
@@ -1205,7 +1206,7 @@ BOOL is_current_process( HANDLE handle )
...
@@ -1205,7 +1206,7 @@ BOOL is_current_process( HANDLE handle )
/***********************************************************************
/***********************************************************************
* virtual_init
* virtual_init
*/
*/
static
inline
void
virtual_init
(
void
)
void
virtual_init
(
void
)
{
{
const
char
*
preload
;
const
char
*
preload
;
#ifndef page_mask
#ifndef page_mask
...
@@ -1229,26 +1230,11 @@ static inline void virtual_init(void)
...
@@ -1229,26 +1230,11 @@ static inline void virtual_init(void)
/***********************************************************************
/***********************************************************************
* VIRTUAL_alloc_teb
* virtual_init_threading
*
* Allocate a memory view for a new TEB, properly aligned to a multiple of the size.
*/
*/
NTSTATUS
VIRTUAL_alloc_teb
(
void
**
ret
,
size_t
size
)
void
virtual_init_threading
(
void
)
{
{
NTSTATUS
status
;
use_locks
=
1
;
struct
file_view
*
view
;
virtual_init
();
*
ret
=
NULL
;
status
=
map_view
(
&
view
,
NULL
,
size
,
size
-
1
,
TRUE
,
VPROT_READ
|
VPROT_WRITE
|
VPROT_COMMITTED
);
if
(
status
==
STATUS_SUCCESS
)
{
view
->
flags
|=
VFLAG_VALLOC
;
*
ret
=
view
->
base
;
}
return
status
;
}
}
...
@@ -1369,7 +1355,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
...
@@ -1369,7 +1355,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
/* Reserve the memory */
/* Reserve the memory */
RtlEnterCriticalSection
(
&
csVirtual
);
if
(
use_locks
)
RtlEnterCriticalSection
(
&
csVirtual
);
if
(
type
&
MEM_SYSTEM
)
if
(
type
&
MEM_SYSTEM
)
{
{
...
@@ -1397,7 +1383,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
...
@@ -1397,7 +1383,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG zero_
else
if
(
!
VIRTUAL_SetProt
(
view
,
base
,
size
,
vprot
))
status
=
STATUS_ACCESS_DENIED
;
else
if
(
!
VIRTUAL_SetProt
(
view
,
base
,
size
,
vprot
))
status
=
STATUS_ACCESS_DENIED
;
}
}
RtlLeaveCriticalSection
(
&
csVirtual
);
if
(
use_locks
)
RtlLeaveCriticalSection
(
&
csVirtual
);
if
(
status
==
STATUS_SUCCESS
)
if
(
status
==
STATUS_SUCCESS
)
{
{
...
...
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