From 3bc37f8fb297f48788ebb34ff7bdbed96566bd2a Mon Sep 17 00:00:00 2001 From: midipix Date: Dec 15 2016 06:48:02 +0000 Subject: __ntapi_tt_create_thread(): do not alter value of caller's params->reg_context. --- diff --git a/src/thread/ntapi_tt_create_thread.c b/src/thread/ntapi_tt_create_thread.c index 50a7d2f..f70d66f 100644 --- a/src/thread/ntapi_tt_create_thread.c +++ b/src/thread/ntapi_tt_create_thread.c @@ -157,9 +157,15 @@ int32_t __stdcall __ntapi_tt_create_thread( status); /* context */ - if (!params->reg_context) { - params->reg_context = &context; - __ntapi->tt_aligned_block_memset(&context,0,sizeof(nt_thread_context)); + if (params->reg_context) { + __ntapi->tt_aligned_block_memcpy( + (uintptr_t *)&context, + (uintptr_t *)params->reg_context, + sizeof(context)); + } else { + __ntapi->tt_aligned_block_memset( + &context,0,sizeof(context)); + __INIT_CONTEXT(context); context.INSTRUCTION_POINTER_REGISTER = (uintptr_t)params->start; context.STACK_POINTER_REGISTER = (uintptr_t)(stack.expandable_stack_base) @@ -265,7 +271,7 @@ int32_t __stdcall __ntapi_tt_create_thread( params->obj_attr, params->hprocess, &cid, - params->reg_context, + &context, &stack, fsuspended);