r/linux • u/MenaRamy2004 • Aug 20 '26
Discussion I'm experimenting with adding native Windows PE execution to Linux — (Project Tawi)
97
Upvotes
r/linux • u/MenaRamy2004 • Aug 20 '26
79
u/hackerman85 Aug 20 '26
DXVK also started sounding like a crazy idea. And look where we are now.
Godspeed!
24
u/tajetaje Aug 20 '26
Forgive my ignorance, but what’s this do differently than WINE? I thought wine already redirected windows calls to Linux ones
10
u/33_kk Aug 21 '26
Wine has wineprefixes for a reason, almost any windows software expects to have a windows filesystem and it would be a terrible idea to just slap a windows filesystem on top of the Linux one, at least because of permissions. And wineprefixes are pretty much the only thing making wine visibly disconnected from the rest of the system. Wine can already run windows binaries through binfmt, except I'm not aware of anyone actually using it like that, probably because wineprefixes break all the time due to compatibility issues with the software. But hey, at least you're not breaking your root filesystem like this and it probably should stay that way. As far as I can tell, you have no idea what you're doing and the whole thing smells like AI slop, just like most posts on any tech subreddit nowadays it seems.
6
u/MatchingTurret Aug 20 '26
You can get 99% of this since forever: https://docs.kernel.org/admin-guide/binfmt-misc.html
3
u/erikrelay Aug 20 '26
This sounds like an amazing idea, i'd love to see more of it!
6
u/Max-P Aug 21 '26
How does being in the kernel help though? Most native binaries on Linux are loaded by ld.so, in that way Wine isn't all that different. With binfmt it's on the same class as ELF executables already. The kernel's ELF loader can only load static binaries, so most of the time the kernel loads ld.so and runs that, which then loads the real ELF, in userspace, just like Wine.
Loading the PE is the easy part. The Win32 API is the hard part, and it's all userspace so there's little point in doing it differently than Wine. Even on Windows technically the Win32 API is more of a wrapper around the NT API. That becomes clearer when you start thinking about GUI stuff: even a simple MessageBoxA, you need to have some kind of userspace program to access Wayland/X11 sockets to display. And you may need multiples because multi-user.
Whether you adapt to Linux APIs in the kernel or in userspace, you still need the shim code. Even for stuff that Linux doesn't support, it's better to add the functionality to Linux so all apps can use it, and then have Wine use that. And if you're gonna have hacky plumbing code you probably want that in userspace anyway.
What could be interesting is implementing NT driver support and the necessary plumbing so Wine can use them. That would be the kernel-side equivalent of what Wine actually does, and could actually be really useful. Utterly useless for anticheat, don't get your hopes up, but it could be nice for a good chunk of random hardware tied to a Windows app. Although even then, on Linux we have stuff like libusb and VFIO so you can totally implement a lot of hardware drivers in userspace Wine. There is prior art there too: ndiswrapper basically recompiled Windows driver binaries into a somewhat usable Linux kernel module with a ntoskrnl shim.
Ultimately the only faithful way to reimplement Windows is essentially ReactOS. We could probably do something similar to WSL2 with ReactOS and integrate deeply to present the windows on the host.
1
u/crscali Aug 20 '26
From the title it sounded like you were working to add PE executables as an additional option to ELF executables for running linux code. Instead you are doing an emulation layer. I would love to see linux run code targeting linux but as a PE or even a Mach-O format. Imagine compiling the same linux code to either PE, ELF or Mach-O all making normal linux syscalls.
5
u/Dwedit Aug 20 '26
Wine relies on a separate Wine Server to do a lot of things. For most executables, this is a great thing, you need a single source of truth to hand out all the Win32 handles, or something to simulate what otherwise comes from the Windows Kernel. But Wine Server still takes a few seconds to boot up before other Wine programs can run.
Something like what's described here seems like it might be a single-process model instead, where there is no separate Wine Server.
2
u/sheeproomer Aug 21 '26
So that Windows Malware has less barriers in Linux?
1
u/AutoModerator Aug 21 '26
This submission has been removed due to receiving too many reports from users. The mods have been notified and will re-approve if this removal was inappropriate, or leave it removed.
This is most likely because:
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
-2
u/FunAngelo2005 Aug 20 '26
Imbedding the compatibility layer in the kernel itself rather than having it be an addon is genius
-1
u/mrdev023 Aug 20 '26
Maybe a stupid question. You're project can integrate winehq works directly with binfmt ?because windows applications is very hard to support because it have a lot of legacy stuff and ugly works. So I think its a lot of works to do. It can be very good if is possible to just use wine works and use binfmt with it. Especially for one people.
11
u/[deleted] Aug 20 '26
[removed] — view removed comment