WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Compiler
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Decompilation of EXE-Files

Keywords:    decompile	  uncompile  decompiler

Question:

The Harddisk containing all my actual WBT-Sorce-Files has been formatted last week. The EXE-files already exist in all the different applications. My question is: How can I get back the source files without thinking hours and hours about the last changes??? A reasonable answer that helps would be some dollars worth.

Answer:

  1. No real way to decompile WinBatch scripts.

    It is extremely difficult to extract source code back from a compiled .EXE file, and that gives our users a level of comfort with respect to thoughts about people illicitly decompiling a compiled script that is part of a commecial software product.

    Real competent hackers can sometimes get glimpses of code in certain circumstances, but there is no easy way of doing it.

    The going rate for decompiling a WB script seems to be in the near-ten-thousand dollar range. I would guess quantity discounts might be available.

    If you're finding that you need to decompile WB EXEs, and can't find the source, this would be a good time to invest in a source code control system or at least some way of backing up your source code.

    As I understand it with the Micrsoft Visual C tool "HeapWalker" and lots of knowhow and patience you can get some code to display on the screen ASSUMING your program hangs around in memory long enough to see it.

    The basic idea is that you launch your compiled WB EXE from HeapWalker. It can look in memory where the script lives, so if it's still in memory, then you can look at it, and retype it. Unfortunately, HeapWalker doesn't have a cut and paste utility.

  2. Another possibility is:

    http://www.numega.com/products/sys.shtml

    and lots and lots of coffee. Basically the tool can look into the memory structures and one of them has something like your source code.

  3. The best solution I've seen with this is something you have to add in when you're writing your code. Something like adding to the top lines of your scripts...
    	ddd=IniReadPvt("Main","DebugTrace",0,"c:\wbdebug.ini")
    	Debug(ddd)
    
    Then if there is no wbdebug file (or if the debug keyword is set to zero, then debug is off).

    By adding a wbdebug.ini file and setting debug to 1 then you turn debug on for the script. Unfortunately you have to have this in the existing code for it to work.

    It quite difficult to decompile an existing executable. There are a handful of people (and the NSA I think) that do this on an occasional basis. It tends to be very expensive.

  4. For simple emergencies, when you're developing your scripts, you can add:
    
            if FileExist("C:\UNCOMPILE.TXT") then Debug(1)
    
    in which case you will turn debug on if a dummy file by the name of UNCOMPILE.TXT is there, and then you can copy it line by line into a file to rebuild it.

  5. Alternatively, add the following code the your WBTs as you write them, if you want to turn debug on:

    The compiled exe is named STARTNT.EXE

    
            STARTNT /DEBUG
    
    or
    
            STARTNT /HELP
    
    The parameters after the exe are PARAM1, PARAM2 etc.
    
            <.......snip.....>
            dbg="%param1%"
            if dbg=="/DEBUG"
               Message("STARTNT - DEBUG MODE","Startnt is running in DEBUG-Mode now !" )
               Debug(@on)
            Endif
            
            if dbg=="/HELP"
            line1="/DEBUG Starts STARTNT in Debug Mode"
            line2="/HELP Shows this Window"
            line3="History"
            
            InfoLine=StrCat(line1,line2,line3)
            
            Message("STARTNT - HELP",Infoline )
            Exit
            Endif
            <......snip......>
    

  6. Another thing you could do is to include the original source in with the BIG EXE files by making your own extender.

    Let's say your source code is ABC.WBT.

    • Copy ABC.WBT to the \winbatch\system directory.
    • Make a new file, also in \winbatch\system called ABC.DAT. It contains...
      
      	;-----snip----
      	ABC.WBT SOURCE CODE
      	ABC.WBT
      	;-----snip----
      
    • And then when you compile, be sure to include the ABC.WBT extender.

    • Result: 1) Source will always be with the EXE, and; 2) It ALWAYS gets written to disk when run.

Article ID:   W12781
Filename:   Decompile a Compiled WB EXE.txt
File Created: 2004:05:25:11:54:18
Last Updated: 2004:05:25:11:54:18