summaryrefslogtreecommitdiffhomepage
path: root/src/process
diff options
context:
space:
mode:
Diffstat (limited to 'src/process')
-rw-r--r--src/process/ntapi_tt_spawn_native_process.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/process/ntapi_tt_spawn_native_process.c b/src/process/ntapi_tt_spawn_native_process.c
index be1dde0..3421fcf 100644
--- a/src/process/ntapi_tt_spawn_native_process.c
+++ b/src/process/ntapi_tt_spawn_native_process.c
@@ -69,6 +69,8 @@ int32_t __stdcall __ntapi_tt_spawn_native_process(nt_spawn_process_params * spar
uint32_t fsuspended;
size_t buflen;
size_t written;
+ char * raddr;
+ size_t rsize;
/* rtctx (convenience) */
rtctx = sparams->rtctx;
@@ -279,6 +281,56 @@ int32_t __stdcall __ntapi_tt_spawn_native_process(nt_spawn_process_params * spar
if (!sparams->himage)
__ntapi->zw_close(hfile);
+ /* additional context */
+ if (rtctx->ctx_addr) {
+ rdata->ctx_addr = 0;
+ rdata->ctx_commit = rtctx->ctx_size;
+
+ rdata->ctx_commit += (__NT_INTERNAL_PAGE_SIZE - 1);
+ rdata->ctx_commit |= (__NT_INTERNAL_PAGE_SIZE - 1);
+ rdata->ctx_commit ^= (__NT_INTERNAL_PAGE_SIZE - 1);
+
+ if ((status = __ntapi->zw_allocate_virtual_memory(
+ cparams.hprocess,
+ &rdata->ctx_addr,0,
+ &rdata->ctx_commit,
+ NT_MEM_COMMIT,
+ NT_PAGE_READWRITE)))
+ return __tt_spawn_return(
+ &rtblock,
+ cparams.hprocess,
+ cparams.hthread,
+ status);
+
+ if ((status = __ntapi->zw_write_virtual_memory(
+ cparams.hprocess,
+ rdata->ctx_addr,
+ rtctx->ctx_addr,
+ rtctx->ctx_size,
+ &rdata->ctx_size)))
+ return __tt_spawn_return(
+ &rtblock,
+ cparams.hprocess,
+ cparams.hthread,
+ status);
+
+ raddr = crtblock.remote_addr;
+ raddr += __offsetof(nt_runtime_data,ctx_addr);
+
+ rsize = __offsetof(nt_runtime_data,ctx_offset);
+ rsize -= __offsetof(nt_runtime_data,ctx_addr);
+
+ if ((status = __ntapi->zw_write_virtual_memory(
+ cparams.hprocess,
+ raddr,(char *)&rdata->ctx_addr,
+ rsize,&rsize)))
+ return __tt_spawn_return(
+ &rtblock,
+ cparams.hprocess,
+ cparams.hthread,
+ status);
+ }
+
/* tty session (optional) */
if (sparams->hsession) {
if ((status = __ntapi->tty_client_process_register(