willichan Posted October 11, 2010 Share Posted October 11, 2010 This is a script I banged out for a project where, for some reason, my client's anti-virus program detected any compiled script that used FileInstall() as infected. (They were using some program from China I was not familiar with, nor could I read the messages.) It creates an include file patterned somewhat after the SQLite.dll.au3 that is included with AutoIt. This makes the resulting EXE file a little larger than FileInstall() does (even after /striponly), but it solved my particular problem.It is intended to be compiled, and then drag/drop the binary file onto it to do the conversion.If the dropped file is a DLL file, it will add the DllOpen() and DllClose() commands to the startup and shutdown functions.InlineMe.au3expandcollapse popupConst $blocksize = 512 Dim $fromfile, $fromname, $curpos, $tag, $tofile, $toname, $ext, $name If $CmdLine[0] = 0 Then Exit Else $fromname = $CmdLine[1] EndIf If Not FileExists($fromname) Then Exit $toname = $fromname & ".au3" $fromfile = StringToBinary(BinaryToString(FileRead($fromname))) $curpos = 0 $tofile = FileOpen($toname, 2) If $tofile = -1 Then Exit If StringInStr($fromname, ".") Then $ext = StringUpper(StringRight($fromname, StringLen($fromname) - StringInStr($fromname, ".", 0, -1))) Else $ext = "" EndIf $name = StringRight($fromname, StringLen($fromname) - StringInStr($fromname, "\", 0, -1)) FileWriteLine($tofile, '#include-once') FileWriteLine($tofile, '#include <file.au3>') FileWriteLine($tofile, '') FileWriteLine($tofile, 'Func _' & CleanName($name) & '_Startup()') FileWriteLine($tofile, ' Local $Inline_Filename = _TempFile(@TempDir, "~", ".' & $ext & '")') FileWriteLine($tofile, ' Local $InlineOutFile = FileOpen($Inline_Filename, 2)') FileWriteLine($tofile, ' If $InlineOutFile = -1 Then Return SetError(1, 0, "")') FileWriteLine($tofile, '') FileWriteLine($tofile, ' FileWrite($InlineOutFile, _' & CleanName($name) & '_Inline())') FileWriteLine($tofile, ' FileClose($InlineOutFile)') If $ext = "DLL" Then FileWriteLine($tofile, ' If DllOpen($Inline_Filename) = -1 Then') FileWriteLine($tofile, ' Return SetError(1, 0, "")') FileWriteLine($tofile, ' Else') FileWriteLine($tofile, ' Return $Inline_Filename') FileWriteLine($tofile, ' EndIf') Else FileWriteLine($tofile, ' Return $Inline_Filename') EndIf FileWriteLine($tofile, 'EndFunc ;==>_' & CleanName($name) & '_Startup') FileWriteLine($tofile, '') FileWriteLine($tofile, 'Func _' & CleanName($name) & '_Shutdown($Inline_Filename)') If $ext = "DLL" Then FileWriteLine($tofile, ' DllClose($Inline_Filename)') EndIf FileWriteLine($tofile, ' FileDelete($Inline_Filename)') FileWriteLine($tofile, 'EndFunc ;==>_' & CleanName($name) & '_Shutdown') FileWriteLine($tofile, '') FileWriteLine($tofile, 'Func _' & CleanName($name) & '_Inline()') FileWriteLine($tofile, ' Local $sData') FileWriteLine($tofile, " #region ;" & $name) While $curpos < StringLen($fromfile) If $curpos = 0 Then $curpos = 1 $tag = ' $sData = "' Else $tag = ' $sData &= "' EndIf FileWriteLine($tofile, $tag & StringMid($fromfile, $curpos, $blocksize) & '"') $curpos += $blocksize WEnd FileWriteLine($tofile, " #endregion ;" & StringRight($fromname, StringLen($fromname) - StringInStr($fromname, "\", 0, -1))) FileWriteLine($tofile, ' Return Binary($sData)') FileWriteLine($tofile, 'EndFunc ;==>_' & CleanName($name) & '_Inline') FileClose($tofile) Func CleanName($name) $name = StringReplace($name, ".", "") $name = StringReplace($name, " ", "") $name = StringReplace($name, "[", "") $name = StringReplace($name, "]", "") $name = StringReplace($name, "(", "") $name = StringReplace($name, ")", "") $name = StringReplace($name, "{", "") $name = StringReplace($name, "}", "") Return $name EndFunc ;==>CleanName LukeLe and Sudiro 1 1 My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
wakillon Posted October 12, 2010 Share Posted October 12, 2010 (edited) It works well but why use a random file name, and don't put an autostart to the new script for get the file ? Edited October 12, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
willichan Posted October 12, 2010 Author Share Posted October 12, 2010 but why use a random file nameI generally try to make my includes as general use as possible. Creating the file as a temp file allows for it to be used where you may not intend for the file to be permanently installed on the system the script runs on. Since I don't want to stomp on temp files being used by another script/app, I use the _TempFile() function to ensure a unique name. Since the filename is made available to you, you can move/copy/rename as you need to, if you do want it kept.and don't put an autostart to the new script for get the file ?Since I don't know what the file is, how it will be used, or even if it is executable; it does not make sense to autostart it here. It would be up to the script author to determine when and how the file is used. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
jvanegmond Posted October 12, 2010 Share Posted October 12, 2010 I know which anti virus you mean. It's eSafe/Aladdin with one of their many variants which all use the same definition library. github.com/jvanegmond Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 12, 2010 Share Posted October 12, 2010 The script works well and I can see myself using it (actually I just did). 4 stars from me! .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
willichan Posted October 13, 2010 Author Share Posted October 13, 2010 @Manadar You are probably right. I can make my way around Japanese screens, but Chinese was a bit beyond me, so I had no idea what it was. @AdmiralAlkex Thank you. I appreciate it. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
yahaosoft Posted November 15, 2012 Share Posted November 15, 2012 nice works! thanks for sharing it. five start voted. Thanksgiving... Link to comment Share on other sites More sharing options...
Sudiro Posted October 24, 2016 Share Posted October 24, 2016 On 12/10/2010 at 4:02 AM, willichan said: This is a script I banged out for a project where, for some reason, my client's anti-virus program detected any compiled script that used FileInstall() as infected. (They were using some program from China I was not familiar with, nor could I read the messages.) It creates an include file patterned somewhat after the SQLite.dll.au3 that is included with AutoIt. This makes the resulting EXE file a little larger than FileInstall() does (even after /striponly), but it solved my particular problem. It is intended to be compiled, and then drag/drop the binary file onto it to do the conversion. If the dropped file is a DLL file, it will add the DllOpen() and DllClose() commands to the startup and shutdown functions. InlineMe.au3 expandcollapse popupConst $blocksize = 512 Dim $fromfile, $fromname, $curpos, $tag, $tofile, $toname, $ext, $name If $CmdLine[0] = 0 Then Exit Else $fromname = $CmdLine[1] EndIf If Not FileExists($fromname) Then Exit $toname = $fromname & ".au3" $fromfile = StringToBinary(BinaryToString(FileRead($fromname))) $curpos = 0 $tofile = FileOpen($toname, 2) If $tofile = -1 Then Exit If StringInStr($fromname, ".") Then $ext = StringUpper(StringRight($fromname, StringLen($fromname) - StringInStr($fromname, ".", 0, -1))) Else $ext = "" EndIf $name = StringRight($fromname, StringLen($fromname) - StringInStr($fromname, "\", 0, -1)) FileWriteLine($tofile, '#include-once') FileWriteLine($tofile, '#include <file.au3>') FileWriteLine($tofile, '') FileWriteLine($tofile, 'Func _' & CleanName($name) & '_Startup()') FileWriteLine($tofile, ' Local $Inline_Filename = _TempFile(@TempDir, "~", ".' & $ext & '")') FileWriteLine($tofile, ' Local $InlineOutFile = FileOpen($Inline_Filename, 2)') FileWriteLine($tofile, ' If $InlineOutFile = -1 Then Return SetError(1, 0, "")') FileWriteLine($tofile, '') FileWriteLine($tofile, ' FileWrite($InlineOutFile, _' & CleanName($name) & '_Inline())') FileWriteLine($tofile, ' FileClose($InlineOutFile)') If $ext = "DLL" Then FileWriteLine($tofile, ' If DllOpen($Inline_Filename) = -1 Then') FileWriteLine($tofile, ' Return SetError(1, 0, "")') FileWriteLine($tofile, ' Else') FileWriteLine($tofile, ' Return $Inline_Filename') FileWriteLine($tofile, ' EndIf') Else FileWriteLine($tofile, ' Return $Inline_Filename') EndIf FileWriteLine($tofile, 'EndFunc ;==>_' & CleanName($name) & '_Startup') FileWriteLine($tofile, '') FileWriteLine($tofile, 'Func _' & CleanName($name) & '_Shutdown($Inline_Filename)') If $ext = "DLL" Then FileWriteLine($tofile, ' DllClose($Inline_Filename)') EndIf FileWriteLine($tofile, ' FileDelete($Inline_Filename)') FileWriteLine($tofile, 'EndFunc ;==>_' & CleanName($name) & '_Shutdown') FileWriteLine($tofile, '') FileWriteLine($tofile, 'Func _' & CleanName($name) & '_Inline()') FileWriteLine($tofile, ' Local $sData') FileWriteLine($tofile, " #region ;" & $name) While $curpos < StringLen($fromfile) If $curpos = 0 Then $curpos = 1 $tag = ' $sData = "' Else $tag = ' $sData &= "' EndIf FileWriteLine($tofile, $tag & StringMid($fromfile, $curpos, $blocksize) & '"') $curpos += $blocksize WEnd FileWriteLine($tofile, " #endregion ;" & StringRight($fromname, StringLen($fromname) - StringInStr($fromname, "\", 0, -1))) FileWriteLine($tofile, ' Return Binary($sData)') FileWriteLine($tofile, 'EndFunc ;==>_' & CleanName($name) & '_Inline') FileClose($tofile) Func CleanName($name) $name = StringReplace($name, ".", "") $name = StringReplace($name, " ", "") $name = StringReplace($name, "[", "") $name = StringReplace($name, "]", "") $name = StringReplace($name, "(", "") $name = StringReplace($name, ")", "") $name = StringReplace($name, "{", "") $name = StringReplace($name, "}", "") Return $name EndFunc ;==>CleanName Dear.. My Exe File 289 kb.. Drop to inlineme Execute file.. Display command Prompt.. File to big to fit in memory.. How to change blocksize .. ? Thank you.. Link to comment Share on other sites More sharing options...
willichan Posted October 31, 2016 Author Share Posted October 31, 2016 On Monday, October 24, 2016 at 3:32 PM, Sudiro said: My Exe File 289 kb.. Drop to inlineme Execute file.. Display command Prompt.. File to big to fit in memory.. How to change blocksize .. ? blocksize is set in the first line of the script. It won't change much as far as the final size goes though. My UDFs: Barcode Libraries, Automate creation of any type of project folder, File Locking with Cooperative Semaphores, Inline binary files, Continue script after reboot, WinWaitMulti, Name Aggregator, Enigma, CornedBeef Hash Link to comment Share on other sites More sharing options...
BisherSH Posted February 10, 2017 Share Posted February 10, 2017 (edited) Hi, Great script , thanks for sharing I ran the script and created the SQLite.dll.au3 file , and included it in my script but im still getting error "SQLite3.dll Can't be Loaded!" I will really appreciate it if you took a look at my code below Thanks #include <SQLite.au3> #include <SQLite.dll.au3> _SQLite_Startup() If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!") Exit -1 EndIf $DB = _SQLite_Open("C:\Temp\Test.db") $Action = "TestAction" $Time = @HOUR&":"&@MIN&":"&@SEC $Date = @YEAR&"-"&@MON&"-"&@MDAY $User = @UserName $Computer = @ComputerName $DC = @LogonServer If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Couldnt open Database") Exit -1 EndIf _SQLite_Exec($DB,"INSERT INTO QLogs (Action,Date,Time,User,Computer,DC) " & _ "VALUES ("& _SQLite_FastEscape($Action) & "," & _ _SQLite_FastEscape($Date) & "," & _ _SQLite_FastEscape($Time) & "," & _ _SQLite_FastEscape($User) & "," & _ _SQLite_FastEscape($Computer) & "," & _ _SQLite_FastEscape($DC) & ");") If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Couldnt insert!") Exit -1 EndIf _SQLite_Shutdown() Edited February 10, 2017 by BisherSH Link to comment Share on other sites More sharing options...
AdamUL Posted June 25, 2018 Share Posted June 25, 2018 I know this is an old post, but I wanted to give a solution to the problem for anyone that comes up on this topic. The _Starup and _Shutdown functions created by the Inline script are not being called. The updated script is below. expandcollapse popup#include <SQLite.au3> #include "SQLite.dll.au3" ;Created by InlineMe.au3 Global $sSQLiteDLL = _SQLitedll_Startup() _SQLite_Startup($sSQLiteDLL) If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "SQLite3.dll Can't be Loaded!") Exit -1 EndIf Global $DB = _SQLite_Open("C:\Temp\Test.db") Global $Action = "TestAction" Global $Time = @HOUR&":"&@MIN&":"&@SEC Global $Date = @YEAR&"-"&@MON&"-"&@MDAY Global $User = @UserName Global $Computer = @ComputerName Global $DC = @LogonServer If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Couldnt open Database") Exit -1 EndIf _SQLite_Exec($DB,"INSERT INTO QLogs (Action,Date,Time,User,Computer,DC) " & _ "VALUES ("& _SQLite_FastEscape($Action) & "," & _ _SQLite_FastEscape($Date) & "," & _ _SQLite_FastEscape($Time) & "," & _ _SQLite_FastEscape($User) & "," & _ _SQLite_FastEscape($Computer) & "," & _ _SQLite_FastEscape($DC) & ");") If @error Then MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Couldnt insert!") Exit -1 EndIf _SQLite_Shutdown() _SQLitedll_Shutdown($sSQLiteDLL) Adam Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now