Commit 6de7fa1b authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Take the zero_bits parameter into account in NtCreateThreadEx().

parent 6a296592
......@@ -1871,7 +1871,7 @@ static void start_main_thread(void)
if (p___wine_main_argv) *p___wine_main_argv = main_argv;
if (p___wine_main_wargv) *p___wine_main_wargv = main_wargv;
set_load_order_app_name( main_wargv[0] );
virtual_alloc_thread_stack( &stack, 0, 0, NULL );
virtual_alloc_thread_stack( &stack, is_win64 ? 0x7fffffff : 0, 0, 0, NULL );
teb->Tib.StackBase = stack.StackBase;
teb->Tib.StackLimit = stack.StackLimit;
teb->DeallocationStack = stack.DeallocationStack;
......
......@@ -178,6 +178,9 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
INITIAL_TEB stack;
NTSTATUS status;
if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3;
if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3;
if (process != NtCurrentProcess())
{
apc_call_t call;
......@@ -244,7 +247,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT
if ((status = virtual_alloc_teb( &teb ))) goto done;
if ((status = virtual_alloc_thread_stack( &stack, stack_reserve, stack_commit, &extra_stack )))
if ((status = virtual_alloc_thread_stack( &stack, zero_bits, stack_reserve, stack_commit, &extra_stack )))
{
virtual_free_teb( teb );
goto done;
......
......@@ -197,8 +197,8 @@ extern TEB *virtual_alloc_first_teb(void) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_teb( TEB **ret_teb ) DECLSPEC_HIDDEN;
extern void virtual_free_teb( TEB *teb ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_clear_tls_index( ULONG index ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size,
SIZE_T *pthread_size ) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR zero_bits, SIZE_T reserve_size,
SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN;
extern void virtual_map_user_shared_data(void) DECLSPEC_HIDDEN;
extern NTSTATUS virtual_handle_fault( void *addr, DWORD err, void *stack ) DECLSPEC_HIDDEN;
extern unsigned int virtual_locked_server_call( void *req_ptr ) DECLSPEC_HIDDEN;
......
......@@ -3044,9 +3044,10 @@ NTSTATUS virtual_clear_tls_index( ULONG index )
/***********************************************************************
* virtual_alloc_thread_stack
*/
NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SIZE_T commit_size,
SIZE_T *pthread_size )
NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, ULONG_PTR zero_bits, SIZE_T reserve_size,
SIZE_T commit_size, SIZE_T *pthread_size )
{
unsigned short zero_bits_64 = zero_bits_win_to_64( zero_bits );
struct file_view *view;
NTSTATUS status;
sigset_t sigset;
......@@ -3063,7 +3064,7 @@ NTSTATUS virtual_alloc_thread_stack( INITIAL_TEB *stack, SIZE_T reserve_size, SI
server_enter_uninterrupted_section( &virtual_mutex, &sigset );
if ((status = map_view( &view, NULL, size + extra_size, FALSE,
VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, 33 )) != STATUS_SUCCESS)
VPROT_READ | VPROT_WRITE | VPROT_COMMITTED, zero_bits_64 )) != STATUS_SUCCESS)
goto done;
#ifdef VALGRIND_STACK_REGISTER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment