Blockland Fan Forums
Wine Blockland server guide for Linux VPS (Debian) - Printable Version

+- Blockland Fan Forums (https://forum.bcs.place)
+-- Forum: Blockland Forums (https://forum.bcs.place/forumdisplay.php?fid=1)
+--- Forum: Tools and Resources (https://forum.bcs.place/forumdisplay.php?fid=3)
+--- Thread: Wine Blockland server guide for Linux VPS (Debian) (/showthread.php?tid=89)



Wine Blockland server guide for Linux VPS (Debian) - Queuenard - 05-09-2026

https://codeberg.org/Queuenard/blockland-wine-vps-dedi-server

I wrote this so that there's a current guide for running dedicated Blockland servers on a Linux VPS. New Wine versions have been a nightmare since they keep removing features that dedi servers require.

I can't explain everything about managing Linux servers but I can hopefully help people who just need to know how we currently deal with Wine. I also made the script so that multiple Wine versions can be easily swapped.

Goals
  • Setup Wine and a Blockland server on a Linux VPS (Debian 13)
  • Use a separate user account, the screen command and bwrap (bubblewrap) protection
  • Have the server start automatically at boot
  • Save all console logs

Assumptions
  • You know how to run commands
  • You already setup your VPS already and have SSH access
  • You know how to setup an FTP server or use rsync to change files on your VPS
  • You already have Blockland files you want to upload

Current Wine problems
  • Blockland with Wine versions 9 and higher produce no output
  • Using a package manager (apt) forces you to stick to one Wine version
  • Your distribution’s package manager may not offer the version of Wine you want
  • The Wine packages require you to install dependencies that are not needed for headless servers
  • Adding an apt repository (winehq) could open up an additional vector for malicious package installation beyond just the distribution’s defaults



RE: Wine Blockland server guide for Linux VPS (Debian) - Queuenard - 05-25-2026

Major breakthrough.

By changing the Blockland executable's subsystem from 2 to 3 (IMAGE_SUBSYSTEM_WINDOWS_GUI -> IMAGE_SUBSYSTEM_WINDOWS_CUI) Wine can then correctly handle console input and output as a normal console application. The requirements of having xvfb and WineFix.dll would be dropped.

The Torque executable is compiled with the WINDOWS_GUI subsystem flag (which is meant for applications that spawn windows on the desktop) but spawns its own console window. It's probably a miracle the console even worked in some older versions of Wine.

Converting an executable can be done in 10 lines of Python with python3-pefile installed. I also assigned MajorSubsystemVersion to 4 because that's what console applications appear to use.

Code:
import pefile

exe_path = "Blockland.exe"
new_exe_path = "Blockland.patched.exe"

print(' - Input file: '+ exe_path)

pe = pefile.PE(exe_path)
pe.OPTIONAL_HEADER.Subsystem = 3
pe.OPTIONAL_HEADER.MajorSubsystemVersion = 4
pe.OPTIONAL_HEADER.MinorSubsystemVersion = 0

print(' - Writing new EXE with modified headers...')
pe.write(new_exe_path)

A full solution needs some time to finish.

Credit to Trigun for mentioning subsystem designations which proved to be the key to fixing the problem.

Resources used
https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#windows-subsystem
https://www.devever.net/~hl/win32con
https://stackoverflow.com/questions/493536/can-one-executable-be-both-a-console-and-gui-application/494000#494000
https://devblogs.microsoft.com/oldnewthing/20090101-00/?p=19643


RE: Wine Blockland server guide for Linux VPS (Debian) - Queuenard - 05-27-2026

The bash method to patch the EXE to a IMAGE_SUBSYSTEM_WINDOWS_CUI executable is this:

Code:
PatchedExe="Blockland.patched.exe";
cp Blockland.exe $PatchedExe;
printf \\x04\\x00\\x00\\x00 | dd of=$PatchedExe bs=1 count=4 seek=368 conv=notrunc 2>&1;
printf           \\x03\\x00 | dd of=$PatchedExe bs=1 count=2 seek=388 conv=notrunc 2>&1;


If you use the script from this thread, you can insert the above code in the startup script and transparently map the patched EXE into the bwrap namespace using the normal EXE name:
Code:
--ro-bind $server_location/Blockland.exe /home/user/$server/Blockland.exe \

Code:
--ro-bind $server_location/$PatchedExe /home/user/$server/Blockland.exe \

Remember to remove xvfb-run and WineFix.dll.


The guide needs a rewrite since Wine 11 is now the minimum version and several other requirements have disappeared. The distro-supplied Wine versions are now usable as well and this will require a new method.


RE: Wine Blockland server guide for Linux VPS (Debian) - Queuenard - 06-13-2026

(05-27-2026, 03:35 AM)Queuenard Wrote: The bash method to patch the EXE to a IMAGE_SUBSYSTEM_WINDOWS_CUI executable is this:
Code:
PatchedExe="Blockland.patched.exe";
cp Blockland.exe $PatchedExe;
printf \\x04\\x00\\x00\\x00 | dd of=$PatchedExe bs=1 count=4 seek=368 conv=notrunc 2>&1;
printf           \\x03\\x00 | dd of=$PatchedExe bs=1 count=2 seek=388 conv=notrunc 2>&1;

This requires a switch of shell from /bin/sh to /bin/bash, which I will address when I update the script. /bin/sh (defaults to /bin/dash shell on Debian) does not support hex escape characters as used in those printf calls, only octal, because I don't fucking know why. The good news is that I immediately learned about dash's limitation when I was first constructing the statement.

The bad news is that I forgot to switch shells in my script when finally testing on my VPS, so I wasted hours trying to figure out how the environments were so different, culminating in me compiling Wine from source and adding a few debug trace statements. I found out the image (EXE) wasn't being loaded as IMAGE_SUBSYSTEM_WINDOWS_CUI, making me realize the patch wasn't being applied correctly because I wasn't using the correct shell.

The good part of the bad news is that besides teaching me how to compile and edit Wine, it's clear that some parts of Wine (including the relevant dlls/ntdll/unix/env.c) are missing documentation of certain important behaviors and missing TRACE statements that would have exposed this behavior, so I can make a more complete bug report.


Cool Smile  when figure out how to fix a problem but forget to fix the problem  Cool Smile