Jump to content

Decompiled Source Cleaner


logi
 Share

Recommended Posts

Title say's it all, this program cleanes your decompiled source.

#region INCLUDE
#include <GuiConstants.au3>
#include<file.au3>
#endregion
#region Declare
$file       =   ""
$target     =   ""
$line       =   ""
$include    =   ""
$end        =   0
$end1       =   0
$L          =   1
$b          =   0
#endregion

#region GUI
GuiCreate("Decompiled Source Cleaner", 593, 179,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Source         =   GuiCtrlCreateInput      ("", 110, 70, 320, 20,$ES_READONLY)
$Destenation    =   GuiCtrlCreateInput      ("", 110, 110, 320, 20,$ES_READONLY)
$B_Source       =   GuiCtrlCreateButton     ("&Browse", 440, 70, 60, 20)
$B_Destenation  =   GuiCtrlCreateButton     ("B&rowse", 440, 110, 60, 20)
                    GuiCtrlCreateLabel      ("Source (.au3)", 30, 70, 80, 20)
                    GuiCtrlCreateLabel      ("Destination", 30, 110)
                    GuiCtrlCreateGroup      ("Settings", 10, 40, 570, 100)
$go             =   GuiCtrlCreateButton     ("Go!", 510, 70, 60, 60)
                    GuiCtrlCreateLabel      ("2006 By Logi", 490, 20)
                    GuiCtrlCreateLabel      ("Decompiled Source Cleaner", 230, 5, 150, 20)
                    GuiCtrlCreateLabel      ("Version 1.0", 260, 20)
$Progress       =   GuiCtrlCreateProgress   (10, 150, 500, 20)
$phase          =   GuiCtrlCreateLabel      ("Phase 1", 520, 155, 50, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $B_Source
        $source1 = FileOpenDialog("Open decompiled source", @DocumentsCommonDir,"source (*.au3)")
        GUICtrlSetData($Source, $source1)
    Case $msg = $B_Destenation
        $Destenation1 = FileSaveDialog("Save clean decompiled source", @DocumentsCommonDir,"source (*.au3)")
        GUICtrlSetData($Destenation, $Destenation1)
    case $msg = $go
        ExitLoop
    Case Else
;;;
    EndSelect
WEnd

#endregion  GUI



#region CLEAN CORE

;   check if the source realy excists and is reachable.
    $file   =   GUICtrlRead($Source)
    $target =   GUICtrlRead($Destenation)
if not      FileExists($file) then 
            MsgBox(0, "Sorry", "Sorry this file does not exists")
    $source1 =  FileOpenDialog("Open decompiled source", @DocumentsCommonDir,"source (*.au3)")
            GUICtrlSetData($Source, $source1)
    $file   =   GUICtrlRead($Source)            
if not      FileExists($file) then Exit
EndIf

;check if the Destination is filled in
if  $target         =   "" Then
    $Destenation1   =   FileSaveDialog("Save clean decompiled source", @DocumentsCommonDir,"source (*.au3)")
                        GUICtrlSetData($Destenation, $Destenation1)
    $target         =   GUICtrlRead($Destenation)
    if  $target     =   "" Then Exit
EndIf

    $count          =   _FileCountLines ($file)
                        _FileReadToArray($file,$line)
;checking includes
while 1
if  StringInStr($line[$L],"; <AUT2EXE INCLUDE-START:") <> 0 Then 
    $begin      =   StringInStr($line[$L], "\",0,-1)
    $include    =   StringMid ( $line[$L], $begin)
    $include    =   StringReplace($include,"\", "#include<")
    FileWriteline($target,$include) 
EndIf
$L  =    $L     +   1
$Pro    =   $L  /   $count  
$pro    =   $pro    *   100
GUICtrlSetData($Progress, $pro)
IF $L = $count Then sourcefind()
WEnd
;end checking includes

Func sourcefind()
while 1
if StringInStr($line[$L],"; <AUT2EXE INCLUDE-END:") <> 0 Then 
    $end    =   $L
    $end    =   $end    -   1
    
    while 1
    $l = $L - 1
    if StringInStr($line[$L],"; <AUT2EXE INCLUDE-END:") <> 0 Then 
    sourcewrite()
    ExitLoop
    EndIf
    WEnd
Else
$l = $L - 1
EndIf
WEnd


EndFunc

func sourcewrite()
$L  =   $L  +   2
GUICtrlSetData($phase,"Phase 2")
$end1       =   $end    -   $l
while 1
    
FileWriteLine($target,$line[$L])

$L  =   $L  +   1
$b  =   $b  +   1
$pro=   $b  /   $end1
$pro    =   $pro    *   100
GUICtrlSetData($Progress, $pro)
if $L   =   $end    Then    exitloop
WEnd
MsgBox(262208,"Ready","Your file has been cleaned, this program will close after you press OK.")
Exit
EndFunc
Edited by logi
Link to comment
Share on other sites

I give it 2 thumbs up... 2 small issues though.

1) It puts alot of #includes in there that weren't in the original source.

2) I changed your Func below to properly exit... it went in to a death loop for me.

Func sourcewrite()
    $L = $L + 2
    GUICtrlSetData($phase, "Phase 2")
    $end1 = $end - $L
    While 1
        
        FileWriteLine($target, $line[$L])
        
        $L = $L + 1
        $b = $b + 1
        $Pro = $b / $end1
        $Pro = $Pro * 100
        GUICtrlSetData($Progress, $Pro)
        If $L = $end Then ExitLoop
    WEnd
    MsgBox(0, "Ready", "Your file has been cleaned, this program will close after you press OK.")
Exit
EndFunc

Great job :)

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

I gots some questions.... :P

Is your code producing these duplicates (Blue) or triplicates (Red) ? :D

If not, then it must (might) be the compiler..... if so, are the compiled .exe's getting packed with all these .au3 files ? :)

And if this is true, can we not include them if they are not needed ? :party:

Don't know if it would make the files smaller or not.... but it's definitely on the odd side. :D

#include<Original Source Code.au3>

#include<GUIConstants.au3>

#include<GUIDefaultConstants.au3>

#include<WindowsConstants.au3>

#include<AVIConstants.au3>

#include<ComboConstants.au3>

#include<DateTimeConstants.au3>

#include<EditConstants.au3>

#include<StaticConstants.au3>

#include<ListBoxConstants.au3>

#include<ListViewConstants.au3>

#include<SliderConstants.au3>

#include<TreeViewConstants.au3>

#include<UpDownConstants.au3>

#include<GUIConstantsEx.au3>

#include<WindowsConstants.au3>

#include<ComboConstants.au3>

#include<ListViewConstants.au3>

#include<StaticConstants.au3>

#include<ButtonConstants.au3>

#include<ListBoxConstants.au3>

#include<TabConstants.au3>

#include<EditConstants.au3>

#include<DateTimeConstants.au3>

#include<SliderConstants.au3>

#include<TreeViewConstants.au3>

#include<ProgressConstants.au3>

#include<AVIConstants.au3>

#include<UpDownConstants.au3>

#include<GuiListView.au3>

#include<ListViewConstants.au3>

#include<Array.au3>

#include<GuiStatusBar.au3>

#include<Array.au3>

#include<StatusBarConstants.au3>

#include<WindowsConstants.au3>

If I missed any... well you get the point. :party:

Edit: The files total 113.28kb, the compiled file is 212kb... not including the blue ones... just a point to ponder. :alien:

Edited by Fossil Rock

Agreement is not necessary - thinking for one's self is!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

  • Developers

More then 100 views but only 2 reply's?

:P

Ok since you insist:

General: When you have a need for this utility you are doing something wrong. Use a backup/versioning system to store your sources in stead of depending on decompiling.

Tidy your posted code for readability.

Use AutoIt code tags when posting .

:)

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Ok since you insist:

General: When you have a need for this utility you are doing something wrong. Use a backup/versioning system to store your sources in stead of depending on decompiling.

Tidy your posted code for readability.

Use AutoIt code tags when posting .

:)

1. I know you are right but when i am at work i don't have the au3 files so i decompile the .exe ^-^..

2. Already are tiding it... i am also adding information to it

3. I didn't use autoit code because sometimes i notice that if you try to copy/paste it it is pasted as one long line

EDIT: Ofcourse i will take care of the last 2 things.. ^-^

Edited by logi
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...