06-13-2026, 02:46 AM
(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.
when figure out how to fix a problem but forget to fix the problem

