peet Posted August 26, 2010 Share Posted August 26, 2010 (edited) Hi =) I often need to edit some of my files with a hex-editor, so I tried to make it a little easier with AutoIt. Cheap .txt files work like a charm but if try to read .exe files, FileOpen refuses to read them. I just get the first two or three characters. $myFile = "..." FileOpen($myFile, 16) $fileContent = FileRead($myFile,FileGetSize($myFile)) FileClose($myFile) ConsoleWrite($fileContent & @CRLF) Edited August 26, 2010 by peet Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted August 26, 2010 Share Posted August 26, 2010 Hi and Welcome to the forums! The third character is a NULL, and ConsoleWrite() uses that to signal end of line or something. If you use lets say BinaryLen() you will see that everything is there. ConsoleWrite(@AutoItExe & @CRLF) $handle = FileOpen(@AutoItExe, 16) $fileContent = FileRead($handle) FileClose($handle) ConsoleWrite(BinaryLen($fileContent) & @CRLF) Also 2 things: 1. Use the autoit tags instead of code tags, gets more easy to read that way. 2. Your usage of the File*() funcs make no sense. See helpfile. .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...
peet Posted August 27, 2010 Author Share Posted August 27, 2010 Yey I finally made it work ConsoleWrite(@AutoItExe & @CRLF) ;Specify your file: $datei = "..." ;find this Hexcode: $findeHex = "..." ;replace it whith this: $ersetzeMit = "..." ;Open the file in binary mode (16) $dateiLesen = FileOpen($datei, 16) $dateiInhalt = FileRead($dateiLesen) FileClose($dateiLesen) ;ConsoleWrite($dateiInhalt & @CRLF) $dateiInhalt = StringReplace($dateiInhalt, $findeHex, $ersetzeMit) ;Mode 2, too create a new modified file $dateiErsetzen = FileOpen($datei, 2) FileWrite($dateiErsetzen, Binary($dateiInhalt)) FileClose($dateiErsetzen) ;ConsoleWrite($dateiInhalt & @CRLF) Now I'm going to make a nice interface. Thanks for the advice, to look at my File* functions. Link to comment Share on other sites More sharing options...
abybaddi009 Posted June 24, 2011 Share Posted June 24, 2011 Yey I finally made it work ConsoleWrite(@AutoItExe & @CRLF) ;Specify your file: $datei = "..." ;find this Hexcode: $findeHex = "..." ;replace it whith this: $ersetzeMit = "..." ;Open the file in binary mode (16) $dateiLesen = FileOpen($datei, 16) $dateiInhalt = FileRead($dateiLesen) FileClose($dateiLesen) ;ConsoleWrite($dateiInhalt & @CRLF) $dateiInhalt = StringReplace($dateiInhalt, $findeHex, $ersetzeMit) ;Mode 2, too create a new modified file $dateiErsetzen = FileOpen($datei, 2) FileWrite($dateiErsetzen, Binary($dateiInhalt)) FileClose($dateiErsetzen) ;ConsoleWrite($dateiInhalt & @CRLF) Now I'm going to make a nice interface. Thanks for the advice, to look at my File* functions. OMG! OMG! OMG! You are awesome, thanks a million!!! #include<god.h>_asm //don't look!!![spoiler]x DB "aby'y DB 'GOD'tmp DB ? MOV CX,3 LEA SI, y LEA DI, tmp REP MOVSB LEA SI, x LEA DI, y REP MOVSB LEA SI, tmp LEA DI, x REP MOVSB MOV AH,09 MOV DX, OFFSET x INT 21h MOV DX, OFFSET y INT 21h[/spoiler] 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