diff options
Diffstat (limited to 'src/thread')
-rw-r--r-- | src/thread/ntapi_tt_create_thread.c | 47 |
1 files changed, 8 insertions, 39 deletions
diff --git a/src/thread/ntapi_tt_create_thread.c b/src/thread/ntapi_tt_create_thread.c index 50b23d9..a8dcb11 100644 --- a/src/thread/ntapi_tt_create_thread.c +++ b/src/thread/ntapi_tt_create_thread.c @@ -327,36 +327,17 @@ int32_t __stdcall __ntapi_tt_create_thread(nt_thread_params * params) int32_t __stdcall __ntapi_tt_create_local_thread(nt_thread_params * params) { nt_status status; - void * hprocess; void * image_base; struct pe_stack_heap_info stack_heap_info; - nt_client_id cid; - nt_object_attributes oa; - - /* oa init */ - oa.len = sizeof(oa); - oa.root_dir = 0; - oa.obj_name = 0; - oa.obj_attr = 0; - oa.sec_desc = 0; - oa.sec_qos = 0; - - /* init cid */ - cid.process_id = pe_get_current_process_id(); - cid.thread_id = pe_get_current_thread_id(); - - /* obtain a handle to our own process */ - /* TODO: use cached handle, no close */ - if (params->hprocess) - hprocess = 0; - - else if ((status = __ntapi->zw_open_process( - &hprocess, - NT_PROCESS_ALL_ACCESS, - &oa,&cid))) - return status; - /* retrieve the stack defaults as needed */ + /* flags */ + params->creation_flags |= NT_CREATE_LOCAL_THREAD; + + /* hprocess */ + if (!params->hprocess) + params->hprocess = __ntapi_internals()->hprocess; + + /* stack defaults */ if (params->stack_info) (void)0; @@ -385,18 +366,6 @@ int32_t __stdcall __ntapi_tt_create_local_thread(nt_thread_params * params) return NT_STATUS_INVALID_IMAGE_FORMAT; } - params->creation_flags |= NT_CREATE_LOCAL_THREAD; - - if (hprocess) { - params->hprocess = hprocess; - - status = __ntapi_tt_create_thread(params); - __ntapi->zw_close(hprocess); - - return status; - } - - /* TODO: use cached handle, no close */ return __ntapi_tt_create_thread(params); } |