Devjunk Posted March 12, 2007 Share Posted March 12, 2007 Hi AutoIt-Community, i found this nifty little scripting language some days ago and i love it Anyway i've got a little problem while trying to get my script working. I'm trying to read hexed data from an non-autoit .exe-File and replace this hex data with something else what is also in hex. ;So my first idea was reading the whole file.. $ahandle = FileOpen("C:\myexe.exe", 0) $hex = Hex(BinaryString(FileRead($handle))) FileClose($handle) ;... then using StringReplace to replace the hex searching for with another hexvalue ... StringReplace($hex, "376869746530322E626E70", "0000000000000000000000") ; .. and then writing the new hex into a file called myexe_new.exe $bhandle = FileOpen("C:\myexe_new.exe", 2) FileWrite($bhandle, BinaryString($hex)) FileClose($bhandle) Ok, this doesn't works as it was supposed to. So, my question now is: is there some other - maybe better or at least working - way to do this or otherwise is there a way to fix my script? What did I wrong? Or is there even an existing script in these forums for this which i havn't found? Thank you for reading and helping! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 12, 2007 Moderators Share Posted March 12, 2007 Hi AutoIt-Community, i found this nifty little scripting language some days ago and i love it Anyway i've got a little problem while trying to get my script working. I'm trying to read hexed data from an non-autoit .exe-File and replace this hex data with something else what is also in hex. ;So my first idea was reading the whole file.. $ahandle = FileOpen("C:\myexe.exe", 0) $hex = Hex(BinaryString(FileRead($handle))) FileClose($handle) ;... then using StringReplace to replace the hex searching for with another hexvalue ... StringReplace($hex, "376869746530322E626E70", "0000000000000000000000") ; .. and then writing the new hex into a file called myexe_new.exe $bhandle = FileOpen("C:\myexe_new.exe", 2) FileWrite($bhandle, BinaryString($hex)) FileClose($bhandle) Ok, this doesn't works as it was supposed to. So, my question now is: is there some other - maybe better or at least working - way to do this or otherwise is there a way to fix my script? What did I wrong? Or is there even an existing script in these forums for this which i havn't found? Thank you for reading and helping!Walk us through this as if we don't know what you are talking about step by step of what you are attempting and wish the outcome to be In addition, it's always best to provide all the tools necessary to help you efficiently. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Devjunk Posted March 12, 2007 Author Share Posted March 12, 2007 (edited) Okay, i'll try to explain it a bit more detailed I've got this Exe-File, let's call it myexe.exeI need to edit this file like in a hex-editor. In Example, i know the file contains the hex-string "376869746530322E626E70" and now i want to replace this string with another hex-string which is "0000000000000000000000".Finally i want to save the edited file where the mentioned strings were replaced as myexe_new.exe.I don't want to automate the application, i want to edit the file with autoit commands.My english is not the best i guess.. I hope i could at least explain it well.(the editor used on the pics is called xvi32) Edited March 12, 2007 by Devjunk Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 12, 2007 Moderators Share Posted March 12, 2007 I've only been successful with AutoIt and this if I am able to un-pack it first... do the editing... then repack it... Larry and The Kandie Man have written "patchers" though that I'm sure since they go through the binary would be able to do it more successfully. I believe Larry even posted in the Examples forum. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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