How to write a disassembler.

An implementation example of machine code decoder:
an open ended implementation.

Tsuyoshi Watanabe

1/99

Screenshot
You can download the project file that contains all source codes as well as a pre-built binary executables.

What is this document about?

This document descirbes the design and implementation of a tool which takes 32-bit Windows executable file and disassembles the raw machine code of the executable file into some form of human readable representation such as "assembly language", and displays it to the user.

What is the purpose of this document?

Besides it serves as my personal note of what I studies, the document is mainly created for those of you who may be interested in learning how to write a disassembler. I also make all the source files available for download. I have extensive comments in the source, but some parts of the project may be still difficult to understand without understanding an overall design, so this document fills that hole.

It is, unfortunately, not possible for me (or anybody) to fully describe every detail of how to write a disassembler from A to Z. Moreover, I do not claim that my design and implementation is "the best". In fact, this project was more for educating myself than showing it to others. My original intent was to write just a framework, then publish it so that other people can extend it.

"Open ended implementation"

The subtitle says "open dended impelmentation". What I mean by that is, as you will learn in this document later on, my implementation is basically incomplete, and you are more than welcome to take a part in it, completing the part that I left off. To start working on the part that I left, all you have to do is to copy a couple of DLLs (and associated header file and lib file) and start writing your own "decoder". See the document for detail.

I will also complete the project eventually...

NOTE:

I make no guarantee that my design nor implementation is the most efficient and correct. Indeed, my design only reflects how I solve the problem, and it should differ from yours.

I make certain assumptions:

  • Using Microsoft Visual C++ as the compiler
  • Executable file that can be disassembed is compiled by Microsoft tool (you can change this easily).
  • It is only for 32-bit executable.

Table of contents


Copyright © 2008 SpiralSpace All rights reserved.