Fix platform detection: LE (DOS/4GW extender) is DOS, not Windows
Build & Deploy / build-and-deploy (push) Successful in 48s

Many classic DOS games (Blood, DOOM, Duke Nukem 3D, Quake) use
DOS/4GW or DOS/32A — 32-bit DOS extenders with Linear Executable
(LE) format. My code was detecting LE as 'windows', causing these
games to be incorrectly flagged as unplayable.

Only PE (Portable Executable / Win32) and NE (New Executable /
Windows 3.x) are actually Windows.
This commit is contained in:
Hermes Agent
2026-05-28 15:46:36 +02:00
parent 95c7ba7192
commit 41d1e22522
@@ -447,10 +447,13 @@ public class UploadResource {
/** /**
* Detect whether an executable targets DOS or Windows by reading its PE/NE header. * Detect whether an executable targets DOS or Windows by reading its PE/NE header.
* <ul> * <ul>
* <li>Pure MZ (no NE/PE/LE) → "dos"</li> * <li>Pure MZ, LE (DOS/4GW extender), LX (OS/2) → "dos"</li>
* <li>NE (Windows 3.x), PE (Win32), LE (VxD) → "windows"</li> * <li>NE (Windows 3.x), PE (Win32) → "windows"</li>
* <li>Cannot read → null</li> * <li>Cannot read → null</li>
* </ul> * </ul>
* Note: LE (Linear Executable) is used by DOS/4GW, DOS/32A, PMODE/W
* — all 32-bit DOS extenders for games like DOOM, Blood, Duke Nukem 3D.
* Only PE (Portable Executable) and NE (New Executable) are Windows.
*/ */
static String detectPlatform(Path exePath) { static String detectPlatform(Path exePath) {
String name = exePath.getFileName().toString().toLowerCase(); String name = exePath.getFileName().toString().toLowerCase();
@@ -487,12 +490,10 @@ public class UploadResource {
// PE = Portable Executable (Win32) // PE = Portable Executable (Win32)
// NE = New Executable (Windows 3.x) // NE = New Executable (Windows 3.x)
// LE = Linear Executable (VxD, OS/2) // LE = Linear Executable (DOS/4GW, DOS/32A — 32-bit DOS extenders)
// LX = Extended Linear Executable (OS/2 2.x) // LX = Extended Linear Executable (OS/2 2.x)
if ((sig1 == 0x50 && sig2 == 0x45) // PE if ((sig1 == 0x50 && sig2 == 0x45) // PE
|| (sig1 == 0x4E && sig2 == 0x45) // NE || (sig1 == 0x4E && sig2 == 0x45)) // NE
|| (sig1 == 0x4C && sig2 == 0x45) // LE
|| (sig1 == 0x4C && sig2 == 0x58)) // LX
return "windows"; return "windows";
return "dos"; // Plain MZ without known Windows signature return "dos"; // Plain MZ without known Windows signature