wkeeter Posted December 28, 2006 Share Posted December 28, 2006 I've been searching and trying things for days and i'm hereto tell you im confused as heck and cant get nothing to work.Senario:FileName = test.binIn a hex editor i can goto offset 0x350 and i see example "Please Change Me Now"But i want it changed to "Changed" or what ever.Ok 2 delimas i'm running into is one changing this hex value, and the other is whenyou wright "Changed" it leaves "Change Me Now" still in the test.bin file.I would also like to know how to change these values to null or 00's in the hex valuebecuase they are no longer needed.Really what i'm looking for is some sample code if at all possible because i really am confused.And the closest i've found in the forums is this post http://www.autoitscript.com/forum/index.php?showtopic=12604 But that even confuses me more. I'd even be happy if someone knew of a commandline utility that would accomplish the same thing but googling for days hasn't brought much help either.Any help would be appreciated.Thanks Link to comment Share on other sites More sharing options...
Zedna Posted December 28, 2006 Share Posted December 28, 2006 See my hexa patcher: here Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
wkeeter Posted December 29, 2006 Author Share Posted December 29, 2006 I would Zedna If i could read it. I tried to spend some time with a translator but even a translator dont even know what a lot of these words are. Any chance u can convert that to english? Thanks Link to comment Share on other sites More sharing options...
Zedna Posted December 29, 2006 Share Posted December 29, 2006 I would Zedna If i could read it. I tried to spend some time with a translator but even a translator dont even know what a lot of these words are. Any chance u can convert that to english? Thanks Try something like this you can simplicify it even more... expandcollapse popup#NoTrayIcon #include "APIFileReadWrite.au3" Global $def_rows, $count ; 00000073: 65 FC _FileReadToArray('c:\file_def.txt', $def_rows) $count = $def_rows[0] Dim $values[$count + 1][3] $values[0][0] = $count For $i = 1 To $count $line = StringStripWS($def_rows[$i],3) $line = StringSplit($line, ' ') ; 00000073: 65 FC If $line[0] <> 3 Then MsgBox(48,"Error","Definition file contains bad data") Exit EndIf $line[1] = StringTrimRight($line[1], 1) ; remove char : $values[$i][0] = $line[1] $values[$i][1] = $line[2] $values[$i][2] = $line[3] Next $f = _APIFileOpen('c:\file_to_patch.exe') For $i = 1 To $values[0][0] _APIFileSetPos($f, Dec($values[$i][0])) $written = _APIFileWrite($f, $values[$i][2], 1) If $written <> 1 Then MsgBox(48,"Error","Error in writing data") Exit EndIf Next _APIFileClose($f) Func _FileReadToArray($sFilePath, ByRef $aArray) Local $hFile $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $aArray = StringStripCR( FileRead($hFile, FileGetSize($sFilePath))) ; remove last @CRLF to avoid empty last line in array of definition values If StringRight($aArray,1) = @LF Then $aArray = StringTrimRight($aArray,1) $aArray = StringSplit( $aArray, @LF) FileClose($hFile) Return 1 EndFunc Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
wkeeter Posted December 30, 2006 Author Share Posted December 30, 2006 Try something like this you can simplicify it even more... expandcollapse popup#NoTrayIcon #include "APIFileReadWrite.au3" Global $def_rows, $count ; 00000073: 65 FC _FileReadToArray('c:\file_def.txt', $def_rows) $count = $def_rows[0] Dim $values[$count + 1][3] $values[0][0] = $count For $i = 1 To $count $line = StringStripWS($def_rows[$i],3) $line = StringSplit($line, ' ') ; 00000073: 65 FC If $line[0] <> 3 Then MsgBox(48,"Error","Definition file contains bad data") Exit EndIf $line[1] = StringTrimRight($line[1], 1) ; remove char : $values[$i][0] = $line[1] $values[$i][1] = $line[2] $values[$i][2] = $line[3] Next $f = _APIFileOpen('c:\file_to_patch.exe') For $i = 1 To $values[0][0] _APIFileSetPos($f, Dec($values[$i][0])) $written = _APIFileWrite($f, $values[$i][2], 1) If $written <> 1 Then MsgBox(48,"Error","Error in writing data") Exit EndIf Next _APIFileClose($f) Func _FileReadToArray($sFilePath, ByRef $aArray) Local $hFile $hFile = FileOpen($sFilePath, 0) If $hFile = -1 Then SetError(1) Return 0 EndIf $aArray = StringStripCR( FileRead($hFile, FileGetSize($sFilePath))) ; remove last @CRLF to avoid empty last line in array of definition values If StringRight($aArray,1) = @LF Then $aArray = StringTrimRight($aArray,1) $aArray = StringSplit( $aArray, @LF) FileClose($hFile) Return 1 EndFunc Thank You Much! 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