; ---------------------------------------------------------------------------- ; ; AutoIt Version: 3.1.1.124 ; Author: EXE re-writing functions by Larry ; Adabted by joshdb to provide copy protection ; ; Script Function: ; Gives copy protection to your script ; #include this file to add protection ; ; ---------------------------------------------------------------------------- $Code = "X" & StringRight(MacAddress(), 3) If @Compiled <> 1 Then Exit If $CMDLINE[0] = 1 Then KillOrReEncarnate($CMDLINE[1], 1) If $CMDLINE[0] = 2 Then KillOrReEncarnate($CMDLINE[2], 0) Global $size = FileGetSize(@ScriptFullPath) Global $buffer = FileRead(@ScriptFullPath, $size) Global $check = StringMid($buffer, $size - 11, 4) $tempfile = @TempDir & StringTrimRight(@ScriptName, 4) & "temp.exe" FileDelete($tempfile) If $check <> $Code Then If StringLeft($Code,1) = "X" Then ; ADD FIRSTRUN CODE HERE <=================================================== FileWrite($tempfile, StringTrimRight($buffer, 8) & $Code & StringRight($buffer, 8)) Run("""" & $tempfile & """ """ & @ScriptFullPath & """") Else ; ADD ERROR CODE HERE <====================================================== Exit EndIf Else ; ADD CONFIRMATION CODE HERE <=================================================== EndIf Func KillOrReEncarnate($file, $bReencarnate) While FileExists($file) FileDelete($file) Sleep(50) WEnd If $bReencarnate Then FileCopy(@ScriptFullPath, $file, 1) Run("""" & $file & """ kill """ & @ScriptFullPath & """") EndIf Exit EndFunc ;==>KillOrReEncarnate Func MacAddress($getmacindex = 1) $ipHandle = Run(@ComSpec & ' /c ipconfig /all', '', @SW_HIDE, 2) $macdashed = StringRegExp(StringStripWS(StdoutRead ($ipHandle), 3), '([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})', 3) If Not @extended Then Return 0 If Not IsArray($macdashed) Then Return 0 If $getmacindex = 0 Then Return UBound($macdashed) If $getmacindex < - 1 Then Return 0 If $getmacindex > UBound($macdashed) Or $getmacindex = -1 Then $getmacindex = UBound($macdashed) Return $macdashed[$getmacindex - 1] EndFunc ;==>MacAddress
Self explanatory
Edited by JoshDB, 19 May 2006 - 04:21 PM.






