My progress in porting Wine

I found that TLS registers are different in 64 bit Windows (GS) and Haiku (FS).

NtCurrentTeb()
mov %gs:0x30, %r13

static inline void**
get_tls()
{
	void** tls;
	__asm__ __volatile__ ("movq	%%fs:0, %0" : "=r" (tls));
	return tls;
}

So I tried to implement setting GS base in kernel and got some success.

Cmd is already working. No GUI yet.

Microsoft Windows 6.1.7601

Z:\Haiku\data\packages\wine-6.23>
Z:\Haiku\data\packages\wine-6.23>
Z:\Haiku\data\packages\wine-6.23>
Z:\Haiku\data\packages\wine-6.23>dir
00c4:fixme:file:get_default_drive_device auto detection of DOS devices not supported on this platform
Volume in drive Z has no label.
Volume Serial Number is 5a00-0000

Directory of Z:\Haiku\data\packages\wine-6.23

12/31/2021   6:47 AM  <DIR>         .
12/30/2021  11:27 PM  <DIR>         ..
 12/4/2021   6:17 AM        16,635  aclocal.m4
 12/4/2021   6:17 AM        33,128  ANNOUNCE
 12/4/2021   6:17 AM        26,847  AUTHORS
12/30/2021  11:32 PM       908,816  config.log
12/30/2021  11:31 PM        71,114  config.status
 12/4/2021   6:17 AM       770,828  configure
 12/4/2021   6:17 AM       161,964  configure.ac
 12/4/2021   6:17 AM        26,434  COPYING.LIB
 12/4/2021   6:17 AM  <DIR>         dlls
 12/4/2021   6:17 AM  <DIR>         documentation
12/30/2021  11:52 PM  <DIR>         fonts
12/30/2021  11:52 PM  <DIR>         include
12/31/2021   6:29 AM  <DIR>         install
 12/4/2021   6:17 AM  <DIR>         libs
 12/4/2021   6:17 AM           824  LICENSE
 12/4/2021   6:17 AM         1,324  LICENSE.OLD
12/30/2021  11:51 PM  <DIR>         loader
 12/4/2021   6:17 AM         8,766  MAINTAINERS
12/31/2021  12:16 AM    16,079,205  Makefile
12/30/2021  11:32 PM  <DIR>         nls
12/30/2021  11:32 PM  <DIR>         po
 12/4/2021   6:17 AM  <DIR>         programs
 12/4/2021   6:17 AM         5,586  README
12/31/2021  12:16 AM  <DIR>         server
12/30/2021  11:42 PM  <DIR>         tools
 12/4/2021   6:17 AM            18  VERSION
 12/4/2021   6:17 AM         2,629  wine
 12/4/2021   6:17 AM         2,629  wine64
      16 files               18,116,747 bytes
      14 directories                  0 bytes free


Z:\Haiku\data\packages\wine-6.23>

UPDATE:
Source code repository (rebase policy): https://github.com/X547/wine.

37 Likes

This is gonna be good…

If Wine gets ported to Haiku, it would be interesting to see how much of a jump in interest there would be from the computing community.

7 Likes

Patches:

13 Likes

I can compile and run programs with MinGW in Wine:

/Haiku/data/packages/wine-6.23> wine cmd
GetCurrentTeb(): 0x67fe0000
002c:fixme:file:get_device_info device info not properly supported on this platform
002c:fixme:ntdll:get_firmware_info info_class SYSTEM_FIRMWARE_TABLE_INFORMATION
002c:fixme:ntdll:get_firmware_info info_class SYSTEM_FIRMWARE_TABLE_INFORMATION
002c:fixme:winsock:unix_getaddrinfo getaddrinfo() not found during build time
002c:err:winediag:getaddrinfo Failed to resolve your host name IP
002c:fixme:winsock:unix_getaddrinfo getaddrinfo() not found during build time
0034:fixme:file:get_device_info device info not properly supported on this platform
003c:fixme:file:get_device_info device info not properly supported on this platform
0048:fixme:file:get_device_info device info not properly supported on this platform
0050:fixme:file:get_device_info device info not properly supported on this platform
0070:fixme:file:get_device_info device info not properly supported on this platform
resolve symbol "XESetCreateGC" returned: -2147478780
0050:err:module:open_builtin_so_file failed to load .so lib "/Haiku/data/packages/wine-6.23/dlls/winex11.drv/winex11.drv.so"
0050:err:explorer:initialize_display_settings Failed to query current display settings for L"\\\\.\\DISPLAY1".
0050:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0050:err:winediag:nodrv_CreateWindow Unknown error (127).
0050:err:systray:initialize_systray Could not create tray window
0050:err:ole:start_rpcss Failed to start RpcSs service
0050:err:ole:start_rpcss Failed to start RpcSs service
003c:err:service:process_send_command receiving command result timed out
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"wineusb" failed to start: 1053
003c:err:service:process_send_command receiving command result timed out
003c:fixme:service:scmdatabase_autostart_services Auto-start service L"winebus" failed to start: 1053
0090:fixme:file:get_device_info device info not properly supported on this platform
00ac:fixme:file:get_device_info device info not properly supported on this platform
005c:err:dnsapi:DllMain No libresolv support, expect problems
0024:fixme:file:get_device_info device info not properly supported on this platform
GetCurrentTeb(): 0x67fe0000
00c4:fixme:file:get_device_info device info not properly supported on this platform
GetCurrentTeb(): 0x67fe0000
00cc:fixme:file:get_device_info device info not properly supported on this platform
Microsoft Windows 6.1.7601

Z:\Haiku\data\packages\wine-6.23>00d8:fixme:file:get_device_info device info not properly supported on this platform
resolve symbol "XESetCreateGC" returned: -2147478780
00d8:err:module:open_builtin_so_file failed to load .so lib "/Haiku/data/packages/wine-6.23/dlls/winex11.drv/winex11.drv.so"
00d8:err:explorer:initialize_display_settings Failed to query current display settings for L"\\\\.\\DISPLAY1".
00d8:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
00d8:err:winediag:nodrv_CreateWindow Unknown error (127).
00d8:err:systray:initialize_systray Could not create tray window
00e8:fixme:file:get_device_info device info not properly supported on this platform

Z:\Haiku\data\packages\wine-6.23>/boot/home/received/mingw64/bin/x86_64-w64-mingw32-gcc.exe Test.c -o Test.exe
GetCurrentTeb(): 0x3e0000
0110:fixme:file:get_device_info device info not properly supported on this platform
GetCurrentTeb(): 0x3e0000
0118:fixme:file:get_device_info device info not properly supported on this platform
0118:fixme:ntdll:NtQuerySystemInformation info_class SYSTEM_PERFORMANCE_INFORMATION
GetCurrentTeb(): 0x67fe0000
0120:fixme:file:get_device_info device info not properly supported on this platform
GetCurrentTeb(): 0x3e0000
0128:fixme:file:get_device_info device info not properly supported on this platform
0130:fixme:file:get_device_info device info not properly supported on this platform
GetCurrentTeb(): 0x3e0000

Z:\Haiku\data\packages\wine-6.23>Test.exe
GetCurrentTeb(): 0x3e0000
0138:fixme:file:get_device_info device info not properly supported on this platform
C program compiled with Wine on Haiku.

Z:\Haiku\data\packages\wine-6.23>
28 Likes

wowww… superrr :+1: :+1: :+1:

2 Likes

Amaaaaaazing work.

1 Like

That’s damn cool

2 Likes

After fixing dll.so loading problem, GUI is now working:

screenshot89

42 Likes

You are awesome!

3 Likes

Some applications:
screenshot90

36 Likes

Beautiful!

With @waddlesplash’s Xlibe work, there won’t need to be a Freedesktop-dot-org X window then? It’s nice seeing things coming together :slight_smile:

9 Likes

Yes, that’s the idea. X512 already sent me an initial log of trying to compile WINE with Xlibe, there are some things that have to be implemented and probably work to do once it compiles. I will look at it down the road.

29 Likes

And this is with just one day of work! Simply amazing!

10 Likes

screenshot91

34 Likes

It cannot be overstated what a huge milestone this is for Haiku. I can’t wait to see this port mature. Great job!

4 Likes

Awesome work! Please try Inkscape and Gimp.

1 Like

screenshot94

screenshot95

GTK 3 based Inkscape won’t run.

31 Likes

Perfect !!! :slightly_smiling_face:

1 Like

Very cool, I’d be impressed to see a game like Plants vs Zombies run or any other game that doesn’t need hardware accelerated graphics.

2 Likes

Wine with Xlibe. Wrong stride and input not working.

screenshot97

13 Likes