|
|
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 |
|
|
|
e3e583 |
msg.data.ipcinfo.ctrlsvc.keys.key[0] = toks_get_driver_tokpid(dctx);
|
|
|
658181 |
msg.data.ipcinfo.hevent = toks_get_driver_hevent(dctx);
|
|
|
e3e583 |
|
|
|
02451d |
if ((status = ntapi->zw_request_wait_reply_port(hport,&msg,&msg)))
|
|
|
02451d |
return status;
|
|
|
02451d |
|
|
|
658181 |
switch (msg.data.ttyinfo.status) {
|
|
|
658181 |
case NT_STATUS_SUCCESS:
|
|
|
658181 |
break;
|
|
|
658181 |
|
|
|
658181 |
case NT_STATUS_PENDING:
|
|
|
658181 |
status = ntapi->zw_wait_for_single_object(
|
|
|
658181 |
msg.data.ipcinfo.hevent,
|
|
|
658181 |
NT_SYNC_NON_ALERTABLE,
|
|
|
658181 |
0);
|
|
|
658181 |
break;
|
|
|
658181 |
|
|
|
658181 |
default:
|
|
|
658181 |
return msg.data.ttyinfo.status;
|
|
|
658181 |
}
|
|
|
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 |
|
|
|
658181 |
return status;
|
|
|
02451d |
}
|