summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-08-19 21:20:12 +0000
committermidipix <writeonce@midipix.org>2024-08-19 21:43:30 +0000
commit4471476c8c75192b44ff37f1d4d08fd111ef6d05 (patch)
tree63088e3dedf03d656f0181906a1f45386979e6f4
parent41736e9019c8bcf3fc45f042759182ea2c2d28bb (diff)
downloadptycon-4471476c8c75192b44ff37f1d4d08fd111ef6d05.tar.bz2
ptycon-4471476c8c75192b44ff37f1d4d08fd111ef6d05.tar.xz
daemon: utilize the framework's ipc object directories.
-rw-r--r--src/daemon/ptyc_daemon_loop.c51
-rw-r--r--src/internal/ptycon_driver_impl.h2
2 files changed, 53 insertions, 0 deletions
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)