Which libraries must be Wine's, which may be Microsoft's, and how to find out where the line actually falls.
This is the part of Raven that is a research question rather than an engineering task. Everything else in the design is known to be buildable; this is the part nobody has published an answer to.
Once a real Windows is mounted as C:, Microsoft's System32 is present. Every
library a program imports exists on disk, in its genuine form.
Some of them will work. Some of them will fail in ways that produce a crash with no explanation. And a small number will fail in the specific way that matters most: by appearing to work.
The shadow set is the list of libraries Raven forces to Wine's implementation despite Microsoft's being right there. Every name on that list is a place where the program gets a reimplementation instead of the real thing. Shrinking it is the whole point.
ntdll.dll and win32u.dll are where Windows crosses into its kernel. On
Windows they issue syscall instructions carrying NT syscall numbers. Those
numbers mean unrelated things to Linux, and the numbering is not even stable
across Windows builds.
These are not "hard to make work." They are the definition of the boundary between the two operating systems, and Wine's implementations of them are what Wine fundamentally is. They stay Wine's under every possible design.
kernel32, kernelbase, user32, gdi32 and advapi32 are user-mode
libraries with no syscalls of their own, so in principle they are candidates.
In practice they are coupled to two things Wine owns:
ntdll's internals. They call into it constantly, and not only through the documented surface. Microsoft'skernel32is built against Microsoft'sntdll, including behaviour that was never contracted.wineserver. Wine implements NT's object model - processes, threads, handles, sections, synchronization - in a separate server process. Wine'skernel32talks to it. Microsoft's talks to a kernel that is absent.
The expectation is that these stay Wine's. That expectation should still be tested rather than assumed, because "obviously impossible" and "actually impossible" have historically not been the same list.
ole32, oleaut32, rpcrt4, shell32, shlwapi, comctl32, comdlg32,
ws2_32, and their neighbours.
Wine reimplements all of them. They are large, they are old, they are used by almost everything, and their Wine implementations are the usual location of "works, except." Microsoft's versions are sitting in the mounted base.
Whether they can be used is unknown. It is unknown per library, and it is unknown per combination of libraries, which is the part that makes this a real experiment rather than a checklist.
Microsoft's ucrtbase and msvcr*, the DirectX redistributables, .NET, media
codecs, xinput - these work under Wine today. This is not a hypothesis:
winetricks has been installing exactly these, as genuine Microsoft
redistributables into Wine prefixes, for over fifteen years, and it is the
standard fix for a large class of problems.
Raven's contribution here is not making it work. It is that these arrive from a coherent Windows installation rather than from fifteen years of accumulated per-application workarounds.
The two mechanisms below were the plan. Running Wine against a real deployed Windows found a third, and it is better than either.
Wine refuses to run against a bare real Windows at all: finding Microsoft's
C:\windows where its own belongs, it decides the prefix needs rebuilding and
runs wineboot instead of the program.
overlayfs takes multiple lower layers, leftmost winning. So:
lowerdir=<wine-skeleton>:<real-windows>
gives Wine's files precedence wherever they exist and Microsoft's everywhere
else - and that is the shadow set, expressed as a filesystem layer. Measured:
ntdll.dll read through such a mount is Wine's 770 139 bytes rather than
Microsoft's 2 522 008.
This is better than an environment variable because it is inspectable: the shadow set becomes "what the Wine layer contains", which can be listed, diffed and reviewed, rather than a string that has to be believed.
The casing mismatch was real, and the fix ships. Wine's skeleton uses
windows and users; Microsoft's uses Windows and Users; overlayfs
merges on the exact byte path, so the trees stayed separate and the mount
showed both. Wine's own case-insensitivity acts a layer above the filesystem
and could not help. env create now renames the Wine layer to the base's
spelling - normalise_case in crates/raven/src/layer.rs, 338 renames
against a real Windows 11 base - after which the trees merge, and the merged
mount is what carried a real installer and a running game end to end.
Running a real Windows installer found the first thing the base must not provide, and it turned out to be an entire assembly store rather than a DLL.
Windows\WinSxS is shadowed. A real Windows carries a populated
side-by-side store. An installer whose manifest asks for
Microsoft.Windows.Common-Controls version 6.0 - which Inno Setup, and a large
share of Windows installers, do - gets Microsoft's comctl32 out of it. That
library loads, and then does not work against Wine's user32.
The symptom is precise and thoroughly misleading:
| The window | drawn, correct size, correct frame |
| Its bitmaps | drawn correctly |
| Every control | created, and positioned |
| Text in any of them | absent |
| Response to a click | none at all |
Nothing errors. Nothing appears in a log. The installer simply sits there, whole and inert, and a person would reasonably conclude the fonts are broken.
WINEDLLOVERRIDES cannot fix this, which is what makes it worth writing
down. Forcing comctl32=b changes nothing, because side-by-side resolution goes
through the activation context rather than the loader search path the override
governs. The override was the obvious remedy and it was measured to be useless.
Hiding the store fixes it completely: the wizard renders its text and its buttons answer clicks. The mask sits in the read-only layer, so an installer that registers its own assemblies into the environment is unaffected - only the base's store disappears.
Two earlier findings turn out to have been the same thing seen from different angles. The 112 373 WinSxS manifest lookups measured during the performance investigation were Wine genuinely resolving activation contexts against the real store; and the reason a bare game exited while its dialog flashed was the same machinery failing earlier.
Windows\Fonts was shadowed. win32u re-enumerates and re-checks every font
file at every process start; the real base carries ~340 of them, and that was
92 of the 105 milliseconds each process spawn cost over plain Wine (227 → 135
ms with the mask - the full attribution is in
performance.md). Wine's own Fonts directory is empty and
text renders through the host's fontconfig, so the mask restored exactly the
plain-Wine situation, and the game still reached its title screen under it.
What the entry cost: a program that reads Microsoft's font files - not just
the faces - would not find them. None was ever seen. The cost that withdrew
the entry was a different one, set out below.
The layer wins at every path where Wine ships a file, and that includes paths
where the program needs Microsoft's. wineboot installs Wine's mscoree.dll
into System32 and SysWOW64 like any other builtin, and in the layer it
hid the base's. Wine's mscoree runs managed code on Wine Mono. Raven builds
its prefixes without Mono, so every .NET program failed in a new environment
although the base carries .NET Framework 4.8:
err:mscoree:CLRRuntimeInfo_GetRuntimeHost Wine Mono is not installed
On the win11-26200-pro base with Wine 11.20 this stopped
MSBuild.exe -version (exit code 255) and the WiX managed custom actions of
the Epic Online Services MSI (SFXCA: Failed to bind to the CLR, then error
1603). csc.exe /help proves nothing here: the C# 5 compiler that ships with
.NET Framework is native code and runs with or without the CLR.
These two files are the only paths the layer and the base's .NET share; the
rest of .NET lives under Windows\Microsoft.NET, where the layer has nothing.
With them gone, MSBuild.exe -version prints 4.8.9221.0 from both
Framework and Framework64, WINEDEBUG=+loaddll shows mscoree.dll,
mscoreei.dll and clr.dll loaded native, and the Epic Online Services MSI
installs under /qn with all six of its managed custom actions.
No DllOverrides entry is involved. Wine loads a native file it finds in
System32 as native, and the custom-action servers msiserver starts for
deferred actions do the same, so there is nothing for a service to inherit.
With .NET running, the next failure was the Windows Runtime. Wine ships ten
.winmd files of its own in System32\WinMetadata and SysWOW64\WinMetadata,
and they hid the base's: Wine's Windows.Networking.winmd is 5.7 KB,
Microsoft's 262 KB. Wine's RoResolveNamespace hands .NET whichever file it
finds there, so a lookup of a type Wine's file does not describe failed. The
Visual Studio 2019 Build Tools installer died on
Error 0x80131522: Could not find Windows Runtime type 'Windows.Networking.Connectivity.NetworkCostType'
and a short C# program doing the same lookup reproduced it. With Wine's
.winmd files gone from the layer, the type resolves from the base's file,
and activating Windows.Networking.Connectivity.NetworkInformation returns a
ConnectionProfile from Wine's own implementation. The registry needed
nothing: Wine registers its WinRT classes itself, and the projection does not
have to carry HKLM\Software\Microsoft\WindowsRuntime.
Both entries are in layer::UNCOVERED, and env create deletes them from the
new layer. A Wine upgrade treats them differently. wineboot -u finds a file
at System32\mscoree.dll that is not one of Wine's and leaves its content
alone. It does open it for writing, so overlayfs copies the base's file into
the upper layer, byte for byte. The .winmd files are copied over the base's
on every update (wine.inf lists them in [WinmdFiles]), into the upper
layer, and the lookup fails again for the rest of that session.
layer::reconcile runs before every session mount and removes Wine's copies
from the layer and from the upper layer. That heals both an environment
created before these entries existed and one a Wine upgrade has just written
over. For mscoree.dll it removes only a file that carries Wine's signature,
so a native copy an installer or a person put in the upper layer stays. Wine's
.winmd files carry no signature, so in WinMetadata every file the base also
has is removed; nothing but wineboot writes the OS's own namespaces there. A
session that is already running keeps what it has until it is stopped.
WINEDLLOVERRIDES asks Wine which implementation to prefer, per library:
WINEDLLOVERRIDES="ole32,oleaut32=n,b;comctl32=b"
n selects native - Microsoft's file, the one in the base. b selects Wine's
builtin. n,b means try native and fall back. This is Wine's own supported
interface and it is the right tool for everything above the floor.
Physically shadowing the file in the read-only Wine layer replaces the file Wine would find at all. It is heavier, it is visible in the filesystem rather than in an environment variable, and it is the fallback for cases where the override is not respected.
Prefer the override. Reach for the shadow only with a recorded reason, because a shadowed file is a divergence from the base that is easy to forget about.
The naive experiment - flip each library to native, one at a time, see what
breaks - answers the wrong question, because these libraries interact. ole32
native with rpcrt4 builtin is a different system from both-native, and a
per-library result that ignores that will be confidently wrong.
The shape of a real measurement:
- Start from the maximal shadow set, where everything Wine can provide is Wine's. That is approximately Wine's behaviour today, with the real files merely present, and it is the configuration most likely to work at all. It is the baseline.
- Fix a corpus of programs with observable success criteria - starts, reaches a known state, produces a known output. A corpus of "seems to work" measures nothing.
- Move candidates to native in groups that are used together, not one at a
time.
ole32andoleaut32andrpcrt4are one COM decision, not three. - Record the whole configuration with each result. The output of this work is a table of (Windows build, library set, corpus outcome), and a result without its configuration is not a result.
- Diagnose failures with
WINEDEBUGfirst - theloaddllandrelaychannels report what was loaded and what was called, and they are already there. Only if those prove insufficient does instrumenting Wine from the inside become worth its cost, and that instrument would be a Wine DLL, in C.
The output is a data file, keyed by Windows build, not a constant in the
source. It is derived from measurement, it will change as Wine changes, and it is
exactly the kind of table
the org layout rule
says belongs in a data file rather than a const array.
The middle band may turn out to be thin. It is entirely possible that ole32 and
its neighbours are coupled to ntdll internals tightly enough that Microsoft's
versions cannot be used, and that the honest shadow set is nearly as large as
Wine's default.
That would mean Raven's value rests on the real registry, the real application libraries and the immutable base - which is still worth having - rather than on a thin shadow set. It would also be the first published measurement of where that line falls, which is worth having regardless of which side of it the answer lands on.
What would make this work worthless is measuring it badly and reporting a number nobody can reproduce. Hence the insistence on recording configurations.
The Windows/Fonts entry was added on a measurement - it took process spawn
from 227 ms to 135 ms, because win32u re-checks every font file on every
spawn - and the correctness side of that trade was never written down. It is
this:
| fonts the environment's registry declares | 961 |
font files a program can actually open in C:\Windows\Fonts |
0 |
| Linux fonts Wine falls back to through fontconfig | 904 |
what Segoe UI resolves to |
Adwaita Sans |
what Arial resolves to |
Noto Sans |
So text renders, which is why nothing looked wrong: Wine substitutes through fontconfig. Three things are nevertheless lost.
- The registry lies. It lists 961 fonts whose files do not exist. A program that reads the list and opens what it names fails.
- A program that enumerates the directory sees nothing, where a real Windows would show 338 files.
- Metrics change. Arial is not Noto Sans and Segoe UI is not Adwaita Sans;
a layout tuned to the real ones will shift. Proton bundles
liberation-fontsprecisely to supply metric-compatible substitutes, which Raven does not.
It was re-decided, and the fonts are back. Re-measured with sessions in place, a warm launch costs 0.16 s masked and 0.257 s unmasked - about the same 92 ms, which is now over a third of a warm launch rather than a small part of a two-second cold one. Unmasked, a warm launch is still seven to eight times faster than the 1.89-2.07 s every launch paid before sessions, and about twice plain Wine's warm 0.12 s.
What settled it was not the arithmetic but the premise. Raven's premise is
that a program runs against a real Windows; an installation whose fonts are
hidden is not one, and the registry declaring 961 faces whose files do not
exist is an incoherence no measurement justifies. SHADOWED is one entry
again.
Environments created while the mask existed are healed rather than abandoned:
layer::reconcile runs before every session mount and removes markers the
shadow set no longer wants, so nobody has to rebuild an environment to receive
a fix they never opted into.