Contents ----- Copyright Previous Next

Use-Case 5: Unvahunzing

Imagine you found a vahunzed source code, and you want to modify it. What can you do to turn all the garble into something you can work with?

Restoring indention is easy: Take an indent tool, and apply it to every file.

Comments can't be restored at all. Maybe this is not really a pity, as most programmers do not comment there sources anyway - because of the usual reasons and with the usual results.

But now to the interesting part: how to reestablish meaningful names.

Who is Vahunz's biggest enemy? You might already have guessed it: Vahunz itself! Most of the work needed for unvahunzing can be described as a single big, fat Great Renaming.

So the main problem is to find out what all those functions do, and choose a meaningful name for them. Here are some hints how to do this:

Look at the filenames. Vahunz does not touch them, and they might still have a name allowing you to guesstimate what's going on inside.

Try to get names for data types soon, this already makes the code a lot better legible.

Get the file with the main() function. Obtain the names for argc and argv. With this, you should be able to find the part where the handling of command line arguments is performed. There you can often find out several global variables - if the programmer was lazy. Most are.

Look out for a debug mode. Compile the program in debug mode, scan the source for debugging messages and add your own "still alive" messages to find out where you are. In general calls to printf and meaningful string constants can be very helpful.

If the program is doing many calls to system functions like GetMsg() or DoIO(), you can filter high-level and low-level functions of the program. The later ones are often of no interest. Calls to standard system functions and constants can not be vahunzed, as it would break the program.

Happy unvahunzing!