Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Pascal Decompiler?

1,128 views
Skip to first unread message

Zar the Mad

unread,
Nov 4, 1993, 11:05:53 PM11/4/93
to

I would like to obtain a pascal decompiler. Is there one on the net
somewhere, or do I need to purchase one? If so, from where?
Any help will be appreciated.
Thanks in advance,

Jon Carman
man...@matt.ksu.ksu.edu

Michael Conwell

unread,
Nov 5, 1993, 12:26:35 PM11/5/93
to
There is a program called TWU1 that sort of decompiles TPU files. It
contains the source code for the decompiler and it shouldn't be hard
to change it to do a regular EXE file.



Duncan Murdoch

unread,
Nov 5, 1993, 3:14:56 PM11/5/93
to

As a matter of fact, that's the decompiler used in DUMPPROG. Look around
for DMPPRGxx.ZIP. The main addition in DUMPPROG is to make use of the .MAP
file to put some names to the addresses.

Duncan Murdoch
dmur...@mast.queensu.ca

Jeroen Pluimers

unread,
Nov 6, 1993, 4:05:00 AM11/6/93
to

Can anybody please put this question into the comp.lang.pascal FAQ? (Timo?)


Thursday November 04 1993 22:05, man...@matt.ksu.ksu.edu wrote:


mkke> I would like to obtain a pascal decompiler.

A Pascal Decompiler would be like a chemical machine that reverses the process
of cooking soup. It would get fresh water, vegetables, herbs, salt etc. out of
cooked soup.

During the compilation, important information get's lost about variables,
types, identifiers etc. Writing a Pascal Decompiler is impossible. The best you
can achieve is a disassembler that can help you recognize some Pascal
statements. Two good disassemblers is TW1UNA (which disassembles unit files)
and DUMPPROG (which disassembles .EXE files - both DOS and Windows style).


Jeroen

D.J. Wischik

unread,
Nov 6, 1993, 4:41:42 PM11/6/93
to
Compilation with a given compiler is a function.
That is, for a given source code we will always get one specific object-code.
Let us say, C(source)=object

The function, however, is not 1-1.
For instance, we could have two source programs s1 and s2, suthat
C(s1)=C(s2)

Clearly, then, the inverse of C does not exist.

However, we may define a decompiler-function - let us call it D - such that
for all oc (object code),
C(D(oc))= oc

We see, then, that a decompiler exists for any compiler.

Duncan Murdoch

unread,
Nov 6, 1993, 5:27:38 PM11/6/93
to
In article <1993Nov6.2...@infodev.cam.ac.uk> djw...@cl.cam.ac.uk (
D.J. Wischik) writes:>Compilation with a given compiler is a function.

>That is, for a given source code we will always get one specific object-code.
>Let us say, C(source)=object

For most compilers this is not true. Most compilers have compile options,
and many give different results depending on the time at which
they're run (e.g. the ones that support macros expanding to the current
time & date).

Even if it were true...

> ...


>However, we may define a decompiler-function - let us call it D - such that
>for all oc (object code),
>C(D(oc))= oc
>
>We see, then, that a decompiler exists for any compiler.

... an existence proof isn't of much use to anyone. Show me an efficient
construction of one. I can outline a decompiler strategy --- just try every
possible source file until you find one producing the right object code ---
but I wouldn't claim to have a decompiler unless it actually had a chance of
finishing before I died.

Duncan Murdoch

I'm not paranoid, the universe really is out to get me!

unread,
Nov 6, 1993, 10:13:18 PM11/6/93
to

I agree! I recently found a decompiler which makes a .ASM file out of an
executable. Sure, it did it all right, but (and this was a highly rated one),
it couldn't even properly disassemble/decompile loops! A loop which went for
a hundred times came out in assembler code as the body repeated 100 times.
Considering the incredibly varied compiler options _for each compiler_,
writing a decompiler would be much less efficient than rewriting the source!

Preston Guise
c922...@cc.newcastle.edu.au

Scott Moore

unread,
Nov 7, 1993, 12:52:52 AM11/7/93
to
jer...@dragons.nest.nl (Jeroen Pluimers) writes:


>Jeroen

Not really impossible. Many low quality compilers could be decompiled. The
trick is that the object code never got real far from the source code. The
more the compiler optimizes (and therefore adds distance between the source
representation and the object), the more difficult the task, and the less
likelyhood that the result would resemble the original program.
I would argue that any program, even a complex one with a great deal of
optimization, could be "decompiled". But the result would probably be
quite different from the original program. In fact, what you are asking is
essentially to have an automatic program write a source code from scratch
that accomplishes the same result as what it has seen.
Note that judging what an assembly language program does without simulating
it outright is considered hard or impossible today.
If however, you wish to "decompile" the output of a very simple compiler,
you can usually "recognize" sections of code as standard constructions of that
compiler. This is the mirror image of the set of routines in the compiler that
generate those sections of code. It works because the low performing compiler
basically generates predefined sections of code with the "blanks" filled in.

Finally, for those of you still awake, many compilers in existance on the PC
deliberately try to generate code that is somewhat decompilable !
Why ? The typical "IDE" mode debuggers must keep track of both the variables
in memory and on the stack, and also must relate the original program lines
one-two-one with the original program. Although this is commonly misconcevied
of as being reletively automatic, it in fact does not work when a high
degree of optimization is used. The reason is that optimizations like keeping
operands stored in fast registers (and delaying their store), or such as
extreme code movement all tend to erase the "relatability" of the final
object to the original code.
In fact this is somewhat of a problem for PC compilers. Creating IDEs was
simple when the compilers were low performing. But the race to take advantage
of optimization will cause problems, leaving compiler makers to either
hold back optimizations to let IDE methods work, or create a special low
performing optimization mode that will run under an IDE. I personally expect
the latter to create screams of agony as users find that their programs no
longer run when the "super" optimization mode kicks in.

[sam]


--
Scott A. Moore [SAM] | If my posts have not offended you
sam...@netcom.com | perhaps you aren't reading them closely enough !
San Jose, CA USA | ------------------------------------------------
408-452-8860 | At Exabyte, we make some DATs. And some of DOSE.
ExaByte Corp. | And some o' DEM over DERE.
------------------------------------------------------------------------

Timo Salmi

unread,
Nov 7, 1993, 1:46:33 AM11/7/93
to
In article <75261241...@dragons.nest.nl.dragons.nest.nl> jer...@dragons.nest.nl (Jeroen Pluimers) writes:
>Can anybody please put this question into the comp.lang.pascal FAQ? (Timo?)

Yes, Jeroen, thank you. I think I will. Your input came at an
opportune moment since I am just in the process of updating our TP
FAQ.

>Thursday November 04 1993 22:05, man...@matt.ksu.ksu.edu wrote:
> mkke> I would like to obtain a pascal decompiler.

All the best, Timo

..................................................................
Prof. Timo Salmi Co-moderator of comp.archives.msdos.announce
Moderating at garbo.uwasa.fi anonymous FTP archives 128.214.87.1
Faculty of Accounting & Industrial Management; University of Vaasa
Internet: t...@uwasa.fi BBS +(358)-61-3170972; FIN-65101, Finland

Carlos Henrique Cantu

unread,
Nov 7, 1993, 8:11:23 AM11/7/93
to

A real decompiler really can be done... I don't know for Pascal,
but Clipper has a decompiler called UNCLIP, and it generates a source code
exactly like the original...

Well, Clipper has a different way to compile the program, and the
program's sizes is biggest than the Pascal's EXEs so, I think it saves a
lot of information inside the program that are used in the decompilation
process...

Only for knowledge...

WarmBooter

=============================================================================

Carlos Henrique Cantu | InterNet: cahc...@pintado.ciagri.usp.br
---------o----------- | Fidonet : 4:801/47 - RBT : 12:1214/1
CIAGRI - University of Sao Paulo | "This isn't a Macintosh, but works..."

=============================================================================


Tim Tschirner

unread,
Nov 9, 1993, 4:12:47 AM11/9/93
to
Is this commercial or shareware? If the latter, where is it available
from?

Thanks in advance,

Tim

Michael Conwell

unread,
Nov 9, 1993, 12:13:47 PM11/9/93
to
Tim Tschirner asked about the program TPW1...

>Is this commercial or shareware? If the latter, where is it available
>from?

It is not commercial and is available at garbo.uwasa.fi in a windows
directory. Please note that it only works with Turbo Pascal ver 6 and
TPW 1.5. Hope that helps.

Michael Conwell

Crystobal J. Junta

unread,
Nov 12, 1993, 7:32:46 AM11/12/93
to
In article <75261241...@dragons.nest.nl.dragons.nest.nl>, jer...@dragons.nest.nl (Jeroen Pluimers) writes: |> During the compilation, important information get's lost about variables, |> types, identifiers etc. Writing a Pascal Decompiler is impossible. The best you |> can achieve is a disassembler that can help you recognize some Pascal |> statements. Two good disassemblers is TW1UNA (which disassembles unit files) |> and DUMPPROG (which disassembles .EXE files - both DOS and Windows style). Are there any good disassemblers in Public Domain? Thanks.

Russell Schulz

unread,
Nov 15, 1993, 1:20:41 PM11/15/93
to
jer...@dragons.nest.nl (Jeroen Pluimers) writes:

> Can anybody please put this question into the comp.lang.pascal FAQ? (Timo?)

sure, but not this answer!

> During the compilation, important information get's lost about variables,
> types, identifiers etc. Writing a Pascal Decompiler is impossible.

what big difference is it if all the variables are named var0001 and
up? what big diff does it make if you have `if (boolean_var)' or
`if (ord(char_var_0037)=1)'? if you can make some trivial changes,
and then recompile it, you've done what most people usually want a
decompiler for. (of course some _would_ want it to steal source, but
let's just ignore them for as long as possible)
--
Russell Schulz rus...@alpha3.ersys.edmonton.ab.ca ersys!rschulz Shad 86c

0 new messages