473,385 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Converting ASM to C

Is there a way to do this. I mean there is a company who converts asm to
their wsl language and then from that to c is there a way that we can do
this?
Nov 14 '05 #1
13 13479
Glen Richards wrote:
Is there a way to do this. I mean, is there a company
who converts asm to their wsl language and then from that to c?
No.
Is there a way that we can do this?


No.

Information is discarded in the process
of compiling a higher level language to assembler
that cannot be recovered from the assembler alone.

Nov 14 '05 #2
E. Robert Tisdale wrote:
Glen Richards wrote:
Is there a way to do this. I mean, is there a company who converts asm
to their wsl language and then from that to c?


No.
Is there a way that we can do this?


No.

Information is discarded in the process
of compiling a higher level language to assembler
that cannot be recovered from the assembler alone.


OK, this is off-topic here, but I'm not convinced by the impossibility
claim. What is surely impossible is to retrieve the _particular_ C
code that, when run through some (unknown) compiler, generated a given
glob of machine code. But given the asm, shouldn't it be possible
in principle to generate (non-unique) C code of equivalent effect?
Whether anyone provides this sort of service commercially, I have
no idea.

--
Allin Cottrell
Department of Economics
Wake Forest University, NC
Nov 14 '05 #3
Allin Cottrell wrote:
OK, this is off-topic here
but I'm not convinced by the impossibility claim.
What is surely impossible is to retrieve the _particular_ C code
that, when run through some (unknown) compiler,
generated a given glob of machine code.
But given the assembler, shouldn't it be possible, in principle,
to generate (non-unique) C code of equivalent effect?
In general, no. You would be obliged to emulate
the machine architecture and the operating system (OS).
You would need to be able to recognize calls to the OS
for I/O for example. In other words, you would need information
about the program besides what remains in the assembler listing
to resolve all of these references.
Whether anyone provides this sort of service commercially,
I have no idea.


There are (or at least were) people in the KBG, CIA, NSA, etc.
that could do a fairly reasonable job of "reverse engineering"
machine codes (assembler).

Nov 14 '05 #4
"Glen Richards" <gm******@comcast.net> wrote in message
news:GYhWb.143769$U%5.658804@attbi_s03...
Is there a way to do this.
Sure. Find out what the ASM program does, then
write the C code to do the same thing.
I mean there is a company who converts asm to
their wsl language and then from that to c is there a way that we can do
this?


There might indeed exist some 'automated' methods, but
their output (C source) would very likely be very cryptic,
usually meant only for consumption by a computer.

-Mike
Nov 14 '05 #5
Allin Cottrell wrote:
E. Robert Tisdale wrote:
Glen Richards wrote:
Is there a way to do this. I mean, is there a company who converts
asm to their wsl language and then from that to c?

>

No.
Is there a way that we can do this?

No.

Information is discarded in the process
of compiling a higher level language to assembler
that cannot be recovered from the assembler alone.

OK, this is off-topic here, but I'm not convinced by the impossibility
claim. What is surely impossible is to retrieve the _particular_ C
code that, when run through some (unknown) compiler, generated a given
glob of machine code. But given the asm, shouldn't it be possible
in principle to generate (non-unique) C code of equivalent effect?


In principle, yes. Enumerate all possible files (an infinite, but
countable set); compile them with all possible compiler/flags
combinations (a finite set); compare the results with the executable.
You will lose information (comments; symbol names; high-level
constructs) but it is guaranteed to work (given a rather large amount of
time).

But of course, there are smarter ways. Searching for "decompilation" on
Google gives a couple of interesting hits.

A large amount of work has been done in this area; both in an academic
setting and a commercial setting. With regard to the latter: there's a
terrifying quantity of code out there that is in active use, but for
which the source code is no longer available (mostly COBOL). Some
companies specialize in semi-automatic reverse-engineering of this vital
software.

Best regards, Sidney

Nov 14 '05 #6
Mike Wahler wrote:
There might indeed exist some 'automated' methods, but
their output (C source) would very likely be very cryptic,
usually meant only for consumption by a computer.

-Mike


Yes, it might seem as a Basic program... (only gotos)...

Nov 14 '05 #7
On Wed, 11 Feb 2004, Glen Richards wrote:
Is there a way to do this. I mean there is a company who converts asm to
their wsl language and then from that to c is there a way that we can do
this?


Normally people ask if you can convert machine language to C source. Two
reasons for this. First is that I have the binaries but lost the source
code (it happens even with backups). The second is that I have someone
else's binaries and I want to reverse engineer them.

If you want to go from machine code to C source there are programs out
there that will do something. All are operating system specific and most
are compiler specific as well. Just do a search on "reverse engineer <your
OS> <your compiler>" and you might find something. The source code they
product is difficult to read and next to impossible to maintain. It is
often easier to reverse engineer the requirements and write the program
from scratch.

If you have actual assembly source code and want to turn it into C source
code that might actually be harder. The market for people who know C but
have some assembly code is a lot smaller than people who want to reverse
engineer binaries. It would also be specific to the assembler and the
operating system. Maybe the search for reverse engineering might find
something but the results will be about the same or worse than going from
binary to C source. If you cannot find an assembly language to C source
converter you can try getting an assembler, create a binary then use
machine language to C source converts.

Bottom line, it is usually more effort to maintain the resulting source
code then it would be to write the application from scratch.

--
Send e-mail to: darrell at cs dot toronto dot edu
Don't send e-mail to vi************@whitehouse.gov
Nov 14 '05 #8
[snips]

On Tue, 10 Feb 2004 21:44:59 -0800, E. Robert Tisdale wrote:
Whether anyone provides this sort of service commercially,
I have no idea.


There are (or at least were) people in the KBG, CIA, NSA, etc.
that could do a fairly reasonable job of "reverse engineering"
machine codes (assembler).


Umm... it's not all that hard to reverse-engineer machine code, actually.
It's just tedious, slow, and not amenable to algorithmic solutions.
Nov 14 '05 #9
In <pa****************************@lightspeed.bc.ca > Kelsey Bjarnason <ke*****@lightspeed.bc.ca> writes:
[snips]

On Tue, 10 Feb 2004 21:44:59 -0800, E. Robert Tisdale wrote:
Whether anyone provides this sort of service commercially,
I have no idea.


There are (or at least were) people in the KBG, CIA, NSA, etc.
that could do a fairly reasonable job of "reverse engineering"
machine codes (assembler).


Umm... it's not all that hard to reverse-engineer machine code, actually.
It's just tedious, slow, and not amenable to algorithmic solutions.


It's an excellent exercise for anyone heavily involved in assembly
programming. And, occasionally, a must if a piece of software (or even
hardware) is not properly documented.

As a trivial example, it's usually easier to figure out how to interface
C code to a Fortran program by looking at the Fortran compiler output
than by digging into the documentation.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #10
Darrell Grainger wrote:

(snip)
If you have actual assembly source code and want to turn it into C source
code that might actually be harder. The market for people who know C but
have some assembly code is a lot smaller than people who want to reverse
engineer binaries. It would also be specific to the assembler and the
operating system. Maybe the search for reverse engineering might find
something but the results will be about the same or worse than going from
binary to C source. If you cannot find an assembly language to C source
converter you can try getting an assembler, create a binary then use
machine language to C source converts.


It was more popular some years ago when some assembly programs
needed Y2K fixes. Some decided if they were going to work on them
at all they might use more modern machines. The result might be C
that is about as readable as the assembly language. Maybe C variables
named after each register, and then operations are done to those
variables as they would be to the registers of the source machine.

-- glen

Nov 14 '05 #11
Dan Pop wrote:

(snip regarding reverse engineering)
It's an excellent exercise for anyone heavily involved in assembly
programming. And, occasionally, a must if a piece of software (or even
hardware) is not properly documented. As a trivial example, it's usually easier to figure out how to interface
C code to a Fortran program by looking at the Fortran compiler output
than by digging into the documentation.


Especially if the compiler will generate the assembly code
in people readable form, as most will. Though it might
take more work to find the special cases and exceptions.

-- glen

Nov 14 '05 #12
In <hZ_Wb.20166$jk2.64393@attbi_s53> glen herrmannsfeldt <ga*@ugcs.caltech.edu> writes:
Dan Pop wrote:

(snip regarding reverse engineering)
It's an excellent exercise for anyone heavily involved in assembly
programming. And, occasionally, a must if a piece of software (or even
hardware) is not properly documented.
As a trivial example, it's usually easier to figure out how to interface
C code to a Fortran program by looking at the Fortran compiler output
than by digging into the documentation.


Especially if the compiler will generate the assembly code
in people readable form, as most will.


Even if it doesn't, there may be tools that "reverse engineer" object
files into highly readable assembly, because the symbol table is
present in the file. E.g. objdump from the GNU binutils, but I remember
using a similar tool under MSDOS, too.
Though it might take more work to find the special cases and exceptions.


The idea is that you investigate the cases that are relevant to you.
If you need to pass 2 double precision numbers and one integer number
to the C routine, you couldn't care less about how Fortran passes strings.
You simply write the function/subroutine call of interest to you and
compile it. By examining the generated code, you know what the C
function will receive.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #13
On 11 Feb 2004 14:57:06 GMT, da*****@NOMORESPAMcs.utoronto.ca.com (Darrell
Grainger) wrote:
On Wed, 11 Feb 2004, Glen Richards wrote:
Is there a way to do this. I mean there is a company who converts asm to
their wsl language and then from that to c is there a way that we can do
this?
Normally people ask if you can convert machine language to C source. Two
reasons for this. First is that I have the binaries but lost the source
code (it happens even with backups). The second is that I have someone
else's binaries and I want to reverse engineer them.


Binary to Asm is often difficult, requireing many person-oriented passes
with a disassembler, making the judgements: (often for each byte!)
is that BYTE DATA or part of an INSTRUCTION?
When you decide it is an instruction, because of the flow, is the
referenced word an "long int", "float", pointer or some struct or array
base-address?
This process can only be verified when the resultant Assy source is
understandable, assembled and then linked into the IDENTICAL core image the
original program had.
I have proposed an instruction interpretor which could mark each byte as it
is used by each instruction while running the code (but i've never seen
one!).
Most disassemblers dont work(by themselves)! -- especially with variable
length instruction formats (like x86!)

If you want to go from machine code to C source there are programs out
there that will do something. All are operating system specific and most
are compiler specific as well. A person who knows what a compiler will generate for each statement can
de-compile the assembly source fairly easily, that person can also write a
program to do the same thing more rapidly
Just do a search on "reverse engineer <your
OS> <your compiler>" and you might find something. The source code they
product is difficult to read and next to impossible to maintain. It is
often easier to reverse engineer the requirements and write the program
from scratch. This depends a lot on the AMOUNT of programs you need to de-compile
certainly Hundreds of lines, maybe a Thousand lines and NOT MILLIONS of
lines.

If you have actual assembly source code and want to turn it into C source
code that might actually be harder. Applied Conversion Technologies (www.actworld.com) was originally started
to exploit the technology I developed to translate 45MB of DG NOVA assembly
to C to move a CAM system to the PC/AT platform in the 80's. Much of the
Assy source contained comments that were useful in maintaining the
translated C source, some was not. The main features were simularities in
the programs that could be recognized and consistently translated.
Another project: involving the CDC 469 (Phalanx Gun) computer Assy to Ada
required discarding lots of comments relating to fixed point arithmetic
magnitue which was irrelevant when variables were re-cast to floating
point.
The market for people who know C but
have some assembly code is a lot smaller than people who want to reverse
engineer binaries.
RIGHT!
It would also be specific to the assembler and the
operating system. Maybe the search for reverse engineering might find
something but the results will be about the same or worse than going from
binary to C source. absolutely NOT, there is information in the Assy source that shouldn't be
lost! However, each case will be different and custom for each
programmer/compiler and the effort expended to extract the design will be
a judgement of the business-persons involved.
If you cannot find an assembly language to C source
converter you can try getting an assembler, create a binary then use
machine language to C source converts. one step forward, TWO or more back!

Bottom line, it is usually more effort to maintain the resulting source
code then it would be to write the application from scratch.

UNLESS you factor in the NEWLY introduced bugs while writing fro SCRATCH.
also: "better the bugs you know than the bugs you haven't met yet"

You must also factor in advances in interface design:
Does Visual XX replace all that code with a few mouse KLIKS? and MegaBytes
of DLL

Further, you must consider the goodness in moving forward from previous
designs accurately translated (warts and all), and not "re-inventing the
wheel".

Bob Sheff; PBgeek at att dot net
Independent Consultant:
Software(Pascal,PL/M,CHILL,FORTRAN,..assy) Conversion to C/C++
please do not reply to vi************@whitehouse.gov or
pr*******@whitehouse.gov
Nov 14 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mustafa | last post by:
Dear sir , I have built my application in visual basic 6.0 and crystal Report8.5 , Now i migrated my application to VB.net using the upgrade wizard.My visual basic form is upgraded to vb.net...
29
by: Armand Karlsen | last post by:
I have a website ( http://www.zen62775.zen.co.uk ) that I made HTML 4.01 Transitional and CSS compliant, and I'm thinking of converting it into XHTML to learn a little about it. Which XHTML variant...
8
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
3
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
2
by: Map Reader | last post by:
Greetings, I am converting an old VB6 application to use .NET. One of the old controls loads icons from the disk and displays them. However, the transparent color turns to blue somewhere in the...
12
by: Frederik Vanderhaeghe | last post by:
Hi, I have a problem converting text to a double. Why doesn't the code work: If Not (txtdocbedrag.Text = "") Then Select Case ddlBedrag.SelectedIndex Case 0 Case 1
7
by: Tor Aadnevik | last post by:
Hi, I have a problem converting values from Single to double. eg. When the Single value 12.19 is converted to double, the result is 12.1899995803833. Anyone know how to avoid this? Regards...
4
by: gg9h0st | last post by:
i'm a newbie studying php. i was into array part on tutorial and it says i'll get an array having keys that from member variable's name by converting an object to array. i guessed "i can...
2
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 .........
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.