OFFSET偏移
← All articlesOFFSET / FIELD NOTESNO. 150

Wine: the compatibility layer and prefixes

Understand Wine's DLLs, prefixes, configuration, and runtime boundaries through Windows API compatibility.

English translation · Code and commands follow the Chinese original.

IN THESE READING PATHSWine and application environments ↗
About 11 min readStart reading

"Wine Is Not an Emulator": it is a compatibility layer that reimplements the Windows API on Linux. This article covers API compatibility, prefix management, and the conditions for verifying NTSYNC, WoW64, and Wayland support. The exact scope of support depends on the version, build, and distribution you use.


Wine's core principles and architecture#

API translation, not CPU emulation

Wine loads Windows PE (Portable Executable) files into Linux user space and translates Windows API calls into POSIX/Linux system calls at runtime. Unlike a virtual machine, Wine does not emulate CPU instructions. On a compatible CPU architecture, Windows programs generally execute the corresponding machine instructions directly, while Wine handles loading and API/system behavior compatibility. Running across CPU architectures may require a separate instruction-translation tool; Wine itself should not be treated as a CPU emulator:

graph LR
    subgraph "Windows .exe"
        APP["应用程序"]
    end
    subgraph "Wine"
        NTDLL["ntdll.dll — NT 内核模拟"]
        KERNEL["kernel32.dll — 进程/线程/文件"]
        USER["user32.dll / gdi32.dll — 窗口与绘制"]
    end
    subgraph "Linux Kernel"
        SYSCALL["syscall"]
        DRIVER["GPU / FS / Net"]
    end
    APP --> NTDLL
    APP --> KERNEL
    APP --> USER
    NTDLL --> SYSCALL
    KERNEL --> SYSCALL
    USER --> DRIVER

Performance depends on the application, API paths, drivers, synchronization implementation, and graphics translation. It may be slower, close to native, or faster. Without benchmarks, versions, and hardware conditions, no fixed overhead percentage can be given.

Two DLL sources: Builtin vs Native

Wine can load either built-in implementations or external DLLs. Not every Windows DLL has two complete, usable implementations:

Type Source Characteristics
Builtin Implemented by Wine Open-source alternatives; functionality may be incomplete
Native Actual Windows / Microsoft distribution packages Verify provenance and compatibility; other Windows components may be required, and distribution licenses must be respected

Use the Libraries tab in winecfg to set the priority for a specific DLL. A common use case is using a native riched20.dll to address Chinese input problems in rich-text editors.

Graphics backends: a multilayer translation pipeline

Windows App (D3D9/10/11)
    ↓
WineD3D (Wine 内置 D3D→OpenGL)
    ↓ 可替换为 DXVK (D3D→Vulkan)
OpenGL 或 Vulkan
    ↓
X11 / Wayland

DXVK's Vulkan path can reduce translation overhead for some workloads, but the benefit depends on the game, DXVK version, and driver version. Falling back to WineD3D is useful for diagnosis or environments without the required Vulkan support; no fixed frame-rate improvement can be promised.


Wine Prefix: a virtual Windows environment#

Prefix directory structure

A Prefix is Wine's central concept: a separate directory containing a complete virtual Windows environment:

~/.wine/                    # 默认 Prefix
├── drive_c/                # 虚拟 C:\
│   ├── windows/
│   │   ├── system32/       # Windows 目录布局;DLL/PE 与宿主库形式随 Wine 构建变化
│   │   └── ...
│   ├── Program Files/
│   └── users/
├── dosdevices/             # 驱动器映射 (c: -> drive_c)
├── system.reg              # 注册表 HKLM
├── user.reg                # 注册表 HKCU
└── .update-timestamp

Key features

  • Separate configurations: Use different prefixes for different programs to separate DLLs, registry settings, and application files, reducing configuration conflicts. They may still share the host user's privileges, files, and network access; this is not security isolation.
  • Architecture control: Specify the architecture at creation according to the selected Wine build. Traditional builds and new WoW64 builds support different options; you cannot universally claim that win32 is deprecated or that every version accepts wow64.
  • Backup and recreation: A prefix is an ordinary directory, but may contain saved games, licensing information, and configuration. Shut down related processes and confirm the backup scope, then rename and retain the original directory before creating a new prefix for testing. Do not simply delete the only copy.

Create a prefix

# 创建 64 位 Prefix(推荐)
WINEARCH=win64 WINEPREFIX=~/Games/MyApp winecfg

# 新 WoW64 构建可减少对 32 位 Unix 库的依赖;先核对发行包说明。
# WINEARCH 的可用值随 Wine 版本与构建不同,不在这里强制 wow64。

# 为特定 Prefix 安装依赖
WINEPREFIX=~/Games/MyApp winetricks vcrun2022 dotnet48

In practice: from scratch to a running Windows program#

The complete workflow

The following example uses a separate, ordinary Wine prefix. /home/user is a generic user path that must be replaced. Use the Arch or NixOS installation method as appropriate. Choose dependencies according to the application's requirements; preinstalling more is not inherently better.

# 第一步:安装 Wine(以 Arch/NixOS 为例)
# Arch
sudo pacman -Syu wine wine-mono wine-gecko winetricks
# NixOS — 在 configuration.nix 中声明(见 05_NixOS_Management)

# 第二步:创建独立 Prefix
WINEPREFIX="$HOME/Games/MyTool" winecfg
# 首次运行会弹出 winecfg 窗口,同时创建 Prefix 骨架

# 第三步:安装 Windows 运行时依赖
WINEPREFIX=~/Games/MyTool winetricks -q vcrun2022 dotnet48 allfonts

# 第四步:运行安装程序
WINEPREFIX=~/Games/MyTool wine ~/Downloads/Setup_MyTool.exe
# 安装完成后,程序默认安装在 Prefix 内的 C:\Program Files\

# 第五步:运行已安装的程序
cd ~/Games/MyTool/drive_c/Program\ Files/MyTool
WINEPREFIX=~/Games/MyTool wine MyTool.exe

# 第六步(可选):创建桌面快捷方式
cat > ~/.local/share/applications/mytool.desktop <<'EOF'
[Desktop Entry]
Name=MyTool
Exec=env WINEPREFIX=/home/user/Games/MyTool wine "/home/user/Games/MyTool/drive_c/Program Files/MyTool/MyTool.exe"
Type=Application
Icon=wine
EOF

Everyday operations: quick reference

# 为某个 Prefix 打开 winecfg 面板
WINEPREFIX=~/Games/MyTool winecfg

# 直接运行 .exe(不安装)
WINEPREFIX=~/Games/MyTool wine ./portable-app.exe

# 打开虚拟 C 盘的文件管理器
WINEPREFIX=~/Games/MyTool winefile

# 打开注册表编辑器
WINEPREFIX=~/Games/MyTool regedit

# 打开 Windows 命令行(cmd.exe)
WINEPREFIX=~/Games/MyTool wine cmd

# 卸载程序(通过 Windows 添加/删除程序)
WINEPREFIX=~/Games/MyTool wine uninstaller

# 查看当前 Prefix 的 Windows 进程与窗口
WINEPREFIX=~/Games/MyTool wine taskmgr
# wineserver -d 用于服务器调试输出,不是进程列表命令。

The winecfg configuration tabs in detail#

After running WINEPREFIX=... winecfg, you can access the following tabs:

Applications: set the Windows version per application

Setting Purpose
Windows Version The Windows version number reported to the program. The default varies with the version and prefix state; some older programs need a particular version to be reported.
Per-application override Set a different Windows version for a specific .exe

A common use case: some installers refuse to run when they detect Win10/Win11; setting Win7 can bypass this check.

Libraries: DLL overrides (the most frequently used tab)

Set an override priority for each DLL:

Override mode Meaning
Builtin then Native (b,n) Try Wine's built-in DLL first, then the native one if that fails (a load order, not a security policy)
Native then Builtin (n,b) Try the native DLL first, then Wine's built-in DLL if that fails (give priority to the component installed as an override)
Builtin only (b) Use only Wine's built-in DLL
Native only (n) Use only the native DLL (such as one copied from Windows)
Disable Disable this DLL

Common override scenarios:

d3d9, d3d10core, d3d11, dxgi   → (n,b)  启用 DXVK
nvapi64, nvapi                  → Disable  禁用 NVAPI(防崩溃)
riched20                        → (n,b)  修复中文输入
mscoree, mscorsvw               → Disable  禁用 .NET(用 Wine Mono 代替)

Graphics: graphics settings

Setting Recommendation
Automatically capture the mouse Enable for full-screen games
Emulate a virtual desktop If the application window does not display correctly, enter a resolution such as 1920×1080
DPI For a high-DPI display, try 144 or 192

Drives: drive mappings

By default, C: → drive_c/ inside the prefix, and Z: → the Linux root directory /. You can add mappings such as D: → /mnt/games for convenient access to external files. Removing Z: removes only one convenient file-access entry point; it does not create a filesystem or network security boundary. Untrusted programs require a separate assessment of host privileges, mounts, network access, and display services. An appropriately configured sandbox or virtual machine may be used.

Audio / Staging tabs

  • Audio: select the audio driver (winepulse.drv / winealsa.drv)
  • Staging: appears only when provided by the corresponding build and version. Historical options such as CSMT do not represent all current builds; consult the relevant release notes and measure their actual effects.

Manage dependencies with winetricks#

Basic usage

# GUI 模式(首次推荐,可浏览所有可安装组件)
WINEPREFIX=~/Games/MyTool winetricks

# 命令行静默安装(-q 参数)
WINEPREFIX=~/Games/MyTool winetricks -q <组件名>

# 列出所有可用组件
winetricks list-all

Recipes for common scenarios

Choose dependencies from the application's documentation or verified compatibility reports, and test them in a separate prefix first. Installing .NET, VC runtimes, and fonts does not guarantee compatibility with a particular Office or Photoshop version. Licensing, installers, online services, and unimplemented APIs can all be limiting factors.

Potential dependencies for modern Windows applications:

# Visual C++、.NET 与字体分别按应用要求选取;不是每个程序都需要全部安装。
WINEPREFIX="$HOME/Games/MyTool" winetricks -q \
  vcrun2022 dotnet48 corefonts

Potential dependencies for older games:

# DirectX 辅助库、VC 2015 与 XACT 按日志缺项选择。
WINEPREFIX="$HOME/Games/OldGame" winetricks -q \
  vcrun2015 d3dx9 d3dx10 xact

Chinese fonts:

WINEPREFIX="$HOME/Games/MyTool" winetricks -q cjkfonts

Check the current winetricks lists before assuming that names such as allfonts, directx9, and fakechinese are available. Locale issues, encoding issues, and missing fonts are not the same problem, and installing every component indiscriminately is not a solution.

Media Foundation / cutscenes: First check the media fixes provided by Proton or your chosen runner for the target game, then diagnose codecs and GStreamer. mf-install is an external approach cited by past tutorials; do not assume without verification that it is a current built-in winetricks verb. Check the availability and applicability of lavfilters against the current list, the application, and the license as well.

winetricks list-all
WINEPREFIX="$HOME/Games/MyGame" winetricks list-installed

A shell line-continuation backslash must be the last character on its line: do not append spaces or comments after \. Put component explanations on separate comment lines before the command to avoid accidentally splitting a single command.

Version boundaries for synchronization, architecture, and display drivers#

1. NTSYNC: kernel synchronization primitives

NTSYNC provides Linux kernel interfaces for Windows NT-style synchronization objects, covering operations such as waits, events, mutexes, and semaphores. It is a different implementation path from the esync/fsync approaches used by runners. Those also involve kernel facilities and should not be broadly described as operating entirely in user space.

To determine whether NTSYNC is usable, check kernel configuration, drivers/devices, permissions, the runner's implementation, and what the current process actually selects separately. A kernel version above a certain number, the presence of /dev/ntsync, or a single log message is not complete runtime evidence. Kernel documentation defines the interface; Wine/Proton release notes define user-space support. Unverified game frame-rate tables are not retained as performance promises.

# 仅检查设备节点是否存在及其权限,不证明当前游戏正在使用。
ls -l /dev/ntsync

# 对支持该日志通道的 runner 收集线索,再结合进程/版本信息判断。
WINEPREFIX="$HOME/Games/MyApp" WINEDEBUG=+ntsync \
  wine myapp.exe 2>&1 | grep -i ntsync

At minimum, performance evaluation should hold the game scene, runner, driver, synchronization mode, and hardware constant, and record frame times across repeated measurements. Extreme test results from other machines or developers are not universal benefits.

2. New WoW64 and existing prefixes

The new WoW64 path aims to let 32-bit Windows code use a 64-bit Unix-side runtime, reducing dependence on 32-bit Unix libraries. This does not mean that all 32-bit applications, Unix plugins, OpenGL paths, or distribution packages are already compatible.

  • WINEARCH affects architecture when a prefix is created, but accepted values, defaults, and compatibility with existing prefixes depend on the Wine version and build.
  • Traditional win32, win64, and new WoW64 are not interchangeable labels. If you encounter an architecture mismatch, inspect the package's build notes and the existing prefix first; do not force an upgrade of the original directory.
  • If migration is needed, retain a complete backup taken with the prefix's processes shut down, and verify applications, dependencies, and saved games in a new directory. Setting a single variable cannot be promised to provide a lossless conversion.
  • Whether a separate wine64 command still exists and whether multilib is required depend on the actual installed package.

3. Wayland graphics driver

winewayland.drv provides a driver path that talks directly to Wayland, as opposed to using the X11 driver through XWayland. Availability depends on the Wine/Proton build, compositor, protocols, and specific application.

Feature Verification requirements
Windows and full-screen mode Confirm which driver is actually loaded; test window switching and recovery from full-screen mode
Clipboard and drag-and-drop Test text, files, and formats in both directions between the application and host
Shaped/transparent windows Check rendering and input regions for each application and compositor
Low-resolution scaling Verify display modes, scaling, mouse coordinates, and frame rates
Input methods Test preedit text, candidate windows, and committed text in each application
32-bit graphical programs Verify the runner, WoW64, driver, and required Vulkan/OpenGL features

A major version number alone does not justify claiming feature completeness or that every scenario can run without XWayland.

4. How to document development-release features

The source material mentions DLL-loading heuristics, Android drivers, VBScript functions, and Vulkan specification updates. These are feature lists for particular development snapshots, not universal compatibility guarantees. DLL/mod loading must be checked against the relevant version and game logs; Android also involves target-platform builds; VBScript must be verified for the specific functions and programs; and updated Vulkan headers do not mean that a driver supports every extension.

Access to the official WineHQ 11.0 release notes was restricted during this review, so they were not used to confirm the source material's specific claims about the release status of 11.x/11.6. The technical directions and verification methods above are retained, without presenting unverified descriptions of future/latest versions as facts.

Wine's limitations#

Unreliable compatibility

Wine's API implementation relies on "reverse engineering + behavior matching", rather than official Microsoft code. Any unimplemented corner case can cause a crash. WineHQ AppDB records application compatibility ratings (Platinum → Garbage).

High configuration complexity

A purely command-line workflow requires understanding DLL overrides, registry editing, and architecture constraints. GUI tools such as Bottles and Lutris lower the learning barrier.

Weak security boundaries

Wine is not a sandbox. Programs running in Wine can access the Linux filesystem (by default, Z: maps to /). Malicious programs can read and write files permitted by the current user's privileges and execution environment; files lacking the required permissions do not automatically become writable. Flatpak can impose additional restrictions, but the effective boundary depends on actual permissions, mounts, devices, and network access. Simply “running through Bottles” does not establish safety.

Unsupported scenarios

  • Kernel-level anti-cheat (EasyAntiCheat/BattlEye kernel mode): requires the game developer to actively provide Linux support
  • Hardware driver dependencies: some peripherals or hardware dongles lack Linux drivers
  • The UWP/Windows Store ecosystem: involves multiple constraints, including application models, the store, services, and signing. A method for running traditional Win32 programs does not amount to full support.

Sources and verification boundaries#

The references below define the relevant mechanisms and scope of support. Installation, builds, activation, prefix state, and actual application behavior must each be verified for the target environment. The example commands do not come with any claim of successful execution on a host.

References & further reading

  1. Wine project ↗
  2. Linux NTSYNC interface ↗
  3. Winetricks upstream ↗

Adapted from technical notes. Examples use generic names.

Continue along a reading path

Wine and application environments

  1. 01umu, Wine and Proton: understanding compatibility tools and choosing Bottles runners
  2. 02The relationship between Wine, Proton, and Bottles
  3. 03Wine: the compatibility layer and prefixes
  4. 04Bottles: runners and application environments
CONTINUE READING / NEXT ARTICLEProton: the gaming runtime

Distinguish Steam, official Proton, GE, and umu, and manage runners and prefixes per game.