#ifndef TOKSVC_DAEMON_IMPL_H
#define TOKSVC_DAEMON_IMPL_H
#include <psxtypes/psxtypes.h>
#include <ntapi/ntapi.h>
enum toks_daemon_opcodes {
TOKS_DAEMON_OPCODE_BASE = 0x20000,
TOKS_DAEMON_CONNECT = TOKS_DAEMON_OPCODE_BASE,
TOKS_DAEMON_DISCONNECT,
TOKS_DAEMON_TTYSIGNAL,
TOKS_DAEMON_IPCSIGNAL,
TOKS_DAEMON_SIGCHLD,
TOKS_DAEMON_THREADEXIT,
TOKS_DAEMON_CIDQUERY,
TOKS_DAEMON_ACQUIRE,
TOKS_DAEMON_RELEASE,
TOKS_DAEMON_CANCEL,
TOKS_DAEMON_ABORT,
TOKS_DAEMON_IOCTL,
TOKS_DAEMON_OPCODE_CAP
};
struct toks_daemon_ctx;
struct toks_driver_ctx;
struct toks_client_ctx {
void * hprocess;
void * hinstance;
void * hport;
void * hswap;
void * halert;
void * hevent;
void * hdaemon;
int32_t tokpid;
nt_cid cid;
};
struct toks_token {
struct _nt_port_keys keys;
struct toks_client_ctx client;
struct toks_token * self;
};
struct toks_waiter {
struct toks_client_ctx client;
struct _nt_tty_port_msg msg;
};
typedef int32_t __stdcall toks_daemon_routine(struct toks_daemon_ctx *);
struct toks_daemon_ctx {
struct toks_driver_ctx * driver_ctx;
struct toks_waiter * waiter_base;
struct toks_waiter * waiter_first;
struct toks_waiter * waiter_next;
struct toks_waiter * waiter_cap;
nt_port_keys daemon_keys;
nt_port_attr daemon_attr;
nt_port_name daemon_name;
int ftokens;
int utokens;
intptr_t ctrlpid;
intptr_t csyspid;
void * hctrl;
void * hswap;
void * hport_daemon;
void * hevent_daemon_ready;
void * hport_internal_client;
void * hevent_internal_client_ready;
enum toks_daemon_opcodes opcode;
nt_tty_port_msg request;
nt_tty_port_msg reply;
intptr_t reqtokpid;
intptr_t reqsyspid;
};
int32_t __stdcall toks_daemon_init(struct toks_daemon_ctx *, const nt_guid *);
int32_t __stdcall toks_daemon_loop(void *);
int32_t __stdcall toks_daemon_connect(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_cidquery(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_signal(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_acquire(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_pidopen(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_release(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_cancel(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_abort(struct toks_daemon_ctx *);
int32_t __stdcall toks_daemon_ioctl(struct toks_daemon_ctx *);
#endif