summaryrefslogtreecommitdiffhomepage
path: root/src/thread
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-22 18:27:02 -0400
committermidipix <writeonce@midipix.org>2016-10-23 01:00:38 -0400
commit656c604e5e206b1abd5932e910f7686dc324f3ab (patch)
treedbd11ce5a2e56e654a6826abd6a96a6edd852ed3 /src/thread
parent6c2ba1325ddcb52d44cd2ffccbdf6a4bb2853365 (diff)
downloadntapi-656c604e5e206b1abd5932e910f7686dc324f3ab.tar.bz2
ntapi-656c604e5e206b1abd5932e910f7686dc324f3ab.tar.xz
__ntapi_tt_create_thread(): retain proper value of params->stack_size_commit.
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/ntapi_tt_create_thread.c12
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,
- &params->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,
- &params->stack_size_commit,
+ &size,
NT_PAGE_READWRITE | NT_MEM_PAGE_GUARD,
&protect_type_old);