🐞 Issue: DOS Stub Should Exit Cleanly with Valid Header
Summary
The current DOS stub used in our PE builds is a minimal 64-byte file containing only the MZ header and null padding. While this satisfies the PE loader, it does not behave like a valid DOS executable when run in a DOS environment.
Problem
- The stub lacks any executable DOS code.
- Running the binary in DOS or DOSBox results in undefined behavior or silent failure.
- The header may be technically valid, but there's no instruction to exit DOS cleanly.
Expected Behavior
The DOS stub should:
- Contain a valid
MZ header with a correct PE header offset at 0x3C.
- Include a minimal instruction (e.g.
int 0x20 or retf) to exit DOS cleanly.
- Remain within the 64-byte constraint required by the PE loader.
Suggested Fix
Update the stub to include:
- A properly structured MZ header.
- A single DOS exit instruction at offset
0x40.
- Padding to ensure the total size is exactly 64 bytes.
Even if we can't fit a message like "This program cannot be run in DOS mode.", we should still ensure the stub behaves correctly when executed in a DOS-compatible environment.
Benefits
- Improves compatibility with DOS and DOSBox.
- Aligns with conventional PE stub behavior.
- Adds polish and correctness to low-level binary layout.
🐞 Issue: DOS Stub Should Exit Cleanly with Valid Header
Summary
The current DOS stub used in our PE builds is a minimal 64-byte file containing only the
MZheader and null padding. While this satisfies the PE loader, it does not behave like a valid DOS executable when run in a DOS environment.Problem
Expected Behavior
The DOS stub should:
MZheader with a correct PE header offset at0x3C.int 0x20orretf) to exit DOS cleanly.Suggested Fix
Update the stub to include:
0x40.Even if we can't fit a message like
"This program cannot be run in DOS mode.", we should still ensure the stub behaves correctly when executed in a DOS-compatible environment.Benefits