Jump to content

AU3Stripper - SendTo


Simpel
 Share

Recommended Posts

Hi,

while debugging sometimes I need the au3 stripped script with /mo parameter, so that error lines in the error message match the script. Things I use often I put inside sendto folder (shell:sendto) so I can push my file to this with right click fast. A long time I had problems with some of my scripts stripping this way because the some paths to my script included spaces (you should not do that). But here’s my solution fixing that problem:

Local $sPathToAU3Stripper = "" ; fill in the path here
Local $sPath
If $CmdLineRaw = "" Then ; you didn't do it with sendto
    $sPath = FileOpenDialog("Which file you want to AU3-strip?", "","AU3 (*.au3)", 3)
    If @error Then
        MsgBox(0, 'Error FileOpenDialog:', @error)
        Exit
    EndIf
Else
    $sPath = $CMDLINE[1]
EndIf
Local $sPath_quoted = '"' & $sPath & '"'
ShellExecuteWait($sPathToAU3Stripper, $sPath_quoted & ' /mo', "", "", @SW_HIDE)

I hope someone will find it useful.

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Developers

Hey Conrad,

Why not simply use the following line in your script source and simply run au3stripper?:

#Au3Stripper_Parameters=/MO

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

Hi @Jos 

I did it that way for a long time. But then I decided to “include” the script as a resource that I always can extract via $cmdline. And suddenly I always got an error message that “including” failed. Did I comment the parameter /mo out it worked.

I hope I can post an exampe for my current workflow tomorrow evening.

Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

Hi @Jos,

as written above I have some code I always put via an #include into my scripts. Inside this #include I use this code to have source code always embedded:

#include<ResourcesEx.au3> ; nötig zum Extrahieren der Source
_ExtractSource() ; extrahiert die Source wenn @compiled und $cmdlineraw stimmt

Func _ExtractSource()
    If @Compiled Then
        If StringRegExp($cmdlineraw, "(?i)(extract|extrakt|source|quelle|code|au3)") Then
            Local $sInputExe = @ScriptFullPath
            Local $sResNameOrID = 999
            Local $sFilePathAu3 = StringLeft(@ScriptFullPath, StringInStr(@ScriptFullPath, ".", 0, - 1) - 1) & "_extracted_source.au3"
            Local $bReturn = _Resource_SaveToFile($sFilePathAu3, $sResNameOrID, Default, Default, Default, $sInputExe)
            Local $sErrorAddon
            If @error = 6 Then $sErrorAddon = " - Kein Quellcode gefunden."
            MsgBox(0, 'Sourcecode', 'Extrahiert: ' & $bReturn & @CRLF & @CRLF & 'Error: ' & @error & $sErrorAddon & @CRLF & 'Extended: ' & @extended & @CRLF & @CRLF & "Pfad: " & $sFilePathAu3)
            Exit
        EndIf
    EndIf
EndFunc

Having this inside I get an error message while compiling with these parameters:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/mo

So I have to comment them out. Do you see another possibility to do both?

Regards, Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Developers

What is the error and how does that extract source look when you run it compiled?
When you want me to have a look you need to give me an working example to simulate your issue.

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

Hi @Jos,

sorry I wasn't clear. Both together are a working example. Please try this:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/mo
#include<ResourcesEx.au3>
_ExtractSource()

MsgBox(0, 'Test', "This shows that the script is normally working.")
Exit

Func _ExtractSource()
    If @Compiled Then
        If StringRegExp($cmdlineraw, "(?i)(extract|extrakt|source|quelle|code|au3)") Then
            Local $sInputExe = @ScriptFullPath
            Local $sResNameOrID = 999
            Local $sFilePathAu3 = StringLeft(@ScriptFullPath, StringInStr(@ScriptFullPath, ".", 0, - 1) - 1) & "_extracted_source.au3"
            Local $bReturn = _Resource_SaveToFile($sFilePathAu3, $sResNameOrID, Default, Default, Default, $sInputExe)
            Local $sErrorAddon
            If @error = 6 Then $sErrorAddon = " - No source found."
            MsgBox(0, 'Sourcecode', 'Extracted: ' & $bReturn & @CRLF & @CRLF & 'Error: ' & @error & $sErrorAddon & @CRLF & 'Extended: ' & @extended & @CRLF & @CRLF & "Path: " & $sFilePathAu3)
            Exit
        EndIf
    EndIf
EndFunc

SciTE console out:

>"H:\_Conrad lokal\Downloads\AutoIt3\SciTE\..\AutoIt3.exe" "H:\_Conrad lokal\Downloads\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /NoStatus /prod /in "H:\_Conrad lokal\Downloads\AutoIt3\_COX\Tests\test.au3"
+>16:01:04 Starting AutoIt3Wrapper v.16.306.1237.0 SciTE v.3.6.2.0   Keyboard:00000407  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64  Environment(Language:0407)  CodePage:0  utf8.auto.check:4    # detect ascii high characters and if none found set default encoding to UTF8 and do not add BOM
+>         SciTEDir => H:\_Conrad lokal\Downloads\AutoIt3\SciTE   UserDir => H:\_Conrad lokal\Downloads\AutoIt3\SciTE\AutoIt3Wrapper
>Running AU3Check (3.3.14.2)  params:-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7  from:H:\_Conrad lokal\Downloads\AutoIt3  input:H:\_Conrad lokal\Downloads\AutoIt3\_COX\Tests\test.au3
+>16:01:05 AU3Check ended.rc:0
>Running Au3Stripper (16.306.1237.0)  from:H:\_Conrad lokal\Downloads\AutoIt3\SciTE\Au3Stripper cmdline:
+> 0 Au3Stripper v16.306.1237.0 finished merging 22963 lines of code, stripped 10091 comment lines and Merged 451 Continuation lines.
+>        Created:H:\_Conrad lokal\Downloads\AutoIt3\_COX\Tests\test_stripped.au3 with 12421 lines.
+>16:01:06 Au3Stripper ended.rc:0
>Running AU3Check (3.3.14.2)  params:-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7  from:H:\_Conrad lokal\Downloads\AutoIt3  input:H:\_Conrad lokal\Downloads\AutoIt3\_COX\Tests\test_stripped.au3
+>16:01:06 AU3Check ended.rc:0
>Running:(3.3.14.2):H:\_Conrad lokal\Downloads\AutoIt3\aut2exe\aut2exe.exe  /in "H:\_Conrad lokal\Downloads\AutoIt3\_COX\Tests\test_stripped.au3" /out "C:\Users\zelckc\AppData\Local\AutoIt v3\Aut2exe\~AU9D8A.tmp.exe" /nopack /comp 2
+>16:01:08 Aut2exe.exe ended.C:\Users\zelckc\AppData\Local\AutoIt v3\Aut2exe\~AU9D8A.tmp.exe. rc:0
>16:01:08 Performing the Program Resource Update steps:
...>Updating Program Version information.
!>16:01:08 Skipping SourceSave because this is an stripped script.rc:2
>16:01:08 Program Resource updating finished successfully.
+>16:01:08 Created program:H:\_Conrad lokal\Downloads\AutoIt3\_COX\Tests\test.exe
+>16:01:08 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 4.826

I think this message is the one: !>16:01:08 Skipping SourceSave because this is an stripped script.rc:2

But I don't know why it can't save that stripped file. That would be ok too. My goal at the end would be to include original unstripped and stripped version both could be excluded with to different parameters. (Why include the stripped version if I can strip the excluded original when needed manually? I found out, that a lot of error messages in faulty scripts point to a wee another line then found in the later stripped version (original scripts were definitely unchanged).)

Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Developers

I think I understand that issue now. this piece of code was introduced in Obfuscator and coded in a way that the source would only be included when /StripOnly was specified when Obfuscator was ran. Obfuscator is renamed to Au3Stripper but this logic isn't adapted to the updated parameter structure.

I need to think about this one a little longer what is correct now so please add an feature request in our "Bug Tracker" so I won't forget to have that closer look.

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

Ok, thank you for your information. I use ResourcesEx.au3 only because it works with marcos and variables .In FileInstall() it must be a literal string. It cannot use a variable and because of that I can't use it as a standard function inside an include I include in all of my scripts. Is there another possibility to include my script?

Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Developers

Quick hack to make it always include the master source?
Changed the lines 2545-2562 in AutoIt3Wrapper.au3: 

; Add original source to Resources
            If $INP_Res_SaveSource = "y" Then
                Local $tempfilein
                If $INP_Run_Au3Stripper = "y" Then
                    If StringInStr($INP_Au3Stripper_Parameters, "/so") Or StringInStr($INP_Au3Stripper_Parameters, "/striponly") Then
                        FileCopy(StringTrimRight($ScriptFile_In, StringLen($ScriptFile_In_Ext)) & '_stripped' & $ScriptFile_In_Ext, $TempDir & "\scriptin.tmp", 1)
                        Write_RC_Console_Msg("Adding stripped Script source to RT_RCDATA,999 in the Output executable.", "", "...", 0)
                    Else
                        Write_RC_Console_Msg("Skipping SourceSave because this is an stripped script.", 2)
                    EndIf
                Else
                    $tempfilein = _TempFile($TempDir)
                    FileCopy($ScriptFile_In, $tempfilein, 1)
                    Write_RC_Console_Msg("Adding original Script source to RT_RCDATA,999 in the Output executable.", "", "...", 0)
                    _Res_Update($rh, $tempfilein, 10, 999, $INP_Res_Language)
                    __DelTempFile($tempfilein)
                EndIf
            EndIf

to:

; Add original source to Resources
            If $INP_Res_SaveSource = "y" Then
                Local $tempfilein = _TempFile($TempDir)
                FileCopy($ScriptFile_In, $tempfilein, 1)
                Write_RC_Console_Msg("Adding original Script source to RT_RCDATA,999 in the Output executable.", "", "...", 0)
                _Res_Update($rh, $tempfilein, 10, 999, $INP_Res_Language)
                __DelTempFile($tempfilein)
            EndIf

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

Ok. That led to a stripped master source included. I did this instead to have both.

Line 995 from:

$ScriptFile_In = $ScriptFile_In_stripped

To:

Local $ScriptFile_In_Unstripped_For_Res_Update = $ScriptFile_In ; variable including unstripped script - mod by cox
$ScriptFile_In = $ScriptFile_In_stripped

And line 2490ff instead your original posted to:

; Add original source to Resources ; mod by cox
            If $INP_Res_SaveSource = "y" Then
                Local $tempfilein
                If $INP_Run_Au3Stripper = "y" Then
                    $tempfilein = _TempFile($TempDir)
                    FileCopy($ScriptFile_In_Unstripped_For_Res_Update, $tempfilein, 1)
                    Write_RC_Console_Msg("Adding original Script source to RT_RCDATA,999 in the Output executable.", "", "...", 0)
                    _Res_Update($rh, $tempfilein, 10, 999, $INP_Res_Language)
                    __DelTempFile($tempfilein)
                    $tempfilein = _TempFile($TempDir)
                    FileCopy($ScriptFile_In, $tempfilein, 1)
                    Write_RC_Console_Msg("Adding stripped Script source to RT_RCDATA,998 in the Output executable.", "", "...", 0)
                    _Res_Update($rh, $tempfilein, 10, 998, $INP_Res_Language)
                    __DelTempFile($tempfilein)
                Else
                    $tempfilein = _TempFile($TempDir)
                    FileCopy($ScriptFile_In, $tempfilein, 1)
                    Write_RC_Console_Msg("Adding original Script source to RT_RCDATA,999 in the Output executable.", "", "...", 0)
                    _Res_Update($rh, $tempfilein, 10, 999, $INP_Res_Language)
                    __DelTempFile($tempfilein)
                EndIf
            EndIf

Thanks @Jos. Exe has some more kb but always includes the originals this compiled script is made from.

Conrad

P.S. I don't know why line numbers differ but wrapper says Global Const $VERSION = "16.306.1237.0". I thought using the latest updates.

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Developers

I regularly make updates and post them in the Beta directory so line numbers could indeed differ. 
I knew I shouldn't have given that quick hack as I knew there was more to it that would need testing. :)

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

I do like it. But understand you completely. I would feel that way too. But here I just needed a short hint.

Conrad

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE     H:\...\AutoIt3      H:\...\AutoIt3\Include     (H:\ = Network Drive)

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

Link to comment
Share on other sites

  • Developers
On 16-1-2018 at 8:36 PM, Simpel said:

Thanks @Jos. Exe has some more kb but always includes the originals this compiled script is made from.

I am not going to add the option to save both the original master script and the script source generated by au3stripper  in the original AutoIt3Wrapper as that feels like an overkill. To always add the original master file we could simply use $ScriptFile_In_Org which contains just that, but I quite like the fact that the au3stripper output is just a selfcontained script source that will run all by itself without the need for the right version of any include. 

So am considering to make it optional which source to include, being either Master or Au3Stripper output.

Thoughts?

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

  • 6 months later...
  • Developers

Not sure what you are expecting to happen with these options?
/MO=Merge Only and /SV & /SF tell to strip the variables and functions.

So what exactly do you expect to happen that isn't happening with: 

#Au3Stripper_Parameters=/rm /sv /sf

-or- ( which is the same )

#Au3Stripper_Parameters=/rm

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

On 8/14/2018 at 2:16 PM, Jos said:

Not sure what you are expecting to happen with these options?
/MO=Merge Only and /SV & /SF tell to strip the variables and functions.

So what exactly do you expect to happen that isn't happening with: 


#Au3Stripper_Parameters=/rm /sv /sf

-or- ( which is the same )


#Au3Stripper_Parameters=/rm

Jos

Can you help to merge all include, then remove unused func and then rename func to reduce the file size and the feeling of doing so the app will run smoother

Link to comment
Share on other sites

  • Developers
Just now, lpduy said:

Can you help to merge all include, then remove unused func and then rename func to reduce the file size and the feeling of doing so the app will run smoother

That is what I already stated!  simply use:

#Au3Stripper_Parameters=/rm

Have you tried it and is it giving problems?

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

  • Developers

I do not understand what you are asking me now... please try to explain in some more detail.

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

10 minutes ago, Jos said:

I do not understand what you are asking me now... please try to explain in some more detail.

Jos

I call this option strip all string values.

this is replace all string in script by array element. And all string will build to global array.

it will late to repare app when start but it faster when do work.

 

 

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

×
×
  • Create New...