retdec icon indicating copy to clipboard operation
retdec copied to clipboard

Add Dos MZ support to retdec

Open DerJJ opened this issue 7 years ago • 6 comments

Being able to decompile old MS DOS/MZ programs would be nice.

DerJJ avatar Dec 20 '17 17:12 DerJJ

Yes, I'm struggling with this right now too and upvote this, please add MS-DOS support

asciibox avatar Dec 26 '17 23:12 asciibox

Hello, I also would like to use RetDec to decompile MS-DOS binaries. While it may not be useful for modern security purpose, it would help all the hobbyist around here trying to reverse engineer MS-DOS video games.

Best regards.

ghost avatar Dec 29 '17 10:12 ghost

If anyone wants to help with this one, here are some pointers what needs to be done (and in what order):

  1. Add Dos MZ parser to fileformat.
  2. Add Dos MZ loader to loader.
  3. Modify scripts and other support code to let Dos MZ through.
  4. Modify decoder pass in bin2llvmir to handle 16-bit x86 - use 16-bit x86 mode of capstone2llvmir library.
  5. As we wrote capstone2llvmir, we tried to model 16-bit x86 alongside 32/64-bit. But we have never used it so far, so it is quite possible some problems will need to be fixed, and some more features added.

At this point, decompilation of 16-bit x86 Dos MZ file should produce C. But the output quality probably will not be very good. So:

  1. Pick some very simple binary, decompile it, inspect the results, find out what is wrong, find out why it is wrong, draft a solution, implement it. (E.g. the whole x86 segment registers thing is not dealt with at all, DOS interrupts, etc. Either existing retdec LLVM passes will need to be modified, or new, DOS specific passes will have to be created.)
  2. Write regression tests when results are ok.
  3. Repeat points 6. and 7. with some more complex binaries.

PeterMatula avatar Jan 03 '18 10:01 PeterMatula

Hello @PeterMatula, Thank you very much for the details. I'll definitely give it a try when I'll have some free time. However, I'm pretty sure 90% of us want to decompile 32-bit x86 Dos MZ, and not 16-bit x86.

ghost avatar Jan 03 '18 23:01 ghost

Are there any news after 5 years regarding MS DOS 16 bit binaries support?

greenozon avatar Nov 13 '22 12:11 greenozon

Also interested in this. Anyone still considering implementation?

palmerj avatar Oct 04 '24 06:10 palmerj