diff options
-rw-r--r-- | src/thread/ntapi_tt_create_thread.c | 12 |
1 files 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); |