Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

New kernel compression methods (Announce)

posted by tkchia Homepage, 14.04.2020, 14:46
(edited by tkchia on 14.04.2020, 16:56)

Hello ecm,

> By the way, you can put a FreeDOS kernel (better to use an uncompressed one
> then) into ldosboot's
> fdkernpl stage, then can use that payload for inicomp. You'd use _IMAGE_EXE=0
> then because the FreeDOS kernel cannot be entered as an .EXE file. However,
> the FreeDOS kernel entrypoint (and the lDOS/RxDOS and PC-DOS/MS-DOS
> 6/MS-DOS 7 kernel entrypoints) would still work. The only thing that that
> does not support is the kernel CONFIG section expected fixed at the start
> of the file by FreeDOS's kernel configuration (which is part of the FreeDOS
> SYS program).

Thanks! I guess I will need to look at the lzd.asm code --- and, if necessary, the fdkernpl.asm code --- to see how to stitch everything together.

> Funny, I don't actually know how much UPX would compress things. So I made
> a test. I had to patch out the short jump in the "last page size" bytes of
> the EXE header. (These are used for the MS-DOS 6.x and FreeDOS kernel
> entrypoints.) The invalid value of the short jump instruction in that field
> otherwise leads to "CantPackException: exe header corrupted". (Obviously,
> packing the kernel file with UPX without special handling makes it no
> longer work as a kernel file.)

Not sure which short jump you are referring to --- care to elaborate?

Also, you might already know this --- but the magic for invoking UPX, converting the .exe to .sys, and adding (a second copy of) the CONFIG structure, is pretty much all in utils/exeflat.c in the kernel source tree. So the workflow is roughly like this:

{uncompressed .exe kernel}
|
v
flatten, but keep a .exe header around
|
v
compress with UPX
|
v
flatten, remove .exe header
|
v
wrap compressed kernel with stub code and CONFIG structure
|
v
{compressed .sys kernel}

The first "flattening" pass basically resolves the .exe relocations (since the kernel is known to go to 0x60:0) and removes the relocation entries. A second "flattening" pass is needed to resolve the relocations introduced by UPX itself.

I guess it will be interesting to see if UPX can be replaced with some other compressor (that also supports .exe files).

Thank you!

---
https://gitlab.com/tkchia · https://codeberg.org/tkchia · 😴 "MOV AX,0D500H+CMOS_REG_D+NMI"

 

Complete thread:

Back to the forum
Board view  Mix view
22632 Postings in 2109 Threads, 402 registered users, 408 users online (0 registered, 408 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum