summaryrefslogtreecommitdiffhomepage
path: root/src/internal
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-01-17 21:03:22 +0000
committermidipix <writeonce@midipix.org>2018-01-20 13:48:59 -0500
commit80b89c048ce8168a5dd42fd59ec0432d9adf40d9 (patch)
treeef12a4d2ecec16f83ba02baf901be44268bfdff6 /src/internal
parente870a26f283adadbc369cdcb559bfdad885a10c0 (diff)
downloadntapi-80b89c048ce8168a5dd42fd59ec0432d9adf40d9.tar.bz2
ntapi-80b89c048ce8168a5dd42fd59ec0432d9adf40d9.tar.xz
__ntapi_init(), fork: obtain and keep a handle to the running process.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/ntapi.c19
-rw-r--r--src/internal/ntapi_impl.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/internal/ntapi.c b/src/internal/ntapi.c
index 06a70fe..1b06bcc 100644
--- a/src/internal/ntapi.c
+++ b/src/internal/ntapi.c
@@ -93,6 +93,8 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
int32_t status;
void * hntdll;
size_t block_size;
+ nt_oa oa;
+ nt_cid cid;
ntapi_zw_allocate_virtual_memory * pfn_zw_allocate_virtual_memory;
char fname_allocate_virtual_memory[] =
"ZwAllocateVirtualMemory";
@@ -446,6 +448,23 @@ static int32_t __fastcall __ntapi_init_once(ntapi_vtbl ** pvtbl)
(uintptr_t *)&___ntapi,
sizeof(ntapi_vtbl));
+ /* process handle */
+ oa.len = sizeof(oa);
+ oa.root_dir = 0;
+ oa.obj_name = 0;
+ oa.obj_attr = 0;
+ oa.sec_desc = 0;
+ oa.sec_qos = 0;
+
+ cid.process_id = pe_get_current_process_id();
+ cid.thread_id = pe_get_current_thread_id();
+
+ if ((status = __ntapi->zw_open_process(
+ &internals->hprocess,
+ NT_PROCESS_ALL_ACCESS,
+ &oa,&cid)))
+ return status;
+
/* process token */
if ((status = __ntapi->zw_open_process_token(
NT_CURRENT_PROCESS_HANDLE,
diff --git a/src/internal/ntapi_impl.h b/src/internal/ntapi_impl.h
index 870e5fd..4c26f55 100644
--- a/src/internal/ntapi_impl.h
+++ b/src/internal/ntapi_impl.h
@@ -82,6 +82,7 @@ typedef struct __attr_ptr_size_aligned__ _ntapi_internals {
nt_port_name * subsystem;
nt_security_descriptor seq_desc;
nt_security_quality_of_service seq_qos;
+ void * hprocess;
void * htoken;
void * hport_tty_session;
void * hport_tty_daemon;