m4b / goblin

An impish, cross-platform binary parsing crate, written in Rust
MIT License
1.2k stars 160 forks source link

dos stub length restricts to the first 64 bytes #422

Closed edcdecl closed 4 weeks ago

edcdecl commented 1 month ago

assembling these two files with FASM in the same folder in this order:

  1. DOSS.ASM
    
    format MZ
    entry haha:_entry

segment haha use16 _entry: ; this is bad on purpose mov ah, 0x02 repeat 32 mov dl, 'b' int 21h mov dl, 'o' int 21h mov dl, 'g' int 21h mov dl, 'u' int 21h mov dl, 's' int 21h end repeat mov al, 0 mov ah, 0x4C int 21h


2. MAIN.ASM

format PE CONSOLE on 'DOSS.EXE' include 'win32axp.inc'

.code _entry: invoke MessageBoxA,0,"Text","Caption",0 invoke ExitProcess,0

.end _entry


gives a PE that can be run on WinNT and DOS.
goblin does not support DOS stubs more than 64 bytes long though!!!! so only the first 32
instructions in the DOS stub can be decoded through goblin :(
can this be remedied somehow?
kkent030315 commented 1 month ago

Yes, indeed. I already recognize this issue and would likely to be fixed in #406. But it would be a breaking change no matter how we fix.

kkent030315 commented 1 month ago

See this comment in the PR for more detailed analysis about DOS stub and signature across toolchains.

m4b commented 1 month ago

yes this will be fixed shortly with the linked PR; we may not have a crates release for a bit, since it's a breaking change, and I like to roll up breaking changes as much as possible

m4b commented 4 weeks ago

fixed in #406