Introduction: If you were to ask us, Why did you create TextMaestro?, we would simply reply: to convert Assembly code. All other features here evolved out of this. No other tool out there can handle the hugely repetitive task of rewriting Assembly code into corresponding C code like TextMaestro does. TextMaestro can handle any type of Assembly language, including Alpha, Intel-8086, Motorola, and MIPS. All you need is a library for each kind.
Why would somebody convert Assembly code?, you might ask. The answer is simple. Vast amounts of critical code have been written in Assembly. There comes a time when porting this code to new hardware or new operating system becomes a necessity and nightmare.
However, developers embarking on such a project will soon find themselves entangled in two formidable problems: 1. They do not know the nuances of the Assembly language well enough, 2. They are not intimately acquainted with the algorithms behind the code. This leads to a state where reverse engineering becomes almost impossible.
Remember, learning Assembly instructions by picking up a book is not difficult. Being able to juggle those instructions and express one's thoughts elegantly takes a lifetime.
With TextMaestro, you have the capability to transliterate legacy Assembly code to C without knowing Assembly in depth and without knowing the algorithms crafted in the code. After you have the complete code in C, you can readily port it to a new platform or environment (just because its in C). Then you can comfortably begin the process of reverse engineering from a position of strength.
With that said, a cautionary note is needed. TextMaestro has no magic formula to perform this feat. You, the user, prepare a library by studying the original code. You will need to put forth a good amount of effort to bring the library up to a working stage.
Developing the library is an iterative process. We provide various libraries in our Repository section (which is under development). When it comes to converting Assembly code, the provided libraries do not guarantee completeness. It is almost certain that you will need to enhance the provided library. Thats where we can provide additional assistance with our customized service. Below we provide a simple step by step example.
November 13, 2003 Binary for IDA Pro 4.6 kindly contributed by Joe Stewart. No code improvements.
May 7, 2003 Binary for IDA Pro 4.5. No code improvements.
October 21, 2002 Early support for ARM machine code and a binary for IDA Pro 4.3
June 20, 2002 Desquirr is now available for download!
Desquirr is a decompiler plugin for Interactive Disassembler Pro. It is currently capable of simple data flow analysis of binaries with Intel x86 machine code.
This program is currently under development. Suggestions, bug reports and patches are welcome.
See Downloads for documentation, binary and source code.
/****************************************/
/* ASM to C Hex - Converter */
/* '''''''''''''''''''''''' */
/* 22.05.2005 */
/* CopyLeft 2005 by Jonas Gehring */
/****************************************/
Usage: asmtochex [flag] <type> <infile> <outfile>
flags: -quiet - Don't ouput standard messages
-noarr - Don't use standard array format
types: -uchar - Convert to unsigned char array
-ushort - Convert to unsigned short array
-ulong - Convert to unsigned long array
infile - Name of input file
outfile - Name of output file
Converts 68k ASM data to C Hex arrays
of given type.
ASM to C Hex is a comfortable data converter to convert 68k ASM data
into C Hex arrays of choosable format.
The outputfile can directly copied (or included) into a TIGCC project
(or any other C project). The only thing to change might be the array
name ('data' is default).
If you want to convert the hex data directly into a binary (e.g. with
the TIGCC Tools Suite by TI-Chess Team), you may use the flag -noarr.
By doing so, the output file contains only the real data and the
comments of the ASM file.
I wrote this program as a tool for my RPG project "Shadow Falls".
When working on it, I had to convert LARGE tile arrays and maps,
because CalcGS by Rusty Wagner only gives output in 68k ASM format.
This converting always took some time and was very boring, so this
tool was very helpful for me.
13.05.2005 v1.1 - Fixed counting of tiles (before, the ","s of the
ASM data were counted, now the "$"s are counted
and then divided with the type)
- Changed time output to X.XXX seconds
抛砖引玉:
如何对于_cdecl调用约定,如何确定函数参数的个数?
根据调用者负责压栈和堆栈恢复的行为,可推出参数个数,
如:
push eax ; push parameter
call function_a ; call function A
pop ecx ; restore stack pointer
push eax ; push parameter
call function_b ; call function B
pop ecx ; restore stack pointer
函数a,b各有1个参数
push eax ; push second parameter
push ebx ; push first parameter
call function_c ; call function C
add esp, 8 ; restore stack for call C
push eax ; push second parameter
push ebx ; push first parameter
call function_d ; call function D
add esp, 8 ; restore stack for call D
函数c,d各有2个参数
但下面的情况就不好搞了:
push eax ; push second parameter
push ebx ; push first parameter
call function_c ; call function C
push eax ; push second parameter
push ebx ; push first parameter
call function_d ; call function D
add esp, 10h ; restore stack for both function call C and D
#
# ASMTOC.PL
#
# Takes a file that is an actual listing from the cross assembler and
# makes a C file with a structure containing all the machine code from
# the assembly file.
#
# Copyright (c) 2002, Jason Riffel - TotalEmbedded LLC.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# Neither the name of TotalEmbedded nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
$filename = $ARGV[0];
# Print out the C header file
print "//\n";
print "// $filename.c\n";
print "//\n";
print "// DO NOT EDIT THIS FILE. This file was generated automatically\n";
print "// by a script that converts an assembler listing into a C structure\n";
print "// containing the hex values of the instructions in the listing.\n";
print "// You must edit the assembler source directly and execute the build\n";
print "// again.\n";
print "//\n\n";
print "unsigned int aui_$filename\_code\[\] = {\n";
while(<STDIN>)
{
$line = $_;
$line =~ s/\t/ /g;
$line =~ s/^..........//;
if ($line =~ m/^[0-9A-Fa-f]{8,8}/)
{
print " 0x";
print $&;
print ", // ";
$line = $';
$line =~ s/^ +//;
print $line;
}
else
{
$line =~ s/^ +//;
print " // $line";
}
}
print " 0x00000000}; // <- Inserted by script to terminate array.\n\n";
close(FH);