Package: y file
Version: 1:5.47-4
Severity: normal

Dear Maintainer,

File reports "MS-DOS executable, NE version 5 for unknown OS 0xff" for a plain 
MZ QuickC 2.0 DOS program. The
MZ reserved word at 0x3C reads 0x1076, pointing into incidental code bytes 4E 
45 05 02 59 00 … — "NE",
version 5, OS 0xFF by coincidence.

* Proposed fix: validate NE header fields ( entry/segment table offsets 
in-file) before claiming NE:

1st guard: no NE table may predate the NE header. In a genuine NE image, every 
table offset in the fixed
64-byte header (entry table at +0x04, segment table at +0x22, resident names at 
+0x26, and friends) points at
or after lfanew — the tables live inside the NE region, which starts there. On 
mz-dos-qc2+cv.exe, the alleged
segment-table offset reads 0x000D against lfanew 0x1076: it points into the MZ 
header itself, which is
structurally impossible for a real NE. Reject on that single comparison and 
both false positives die with zero
risk to genuine files — no valid NE can have a table offset below its own 
header base.

Secondary guards: target-OS byte (+0x38) must be a defined value (0x00–0x05); 
ours reads 0xD1. And e_lfanew
paragraph alignment (0x1076 % 16 = 6); useful as a cheap pre-check.


-- System Information:
Debian Release: forky/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 7.3.5+deb14-amd64 (SMP w/8 CPU threads; PREEMPT)
Locale: LANG=fr_CA.UTF-8, LC_CTYPE=fr_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=fr_CA:fr
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages file depends on:
ii  libc6         2.43-7
ii  libmagic1t64  1:5.47-4

file recommends no packages.

file suggests no packages.

-- no debconf information

--- msdos.upstream      2026-12-06 08:44:53.265388250 -0500
+++ msdos.patched       2026-12-06 09:00:24.980931743 -0500
@@ -469,270 +469,27 @@
 >>(0x3c.l) string !PE\0\0 MS-DOS executable
 #!:mime        application/x-dosexec
 
->>(0x3c.l)             string          NE \b, NE
-#!:mime        application/x-dosexec
-!:mime application/x-ms-ne-executable
->>>(0x3c.l+0x02)       ubyte           x       \b version %u
->>>(0x3c.l+0x02)       ubyte           >5
->>>>(0x3c.l+0x03)      ubyte           x       \b.%02u
-# FOR DEBUGGING!
-# Reference:   https://wiki.osdev.org/NE
-# Create time for NE version <5 in FAT12 format
-#>>>(0x3c.l+0x02)    ubyte        <5
-#>>>>(0x3c.l+0x08)    ulelong        !0    \b, Created at
-#>>>>>(0x3c.l+0x0a)    lemsdosdate    x    %s
-#>>>>>(0x3c.l+0x08)    lemsdostime    x    %s
-# ProgFlags; Program flags, bitmapped
-#>>>(0x3c.l+0x0C)      ubyte           x       \b, ProgFlags 0x%2.2x
-# >>>(0x3c.l+0x0c)     ubyte&0x03      =0      \b, no automatic data segment
-# >>>(0x3c.l+0x0c)     ubyte&0x03      =1      \b, single shared
-# >>>(0x3c.l+0x0c)     ubyte&0x03      =2      \b, multiple
-# >>>(0x3c.l+0x0c)     ubyte&0x03      =3      \b, (null)
-# >>>(0x3c.l+0x0c)     ubyte           &0x04   \b, Per-Process Library 
Initialization OR real mode only
-# >>>(0x3c.l+0x0c)     ubyte           &0x08   \b, Protected mode only
-# >>>(0x3c.l+0x0c)     ubyte           &0x10   \b, 8086 instructions in OS/2 
app OR LIM 3.2 EMS API in Win app
-# >>>(0x3c.l+0x0c)     ubyte           &0x20   \b, i286 instructions in OS/2 
app OR each instance in separate EMS bank in Win app
-# >>>(0x3c.l+0x0c)     ubyte           &0x40   \b, i386 instructions in OS/2 
app OR private GlobalAlloc above the EMS line in Win app
-# >>>(0x3c.l+0x0c)     ubyte           &0x80   \b, x87 floating point 
instructions
-# ApplFlags; Application flags, bitmapped
-# https://www.fileformat.info/format/exe/corion-ne.htm
-#>>>(0x3c.l+0x0D)      ubyte           x       \b, ApplFlags 0x%2.2x
-# Application type (bits 0-2); 1~Full screen (not aware of Windows/P.M. API)
-# 2~Compatible with Windows/P.M. API 3~Uses Windows/P.M. API
-#>>>(0x3c.l+0x0D)      ubyte&0x07      =1      \b, Not compatiblr with 
Windows/P.M. API (full screen)
-#>>>(0x3c.l+0x0D)      ubyte&0x07      =2      \b, Compatible with 
Windows/P.M. API (console mode)
-#>>>(0x3c.l+0x0D)      ubyte&0x07      =3      \b, use Windows/P.M. API 
(window mode)
-#>>>(0x3c.l+0x0D)      ubyte           &0x08   \b, Bound OS/2 app OR 
application specific loader in Win app
-#>>>(0x3c.l+0x0D)      ubyte           &0x20   \b, Errors in image
-#>>>(0x3c.l+0x0D)      ubyte           &0x40   \b, Non-conforming OS/2 app OR 
private Win library above EMS line
-# bit 7; DLL or driver (SS:SP info invalid, CS:IP points at FAR init routine 
called with AX handle
-#>>>(0x3c.l+0x0D)      ubyte           &0x80   \b, DLL or driver
-# AutoDataSegIndex; automatic data segment index like: 0 2 3 22
-# zero if the SINGLEDATA and MULTIPLEDATA bits are cleared
-#>>>(0x3c.l+0x0e)      uleshort        x       \b, AutoDataSegIndex %u
-# InitHeapSize; intial local heap size like; 0 400h 1400h
-# zero if there is no local allocation
-#>>>(0x3c.l+0x10)      uleshort        !0      \b, InitHeapSize 0x%x
-# InitStackSize; inital stack size like: 0 10h A00h 7D0h A8Ch FA0h 1000h 1388h
-# 1400h (CBT) 1800h 2000h 2800h 2EE0h 2F3Ch 3258h 3E80h 4000h 4E20h 5000h 6000h
-# 6D60h 8000h 40000h
-# zero if the SS register value does not equal the DS register value
-#>>>(0x3c.l+0x12)      uleshort        !0      \b, InitStackSize 0x%x
-# EntryPoint; segment offset value of CS:IP like: 0 10000h 18A84h 11C1Ah 
307F1h 
-#>>>(0x3c.l+0x14)      ulelong         !0      \b, EntryPoint 0x%x
-# InitStack; specifies the segment offset value of stack pointer SS:SP
-# like: 0 20000h 160000h
-#>>>(0x3c.l+0x18)      ulelong         !0      \b, InitStack 0x%x
-# SegCount; number of segments in segment table like: 0 1 2 3 16h
-#>>>(0x3c.l+0x1C)      uleshort        x       \b, SegCount 0x%x
-# ModRefs; number of module references (DLLs) like; 0 1 3
-#>>>(0x3c.l+0x1E)      uleshort        !0      \b, ModRefs %u
-# NoResNamesTabSiz; size in bytes of non-resident names table
-# like: Bh 16h B4h B9h 2Ch 18Fh 16AAh
-#>>>(0x3c.l+0x20)      uleshort        x       \b, NoResNamesTabSiz 0x%x
-# SegTableOffset; offset of Segment table like: 40h
-#>>>(0x3c.l+0x22)      uleshort        !0x40   \b, SegTableOffset 0x%x
-# ResTableOffset; offset of resources table like: 40h 50h 58h F0h
-# 40h for most fonts likedos737.fon FMFONT.FOT but 60h for L1WBASE.FON
-#>>>(0x3c.l+0x24)      uleshort        x       \b, ResTableOffset 0x%x
-# ResidNamTable; offset of resident names table
-# like: 58h 5Ch 60h 68h 74h 98h 2E3h 2E7h 2F0h
-#>>>(0x3c.l+0x26)      uleshort                x \b, ResidNamTable 0x%x
-# ImportNameTable; offset of imported names table (array of counted strings, 
terminated with string of length 00h)
-# like: 77h 7Eh 80h C6h A7h ACh 2F8h 3FFh
-#>>>(0x3c.l+0x2a)      uleshort        x       \b, ImportNameTable 0x%x
-# OffStartNonResTab; offset from start of file to non-resident names table
-# like: 110h 11Dh 19Bh 1A5h 3F5h 4C8h 4EEh D93h
-#>>>(0x3c.l+0x2c)      ulelong         x       \b, OffStartNonResTab 0x%x
-# MovEntryCount; number of movable entry points like: 0 4 5 6 16 17 24 312 355 
446
-#>>>(0x3c.l+0x30)      uleshort        !0      \b, MovEntryCount %u
-# FileAlnSzShftCnt; log2 of the segment sector size; 4~16 0~9~512 (default)
-#>>>(0x3c.l+0x32)      uleshort        !9      \b, FileAlnSzShftCnt %u
-# nResTabEntries; number of resource table entries like: 0 2
-#>>>(0x3c.l+0x34)      uleshort        !0      \b, nResTabEntries %u
-# Following fields are valid only for NE version 5+
+>>(0x3c.l)             string          NE
+# NE with an undefined target OS at +0x36 is incidental bytes, not a header
+# (e.g. QuickC MZ binaries matching "NE" + version 5 + 0xFF by coincidence).
+# NE version <5 carries no exetype byte; its ladder is unchanged in ne-legacy.
+>>>(0x3c.l+0x02)       ubyte           <5
+>>>>0          use             ne-legacy
 >>>(0x3c.l+0x02)       ubyte           >4
-# targOS; Target OS; 0~unspecified (OS/2 or Windows); detect it based on 
Windows-only flags and OS/2 specific import lib (DOSCALLS)
-#>>>(0x3c.l+0x36)      byte            x TARGOS %x
 >>>>(0x3c.l+0x36)      byte            0
-# if windows version is specified then it is windows binary
->>>>>(0x3c.l+0x3E)     ushort          !0 for MS Windows
->>>>>>(0x3c.l+0x3F)    ubyte           x       %u
->>>>>>(0x3c.l+0x3E)    ubyte           x       \b.%02u
->>>>>>(0x3c.l+0x3F)    ubyte           <3
->>>>>>>(0x3c.l+0x37)   byte&0x04       0       (real mode only)
->>>>>>>(0x3c.l+0x37)   byte&0x04       !0      (real+protected mode)
->>>>>>(0x3c.l+0x3E)    ushort          =0x0300
->>>>>>>(0x3c.l+0x0c)   ubyte&0x08      0       (real+protected mode)
->>>>>>>(0x3c.l+0x0c)   ubyte&0x08      !0      (protected mode only)
->>>>>(0x3c.l+0x3E)     ushort          0
->>>>>>(0x3c.l+0x2a)    leshort         0 for OS/2 1.x or MS Windows 1.x/2.x
->>>>>>(0x3c.l+0x2a)    default         x
-# Binaries with DOSCALLS import library are for OS/2
->>>>>>>&(&0.s-0x29)    search/512/C    \x08DOSCALLS for OS/2 1.x
->>>>>>>(0x3c.l+0x2a)   default         x
-# Binaries with KERNEL, USER or GDI import library are for Windows
-# FIXME: names are prefixed by its length, but regex type does not support 
binary bytes
->>>>>>>>&(&0.s-0x29)   regex/512       KERNEL|USER|GDI for MS Windows 1.x/2.x
->>>>>>>>>(0x3c.l+0x37) byte&0x04       0       (real mode only)
->>>>>>>>>(0x3c.l+0x37) byte&0x04       !0      (real+protected mode)
-# Binaries without any of those import library can be for any OS
->>>>>>>>(0x3c.l+0x2a)  default         x for OS/2 1.x or MS Windows 1.x/2.x
->>>>(0x3c.l+0x36)      byte            1 for OS/2 1.x
->>>>(0x3c.l+0x36)      byte            2 for MS Windows
-# expctwinver; expected Windows version (minor first) like:
-# 0.0~DTM.DLL 203.4~Windows 1.03 GDI.EXE 2.1~TTY.DRV 3.0~dos737.fon FMFONT.FOT 
THREED.VBX 3.10~GDI.EXE 4.0~(ME) VGAFULL.3GR
->>>>>(0x3c.l+0x3E)     ushort          !0
->>>>>>(0x3c.l+0x3F)    ubyte           x       %u
->>>>>>(0x3c.l+0x3E)    ubyte           x       \b.%02u
-# Empty version is is treated by Windows 3.x OS as Windows 2.01 version and by 
Windows 2.x OS as Windows 1.01 version
->>>>>(0x3c.l+0x3E)     ushort          0       1.x/2.x
->>>>>(0x3c.l+0x3F)     ubyte           <3
->>>>>>(0x3c.l+0x37)    byte&0x04       0       (real mode only)
->>>>>>(0x3c.l+0x37)    byte&0x04       !0      (real+protected mode)
->>>>>(0x3c.l+0x3E)     ushort          =0x0300
->>>>>>(0x3c.l+0x0c)    ubyte&0x08      0       (real+protected mode)
->>>>>>(0x3c.l+0x0c)    ubyte&0x08      !0      (protected mode only)
-# Windows P-code application
-# 
https://web.archive.org/web/20000304044656/http://msdn.microsoft.com/library/backgrnd/html/msdn_c7pcode2.htm
-# 
https://library.thedatadungeon.com/msdn-1992-09/msjv7/html/msjv0g6a.content.htm
-# https://en.wikipedia.org/wiki/P-code_machine#Microsoft_P-code
-# Can be created by MSC7 or MSVC1.x CL.EXE /Oq switch which calls MPC.EXE
-# MPC.EXE (Make P-Code utility) sets bit2 in MZ e_res[2] (e_flags) field
-# Filter out false-positive Windows 3.x applications with OS/2 WLO loader
-# (sets bit7 in NE ne_flagsothers) as they do not have MZ e_res[] fields
->>>>>(0x3c.l+0x3E)     ushort          >0x0300
->>>>>>(0x3c.l+0x37)    ubyte&0x80      0
->>>>>>>0x20            ubyte&0x04      !0      \b, P-code application
-# 32-bit Watcom Win386 extender in 16-bit Windows 3.x NE binaries
-# https://www.os2museum.com/wp/watcom-win386/
-# https://github.com/open-watcom/open-watcom-v2/blob/master/bld/win386/
-# https://misc.daniel-marschall.de/spiele/blown_away/disassemble.php
-# Examples: BA_LITE.EXE WALDO.EXE
->>>>>(0x3c.l+0x3E)     ushort          >0x0300
->>>>>>0x38             ulong           !0
->>>>>>>(0x38.l)                string          MQ      \b, Watcom Win386 
extender
-# OS 3 was reserved for Multitasking MS-DOS but it never used NE version 5+ 
(only NE version 4)
-#>>>>(0x3c.l+0x36)     byte            3 for Multitasking MS-DOS
-# OS 4 was reserved for MS Windows/386 device drivers but MS Windows/386 2.x 
never used NE format (Xenix x.out format was used instead)
-#>>>>(0x3c.l+0x36)     byte            4 for MS Windows/386 device driver
-# OS 5 is assigned to BOSS (Borland Operating System Services) but is used 
also by other 16-bit DOS applications
->>>>(0x3c.l+0x36)      byte            5 for MS-DOS
-# HDLD16.BIN
-# x86 jmp near relative (0xe9 0x?? 0x??) + string "MI" (0x4d 0x49)
->>>>>(8.s*16)          ulequad&0xffff0000ff    =0x494d0000e9   \b, HX DOS 
extender 16-bit (embedded with DPMI host)
->>>>>(8.s*16)          ulequad&0xffff0000ff    !0x494d0000e9
-# DPMIST16.BIN
->>>>>>(8.s*16)         search/0x200    cannot\ find\ loader\ DPMILD16.EXE      
\b, HX DOS extender 16-bit (stub)
-# DPMILD16.BIN
->>>>>>(8.s*16)         search/0x4000   DPMILD16:       \b, HX DOS extender 
16-bit (embedded without DPMI host)
-# TLINK.EXE or TD.EXE from TASM 5.0
->>>>>>(8.s*16)         string          16STUB
->>>>>>>(8.s*16)                search/0x1000   rtm.exe\0dpmi16bi.ovl   \b, 
Borland rtm DOS extender (stub)
->>>>>>(8.s*16)         string          !16STUB
-# TLINK.EXE or BRC.EXE from Borland Pascal 7.0
->>>>>>>(8.s*16)        search/0x1000   BOSS\ Stub\ Version     \b, Borland 
BOSS DOS extender (stub)
-# OS 6 is not assigned but is used by 32-bit DOS application with extender 
(found only with HX DOS extender 32-bit)
-# http://downloads.sourceforge.net/dfendreloaded/D-Fend-Reloaded-1.4.4.zip
-# D-Fend Reloaded/VirtualHD/FREEDOS/DPMILD32.EXE
-# https://www.japheth.de/HX/DPMILD32.TXT
->>>>(0x3c.l+0x36)      byte            6 for MS-DOS
-# HDLD32.BIN
-# x86 jmp near relative (0xe9 0x?? 0x??) + string "MI" (0x4d 0x49)
->>>>>(8.s*16)          ulequad&0xffff0000ff    =0x494d0000e9   \b, HX DOS 
extender 32-bit (embedded with DPMI host)
->>>>>(8.s*16)          ulequad&0xffff0000ff    !0x494d0000e9
-# DPMIST32.BIN
->>>>>>(8.s*16)         search/0x200    cannot\ find\ loader\ DPMILD32.EXE      
\b, HX DOS extender 32-bit (stub)
-# DPMILD32.BIN
->>>>>>(8.s*16)         search/0x4000   DPMILD32:       \b, HX DOS extender 
32-bit (embedded without DPMI host)
-# https://en.wikipedia.org/wiki/Phar_Lap_(company)
-# like: TELLPROT.EXE from 286DEX
-# can be created by BIND286.EXE from OS/2 NE binary
->>>>(0x3c.l+0x36)      byte            0x81 for MS-DOS, Phar Lap 286 DOS 
extender, emulating OS/2 1.x
-# like: CVP7.EXE from 286DEX
-# can be created by BIND286.EXE from Windows NE binary
->>>>(0x3c.l+0x36)      byte            0x82 for MS-DOS, Phar Lap 286 DOS 
extender, emulating MS Windows
->>>>>(0x3c.l+0x3E)     ushort          0       1.x/2.x
->>>>>(0x3c.l+0x3E)     ushort          !0
->>>>>>(0x3c.l+0x3F)    ubyte           x       %u
->>>>>>(0x3c.l+0x3E)    ubyte           x       \b.%02u
->>>>(0x3c.l+0x36)      default         x
->>>>>(0x3c.l+0x36)     ubyte           x for unknown OS %#x
-# OS2EXEFlags; other EXE flags
-# 1~Long filename support 2~Win2.x proportional fonts 4~Win2.x protected mode 
8~Executable has gangload area 10~Win9x thunk lib without DllEntryPoint 
80~Win3.x app with OS/2 WLO loader
-#>>>>(0x3c.l+0x37)     byte            !0      \b, OS2EXEFlags 0x%x
-# gangstart; offset to start of gangload area like: 0 34h 58h 246h 
-#>>>>(0x3c.l+0x38)     uleshort        !0      \b, gangstart 0x%x
-# ganglength; size of gangload area
-# like: 0 33Eh 39Ah AEEh
-#>>>>(0x3c.l+0x3A)     uleshort        !0      \b, ganglength 0x%x
-# mincodeswap; minimum code swap area size like 0 620Ch
-#>>>>(0x3c.l+0x3C)     uleshort        !0 \b, mincodeswap 0x%x
->>>>(0x3c.l+0x3F)      ubyte           =3
->>>>>0x3c              ulelong         >0x800
->>>>>>(0x3c.l+0x37)    ubyte           &0x80   with OS/2 WLO loader
-# Detection for NE versions <5 which do not have OS type byte 0x36
-# These versions are used only by WINE, Windows 1.x/2.x and Multitasking MS-DOS
-# WINE binaries have special signature after the dos header (at fixed offset 
0x40)
-# Multitasking MS-DOS binaries imports DOSCALLS library, so use it for 
distinguishing
-# Import libraries are part of the string table which starts one byte after the
-# 16-bit indirect offset 0x2a relative to the beginning of NE header, and 
consist
-# of concatenated pascal strings (first byte of the string is its length)
->>>(0x3c.l+0x02)       ubyte           <5
-# like: fakedlls/krnl386.exe16 fakedlls/gdi.exe16 fakedlls/winsock.dll16 
fakedlls/winoldap.mod16 fakedlls/mouse.drv16
->>>>0x40               string          Wine\ placeholder\ DLL for WINE stub
->>>>(0x3c.l+0x2a)      default         x
-# like: HE_DAEM.EXE POPUP.EXE QUEUER.EXE
->>>>>&(&0.s-0x29)      search/512/C    \x08DOSCALLS for Multitasking MS-DOS
->>>>>(0x3c.l+0x2a)     default         x for MS Windows 1.x/2.x
-# Special case, Windows 3.x OS parse from NE version 4 binaries also following 
NE version 5 fields:
-# - os type if is 0 or 2
-# - bits proportional fonts and protected mode
-# Such NE version 4 binary is treated by Windows 3.x OS as Windows 2.01
-# compatible binary and by Windows 2.x OS as Windows 1.01 compatible binary.
-# So if os type is correct (0 or 2; matched mask 0xfd) and at least one
-# of those bits is set and others are cleared (matched mask 0xf9) then
-# detect if binary has NE version 5 protected mode bit set.
->>>>>>(0x3c.l+0x36)    leshort&0xf9fd  0
->>>>>>>(0x3c.l+0x37)   byte&0x06       !0
->>>>>>>>(0x3c.l+0x37)  byte&0x04       0       (real mode only)
->>>>>>>>(0x3c.l+0x37)  byte&0x04       !0      (real+protected mode)
->>>>>>>(0x3c.l+0x37)   default         x       (real mode only)
->>>>>>(0x3c.l+0x36)    default         x       (real mode only)
-# DRV: Driver
-# 3GR: Grabber device driver
-# CPL: Control Panel Item
-# VBX: Visual Basic Extension          
https://en.wikipedia.org/wiki/Visual_Basic
-# FON: Bitmap font                     
http://fileformats.archiveteam.org/wiki/FON
-# FOT: Font resource file
-# EXE: WINSPOOL.EXE USER.EXE krnl386.exe GDI.EXE
-# CNV: Microsoft Word text conversion  
https://www.file-extensions.org/cnv-file-extension-microsoft-word-text-conversion-data
->>>(0x3c.l+0x0c)       leshort         &0x8000
-# Check segment count, if 0 then this is resource-only DLL
->>>>(0x3c.l+0x1c)      leshort         0
->>>>>(0x3c.l+0x2c)     lelong          !0
->>>>>>(&-4.l+1)                string/C        FONTRES (DLL, font)
-!:ext  fon/fot
->>>>>>(&-4.l+1)                default         x       (DLL, resource-only)
-!:ext  dll
->>>>>(0x3c.l+0x2c)     lelong          0       (DLL, resource-only)
-!:ext  dll
->>>>(0x3c.l+0x1c)      leshort         !0
-# Check description of the module, first word specifies type of the DLL library
->>>>>(0x3c.l+0x2c)     lelong          !0
->>>>>>(&-4.l+1)                string/C        DDRV    (DLL, driver)
-!:ext  drv
->>>>>>(&-4.l+1)                default         x       (DLL)
-!:ext  dll/drv/3gr/cpl/vbx
->>>>>(0x3c.l+0x2c)     lelong          0       (DLL)
-!:ext  dll/drv/3gr/cpl/vbx
->>>(0x3c.l+0x0c)       leshort&0x8000  0 (EXE)
-!:ext  exe/scr
->>>>(0x3c.l+0x0d)      ubyte&0x07      =1 (full screen)
->>>>(0x3c.l+0x0d)      ubyte&0x07      =2 (console)
->>>>(0x3c.l+0x0d)      ubyte&0x07      =3 (GUI)
->>>&(&0x24.s-1)                string          ARJSFX \b, ARJ self-extracting 
archive
->>>(0x3c.l+0x70)       search/0x80     WinZip(R)\ Self-Extractor \b, ZIP 
self-extracting archive (WinZip)
+>>>>>0         use             ne-v5
+>>>>(0x3c.l+0x36)      byte            1
+>>>>>0         use             ne-v5
+>>>>(0x3c.l+0x36)      byte            2
+>>>>>0         use             ne-v5
+>>>>(0x3c.l+0x36)      byte            5
+>>>>>0         use             ne-v5
+>>>>(0x3c.l+0x36)      byte            6
+>>>>>0         use             ne-v5
+>>>>(0x3c.l+0x36)      byte            0x81
+>>>>>0         use             ne-v5
+>>>>(0x3c.l+0x36)      byte            0x82
+>>>>>0         use             ne-v5
 
 >>(0x3c.l)             string          LX \b, LX
 !:mime application/x-dosexec
@@ -3101,3 +2858,273 @@
 #                      (BIFF8W only)
 >>>6   uleshort        =0x0100 Workspace
 
+# NE detail rules (undefined exetypes fall through to plain MZ).
+0      name    ne-legacy
+>(0x3c.l+0x02) ubyte           x       \b, NE version %u
+#!:mime        application/x-dosexec
+!:mime application/x-ms-ne-executable
+>(0x3c.l+0x02) ubyte           <5
+# like: fakedlls/krnl386.exe16 fakedlls/gdi.exe16 fakedlls/winsock.dll16 
fakedlls/winoldap.mod16 fakedlls/mouse.drv16
+>>0x40         string          Wine\ placeholder\ DLL for WINE stub
+>>(0x3c.l+0x2a)        default         x
+# like: HE_DAEM.EXE POPUP.EXE QUEUER.EXE
+>>>&(&0.s-0x29)        search/512/C    \x08DOSCALLS for Multitasking MS-DOS
+>>>(0x3c.l+0x2a)       default         x for MS Windows 1.x/2.x
+# Special case, Windows 3.x OS parse from NE version 4 binaries also following 
NE version 5 fields:
+# - os type if is 0 or 2
+# - bits proportional fonts and protected mode
+# Such NE version 4 binary is treated by Windows 3.x OS as Windows 2.01
+# compatible binary and by Windows 2.x OS as Windows 1.01 compatible binary.
+# So if os type is correct (0 or 2; matched mask 0xfd) and at least one
+# of those bits is set and others are cleared (matched mask 0xf9) then
+# detect if binary has NE version 5 protected mode bit set.
+>>>>(0x3c.l+0x36)      leshort&0xf9fd  0
+>>>>>(0x3c.l+0x37)     byte&0x06       !0
+>>>>>>(0x3c.l+0x37)    byte&0x04       0       (real mode only)
+>>>>>>(0x3c.l+0x37)    byte&0x04       !0      (real+protected mode)
+>>>>>(0x3c.l+0x37)     default         x       (real mode only)
+>>>>(0x3c.l+0x36)      default         x       (real mode only)
+# DRV: Driver
+# 3GR: Grabber device driver
+# CPL: Control Panel Item
+# VBX: Visual Basic Extension          
https://en.wikipedia.org/wiki/Visual_Basic
+# FON: Bitmap font                     
http://fileformats.archiveteam.org/wiki/FON
+# FOT: Font resource file
+# EXE: WINSPOOL.EXE USER.EXE krnl386.exe GDI.EXE
+# CNV: Microsoft Word text conversion  
https://www.file-extensions.org/cnv-file-extension-microsoft-word-text-conversion-data
+>>0            use             ne-tail
+0      name    ne-v5
+>(0x3c.l+0x02) ubyte           x       \b, NE version %u
+#!:mime        application/x-dosexec
+!:mime application/x-ms-ne-executable
+>>(0x3c.l+0x02)        ubyte           >5
+>>>(0x3c.l+0x03)       ubyte           x       \b.%02u
+# FOR DEBUGGING!
+# Reference:   https://wiki.osdev.org/NE
+# Create time for NE version <5 in FAT12 format
+#>>>(0x3c.l+0x02)    ubyte        <5
+#>>>>(0x3c.l+0x08)    ulelong        !0    \b, Created at
+#>>>>>(0x3c.l+0x0a)    lemsdosdate    x    %s
+#>>>>>(0x3c.l+0x08)    lemsdostime    x    %s
+# ProgFlags; Program flags, bitmapped
+#>>>(0x3c.l+0x0C)      ubyte           x       \b, ProgFlags 0x%2.2x
+# >>>(0x3c.l+0x0c)     ubyte&0x03      =0      \b, no automatic data segment
+# >>>(0x3c.l+0x0c)     ubyte&0x03      =1      \b, single shared
+# >>>(0x3c.l+0x0c)     ubyte&0x03      =2      \b, multiple
+# >>>(0x3c.l+0x0c)     ubyte&0x03      =3      \b, (null)
+# >>>(0x3c.l+0x0c)     ubyte           &0x04   \b, Per-Process Library 
Initialization OR real mode only
+# >>>(0x3c.l+0x0c)     ubyte           &0x08   \b, Protected mode only
+# >>>(0x3c.l+0x0c)     ubyte           &0x10   \b, 8086 instructions in OS/2 
app OR LIM 3.2 EMS API in Win app
+# >>>(0x3c.l+0x0c)     ubyte           &0x20   \b, i286 instructions in OS/2 
app OR each instance in separate EMS bank in Win app
+# >>>(0x3c.l+0x0c)     ubyte           &0x40   \b, i386 instructions in OS/2 
app OR private GlobalAlloc above the EMS line in Win app
+# >>>(0x3c.l+0x0c)     ubyte           &0x80   \b, x87 floating point 
instructions
+# ApplFlags; Application flags, bitmapped
+# https://www.fileformat.info/format/exe/corion-ne.htm
+#>>>(0x3c.l+0x0D)      ubyte           x       \b, ApplFlags 0x%2.2x
+# Application type (bits 0-2); 1~Full screen (not aware of Windows/P.M. API)
+# 2~Compatible with Windows/P.M. API 3~Uses Windows/P.M. API
+#>>>(0x3c.l+0x0D)      ubyte&0x07      =1      \b, Not compatiblr with 
Windows/P.M. API (full screen)
+#>>>(0x3c.l+0x0D)      ubyte&0x07      =2      \b, Compatible with 
Windows/P.M. API (console mode)
+#>>>(0x3c.l+0x0D)      ubyte&0x07      =3      \b, use Windows/P.M. API 
(window mode)
+#>>>(0x3c.l+0x0D)      ubyte           &0x08   \b, Bound OS/2 app OR 
application specific loader in Win app
+#>>>(0x3c.l+0x0D)      ubyte           &0x20   \b, Errors in image
+#>>>(0x3c.l+0x0D)      ubyte           &0x40   \b, Non-conforming OS/2 app OR 
private Win library above EMS line
+# bit 7; DLL or driver (SS:SP info invalid, CS:IP points at FAR init routine 
called with AX handle
+#>>>(0x3c.l+0x0D)      ubyte           &0x80   \b, DLL or driver
+# AutoDataSegIndex; automatic data segment index like: 0 2 3 22
+# zero if the SINGLEDATA and MULTIPLEDATA bits are cleared
+#>>>(0x3c.l+0x0e)      uleshort        x       \b, AutoDataSegIndex %u
+# InitHeapSize; intial local heap size like; 0 400h 1400h
+# zero if there is no local allocation
+#>>>(0x3c.l+0x10)      uleshort        !0      \b, InitHeapSize 0x%x
+# InitStackSize; inital stack size like: 0 10h A00h 7D0h A8Ch FA0h 1000h 1388h
+# 1400h (CBT) 1800h 2000h 2800h 2EE0h 2F3Ch 3258h 3E80h 4000h 4E20h 5000h 6000h
+# 6D60h 8000h 40000h
+# zero if the SS register value does not equal the DS register value
+#>>>(0x3c.l+0x12)      uleshort        !0      \b, InitStackSize 0x%x
+# EntryPoint; segment offset value of CS:IP like: 0 10000h 18A84h 11C1Ah 
307F1h 
+#>>>(0x3c.l+0x14)      ulelong         !0      \b, EntryPoint 0x%x
+# InitStack; specifies the segment offset value of stack pointer SS:SP
+# like: 0 20000h 160000h
+#>>>(0x3c.l+0x18)      ulelong         !0      \b, InitStack 0x%x
+# SegCount; number of segments in segment table like: 0 1 2 3 16h
+#>>>(0x3c.l+0x1C)      uleshort        x       \b, SegCount 0x%x
+# ModRefs; number of module references (DLLs) like; 0 1 3
+#>>>(0x3c.l+0x1E)      uleshort        !0      \b, ModRefs %u
+# NoResNamesTabSiz; size in bytes of non-resident names table
+# like: Bh 16h B4h B9h 2Ch 18Fh 16AAh
+#>>>(0x3c.l+0x20)      uleshort        x       \b, NoResNamesTabSiz 0x%x
+# SegTableOffset; offset of Segment table like: 40h
+#>>>(0x3c.l+0x22)      uleshort        !0x40   \b, SegTableOffset 0x%x
+# ResTableOffset; offset of resources table like: 40h 50h 58h F0h
+# 40h for most fonts likedos737.fon FMFONT.FOT but 60h for L1WBASE.FON
+#>>>(0x3c.l+0x24)      uleshort        x       \b, ResTableOffset 0x%x
+# ResidNamTable; offset of resident names table
+# like: 58h 5Ch 60h 68h 74h 98h 2E3h 2E7h 2F0h
+#>>>(0x3c.l+0x26)      uleshort                x \b, ResidNamTable 0x%x
+# ImportNameTable; offset of imported names table (array of counted strings, 
terminated with string of length 00h)
+# like: 77h 7Eh 80h C6h A7h ACh 2F8h 3FFh
+#>>>(0x3c.l+0x2a)      uleshort        x       \b, ImportNameTable 0x%x
+# OffStartNonResTab; offset from start of file to non-resident names table
+# like: 110h 11Dh 19Bh 1A5h 3F5h 4C8h 4EEh D93h
+#>>>(0x3c.l+0x2c)      ulelong         x       \b, OffStartNonResTab 0x%x
+# MovEntryCount; number of movable entry points like: 0 4 5 6 16 17 24 312 355 
446
+#>>>(0x3c.l+0x30)      uleshort        !0      \b, MovEntryCount %u
+# FileAlnSzShftCnt; log2 of the segment sector size; 4~16 0~9~512 (default)
+#>>>(0x3c.l+0x32)      uleshort        !9      \b, FileAlnSzShftCnt %u
+# nResTabEntries; number of resource table entries like: 0 2
+#>>>(0x3c.l+0x34)      uleshort        !0      \b, nResTabEntries %u
+# Following fields are valid only for NE version 5+
+>>(0x3c.l+0x02)        ubyte           >4
+# targOS; Target OS; 0~unspecified (OS/2 or Windows); detect it based on 
Windows-only flags and OS/2 specific import lib (DOSCALLS)
+#>>>(0x3c.l+0x36)      byte            x TARGOS %x
+>>>(0x3c.l+0x36)       byte            0
+# if windows version is specified then it is windows binary
+>>>>(0x3c.l+0x3E)      ushort          !0 for MS Windows
+>>>>>(0x3c.l+0x3F)     ubyte           x       %u
+>>>>>(0x3c.l+0x3E)     ubyte           x       \b.%02u
+>>>>>(0x3c.l+0x3F)     ubyte           <3
+>>>>>>(0x3c.l+0x37)    byte&0x04       0       (real mode only)
+>>>>>>(0x3c.l+0x37)    byte&0x04       !0      (real+protected mode)
+>>>>>(0x3c.l+0x3E)     ushort          =0x0300
+>>>>>>(0x3c.l+0x0c)    ubyte&0x08      0       (real+protected mode)
+>>>>>>(0x3c.l+0x0c)    ubyte&0x08      !0      (protected mode only)
+>>>>(0x3c.l+0x3E)      ushort          0
+>>>>>(0x3c.l+0x2a)     leshort         0 for OS/2 1.x or MS Windows 1.x/2.x
+>>>>>(0x3c.l+0x2a)     default         x
+# Binaries with DOSCALLS import library are for OS/2
+>>>>>>&(&0.s-0x29)     search/512/C    \x08DOSCALLS for OS/2 1.x
+>>>>>>(0x3c.l+0x2a)    default         x
+# Binaries with KERNEL, USER or GDI import library are for Windows
+# FIXME: names are prefixed by its length, but regex type does not support 
binary bytes
+>>>>>>>&(&0.s-0x29)    regex/512       KERNEL|USER|GDI for MS Windows 1.x/2.x
+>>>>>>>>(0x3c.l+0x37)  byte&0x04       0       (real mode only)
+>>>>>>>>(0x3c.l+0x37)  byte&0x04       !0      (real+protected mode)
+# Binaries without any of those import library can be for any OS
+>>>>>>>(0x3c.l+0x2a)   default         x for OS/2 1.x or MS Windows 1.x/2.x
+>>>(0x3c.l+0x36)       byte            1 for OS/2 1.x
+>>>(0x3c.l+0x36)       byte            2 for MS Windows
+# expctwinver; expected Windows version (minor first) like:
+# 0.0~DTM.DLL 203.4~Windows 1.03 GDI.EXE 2.1~TTY.DRV 3.0~dos737.fon FMFONT.FOT 
THREED.VBX 3.10~GDI.EXE 4.0~(ME) VGAFULL.3GR
+>>>>(0x3c.l+0x3E)      ushort          !0
+>>>>>(0x3c.l+0x3F)     ubyte           x       %u
+>>>>>(0x3c.l+0x3E)     ubyte           x       \b.%02u
+# Empty version is is treated by Windows 3.x OS as Windows 2.01 version and by 
Windows 2.x OS as Windows 1.01 version
+>>>>(0x3c.l+0x3E)      ushort          0       1.x/2.x
+>>>>(0x3c.l+0x3F)      ubyte           <3
+>>>>>(0x3c.l+0x37)     byte&0x04       0       (real mode only)
+>>>>>(0x3c.l+0x37)     byte&0x04       !0      (real+protected mode)
+>>>>(0x3c.l+0x3E)      ushort          =0x0300
+>>>>>(0x3c.l+0x0c)     ubyte&0x08      0       (real+protected mode)
+>>>>>(0x3c.l+0x0c)     ubyte&0x08      !0      (protected mode only)
+# Windows P-code application
+# 
https://web.archive.org/web/20000304044656/http://msdn.microsoft.com/library/backgrnd/html/msdn_c7pcode2.htm
+# 
https://library.thedatadungeon.com/msdn-1992-09/msjv7/html/msjv0g6a.content.htm
+# https://en.wikipedia.org/wiki/P-code_machine#Microsoft_P-code
+# Can be created by MSC7 or MSVC1.x CL.EXE /Oq switch which calls MPC.EXE
+# MPC.EXE (Make P-Code utility) sets bit2 in MZ e_res[2] (e_flags) field
+# Filter out false-positive Windows 3.x applications with OS/2 WLO loader
+# (sets bit7 in NE ne_flagsothers) as they do not have MZ e_res[] fields
+>>>>(0x3c.l+0x3E)      ushort          >0x0300
+>>>>>(0x3c.l+0x37)     ubyte&0x80      0
+>>>>>>0x20             ubyte&0x04      !0      \b, P-code application
+# 32-bit Watcom Win386 extender in 16-bit Windows 3.x NE binaries
+# https://www.os2museum.com/wp/watcom-win386/
+# https://github.com/open-watcom/open-watcom-v2/blob/master/bld/win386/
+# https://misc.daniel-marschall.de/spiele/blown_away/disassemble.php
+# Examples: BA_LITE.EXE WALDO.EXE
+>>>>(0x3c.l+0x3E)      ushort          >0x0300
+>>>>>0x38              ulong           !0
+>>>>>>(0x38.l)         string          MQ      \b, Watcom Win386 extender
+# OS 3 was reserved for Multitasking MS-DOS but it never used NE version 5+ 
(only NE version 4)
+#>>>>(0x3c.l+0x36)     byte            3 for Multitasking MS-DOS
+# OS 4 was reserved for MS Windows/386 device drivers but MS Windows/386 2.x 
never used NE format (Xenix x.out format was used instead)
+#>>>>(0x3c.l+0x36)     byte            4 for MS Windows/386 device driver
+# OS 5 is assigned to BOSS (Borland Operating System Services) but is used 
also by other 16-bit DOS applications
+>>>(0x3c.l+0x36)       byte            5 for MS-DOS
+# HDLD16.BIN
+# x86 jmp near relative (0xe9 0x?? 0x??) + string "MI" (0x4d 0x49)
+>>>>(8.s*16)           ulequad&0xffff0000ff    =0x494d0000e9   \b, HX DOS 
extender 16-bit (embedded with DPMI host)
+>>>>(8.s*16)           ulequad&0xffff0000ff    !0x494d0000e9
+# DPMIST16.BIN
+>>>>>(8.s*16)          search/0x200    cannot\ find\ loader\ DPMILD16.EXE      
\b, HX DOS extender 16-bit (stub)
+# DPMILD16.BIN
+>>>>>(8.s*16)          search/0x4000   DPMILD16:       \b, HX DOS extender 
16-bit (embedded without DPMI host)
+# TLINK.EXE or TD.EXE from TASM 5.0
+>>>>>(8.s*16)          string          16STUB
+>>>>>>(8.s*16)         search/0x1000   rtm.exe\0dpmi16bi.ovl   \b, Borland rtm 
DOS extender (stub)
+>>>>>(8.s*16)          string          !16STUB
+# TLINK.EXE or BRC.EXE from Borland Pascal 7.0
+>>>>>>(8.s*16) search/0x1000   BOSS\ Stub\ Version     \b, Borland BOSS DOS 
extender (stub)
+# OS 6 is not assigned but is used by 32-bit DOS application with extender 
(found only with HX DOS extender 32-bit)
+# http://downloads.sourceforge.net/dfendreloaded/D-Fend-Reloaded-1.4.4.zip
+# D-Fend Reloaded/VirtualHD/FREEDOS/DPMILD32.EXE
+# https://www.japheth.de/HX/DPMILD32.TXT
+>>>(0x3c.l+0x36)       byte            6 for MS-DOS
+# HDLD32.BIN
+# x86 jmp near relative (0xe9 0x?? 0x??) + string "MI" (0x4d 0x49)
+>>>>(8.s*16)           ulequad&0xffff0000ff    =0x494d0000e9   \b, HX DOS 
extender 32-bit (embedded with DPMI host)
+>>>>(8.s*16)           ulequad&0xffff0000ff    !0x494d0000e9
+# DPMIST32.BIN
+>>>>>(8.s*16)          search/0x200    cannot\ find\ loader\ DPMILD32.EXE      
\b, HX DOS extender 32-bit (stub)
+# DPMILD32.BIN
+>>>>>(8.s*16)          search/0x4000   DPMILD32:       \b, HX DOS extender 
32-bit (embedded without DPMI host)
+# https://en.wikipedia.org/wiki/Phar_Lap_(company)
+# like: TELLPROT.EXE from 286DEX
+# can be created by BIND286.EXE from OS/2 NE binary
+>>>(0x3c.l+0x36)       byte            0x81 for MS-DOS, Phar Lap 286 DOS 
extender, emulating OS/2 1.x
+# like: CVP7.EXE from 286DEX
+# can be created by BIND286.EXE from Windows NE binary
+>>>(0x3c.l+0x36)       byte            0x82 for MS-DOS, Phar Lap 286 DOS 
extender, emulating MS Windows
+>>>>(0x3c.l+0x3E)      ushort          0       1.x/2.x
+>>>>(0x3c.l+0x3E)      ushort          !0
+>>>>>(0x3c.l+0x3F)     ubyte           x       %u
+>>>>>(0x3c.l+0x3E)     ubyte           x       \b.%02u
+# OS2EXEFlags; other EXE flags
+# 1~Long filename support 2~Win2.x proportional fonts 4~Win2.x protected mode 
8~Executable has gangload area 10~Win9x thunk lib without DllEntryPoint 
80~Win3.x app with OS/2 WLO loader
+#>>>>(0x3c.l+0x37)     byte            !0      \b, OS2EXEFlags 0x%x
+# gangstart; offset to start of gangload area like: 0 34h 58h 246h 
+#>>>>(0x3c.l+0x38)     uleshort        !0      \b, gangstart 0x%x
+# ganglength; size of gangload area
+# like: 0 33Eh 39Ah AEEh
+#>>>>(0x3c.l+0x3A)     uleshort        !0      \b, ganglength 0x%x
+# mincodeswap; minimum code swap area size like 0 620Ch
+#>>>>(0x3c.l+0x3C)     uleshort        !0 \b, mincodeswap 0x%x
+>>>(0x3c.l+0x3F)       ubyte           =3
+>>>>0x3c               ulelong         >0x800
+>>>>>(0x3c.l+0x37)     ubyte           &0x80   with OS/2 WLO loader
+# Detection for NE versions <5 which do not have OS type byte 0x36
+# These versions are used only by WINE, Windows 1.x/2.x and Multitasking MS-DOS
+# WINE binaries have special signature after the dos header (at fixed offset 
0x40)
+# Multitasking MS-DOS binaries imports DOSCALLS library, so use it for 
distinguishing
+# Import libraries are part of the string table which starts one byte after the
+# 16-bit indirect offset 0x2a relative to the beginning of NE header, and 
consist
+# of concatenated pascal strings (first byte of the string is its length)
+>>>0           use             ne-tail
+0      name    ne-tail
+>(0x3c.l+0x0c) leshort         &0x8000
+# Check segment count, if 0 then this is resource-only DLL
+>>(0x3c.l+0x1c)        leshort         0
+>>>(0x3c.l+0x2c)       lelong          !0
+>>>>(&-4.l+1)          string/C        FONTRES (DLL, font)
+!:ext  fon/fot
+>>>>(&-4.l+1)          default         x       (DLL, resource-only)
+!:ext  dll
+>>>(0x3c.l+0x2c)       lelong          0       (DLL, resource-only)
+!:ext  dll
+>>(0x3c.l+0x1c)        leshort         !0
+# Check description of the module, first word specifies type of the DLL library
+>>>(0x3c.l+0x2c)       lelong          !0
+>>>>(&-4.l+1)          string/C        DDRV    (DLL, driver)
+!:ext  drv
+>>>>(&-4.l+1)          default         x       (DLL)
+!:ext  dll/drv/3gr/cpl/vbx
+>>>(0x3c.l+0x2c)       lelong          0       (DLL)
+!:ext  dll/drv/3gr/cpl/vbx
+>(0x3c.l+0x0c) leshort&0x8000  0 (EXE)
+!:ext  exe/scr
+>>(0x3c.l+0x0d)        ubyte&0x07      =1 (full screen)
+>>(0x3c.l+0x0d)        ubyte&0x07      =2 (console)
+>>(0x3c.l+0x0d)        ubyte&0x07      =3 (GUI)
+>&(&0x24.s-1)          string          ARJSFX \b, ARJ self-extracting archive
+>(0x3c.l+0x70) search/0x80     WinZip(R)\ Self-Extractor \b, ZIP 
self-extracting archive (WinZip)

Reply via email to