This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Theos is a Windows NT-compatible kernel written in Rust (2024 edition) targeting x86_64. It implements NT system calls to run Windows PE executables, with support for UEFI EFI stub booting.
The project uses Buck2 (not Cargo) with reindeer for dependency management. Standard cargo build will not work.
# Build everything
buck2 build //...
# Run in QEMU
buck2 run //:run
# Run with custom options
QEMU_MEM=1G ROOTFS_PROFILE=auto buck2 run //:runKey runtime env vars: KERNEL_INIT, KERNEL_ROOT, KERNEL_ROOTFSTYPE, KERNEL_CMDLINE, ROOTFS_SIZE_MIB, ROOTFS_PROFILE (auto/lite/real), QEMU_MEM (default 512M), ROOTFS_ISO, ARCH.
There is currently no linting workflow.
There is no formal test suite. Testing is done by running the kernel in QEMU via buck2 run //:run and observing behavior. CI only runs buck2 build //....
kernel.rs— entry point; handles both UEFI and Limine boot pathsuser.rs— user-mode execution context, memory space management, PE loading (~120KB, central to NT compat)syscall.rs— x86_64 SYSCALL/SYSRET handler setupprocess.rs— task/process structures and scheduler (priority classes: Game/Normal/Background, credit-based wake)nt.rs— NT status codes, handle types, access masks, memory flagsvfs.rs— virtual filesystem layer (pipes, CrabFS, special files)paging.rs,allocator.rs— page tables and linked-list heapapic.rs,gdt.rs,idt.rs,smp.rs— CPU/interrupt infrastructurevirtio_blk.rs,pci.rs— VirtIO block device and PCI enumeration
crabfs— custom XFS-like filesystem (used as the rootfs format), works inno_stdregf— Windows registry hive parser (reads .SAM/.SYSTEM/.SOFTWARE hives)loader— PE/ELF loader using gobliniso9660,udf— disc filesystem readerswim_lzx— WIM image and LZX decompression
run.rs— QEMU launcher: extracts Windows rootfs from ISO via wimunpack, creates CrabFS images, launches QEMUmkrootfs— creates CrabFS filesystem images from directorieswimunpack— extracts Windows WIM images from ISO files
Minimal Windows userspace compiled with clang targeting x86_64-pc-windows-msvc:
init.exe— init process (Windows PE)child.exe— child process examplentdll.dll— minimal NTDLL stub with syscall stubs
- All kernel code is
#![no_std]; library crates usestdfeature gates where needed - Rust 2024 edition throughout (requires nightly)
- Buck2 workspace cells: root, prelude, toolchains, third-party — dependency changes go through reindeer
- The repo uses Jujutsu (
jj) alongside git; the development branch iscanon