h9: Windows programs, through Wine

Jeff Lindsay, h.d.a.

Experimental. Windows programs with windows, and this demo, live on h9's wine-draw branch, not in main, while the work goes on there. The demo is built from that branch.

About

h9 doesn't run Windows programs itself. It runs Linux programs, and Wine is a Linux program that runs Windows ones. So a Windows .exe runs in h9 as Wine's guest, with Wine's system calls going to h9's Plan 9 kernel like any Linux program's.

There is no Linux kernel and no X server. Wine draws through winedraw, a display driver for Wine that h9 adds: each Windows window is a window on Plan 9's /dev/draw, and the mouse and keyboard come from /dev/mouse and /dev/kbd.

Demo

Below is h9's browser host running Alpine Linux's 32-bit Wine 11, unchanged, on h9's own 386 CPU in a Web Worker. The desktop, its taskbar, and the programs on it are Wine's own: Minesweeper, Notepad, Clock, File Manager, WordPad, Command Prompt, Registry Editor, and Task Manager, each a Windows program Wine ships. Double-click an icon to start another.

Give it a minute or two. Wine starts a dozen processes before the first window, each loading its DLLs on an emulated CPU, and the page downloads Wine first, about 80 MB. It needs JavaScript Promise Integration, which Chrome and Edge have from version 137. The demo can also be opened on its own page.

The browser has no amd64 CPU, so this is 32-bit Wine on h9's 386 Linux support. Wine needed two things from it that no other program had: three thread-local storage entries rather than one, and IRET back to user mode, which Wine's system call return uses.

Trying it

On an x86_64 Linux host, h9 runs 64-bit Wine the same way. Console programs run from main. Programs with windows need the wine-draw branch, whose Running Windows programs walks through it: a Wine root, a prefix in your directory, then console programs and programs with windows.

git checkout wine-draw
scripts/wine-root.sh                  # Alpine with Wine 11
win hello.exe "two words" x           # a console program
h9 --gfx --root "$WINEROOT" wine notepad

How it works

The wine-draw proposal has the design.

Gaps