From 80236ad5d20fbed5fc375d79a7aabcef0137553c Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 15 May 2018 19:22:24 +0000 Subject: local thread creation: extended argument: sync via atomic memory access. --- src/thread/ntapi_tt_create_thread.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/thread/ntapi_tt_create_thread.c b/src/thread/ntapi_tt_create_thread.c index 2d46996..b40af7a 100644 --- a/src/thread/ntapi_tt_create_thread.c +++ b/src/thread/ntapi_tt_create_thread.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include "ntapi_impl.h" @@ -216,7 +217,7 @@ int32_t __stdcall __ntapi_tt_create_thread(nt_thread_params * params) /* */ /* A "RAPUNZEL" TOP-OF-STACK, VARIABLE-SIZE ENTRY-ROUTINE CONTEXT */ /* */ -/* COPYRIGHT (C) 2013,2014,2015 ZVI GILBOA */ +/* COPYRIGHT (C) 2013--2018 ZVI GILBOA */ /* */ /* */ /* */ @@ -225,12 +226,17 @@ int32_t __stdcall __ntapi_tt_create_thread(nt_thread_params * params) /**/ context.STACK_POINTER_REGISTER -= params->ext_ctx_size; /**/ /**/ params->arg = (void *)context.STACK_POINTER_REGISTER; /**/ /**/ /**/ -/**/ if (params->creation_flags & NT_CREATE_LOCAL_THREAD) /**/ +/**/ if (params->creation_flags & NT_CREATE_LOCAL_THREAD) { /**/ /**/ __ntapi->tt_aligned_block_memcpy( /**/ /**/ (uintptr_t *)params->arg, /**/ /**/ (uintptr_t *)params->ext_ctx, /**/ /**/ params->ext_ctx_size); /**/ -/**/ else { /**/ +/**/ /**/ +/**/ __ntapi->tt_aligned_block_memlock( /**/ +/**/ (uintptr_t *)params->arg, /**/ +/**/ params->ext_ctx_size); /**/ +/**/ /**/ +/**/ } else { /**/ /**/ status = __ntapi->zw_write_virtual_memory( /**/ /**/ params->hprocess, /**/ /**/ params->arg, /**/ @@ -257,9 +263,10 @@ int32_t __stdcall __ntapi_tt_create_thread(nt_thread_params * params) /**/ /**/ /**/ /**/ /* write entry-routine argument */ -/**/ if ((sizeof(size_t) == 8) /**/ -/**/ || (params->creation_flags&NT_CREATE_LOCAL_THREAD))/**/ -/**/ *parg = (uintptr_t)params->arg; /**/ +/**/ if (params->creation_flags & NT_CREATE_LOCAL_THREAD) /**/ +/**/ at_store( /**/ +/**/ (intptr_t *)parg, /**/ +/**/ (intptr_t)params->arg); /**/ /**/ else { /**/ /**/ status = __ntapi->zw_write_virtual_memory( /**/ /**/ params->hprocess, /**/ -- cgit v1.2.3