diff --git a/src/daemon/ptyc_daemon_loop.c b/src/daemon/ptyc_daemon_loop.c index cacc879..b5a9538 100644 --- a/src/daemon/ptyc_daemon_loop.c +++ b/src/daemon/ptyc_daemon_loop.c @@ -22,8 +22,51 @@ static ptyc_daemon_routine * ptyc_daemon_vtbl[PTYC_VTBL_ELEMENTS] = { 0 }; +static int ptyc_init_pidmap_target_symlink(struct ptyc_daemon_ctx * dctx) +{ + int status; + void * hkeydir; + + struct ptyc_driver_ctx_impl * ictx = ptyc_get_driver_ictx(dctx->driver_ctx); + + if ((status = ntapi->tt_create_keyed_object_directory( + &hkeydir, + NT_SYMBOLIC_LINK_ALL_ACCESS, + ictx->rtdata->hpidmapdir, + pe_get_current_process_id()))) + return status; + + if ((status = ntapi->zw_set_information_object( + hkeydir, + NT_OBJECT_HANDLE_INFORMATION, + &(nt_object_handle_information){0,0}, + sizeof(nt_object_handle_information)))) + return status; + + return ntapi->tt_create_keyed_object_directory_entry( + &ictx->hntpipc, + NT_SYMBOLIC_LINK_ALL_ACCESS, + hkeydir, + dctx->hport_daemon,0, + pe_get_current_process_id()); +} + +static int ptyc_init_ntpipc_target_symlink(struct ptyc_daemon_ctx * dctx) +{ + struct ptyc_driver_ctx_impl * ictx = ptyc_get_driver_ictx(dctx->driver_ctx); + + return ntapi->tt_create_keyed_object_directory_entry( + &ictx->hntpipc, + NT_SYMBOLIC_LINK_ALL_ACCESS, + ictx->rtdata->hntpipcdir, + dctx->hport_daemon,0, + pe_get_current_process_id()); +} + int32_t __stdcall ptyc_daemon_loop(void * ctx) { + int status; + struct ptyc_daemon_ctx * dctx; nt_rtdata * rtdata; @@ -41,6 +84,14 @@ int32_t __stdcall ptyc_daemon_loop(void * ctx) dctx = (struct ptyc_daemon_ctx *)ctx; + /* pidmap daemon symlink */ + if ((status = ptyc_init_pidmap_target_symlink(dctx))) + return status; + + /* ntpipc daemon symlink */ + if ((status = ptyc_init_ntpipc_target_symlink(dctx))) + return status; + /* init */ request = &inbuf; ntapi->tt_aligned_block_memset( diff --git a/src/internal/ptycon_driver_impl.h b/src/internal/ptycon_driver_impl.h index 1037894..3853751 100644 --- a/src/internal/ptycon_driver_impl.h +++ b/src/internal/ptycon_driver_impl.h @@ -61,6 +61,8 @@ struct ptyc_driver_ctx_impl { struct ptyc_loop_ctx lctx; struct ptyc_common_ctx cctx; struct ptyc_driver_ctx ctx; + void * hntpipc; + void * hpidmap; }; static inline struct ptyc_driver_ctx_impl * ptyc_get_driver_ictx(struct ptyc_driver_ctx * dctx)