Blame src/client/toks_client_acquire.c

02451d
/*********************************************************/
02451d
/*  toksvc: a framework-native token broker service      */
02451d
/*  Copyright (C) 2020  Z. Gilboa                        */
02451d
/*  Released under GPLv2 and GPLv3; see COPYING.TOKSVC.  */
02451d
/*********************************************************/
02451d
02451d
#include <psxtypes/psxtypes.h>
02451d
#include <ntapi/ntapi.h>
02451d
02451d
#include <toksvc/toksvc.h>
02451d
#include "toksvc_driver_impl.h"
02451d
#include "toksvc_daemon_impl.h"
02451d
02451d
int32_t toks_client_acquire(struct toks_driver_ctx * dctx)
02451d
{
02451d
	int32_t			status;
02451d
	void *			hport;
02451d
	struct _nt_tty_ipc_msg	msg;
02451d
	struct _nt_port_keys *	keys;
02451d
02451d
	hport = toks_get_driver_hservice(dctx);
02451d
	keys  = toks_get_driver_keys(dctx);
02451d
02451d
	ntapi->tt_aligned_block_memset(
02451d
		&msg,0,sizeof(msg));
02451d
02451d
	msg.header.msg_type	= NT_LPC_NEW_MESSAGE;
02451d
	msg.header.data_size	= sizeof(msg.data);
02451d
	msg.header.msg_size	= sizeof(msg);
02451d
	msg.data.ttyinfo.opcode	= TOKS_DAEMON_ACQUIRE;
02451d
02451d
	if ((status = ntapi->zw_request_wait_reply_port(hport,&msg,&msg)))
02451d
		return status;
02451d
02451d
	else if (msg.data.ttyinfo.status)
02451d
		return msg.data.ttyinfo.status;
02451d
02451d
	keys->key[0] = msg.data.ipcinfo.ipckeys[0];
02451d
	keys->key[1] = msg.data.ipcinfo.ipckeys[1];
02451d
	keys->key[2] = msg.data.ipcinfo.ipckeys[2];
02451d
	keys->key[3] = msg.data.ipcinfo.ipckeys[3];
02451d
	keys->key[4] = msg.data.ipcinfo.ipckeys[4];
02451d
	keys->key[5] = msg.data.ipcinfo.ipckeys[5];
02451d
02451d
	return NT_STATUS_SUCCESS;
02451d
}