diff options
author | midipix <writeonce@midipix.org> | 2019-06-11 17:03:07 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2019-06-11 17:03:07 +0000 |
commit | 1039602ffac9d4585ceb739545c2c3a369100df6 (patch) | |
tree | 244106dcc3b025c4d231d1409d861fd5156acdbe /src/process | |
parent | baceb0cc712831f7962521ebe22fa2b714184911 (diff) | |
download | ntapi-1039602ffac9d4585ceb739545c2c3a369100df6.tar.bz2 ntapi-1039602ffac9d4585ceb739545c2c3a369100df6.tar.xz |
__ntapi_tt_spawn_native_process(): support additional pass-through context.
Diffstat (limited to 'src/process')
-rw-r--r-- | src/process/ntapi_tt_spawn_native_process.c | 52 |
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( |