Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/17/2013 in all areas

  1. willichan

    Create File

    Quotes are a little off. You might try $logfile = $Validation & "\" & @UserName & ".log" FileWriteline($logfile, @UserName) ;although you probably don't need this line since it is the file name. FileWriteLine($logfile, _Now()) FileWriteLine($logfile, @CRLF) ---edit--- You don't really need a function to create the file, since FileWriteLine will create it for you if it does not exist.
    1 point
  2. Remember Matrix? Spoon boy: Do not try and bend the spoon. That's impossible. Instead... only try to realize the truth. Neo: What truth? Spoon boy: There is no spoon. Neo: There is no spoon? Spoon boy: Then you'll see, that it is not the spoon that bends, it is only yourself. Do not try to find .rdata, find "AutoIt v3 GUI" $sCustomParameter = "yehia's class" $sDefaultParameter = "AutoIt v3 GUI" $AutoItBin = FileOpenDialog("Choose file", "", "Autoit compiled script (*.exe)|All files (*)") ConsoleWrite(">Modifying default parameter." & @CRLF) _CustomizeAutoIt3Parameter($AutoItBin, $sDefaultParameter, $sCustomParameter) Switch @error Case 1 ConsoleWrite("- Select different parameter to modify to. Skipping modification." & @CRLF) Case 3 ConsoleWrite("- Default parameter couldn't be located. Skipping modification." & @CRLF) Case 2, 4 ConsoleWrite("- Modifying default parameter cannot proceed. Skipping modification." & @CRLF) Case 5, 6 ConsoleWrite("- Internal error. Skipping default parameter modification." & @CRLF) Case False ConsoleWrite('+>Default parameter successfully modified to: "' & $sCustomParameter & '"' & @CRLF) EndSwitch Func _CustomizeAutoIt3Parameter($AutoItBin, $sDefaultParameter, ByRef $sCustomParameter) If Not $sCustomParameter Or $sCustomParameter == $sDefaultParameter Then Return SetError(1, 0, "") ; $sCustomParameter must be specified and different than original EndIf ; Making sure that $sCustomParameter will be the same size as $sDefaultClass. ; If it's bigger it will be truncated, if smaller anti-truncated (don't know the word) ; Also, converting to UTF16 Little Endian. Local $tCustomParameter = DllStructCreate("byte[" & 2 * StringLen($sDefaultParameter) & "]") DllStructSetData($tCustomParameter, 1, StringToBinary($sCustomParameter, 2)) Local $bCustomParameter = DllStructGetData($tCustomParameter, 1) $sCustomParameter = StringReplace(BinaryToString($bCustomParameter, 2), Chr(0), "") ; will use this to inform about the change after it's done ; Converting $sDefaultParameter to binary (UTF16 Little Endian) Local $bDefaultParameter = StringToBinary($sDefaultParameter, 2) ; reading $AutoItBin, binary mode Local $hBinHandle = FileOpen($AutoItBin, 16) If $hBinHandle = -1 Then Return SetError(2, 0, "") ; $AutoItBin culdn't be opened for reading EndIf Local $bBinary = FileRead($hBinHandle) FileClose($hBinHandle) If StringInStr(BinaryToString($bBinary), BinaryToString("0x497420697320612076696F6C6174696F" & _ "6E206F6620746865204175746F497420" & _ "45554C4120746F20617474656D707420" & _ "746F207265766572736520656E67696E" & _ "65657220746869732070726F6772616D"), 1) Then Exit ConsoleWrite("! Not allowed!!!" & @CRLF); don't be an ass EndIf ; Finding the offset in $AutoItBin where Parameter is written. ; Will use StringInStr() function to find offset after properly convert all binary data to coresponding strings. ; If there is no $sDefaultParameter inside $AutoItBin (no offset) return error. ; Real binary offset is this one minus 1; AutoIt takes offset 0 to be position 1. Local $iOffset = StringInStr(BinaryToString($bBinary), BinaryToString($bDefaultParameter), 1) If Not $iOffset Then Return SetError(3, 0, "") ; For some reason there is no $sDefaultParameter inside $AutoItBin EndIf ; One more checking needs to be done. That is to confirm that $sDefaultParameter is to be found at only one place inside $AutoItBin, ; to avoid possible wrong modification(s). ; Looking for the second occurence of $sDefaultParameter inside $AutoItBin and if found returning error. If StringInStr(BinaryToString($bBinary), BinaryToString($bDefaultParameter), 1, 2) Then Return SetError(4, 0, "") ; Exact unique location of $sDefaultParameter cannot be determined (multiple occurrences) EndIf ; Actual replacing can take place. ; Again using functions that handles strings since there is no binary versions of such. ; Binary data needs to be converted to coresponding strings before replacements. ; StringReplace() returns new string, so converting to new binary data is needed. Local $bBinaryNew = Binary(StringReplace(BinaryToString($bBinary), $iOffset, BinaryToString($bCustomParameter))) ; Will write new data to $AutoItBin now. $hBinHandle = FileOpen($AutoItBin, 18) If @error Then Return SetError(5, 0, "") ; $AutoItBin culdn't be opened for writing EndIf If Not FileWrite($hBinHandle, $bBinaryNew) Then FileClose($hBinHandle) Return SetError(6, 0, "") ; Problem writing. Highly unlikely to happen. EndIf FileClose($hBinHandle) Return SetError(0, 0, 1) ; All done! Return 1, set @error to 0. EndFunc ;==>_CustomizeAutoIt3Parameter There are few things that you should consider. AutoIt EULA strictly forbid any modification of AutoIt3.exe and AutoIt3_x64.exe. AutoIt EULA is also not completely clear about some things, but Jon and devs are lately very clear about compiled scripts not being their property nor responsibility. That would mean you can do what ever you want with them, they are yours if you compiled them.
    1 point
×
×
  • Create New...