From 656c604e5e206b1abd5932e910f7686dc324f3ab Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 22 Oct 2016 18:27:02 -0400 Subject: __ntapi_tt_create_thread(): retain proper value of params->stack_size_commit. --- src/thread/ntapi_tt_create_thread.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/thread/ntapi_tt_create_thread.c b/src/thread/ntapi_tt_create_thread.c index 9105ec0..a76fec9 100644 --- a/src/thread/ntapi_tt_create_thread.c +++ b/src/thread/ntapi_tt_create_thread.c @@ -52,6 +52,8 @@ int32_t __stdcall __ntapi_tt_create_thread( nt_user_stack stack __attr_aligned__(0x10); uintptr_t fsuspended; uintptr_t * parg; + size_t size; + size_t commit; if (!(params->stack_size_commit)) return NT_STATUS_INVALID_PARAMETER; @@ -119,17 +121,17 @@ int32_t __stdcall __ntapi_tt_create_thread( - params->stack_size_commit); /* guard page */ - params->stack_size_commit += __PAGE_SIZE; + commit = params->stack_size_commit + __PAGE_SIZE; stack_system_limit = (void *)((intptr_t)stack.expandable_stack_base - - params->stack_size_commit); + - commit); /* then we commit */ status = __ntapi->zw_allocate_virtual_memory( params->hprocess, &stack_system_limit, 0, - ¶ms->stack_size_commit, + &commit, NT_MEM_COMMIT, NT_PAGE_READWRITE); @@ -140,11 +142,11 @@ int32_t __stdcall __ntapi_tt_create_thread( status); /* finally we protect the guard page */ - params->stack_size_commit = __PAGE_SIZE; + size = __PAGE_SIZE; status = __ntapi->zw_protect_virtual_memory( params->hprocess, &stack_system_limit, - ¶ms->stack_size_commit, + &size, NT_PAGE_READWRITE | NT_MEM_PAGE_GUARD, &protect_type_old); -- cgit v1.2.3