diff --git a/project/common.mk b/project/common.mk index 152a1f4..c4c5132 100644 --- a/project/common.mk +++ b/project/common.mk @@ -3,6 +3,7 @@ API_SRCS = \ INTERNAL_SRCS = \ src/client/toks_client_acquire.c \ src/client/toks_client_connect.c \ + src/client/toks_client_release.c \ src/daemon/toks_daemon_acquire.c \ src/daemon/toks_daemon_connect.c \ src/daemon/toks_daemon_init.c \ diff --git a/src/client/toks_client_release.c b/src/client/toks_client_release.c new file mode 100644 index 0000000..87a5b4d --- /dev/null +++ b/src/client/toks_client_release.c @@ -0,0 +1,45 @@ +/*********************************************************/ +/* toksvc: a framework-native token broker service */ +/* Copyright (C) 2020 Z. Gilboa */ +/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */ +/*********************************************************/ + +#include +#include + +#include +#include "toksvc_driver_impl.h" +#include "toksvc_daemon_impl.h" + +int32_t toks_client_release(struct toks_driver_ctx * dctx) +{ + int32_t status; + void * hport; + struct _nt_tty_ipc_msg msg; + struct _nt_port_keys * keys; + + hport = toks_get_driver_hservice(dctx); + keys = toks_get_driver_keys(dctx); + + ntapi->tt_aligned_block_memset( + &msg,0,sizeof(msg)); + + msg.header.msg_type = NT_LPC_NEW_MESSAGE; + msg.header.data_size = sizeof(msg.data); + msg.header.msg_size = sizeof(msg); + msg.data.ttyinfo.opcode = TOKS_DAEMON_RELEASE; + + msg.data.ipcinfo.ipckeys[0] = keys->key[0]; + msg.data.ipcinfo.ipckeys[1] = keys->key[1]; + msg.data.ipcinfo.ipckeys[2] = keys->key[2]; + msg.data.ipcinfo.ipckeys[3] = keys->key[3]; + msg.data.ipcinfo.ipckeys[4] = keys->key[4]; + msg.data.ipcinfo.ipckeys[5] = keys->key[5]; + + if ((status = ntapi->zw_request_wait_reply_port(hport,&msg,&msg))) + return status; + + return (msg.data.ttyinfo.status) + ? msg.data.ttyinfo.status + : NT_STATUS_SUCCESS; +}