|
|
c78a06 |
/*********************************************************/
|
|
|
c78a06 |
/* toksvc: a framework-native token broker service */
|
|
|
c78a06 |
/* Copyright (C) 2020 Z. Gilboa */
|
|
|
c78a06 |
/* Released under GPLv2 and GPLv3; see COPYING.TOKSVC. */
|
|
|
c78a06 |
/*********************************************************/
|
|
|
c78a06 |
|
|
|
c78a06 |
#include <psxtypes/psxtypes.h>
|
|
|
c78a06 |
#include <ntapi/ntapi.h>
|
|
|
c78a06 |
|
|
|
c78a06 |
#include <toksvc/toksvc.h>
|
|
|
c78a06 |
#include "toksvc_daemon_impl.h"
|
|
|
c78a06 |
#include "toksvc_driver_impl.h"
|
|
|
c78a06 |
|
|
|
c78a06 |
static void toks_daemon_token_reset(struct toks_token * token)
|
|
|
c78a06 |
{
|
|
|
c78a06 |
token->self = 0;
|
|
|
c78a06 |
token->keys.key[0] = 0;
|
|
|
c78a06 |
token->keys.key[1] = 0;
|
|
|
c78a06 |
token->keys.key[2] = 0;
|
|
|
c78a06 |
token->keys.key[3] = 0;
|
|
|
c78a06 |
token->keys.key[4] = 0;
|
|
|
c78a06 |
token->keys.key[5] = 0;
|
|
|
c78a06 |
}
|
|
|
c78a06 |
|
|
|
c78a06 |
int32_t __stdcall toks_daemon_release(struct toks_daemon_ctx * dctx)
|
|
|
c78a06 |
{
|
|
|
c78a06 |
nt_tty_port_msg * msg;
|
|
|
c78a06 |
struct toks_token * token;
|
|
|
c78a06 |
struct toks_token * toptr;
|
|
|
c78a06 |
struct toks_token * tocap;
|
|
|
c78a06 |
uint32_t * keys;
|
|
|
c78a06 |
|
|
|
c78a06 |
msg = &dctx->reply;
|
|
|
c78a06 |
keys = msg->ipcinfo.ipckeys;
|
|
|
c78a06 |
|
|
|
c78a06 |
toptr = toks_get_driver_tokens(dctx->driver_ctx);
|
|
|
c78a06 |
tocap = &toptr[toks_get_driver_ntokens(dctx->driver_ctx)];
|
|
|
c78a06 |
|
|
|
c78a06 |
for (token=0; !token && (toptr
|
|
|
c78a06 |
if ((toptr->self)
|
|
|
c78a06 |
&& (toptr->keys.key[0] == keys[0])
|
|
|
c78a06 |
&& (toptr->keys.key[1] == keys[1])
|
|
|
c78a06 |
&& (toptr->keys.key[2] == keys[2])
|
|
|
c78a06 |
&& (toptr->keys.key[3] == keys[3])
|
|
|
c78a06 |
&& (toptr->keys.key[4] == keys[4])
|
|
|
c78a06 |
&& (toptr->keys.key[5] == keys[5]))
|
|
|
c78a06 |
token = toptr;
|
|
|
c78a06 |
|
|
|
c78a06 |
if (!token)
|
|
|
c78a06 |
return NT_STATUS_INVALID_PARAMETER;
|
|
|
c78a06 |
|
|
|
c78a06 |
toks_daemon_token_reset(token);
|
|
|
c78a06 |
|
|
|
c78a06 |
ntapi->zw_alert_thread(token->client.hinstance);
|
|
|
c78a06 |
ntapi->zw_close(token->client.hinstance);
|
|
|
c78a06 |
|
|
|
c78a06 |
return NT_STATUS_SUCCESS;
|
|
|
c78a06 |
}
|