Repository navigation
Vodka Server and RPC
vodkaserver (vodka/src/server/) is Vodka's standalone Apache-2.0 native Zig NT kernel daemon. It coordinates shared NT kernel state across all Windows processes executing inside a Vodka prefix over a 43-opcode AF_UNIX binary RPC protocol.
vodkaserver locates the active prefix using VODKAPREFIX, falling back to $HOME/.vodka.
To guarantee strict multi-user isolation on Linux:
- Verifies the prefix directory is owned by
getuid()viastatx. - Creates
/tmp/.vodka-<uid>/with0700permissions (rejecting symlinks, non-directories, wrong ownership, or any group/world permission bits0o077). - Creates a per-prefix subdirectory keyed by the prefix directory's device major/minor and inode (
server-<dev>-<ino>/, mode0700). - Acquires an exclusive
fcntlwrite lock (F_SETLK,F_WRLCK) onlockinside that directory. If anothervodkaserveralready owns the lock,vodkaservereither exits cleanly, signals it (-k), waits for it (-w), or pings it (--ping). - Binds an
AF_UNIXSOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXECmaster listener socket (socket). - Unless
-f/--foregroundis specified, daemonizes cleanly using a parent/child synchronization pipe so the parent returns only after the daemon is ready to accept connections.
vodkaserver implements wineserver-compatible CLI flags plus a --ping health probe:
| Short | Long | Description |
|---|---|---|
-d[N] |
--debug[=N] |
Set debug verbosity level (defaults to incrementing by 1 if N is omitted) |
-f |
--foreground |
Stay in the foreground instead of daemonizing |
-h |
--help |
Print CLI usage and exit |
-k[N] |
--kill[=N] |
Terminate the running vodkaserver for the active prefix (optional signal number N) |
-p[N] |
--persistent[=N] |
Keep the server alive for N seconds after the last client disconnects (or indefinitely if N is omitted; default linger is 3 seconds) |
-v |
--version |
Print version (vodka-0.1) and exit |
-w |
--wait |
Wait until the active prefix's vodkaserver exits and releases its lock |
| — | --ping |
Connect to the prefix AF_UNIX socket, send a binary ping RPC frame, and verify the reply |
-
epollMultiplexer (event_loop.zig): Drives all listening sockets, accepted client sockets, and periodic persistence/shutdown timers in a single non-blocking Linuxepollloop. -
Linux
/dev/ntsyncBridge (sync.zig): Probes/dev/ntsyncat startup for kernel-accelerated NT synchronization primitives (semaphores, mutexes, and manual/auto-reset events), with in-process userspace NT wait/signal semantics when/dev/ntsyncis unavailable.
Every client-server RPC exchange uses ABI-verified fixed 64-byte headers matching the NT server IPC wire layout:
pub const RequestHeader = extern struct {
req: i32, // RpcOpcode
request_size: u32, // Variable trailing payload bytes
reply_size: u32, // Max variable reply bytes expected
}; // 12 bytes
pub const ReplyHeader = extern struct {
@"error": u32, // NTSTATUS (0 = STATUS_SUCCESS)
reply_size: u32, // Actual variable reply payload bytes following header
}; // 8 bytes
pub const GenericRequest = extern union {
header: RequestHeader,
raw: [64]u8,
};
pub const GenericReply = extern union {
header: ReplyHeader,
raw: [64]u8,
};Variable-length payloads (UTF-16/UTF-8 names, Registry value data, pipe/mailslot payloads, clipboard data) follow immediately after the 64-byte header on the stream socket.
vodka-proto (vodka/src/server/protocol.zig) parses protocol definitions (@REQ, @REPLY, @END, struct/typedef/enum declarations, and VARARG fields) and emits strongly typed Zig wire definitions with compile-time layout assertions.
ServerKernel (vodka/src/server/dispatch.zig) serves 43 RPC opcodes (0–42) backed by live kernel state engines:
| Subsystem | Source Module | RPC Opcodes & Capabilities |
|---|---|---|
| Core & Lifecycle |
dispatch.zig, wire.zig
|
ping (0), init_first_thread (1), get_kernel_stats (42) |
| Object Manager & Handles |
object.zig, handle.zig
|
Reference-counted NT object namespace, handle allocation, close_handle (4), dup_handle (11), access-mask checks |
| Synchronization | sync.zig |
create_event (2), event_op (3: pulse/set/reset), create_mutex (7), release_mutex (8), create_semaphore (9), release_semaphore (10), /dev/ntsync probe |
| Windows Registry | registry.zig |
Full hive tree (HKLM, HKCU, HKU, HKCR), reg_set_value (5), reg_get_value (6), flush_registry (12), reg_delete_value (13), and .reg text hive load/save persistence (system.reg, user.reg, userdef.reg) |
| Processes & Threads | process.zig |
Process/thread table, PID/TID allocation, exit codes, create_process (14), terminate_process (15), query_process (16) |
| Global Atom Table | atom.zig |
Case-insensitive global atom registry with reference counts: add_atom (17), find_atom (18), get_atom_name (19), delete_atom (20) |
| Named Pipes | pipe.zig |
Byte-stream & message-mode named pipe instances: create_pipe (21), pipe_write (22), pipe_read (23) |
| I/O Completion Ports | iocp.zig |
Completion packet queues with concurrency limits: create_iocp (24), post_iocp (25), dequeue_iocp (26) |
| Section Mappings | mapping.zig |
Named/anonymous shared memory sections (PAGE_*, SEC_*): create_mapping (27), query_mapping (28) |
| Job Objects | job.zig |
Process groups, resource/process limits, and accounting: create_job (29), assign_job (30), query_job (31) |
| Security Tokens & ACLs | token.zig |
SIDs, privileges (LUID), DACL access checks: create_token (32), check_privilege (33) |
| Window Stations, Desktops & Clipboard | winstation.zig |
Pre-populated interactive WinSta0, desktop/message queue management, clipboard format store: open_winstation (34), set_clipboard (35), get_clipboard (36) |
| Byte-Range File Locks | file_lock.zig |
Shared/exclusive byte-range conflict detection (STATUS_FILE_LOCK_CONFLICT, STATUS_RANGE_NOT_LOCKED): lock_file (37), unlock_file (38) |
| Mailslots | mailslot.zig |
Unidirectional datagram IPC queues: create_mailslot (39), mailslot_write (40), mailslot_read (41) |
Inside libvodka_ntdll.so:
-
rpc_client.zigdiscovers the prefix socket (VODKAPREFIX->/tmp/.vodka-<uid>/server-<dev>-<ino>/socket), connects overAF_UNIX, and marshalsGenericRequest/GenericReplyframes. -
reg_thunks.zigroutesadvapi32Registry APIs (RegOpenKeyEx*,RegCreateKeyEx*,RegSetValueEx*,RegQueryValueEx*,RegDeleteValue*,RegCloseKey, etc.) live tovodkaserver. -
kernel_rpc_thunks.zigconnects Win32GlobalAddAtomA/GlobalFindAtomA/GlobalGetAtomNameA/GlobalDeleteAtom,CreateIoCompletionPort/PostQueuedCompletionStatus/GetQueuedCompletionStatus, job objects, named pipes, mailslots, clipboard, andLockFile/UnlockFilelive tovodkaserver.
Copyright (c) 2026 buntatoes. Vodka is a 100% standalone runtime built from scratch and licensed under the Apache License 2.0. The Vodka name, wordmark, and logo are All Rights Reserved.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc. DirectX, Windows, AMD, NVIDIA, Intel, and other third-party trademarks belong to their respective owners; Vodka is an independent project and is not affiliated with or endorsed by them.
Core Runtime
Graphics, Display & Audio
Tools & Programs
Platform & Project
Links