summaryrefslogtreecommitdiffhomepage
path: root/src/process
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2016-10-23 15:27:04 +0000
committermidipix <writeonce@midipix.org>2016-10-23 11:45:40 -0400
commit72fe5e7634ee016e977af8faac14d8a655b78d6a (patch)
tree20f2f28578786f4e732cfe7bb1f2804078ec14d9 /src/process
parent268ef4a7aa53b3be180b0d94463c36ae317359fa (diff)
downloadntapi-72fe5e7634ee016e977af8faac14d8a655b78d6a.tar.bz2
ntapi-72fe5e7634ee016e977af8faac14d8a655b78d6a.tar.xz
__ntapi_tt_fork(): child: obtain hprocess and hthread handles upon success.
Diffstat (limited to 'src/process')
-rw-r--r--src/process/ntapi_tt_fork.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/process/ntapi_tt_fork.c b/src/process/ntapi_tt_fork.c
index 9f498eb..0863ead 100644
--- a/src/process/ntapi_tt_fork.c
+++ b/src/process/ntapi_tt_fork.c
@@ -17,6 +17,45 @@
static intptr_t __fork_retry_stats = 0;
static intptr_t __fork_resume_stats = 0;
+static intptr_t __fastcall __ntapi_tt_fork_finalize(
+ void ** hprocess,
+ void ** hthread)
+{
+ int32_t status;
+ nt_oa oa;
+ nt_cid cid;
+ ntapi_internals * __internals;
+
+ __internals = __ntapi_internals();
+
+ *hprocess = 0;
+ *hthread = 0;
+
+ oa.len = sizeof(oa);
+ oa.root_dir = 0;
+ oa.obj_name = 0;
+ oa.obj_attr = 0;
+ oa.sec_desc = &__internals->seq_desc;
+ oa.sec_qos = &__internals->seq_qos;
+
+ cid.process_id = pe_get_current_process_id();
+ cid.thread_id = pe_get_current_thread_id();
+
+ if ((status = __ntapi->zw_open_process(
+ hprocess,
+ NT_PROCESS_ALL_ACCESS,
+ &oa,&cid)))
+ return status;
+
+ if ((status = __ntapi->zw_open_thread(
+ hthread,
+ NT_THREAD_ALL_ACCESS,
+ &oa,&cid)))
+ return status;
+
+ return 0;
+}
+
static int32_t __stdcall __fork_thread(void * ctx)
{
intptr_t * pstate;
@@ -207,9 +246,12 @@ intptr_t __fastcall __ntapi_tt_fork(
pid = __ntapi_tt_fork_v2(hprocess,hthread);
if (pid == 0) {
- return __ntapi_tt_fork_child(
+ __ntapi_tt_fork_child(
hresumed,hready);
+ return __ntapi_tt_fork_finalize(
+ hprocess,hthread);
+
} else if (pid > 0) {
if (!(__ntapi_tt_fork_parent(
hprocess,hthread,