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

ANNOUNCE: New QuakeC Decompiler

171 views
Skip to first unread message

Christian Knauer

unread,
Feb 10, 1997, 3:00:00 AM2/10/97
to

Hi ererybody!

I've just uploaded the file unqcc098.zip to ftp.cdrom.com.
This is a modification to id's qcc that let`s you decompile
a progs.dat file. Not completely bug free, but very usable.
(Yes, it decompiles the Reaper ...)

Have fun!
Christian

Here is the README:

Title : unqcc
Filename : unqcc098.zip
Version : 0.98 (beta)
Date : 10/02/97
Author(s): Christian Knauer
Email : cnkn...@cip.informatik.uni-erlangen.de
Credits : id Software for creating Quake and
all the QuakeC gurus out there for improving it

Type of Modification
--------------------
Modification to id's QuakeC compiler (qcc)

Deathmatch : -
Single Player : -

Quake C : -
Sound : -
MDL : -

Description of the Modification
-------------------------------
This patch lets you decompile a progs.dat file back to native QuakeC.
It's similar to Armin Rigo's deacc, but it creates ''pure'' QuakeC code,
so you can immediatly recompile the source with qcc.
(well - at least in theory, see below)

The command ''qcc -dec'' will decompile the progs.dat file from the
current directory. Alternatively you can specify a file to decompile,
e.g. ''qcc -dec ../myprogs.dat''.

WARNING: The decompilation process will APPEND it's output to existing
qc files. So you should decompile in an empty directory.

Most of the time you will be able to compile the created source
immediately.
(e.g. with id's original V1.06 source)
Unfortunately unqcc has some shortcomings, so that you sometimes will
have
to modify the source by hand before it compiles cleanly (this happens
e.g.
with Steven Polge's ReaperBot 0.81).

Decompilation currently does not include type synthesis, so the
decompiler
uses a very cheap trick to determine the return type of a function.
Sometimes
this may fail. In that case the default type ''float'' is used (which is
the right choice for most of the time) and the function as well as all
of its
prototypes is marked with a comment of the form
''/* ERROR: Could not determine return type */''.
Use your brain to determine the correct return type and fix it by hand.

The same remark applies to entity function fields. unqcc always uses the
type
.void() for them, so you probably will have to fix it (e.g. ReaperBot's
.th_weight field). (The .th_pain field is the exception to the rule
here.)

Global variables are only initialized if their name starts with
uppercase
letters. Otherwise their (potential) initial value is enclosed in a
comment.
This works for all vital system constant such as TRUE, FL_xx, etc.
but e.g. the chase cam mod uses some lowercase constants. Again: check
the
source and fix by hand.

By the way: The ''error'' in line 153 of misc.qc that you'll get during
recompilation is NOT caused by a unqcc bug. Check the origial 1.06
source
and you will see, who messed things up...

Other comments of the form
''/* ERROR: ... */''
may show up in the generated source and can usually be ignored. Don't
ask
me where they come from. (I suspect that they are caused by qcc bugs,
but
who knows ...)

If you found a progs.dat that can not be decompiled, please drop me an
email. (Tell me where it can be found, which compiler you used, etc.
Please do NOT send the progs.dat file!)

How to Install the Modification
-------------------------------
First, get the source code to id's QuakeC compiler qcc, e.g. from
ftp.cdrom.com. (I've not tested this with modified compilers, like
fastqcc from Jonathan Roy - mail me if you succeed ...)

Create a subdirectory and install the qcc source in it. Next, unzip
the file unqcc098.zip to this directory. This will replace the original
files ''makefile'' and ''qcc.c'' with new versions and add the file
''unqcc.c''. Now compile by issuing a ''make'' command.

This procedure has been tested under Linux and under MSDOS with DJGPPv2.
Please do not bomb me with emails like ''What is a make command?'',
''What is DJGPP?'' and the like. If you don't know what i'm talking
about
then wait until some brave soul will provide a precompiled binary.
(That won't be me!)

Technical Details
-----------------
Most of the code is derived from id Software's source code to the qcc
compiler. The decompilation is just a form of symbolic evaluation of
Quake's assembler code. Check the source code for details.
Since the return type is not always exactly known and since qcc always
uses a vector store opcode to initialize function parameters i had to
use some ''dirty tricks'' in some places. Check the source (and laugh
yourself to death ...).

Famous last words: Don't expect too much! This is a terrible
weekend-hack.
and it defintely has some bugs and flaws. Nevertheless, I hope it will
be
useful for you ..

The files in this archive are:

makefile
qcc.c
unqcc.c

Author Information
------------------
CS Student - check
http://wwwcip.informatik.uni-erlangen.de/~cnknauer
for details.

Distribution Permission
-----------------------
Do whatever you like with it. If you add a major improvement (like
correct type synthesis and the like), please drop me an email.

Availability
------------
This modification is available from the following places:
ftp.cdrom.com

Version Information
-------------------
0.98 First Release - probably the last one, too. I'm
currently working on my master's thesis, so time
is precious right now.

Disclaimer and Trademarks
-------------------------
The author takes no responsiblity for misuse of this program.
He is not responsible for any damage caused by it.

Quake TM (c)1996 id Software, Inc. All Rights Reserved.
All trademarks are the property of their respective companies.


--
Christian Knauer, Computer Science student - University of Erlangen

E-Mail: cnkn...@immd1.informatik.uni-erlangen.de
WWW Home: http://wwwcip.informatik.uni-erlangen.de/user/cnknauer

0 new messages