Object Manager today
Typed objects with Windows lifetimes: a pointer count and a handle count, so an object outlives its last handle exactly as long as Windows says it should.
Architecture
ninjinOS has three layers: a Linux kernel extended with an NT executive, an NT userland that Windows programs link against, and an image-based distribution that ships them together. This page walks through each one, how a call travels between them, and how we know it behaves like Windows.
01 · The layers
A Windows program and a Linux program run side by side. Each talks to the kernel in its own language — NT system calls on one side, Linux system calls on the other — and the same kernel answers both, on the same drivers, scheduler and memory.
Green parts of the executive exist today; the others arrive phase by phase. An NT process is a Linux process and an NT thread is a Linux thread: ntexec attaches Windows state to them — a handle table, a process environment, a thread environment — instead of running a parallel world.
02 · ntexec
ntexec starts as an ordinary loadable module, /dev/ntexec, and adds a small
patch set to the core kernel only where a module cannot reach — system call entry and
exception delivery, in Phase 5. It is written to the Linux kernel's own coding standard
and checked by its tools.
Typed objects with Windows lifetimes: a pointer count and a handle count, so an object outlives its last handle exactly as long as Windows says it should.
\BaseNamedObjects, \Sessions, \??: directories, symbolic links, case rules and every error code programs check for — and a namespace of its own for every Linux user, so one user's programs never touch another's.
Per-process handle tables with granted access, inheritance and protection from closing; duplication, queries and the generic access mappings of each type.
Events, mutants, semaphores and timers; wait-any and atomic wait-all; abandoned mutants. The locking design follows Linux's own ntsync driver.
A binfmt handler that makes .exe files executable, maps PE images and starts them as NT processes — how ./hello.exe runs.
Processes and threads work today: NtCreateUserProcess starts a program as an ordinary Linux child, NtCreateThreadEx adds threads, running or suspended, with inherited handles, exit codes and waits, matching Windows line for line. A program's own crashes are NT exceptions now: access violations, divide errors, illegal instructions and breakpoints reach its vectored handlers, which can repair the context and continue, and NtRaiseException and NtContinue work as on Windows. Virtual memory works too: reserve and commit, protection, guard pages and queries that describe memory exactly as Windows does, and so do sections: shared memory, files and PE images mapped as views, with every program sharing one copy of ntdll.dll through \KnownDlls. Typing ./program.exe now starts it with Wine's full ntdll, kernel32 and C runtime, and so does a program another one creates with NtCreateUserProcess: it keeps the process the kernel prepared for it, with its ID, handles and exit status. A hello world written like any C program, with printf and kernel32, built against Wine's headers and import libraries, prints on ninjinOS exactly the bytes it prints on Windows, and Wine's cmd.exe runs commands, batch files and a dozen console tools, each one an NT process. Threads are controlled from any thread, as on Windows: the kernel asks the thread itself, through one signal its ntdll handles, to stop and resume, to hand over or take back its registers, or to end; a process can start suspended, and a program can start a thread in another process, its handle and IDs the creator's, all matching Windows line for line. Native C structured exception handling now runs compiler-generated __try/__except filters and __finally cleanup, with static-image lookup and AMD64 version-1 frame unwinding. Code a program generates at run time, as a JIT compiler does, unwinds too: the function tables it registers, ordinary, growable or served by a callback, are looked up as Windows looks them up, matching it line for line. An exception raised inside a filter, or by a __finally block while an unwind runs it, reaches the right outer handler without any cleanup running twice, and RtlRaiseException works as on Windows. Whole-stack exit unwinds through RtlUnwind and RtlUnwindEx run active cleanup with the observed record contents and flags. Eighteen readable unwind-record cases also match Windows, including invalid-operation errors and encodings it tolerates. A new thread's stack grows as on Windows, and when it runs out the program gets STATUS_STACK_OVERFLOW and can still catch it. A native debugger attached when a child starts can inspect an exception before user handlers, recover by changing the stopped thread's context, or observe the fatal exit after both chances are declined. Programs can handle the CPU's other traps too, single steps, privileged instructions, stack-segment and alignment faults, and x87 and SSE floating-point errors, each reported as Windows reports it, and resume with an edited context. An allowed access to a guarded page now raises its one-shot exception and clears the guard before a handler retries; an access denied by the underlying protection remains an access violation. This covers the native runtime; C++ handling and broader debugger attachment remain separate work.
Files, pipes, sockets, the registry in real hive files, tokens and access checks, reducing Wine's userspace server to window-manager state. The I/O manager has begun, in Windows' own model: drivers and devices in the namespace, file objects, and every request an I/O request packet that the device's driver serves. Its first device, \Device\Null (NUL), answers opens, reads, writes, control requests and information queries exactly as Windows does, for ntdll-lite's programs and Wine's alike. The C: drive is ext4 with case-insensitive names, chosen by measuring it against both of Linux's NTFS drivers, which the system makes at boot in a sparse file until the installer gives it a partition, each user to have a directory of it as their own C:, and the kernel has its file system: files opened with the program's Linux permissions, Windows' sharing modes and delete-on-close across every program that opens a file, renames, attributes, and directory listings sorted as NTFS sorts them, all matching Windows line for line in a probe of over two hundred cases; and byte-range locks, exclusive and shared, each its handle's and key's, which other handles' reads and writes run into, and which wait, when asked to, until the range is free, or are cancelled, matching Windows line for line in a probe of a hundred cases; and extended attributes, set, replaced, deleted and queried one at a time, by index or by name, given when a file is created and refused as Windows refuses them, matching Windows line for line in another hundred; and change notification, a directory's requests that wait for the next file created, deleted, renamed, written or changed, in the directory or the whole tree below it, Linux programs' changes included, kept between requests as Windows keeps them, matching Windows line for line; and scatter and gather I/O, a file's pages read into and written from a list of the program's own pages, with Windows' rules for sectors, offsets and the handles that may do it. Programs reach it through their current directory and their standard handles for now, and Wine's server can already map its files, as it will every DLL on C:. Named pipes and mailslots are the kernel's too, for Wine's programs as for ntdll-lite's, in buffers of their own within each pipe's quotas: messages read in parts, peeking, listening, disconnecting, transactions, the client's process ID and when a server may impersonate its client, and the first requests that wait — a read, a listen, a flush or a write beyond the quota stays pending until the other end acts, then writes its status block and sets its event, or is cancelled, even from another thread while its own waits — matching Windows line for line; a shell's pipeline is a pipe to the program at either end, as Windows' anonymous pipes are. Wine's server no longer keeps pipes of its own. Completion ports are the kernel's for every program, queues of packets that threads wait on and take from in order, with files whose requests queue themselves there to be finished by whichever thread takes them; so are user APCs and alerts, which run when a thread waits alertably, with the APCs of timers and requests, matching Windows line for line. Security has begun with tokens: every process has one, a copy of its creator's or, for the first of its line, that of an administrator at the desktop, its user a SID made from the Linux user; programs open, read, duplicate and compare them and adjust their privileges; and the kernel's objects have security descriptors, given, inherited from their directory or made from the creator's token, processes, threads and tokens too, and files on C:, which keep theirs on the volume and pass them on as NTFS does, which Wine's programs read and set too, and which only a file's owner may change, each user's C: their own directory of the volume; and one access check, Windows' own order of privileges, owner, DACL and integrity label, answers programs that ask and runs on every open by name and every open of a process or thread by its ID, logging what it would refuse until a type is made strict; and threads impersonate: a token of their own, a copy of another thread's, the anonymous token, or a pipe's client as it opened or as it wrote, which every check and every new object then goes by; and objects carry integrity labels, given, set, passed on by their directory or set by a creator below Medium, so a Low program can write only where Windows lets it; and programs make restricted tokens, as sandboxes do, with groups that only deny, fewer privileges and restricted SIDs that every check then also goes by, all matching Windows line for line. Wine's programs now use these same kernel tokens and access checks: their token services, impersonation and process creation with a token go through the kernel, and the server reads token defaults and asks the kernel to check its remaining objects. The registry has begun in the kernel too, as Windows has it: keys are objects below \REGISTRY, each Linux user with a registry of its own, machine keys included, whose keys and values programs create, open, read, list, rename and delete, with Windows' sorting, limits, access rights and deleted keys, matching Windows line for line in a probe of over four hundred cases; and it outlives a restart, each user's hives saved as Windows' own regf files, whole and synced a few seconds after a change, read back with every cell checked, names folded and sorted by Windows' own uppercase table; and programs can wait for a key to change, its values, its subkeys or its security, or anything in the tree below it, with Windows' own rules for which change wakes which request, matching Windows line for line; and keys can be symbolic links to other keys, followed, opened and refused as Windows does, which Wine's own setup relies on; and a key can be saved to a hive file, and a hive file loaded as a key and unloaded again, with Windows' privileges and refusals. Sockets followed, as Windows has them: a socket is a file of the AFD driver, \Device\Afd, and what that driver answers to reads and writes that wait, cancels, resets, polls, event selection and completion ports has been observed on Windows, over two hundred cases; the driver is now in the kernel, each socket over a Linux socket made for its program's user, so Linux's own permissions and firewall apply: requests that would wait stay on their socket in order and are finished when the socket is ready, in the program's own address space, and Wine's Winsock, driving it in testing, gives Windows' answers line for line, TCP and UDP, polls, event selection and completion ports; AcceptEx, deferred accepts, exclusive polls and Windows' rules for sharing an address followed, and Wine's own socket tests, all of Winsock's, now pass on it exactly as on Wine's server, WSAAsyncSelect's window messages and TransmitFile included, so Wine's sockets have moved to the kernel for good: every Wine program's Winsock now uses the driver. ALPC, Windows' local message passing, has begun in the kernel as well: servers make ports, named or not, clients connect and are accepted or refused, requests wait for their replies and datagrams go without, and a server takes on its client's identity as far as the client allowed, all matching Windows line for line, as do the older LPC services on the same ports. Wine's programs use that registry now, an existing prefix's imported into it once, and Windows services with it. Their files and drive letters followed: C: and Z: are the kernel's for every Wine program, each user with a C: of their own on the C: volume, into which an existing Wine prefix's files move once, and Z: the Linux tree. All 59 of Wine's own test units for ntdll and kernel32 pass on them as they do on Wine's server, apart from known differences, where the kernel does what Windows does and the test wants otherwise, and accepted ones, each with its reason: decisions such as no 8.3 short names and a case-sensitive Z:, and work still to come, such as symbolic links, each with its issue. Wine's server has begun to stop opening files on the drives: a program's image and the directory it starts in are the kernel's opens now, so a program file in use is shared as Windows shares it, and a name on a drive letter that does not exist is answered by the kernel, with Windows' own error. In the ordinary sessions measured, the server no longer opens any file by a drive's name. The server no longer makes directories on C: either. The parts of Wine that read a drive's files by their Linux paths are following: a font keeps its file in use while it is loaded, as on Windows, whether a program added it or it is installed on C:, and so does a library Wine loads from a drive.
Windows, message queues and input in the kernel; later, Windows drivers loaded for hardware that only has them.
03 · A call's journey
Take the most common call a busy game makes — waiting for another thread to signal it. Here is the whole path, as it runs today.
The program calls WaitForSingleObject. Plain Win32, from kernel32.dll, exactly as on Windows.
It reaches NtWaitForSingleObject in ntdll.dll. In Wine, this would become a message to wineserver, a separate process.
ninjinOS's ntdll routes it to the kernel instead, through one entry point on /dev/ntexec that carries the NT service number and its arguments.
ntexec looks up the handle in the process's handle table, checks the granted access, and puts the thread to sleep in the kernel until the object is signalled — or the timeout passes.
Another thread sets the event; the kernel wakes the waiter directly, and the call returns its NT status. No round trip through a userspace server, at any point.
Today the entry is an ioctl on /dev/ntexec. In Phase 5 a small kernel patch lets the program's own syscall instruction reach ntexec directly, with Windows 11's system call numbers, so even raw system calls work.
04 · Wine, step by step
Writing all of Windows' libraries from zero would take decades; Wine has spent thirty
years on them, and they are free software. ninjinOS keeps them, and replaces only what
Wine had to fake: the kernel, which in Wine is a userspace process called
wineserver. The move happens service by service, and the system works at
every step.
Wine 11, as released, plus a small set of patches: the ntdll routing, the handle sharing, the naming, wineserver standing in for the Windows services that keep permanent objects (\KnownDlls, drive letters, DefineDosDevice), process and thread IDs, handles and creation taken from ntexec, one NT environment, with one wineserver, per user, and files opened on ntexec's devices. Rebased on every stable Wine release, never a fork.
While both run, a program sees one set of handles: ntexec hands out every handle value, and objects still in wineserver appear in ntexec as stand-ins.
Every named object lives in ntexec's namespace, even the ones wineserver still serves — so names collide and resolve exactly as on Windows.
Objects, handles, names, synchronization and timers have moved. Processes are moving: ntexec creates every Wine process, gives each process and thread its one ID, and hands out their handles. Tokens and access checks are now the kernel's for Wine's programs too, and so is the registry, its 32-bit view made in Wine's ntdll and an existing prefix's registry files imported once, the server keeping no registry of its own. Files, sections, drivers and the console follow, and the remaining process records; window-manager state stays with the server until Phase 4.
05 · The distribution
ninjinOS is built as a single bootable container image on Fedora Atomic. The image carries the Linux kernel with ntexec, the Wine-derived userland and, later, the desktop.
An update is a whole new system image, switched in at boot. If something is wrong, the previous one is still there to boot into.
The kernel module is signed; enrolling its key once (MOK) lets it load with Secure Boot on. The enrollment is tested on a Secure Boot virtual machine.
Wine is built from a pinned, checksummed release in CI. Two clean builds give byte-identical programs, and the image records exactly what went into its build.
06 · How we know
A compatibility layer is only as good as its evidence. ninjinOS keeps a Windows 11 reference machine (build 26100) and runs the same test programs on both: the output on ninjinOS must match Windows line for line.
Small programs exercise each service — every error code, every edge — on Windows and on ninjinOS. The Windows output is the specification.
Every unit of Wine's ntdll and kernel32 tests (59 of them) runs through ntexec in CI, against upstream Wine on the same machine: ninjinOS must never be worse, except where ntexec matches Windows instead.
The whole suite also runs under a kernel that checks every memory access and every lock. It has already caught two real bugs that a normal kernel would have hidden.
Benchmark · median of 5 rounds, 4 CPUs
| Workload | Stock Wine | Wine + ntsync | ninjinOS |
|---|---|---|---|
| 7-Zip benchmark (MIPS) | 29,964 | 35,080 | 35,032 · ×1.2 |
| Contended mutex (ops/s) | 68,005 | 163,453 | 162,274 · ×2.4 |
| Wait on many events (ops/s) | 44,456 | 165,305 | 160,827 · ×3.6 |
| Uncontended calls (ops/s) | 40,132 | 2,016,535 | 1,777,856 · ×44 |
Where threads wait for each other, ntexec is within a few percent of Linux's ntsync and far ahead of stock Wine. On calls that never block it is still behind ntsync, by 12–30%: every call goes through one generic entry point today, which Phase 5 removes.
07 · Design rules
And under all four, the clean-room rule: behaviour is learned from public documentation and by observing Windows, written down as a specification, and only then implemented. No Microsoft code, ever.
Questions
The source code is not public yet. Until it is, write to us — about the design, about a program you need, or about helping.