summaryrefslogtreecommitdiffhomepage
path: root/src/thread
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-01-17 21:11:42 +0000
committermidipix <writeonce@midipix.org>2018-01-20 13:49:00 -0500
commitf36e2da44d5582f72c56ee8c511881ad1f4244c1 (patch)
treeab5d1755cdbd3693f1b6d1aade34da7120f9041b /src/thread
parent80b89c048ce8168a5dd42fd59ec0432d9adf40d9 (diff)
downloadntapi-f36e2da44d5582f72c56ee8c511881ad1f4244c1.tar.bz2
ntapi-f36e2da44d5582f72c56ee8c511881ad1f4244c1.tar.xz
__ntapi_tt_create_local_thread(): use cached handle to running process.
Diffstat (limited to 'src/thread')
-rw-r--r--src/thread/ntapi_tt_create_thread.c47
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);
}