From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:DOS MZ executable" |
|---|
| claim | "The DOS image size is (e_cp & 0x7FF) * 512, minus (512 - e_cblp) when e_cblp is 1..511; everything in the file after that is the overlay (appended data or a new-format executable). DOSBox masks e_cp to 11 bits (1 MB limit) and never lets the image be shorter than 512 bytes minus the header." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:DOS MZ executable" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "computing where the MZ image ends" |
|---|
| effect | "end_of_dos_code = (pages & 0x7ff)*512, minus 512 and plus e_cblp when e_cblp in 1..511; overlay_len = file length - end_of_dos_code (0 if negative); code starts at e_cparhdr*16" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "fmtutil_collect_exe_info computes end_of_dos_code and overlay_len this way." |
|---|
| repo | "jsummers/deark" |
|---|
| commit | "8997059c4f32af79978fb6c83be7c1c26c259afa" |
|---|
| path | "src/fmtutil-exe.c" |
|---|
| lines | "506-531" |
|---|
|
| type | "source" |
|---|
| detail | "head.pages &= 0x07ff (1 MB limit, fixes TC3 IDE); imagesize = pages*512 - headersize; at least 512 - headersize." |
|---|
| repo | "dosbox-staging/dosbox-staging" |
|---|
| commit | "e8b4771a7de58a7d5c6d7c9c5b36c6ab09c6d93d" |
|---|
| path | "src/dos/dos_execute.cpp" |
|---|
| lines | "332-339" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Image size and overlay" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T01:42:05.613Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T04:14:03.979Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read deark fmtutil_collect_exe_info (nblocks & 0x7ff, end_of_dos_code = nblocks*512 minus 512 plus lfb for lfb 1..511, overlay_len clamped at 0) and DOSBox dos_execute.cpp lines 332-339 (pages &= 0x07ff, imagesize = pages*512 - headersize, at least 512 - headersize). Note DOSBox itself ignores e_cblp; the cblp rule is deark's." |
|---|
|
|
|---|