Michael said:
Hello,
Can I exe file made in Microsoft Visual C++ decompile into source code.
If it is possibly please tell me how.
Thanks
Here is how to do it:
1. Find the format of the executable file.
Try
http://www.wotsit.org
2. Parse the header section of the executable file. Extract
and retain important information.
3. Point to the first instruction data.
4. Read in the instruction data and convert into an assembly
language statement. Display all numeric quantities in hex.
Also, keep track of the addresses. You will need this
information for creating labels for all the loops, function
calls.
5. Output the instruction into a text file.
6. Repeat steps 4 & 5 for all executable bytes in the file.
7. Once the assembly language file is created, parse it looking
for patterns, such as for-loops, while and do-while loops.
Also scan for function prologue (i.e. parameter passing,
local variable allocation) and function epilog.
Once a pattern is found, output it to another text file,
which will be your C source file.
Some notes:
1. Devise some scheme for nameing variables and functions.
2. Recognize the difference between char, int, float and
double representations in memory.
3. Research the operating system. Create a table of
operating system call sequences and their function
names. This will come in handy as you improve your
program to list operating system calls.
4. Along the same lines, research the call sequences for
the C and C++ library routines. You'll need this to
translate the calls to offsets into more readable
function names.
5. The resultant code has a high probability of looking
nothing like your original source code; or an readable
source code.
6. Always test your utility by running your assembly language
output through an assembler and compiling your source
program.
7. Some operating systems have dynamic libraries. Learn how
to recognize the activation of dynamic library functions.
8. Let nobody fool you about turning hamburger back into a
cow. That analogy doesn't apply; as one _can_ convert an
executable into a source file.
This is an excellent project. I personally have other projects
to work on, which is why I'm not doing this.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book