16

I've found a binary copy of a DOS freeware game I was fond of back in the day (Firefighter, downloadable as FIRE.COM) but the source code is not available. I'd like to re-implement it in C or Python using Unix curses and while I'm fully competent to do that part, I know almost nothing about tools for reverse-engineering and decompiling DOS .COM file binaries.

Going by documentation that says .COM is headerless raw machine code, I tried running objdump -D -b binary -m i386 on it. The result didn’t look valid. objdump -D -b binary -m i8086 –adjust-vma=0×100 appeared to do the trick as did using NASM with ndisasm -b 16 -a -o 0×100 and both of those do seem to produce plausible assembly listings.

Ideally, though, I'm looking for something that decompiles and renders to C in as-if-it-were-assembler style with generated variable names and useful annotations on the DOS traps. I understand that such a beast may not exist, but on the chance one does I'm seeking recommendations.

10
  • Welcome to RE! Have you searched and looked at the existing questions on the site?
    – asheeshr
    Mar 5, 2014 at 1:39
  • How is this not in scope under "tools commonly used for reverse engineering hardware or software"?
    – ESR
    Mar 6, 2014 at 20:31
  • Have you looked through the existing questions? Have you tried out any of the solutions already provided? Where/Why have the existing questions failed? This question shows absolutely no previous research.
    – asheeshr
    Mar 7, 2014 at 1:07
  • I have updated the question; Can the on hold status be removed?
    – grkvlt
    Mar 8, 2014 at 23:25
  • 1
    Maybe you can get some hints here program-transformation.org/Transform/MachineCodeDecompilers Mar 9, 2014 at 21:33

6 Answers 6

7

My answer is a little late; newcomer to this site. The Decompiler project was initiated in order to decompile MS-DOS EXE and COM binaries. The project has both a command-line and a GUI tool:

https://sourceforge.net/projects/decompiler/

Use the following command with the command-line tool to decompile COM programs:

decompile --default-to ms-dos-com myprog.com

In the GUI, use the menu command File > Open as... to open the COM file and specify a start address like 0800:0100.

5

IDA Pro and a number of other disassemblers will disassemble your file, assuming that it isn't compressed or otherwise obfuscated. But this is only the first step in producing a working assembly language program, which you will need if you are to translate it into a higher language.

Essentially you are looking at two projects. The first is to produce a working assembly language version of your game. The second is to translate the game mechanics and logic into C++ or whatever. The first is easier than the second.

4

I recently found a DOS program which turns .COM and .EXE into a simple "pseudo-code". The program is --- exe2c.zip

http://www.codeforge.com/dlpre/201558/cb2e19437871.zip__.html

Not an "excellent" tool, but i found it useful. Start by executing ENVMNU.EXE and then entering the .COM or .EXE filename. ---(hint?) If better results are necessary, use the individual modules ( such as the DOS to ASM module ) and hand-edit ASM discrepancies then feed them to the ASM to C module and observe the results.

-- William Gallant

2

no beast exist that will decompile 16 bit com program
if you prefer to debug it look for grdb from ladsoft
also have in hand a copy of ralf browns interrupt list for all the
int 21 / int 10 SetCursor / GetCursor calls

also make sure you rename the downloaded exe to be 8dot3 compatible
(name less than 8 charecters)

GRDB.EXE firefi.com    

Get Real Debugger Version 9.6  Copyright (c) 1997-2009 David Lindauer (LADSoft)
GRDB comes with ABSOLUTELY NO WARRANTY, for details type `?g'
This is free software, and you are welcome to redistribute it
under certain conditions; type `?gr' for details

DPMI Start code hooked
History enabled
eax:00000000 ebx:00000000 ecx:00007500 edx:00000000 esi:00000000 edi:00000000
ebp:00000000 esp:0000FFEE eip:00000100 flag:00000202 NV UP EI PL NZ NA PO NC
ds:1F25 es:1F25 fs:1F25 gs:1F25 ss:1F25 cs:1F25
1F25:0100 E9 25 27       jmp          2828
Size: 00007500
->  
2

As I review your application (Fire.COM), I think you should use some DOS debugger like Turbo Debugger 5.0 to debug and reverse this application because I have some encrypted stage in it. If you want to "decompile" these application to C code, it's very hard, I had tried some tools in the past (2008) but there was not a good tool to do it. I also got a C source but there was many inline assembly in it.

1

For .com (MS DOS) programs I use ndisasm (Netwide Disassembler) as mentioned in this answer. It is very simple, just work without any magic.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.