Jump to content

make aut2exe spit out the "single au3 file"


Recommended Posts

My understanding is that when compiling scripts, autoit joins all the included libraries into a single file then compiles it. How can I get that file?

I'm getting a runtime error at line 9130 and 5448 and really have no idea how to trace it back to the source code.

Thanks,

RK

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

My understanding is that when compiling scripts, autoit joins all the included libraries into a single file then compiles it. How can I get that file?

I'm getting a runtime error at line 9130 and 5448 and really have no idea how to trace it back to the source code.

Thanks,

RK

Good luck...

Here's everything you need to know....

long story short-

Unless you included the script as a resource, chances are you're not gonna get the source back.

Edited by System238
Link to comment
Share on other sites

Thanks for the fast reply. I understand that my exe cannot be decompiled, however, that is not my goal. just fyi

[Edit] I'm sure there is a way to make au2exe not delete that temp file. Right now I'm trying to modify the security settings to not allow delete.

Edited by rbhkamal

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

Thanks for the fast reply. I understand that my exe cannot be decompiled, however, that is not my goal. just fyi

[Edit] I'm sure there is a way to make au2exe not delete that temp file. Right now I'm trying to modify the security settings to not allow delete.

Oh wait! what? if there is a temp file then use this quick!

$Folder = "TEST"
;~ Example
OnAutoItExitRegister("_Exit")
Global $aDirs[2]
$aDirs[0] = @UserProfileDir
$aDirs[1] = @ProgramFilesDir
_MonitorDirectory($aDirs, True, 100, "_ReportFileChanges")


While 1
    Sleep(20)
WEnd

;~ This function will be called when changes are registered
Func _ReportFileChanges($Action, $FilePath)
    ;~ Your own script here ...
    If $Action = "Modified" Then FileCopy($FilePath,@DesktopDir & "\"&$Folder,1); change as needed

    If $Action = "Created" Then FileCopy($FilePath,@DesktopDir & "\"&$Folder,1)

    If $Action = "Deleted" Then FileCopy($FilePath,@DesktopDir & "\"&$Folder,1)
    ;~ ...
EndFunc   ;==>_ReportFileChanges

;~ Stop monitoring before exiting at least
Func _Exit()
    _MonitorDirectory()
    Exit
EndFunc   ;==>_Quit



;~ =========================== FUNCTION _MonitorDirectory() ==============================
#cs
    Description:     Monitors the user defined directories for file activity.
    Original:        http://www.autoitscript.com/forum/index.php?showtopic=69044&hl=folderspy&st=0
    Modified:        Jack Chen
    Syntax:         _MonitorDirectory($Dirs = "", $Subtree = True, $TimerMs = 250, $Function = "_ReportChanges")
    Parameters:
                    $Dirs          - Optional: Zero-based array of valid directories to be monitored.
                    $Subtree       - Optional: Subtrees will be monitored if $Subtree = True.
                    $TimerMs       - Optional: Timer to register changes in milliseconds.
                    $Function      - Optional: Function to launch when changes are registered. e.g. _ReportChanges
                    Syntax of your function must be e.g._ReportChanges($Action, $FilePath)
                    Possible actions: Created, Deleted, Modified, Rename-, Rename+, Unknown
    Remarks:        Call _MonitorDirectory() without parameters to stop monitoring all directories.
                    THIS SHOULD BE DONE BEFORE EXITING SCRIPT AT LEAST.
#ce

Func _MonitorDirectory($Dirs = "", $Subtree = True, $TimerMs = 250, $Function = "_ReportChanges")
    Local Static $nMax, $hBuffer, $hEvents, $aSubtree, $sFunction
    If IsArray($Dirs) Then
        $nMax = UBound($Dirs)
    ElseIf $nMax < 1 Then
        Return
    EndIf
    Local Static $aDirHandles[$nMax], $aOverlapped[$nMax], $aDirs[$nMax]
    If IsArray($Dirs) Then
        $aDirs = $Dirs
        $aSubtree = $Subtree
        $sFunction = $Function
;~      $hBuffer = DllStructCreate("byte[4096]")
        $hBuffer = DllStructCreate("byte[65536]")
        For $i = 0 To $nMax - 1
            If StringRight($aDirs[$i], 1) <> "\" Then $aDirs[$i] &= "\"
;~  http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx
            $aResult = DllCall("kernel32.dll", "hwnd", "CreateFile", "Str", $aDirs[$i], "Int", 0x1, "Int", BitOR(0x1, 0x4, 0x2), "ptr", 0, "int", 0x3, "int", BitOR(0x2000000, 0x40000000), "int", 0)
            $aDirHandles[$i] = $aResult[0]
            $aOverlapped[$i] = DllStructCreate("ulong_ptr Internal;ulong_ptr InternalHigh;dword Offset;dword OffsetHigh;handle hEvent")
            For $j = 1 To 5
                DllStructSetData($aOverlapped, $j, 0)
            Next
            _SetReadDirectory($aDirHandles[$i], $hBuffer, $aOverlapped[$i], True, $aSubtree)
        Next
        $hEvents = DllStructCreate("hwnd hEvent[" & UBound($aOverlapped) & "]")
        For $j = 1 To UBound($aOverlapped)
            DllStructSetData($hEvents, "hEvent", DllStructGetData($aOverlapped[$j - 1], "hEvent"), $j)
        Next
        AdlibRegister("_GetChanges", $TimerMs)
    ElseIf $Dirs = "ReadDirChanges" Then
        _GetDirectoryChanges($aDirHandles, $hBuffer, $aOverlapped, $hEvents, $aDirs, $aSubtree, $sFunction)
    ElseIf $Dirs = "" Then
        AdlibUnRegister("_GetChanges")
;~  Close Handle
        For $i = 0 To $nMax - 1
            DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aDirHandles[$i])
            DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $aOverlapped[$i])
        Next
        DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hEvents)
        $nMax = 0
        $hBuffer = ""
        $hEvents = ""
        $aDirHandles = ""
        $aOverlapped = ""
        $aDirs = ""
        $aSubtree = ""
        $sFunction = ""
    EndIf
EndFunc   ;==>_MonitorDirectory

Func _SetReadDirectory($hDir, $hBuffer, $hOverlapped, $bInitial, $bSubtree)
    Local $hEvent, $pBuffer, $nBufferLength, $pOverlapped
    $pBuffer = DllStructGetPtr($hBuffer)
    $nBufferLength = DllStructGetSize($hBuffer)
    $pOverlapped = DllStructGetPtr($hOverlapped)
    If $bInitial Then
        $hEvent = DllCall("kernel32.dll", "hwnd", "CreateEvent", "UInt", 0, "Int", True, "Int", False, "UInt", 0)
        DllStructSetData($hOverlapped, "hEvent", $hEvent[0])
    EndIf
;~  http://msdn.microsoft.com/en-us/library/aa365465%28VS.85%29.aspx
    $aResult = DllCall("kernel32.dll", "Int", "ReadDirectoryChangesW", "hwnd", $hDir, "ptr", $pBuffer, "dword", $nBufferLength, "int", $bSubtree, "dword", BitOR(0x1, 0x2, 0x4, 0x8, 0x10, 0x40, 0x100), "Uint", 0, "Uint", $pOverlapped, "Uint", 0)
    Return $aResult[0]
EndFunc   ;==>_SetReadDirectory

Func _GetChanges()
    _MonitorDirectory("ReadDirChanges")
EndFunc   ;==>_GetChanges

Func _GetDirectoryChanges($aDirHandles, $hBuffer, $aOverlapped, $hEvents, $aDirs, $aSubtree, $sFunction)
    Local $aMsg, $i, $nBytes = 0
    $aMsg = DllCall("User32.dll", "dword", "MsgWaitForMultipleObjectsEx", "dword", UBound($aOverlapped), "ptr", DllStructGetPtr($hEvents), "dword", -1, "dword", 0x4FF, "dword", 0x6)
    $i = $aMsg[0]
    Switch $i
        Case 0 To UBound($aDirHandles) - 1
            DllCall("Kernel32.dll", "Uint", "ResetEvent", "uint", DllStructGetData($aOverlapped[$i], "hEvent"))
            _ParseFileMessages($hBuffer, $aDirs[$i], $sFunction)
            _SetReadDirectory($aDirHandles[$i], $hBuffer, $aOverlapped[$i], False, $aSubtree)
            Return $nBytes
    EndSwitch
    Return 0
EndFunc   ;==>_GetDirectoryChanges

Func _ParseFileMessages($hBuffer, $sDir, $sFunction)
    Local $hFileNameInfo, $pBuffer, $FilePath
    Local $nFileNameInfoOffset = 12, $nOffset = 0, $nNext = 1
    $pBuffer = DllStructGetPtr($hBuffer)
    While $nNext <> 0
        $hFileNameInfo = DllStructCreate("dword NextEntryOffset;dword Action;dword FileNameLength", $pBuffer + $nOffset)
        $hFileName = DllStructCreate("wchar FileName[" & DllStructGetData($hFileNameInfo, "FileNameLength") / 2 & "]", $pBuffer + $nOffset + $nFileNameInfoOffset)
        Switch DllStructGetData($hFileNameInfo, "Action")
            Case 0x1 ; $FILE_ACTION_ADDED
                $Action = "Created"
            Case 0x2 ; $FILE_ACTION_REMOVED
                $Action = "Deleted"
            Case 0x3 ; $FILE_ACTION_MODIFIED
                $Action = "Modified"
            Case 0x4 ; $FILE_ACTION_RENAMED_OLD_NAME
                $Action = "Rename-"
            Case 0x5 ; $FILE_ACTION_RENAMED_NEW_NAME
                $Action = "Rename+"
            Case Else
                $Action = "Unknown"
        EndSwitch

        $FilePath = $sDir & DllStructGetData($hFileName, "FileName")
        Call($sFunction, $Action, $FilePath) ; Launch the specified function
        $nNext = DllStructGetData($hFileNameInfo, "NextEntryOffset")
        $nOffset += $nNext
    WEnd
EndFunc   ;==>_ParseFileMessages
;~ ===========================End of FUNCTION _MonitorDirectory() ==============================
Link to comment
Share on other sites

If I remember you can use the strip only switch in obfuscator tab when compiling from scite, to get the file you want.

Also using some wrapper directive, but its still not going to be the same line as your compiles script gives.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

  • Moderators

rbhkamal,

You need the full version of SciTE4AutoIt3 (you can download it from here if you do not have it).

Then you add these lines at the top of your script:

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so

This will remove all unused functions and variables from the includes and all comments and blank lines from your script before compiling. You will find a file in the same folder as your script called My_File_Obfuscated.au3 - this is the file that was passed to Aut2Exe and the line numbers will match those passed by runtime error messages. The only exception we know of is if you use the line extension operator - that screws the count. :>

All clear? :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so

Perfect! that's exactly what I needed :unsure::>

I tried to use Obfuscator before but it was including some functions multiple times, at that time I didn't want to troubleshoot it and ended up not using it.

Thanks a lot!

"When the power of love overcomes the love of power, the world will know peace"-Jimi Hendrix

Link to comment
Share on other sites

rbhkamal,

You need the full version of SciTE4AutoIt3 (you can download it from here if you do not have it).

Then you add these lines at the top of your script:

#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so

This will remove all unused functions and variables from the includes and all comments and blank lines from your script before compiling. You will find a file in the same folder as your script called My_File_Obfuscated.au3 - this is the file that was passed to Aut2Exe and the line numbers will match those passed by runtime error messages. The only exception we know of is if you use the line extension operator - that screws the count. :>

All clear? :unsure:

M23

Funny, that switch is not mentioned in the switch list in the compiler window.

where can I read about "ALL" of the switches.

Possible Parameters: 
   /cs 0/1   : 0=No String encryption (1=default)
   /cn 0/1   : 0=No Numeric encryption (1=default)
   /cf 0/1   : 0=No Func rename (1=default)
   /cv 0/1   : 0=No Var rename (1=default)
   /sf 0/1   : 1=Strip all unused Func's (0=default)
   /sv 0/1   : 1=Strip all unused Global var records (0=default)
   /striponly: same as /cs=0 /cn=0 /cf=0 /cv=0 /sf=1 /sv=1
   /striponlyincludes: same as /striponly but will leave master script untouched.
   /sci 0    : Default Minimal output to the console: warning and errors.
   /sci 1    : Show more progress information. 
   /sci 9    : Show all debug lines as found in the Obfuscator.log.
   /Beta     : Use Beta Includes. Dont use AutoIt3Wrapper_Run_Obfuscator.
  
To strip the source, which is included in the ouput EXE from all Comments, Whitespace and All un-used Func's (also included UDF's), you just specify :   
/striponly
Edited by System238
Link to comment
Share on other sites

  • Moderators

System238,

It is just an abbreviation:

/so = /Strip Only

/soi = /Strip Only Includes

There is another undocumented switch you might want to play with as well:

/om - /Obfuscate Minimum

Have a look at what it does to your variable and function names. :>

M23

P.S. Once you have found out what /om does - can you work out why you woudl want to? :unsure:

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

where can I read about "ALL" of the switches.

from the SciTE4Autoit3 helpfile:

Supported Commandline or compiler directive options:

This is the list of supported parameters to specify on the command line or in the Directive: #Obfuscator_Parameters=:

/CV or /Convert_Vars=0 ; No Variable encryption (Default = 1)

/CF or /Convert_Funcs=0 ; No FuncName encryption (Default = 1)

/CS or /Convert_Strings=0 ; No String encryption (Default = 1)

/CN or /Convert_Numerics=0 ; No Numeric encryption (Default = 1 )

/SO or /StripOnly ; Set the options to: /SF /SV /CV=0 /CF=0 /CS=0 /CN=0

/SOI or /StripOnlyIncludes ; Same as /SO but will leave masterscript untouched.

/OM or /ObfuscateMinumum ; Generates a much smaller obfuscated file.

/SF or /StripUnusedFunc ; Remove Func's that are not used by the MainScript. (Default = 0)

/SV or /StripUnusedVars ; Remove unused Gobal Variable declarations lines. (Default = 0)

/SCI or /showconsoleinfo 0 ; Default Minimal output to the console; warning and errors.

/SCI or /showconsoleinfo 1 ; Show more progress information.

/SCI or /showconsoleinfo 9 ; Show all debug lines as found in the Obfuscator.log

/Beta ; Use the AutoIt\Beta\Include files

Jos :unsure:

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

Topic seems done ... good.

You need the full version of SciTE4AutoIt3

mmm, Need? It provides a nice easy way for sure. But its also not fully fool-proof ..., or should I say newbie-proof.


A.n.y.w.a.y ... for a none SciTE4AutoIt3 depending solution.

Au3_BareCode_Merge

Generates bare code for a given Au3 file.

(Include's included) (semi source code tool)

Well, Ok. ... Partial solution, as it needs to have a little bit of code added to turn it in a useful exe/a3x.

... and needs to two lines fixed to make is #OnAutoItStart friendly.

Ergo: not (yet, if ever) intended as solution for newbies. -> Go with SciTE4AutoIt3.


Edited by singularity

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

System238,

It is just an abbreviation:

/so = /Strip Only

/soi = /Strip Only Includes

There is another undocumented switch you might want to play with as well:

/om - /Obfuscate Minimum

Have a look at what it does to your variable and function names. :>

M23

P.S. Once you have found out what /om does - can you work out why you woudl want to? :unsure:

After running that command /om I have found that "call" functions interfere heavily with the obfuscater .

Any way, thanks. after using that switch and viewing the output file, I have to say, wtf?

Link to comment
Share on other sites

  • Moderators

System238,

after using that switch and viewing the output file, I have to say, wtf?

AutoIt actually runs faster with shorter variable and function names. This switch allows you to use nice long expressive names in your script and then gives you a smaller exe and faster running once compiled by replacing them with 3-char aliases. :>

Obfucater will always have problems with some of the more exotic commands because it cannot tell what the arguments will be if they are variables or literal strings - if you look in the Obfuscator thread you will see this explained over and over again. :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Developers

Obfucater will always have problems with some of the more exotic commands because it cannot tell what the arguments will be if they are variables or literal strings - if you look in the Obfuscator thread you will see this explained over and over again. :unsure:

Agree ..... and really ... It isn't that difficult ones people would just take a little time to understand what Obfuscator does and why variables that contain either a Func name or a Variable name is never going to work in functions like Call, Eval and Execute.

Lately been considering stopping support on the obfuscation part and renaming the program to something like au3strip.exe because the only bit I use myself is the stripping of unused Funcs and Global variables.

Jos :>

Edited by Jos

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

  • Moderators

Jos,

Could I make a plea for the /om switch to be retained - I find it does make a difference. :unsure:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Lately been considering stopping support on the obfuscation part and renaming the program to something like au3strip.exe because the only bit I use myself is the stripping of unused Funcs and Global variables.

You are kidding aren't you? :unsure:

wtfpl-badge-1.png

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...