Proph Posted June 19, 2007 Share Posted June 19, 2007 (edited) Autoit Version 3.2.4.9 I used to be able to read the Windows pidgen.dll file into a variable but now it only seems to read the first 2 characters and that's it. I guess it has something to do with the blank spaces after the first 2 characters. I have attached a zip file with a pidgen.dll and a sample filereadbug.au3 filereadbug.au3: $file = (@ScriptDir&'\PIDGEN.DLL') $size = FileGetSize($file) $string = FileRead($file, $size) msgbox(0, 'File String is', $string) When you run the filereadbug.au3 all it returns is: CODEMZ But it should return a lot more: CODEMZ ÿÿ ¸ @ è º ´ Í!¸LÍ!This program cannot be run in DOS mode. $ B1ôÜ#_§Ü#_§Ü#_§m, §Ø#_§,P§ß#_§Ü#^§ñ#_§,§Õ#_§,§Ý#_§,§Ý#_§, §Ö#_§,?§Õ#_§,§Ý#_§RichÜ#_§ PE L âA à - N m) ` ;t j2 p\ Î (X d p P T À ¼ .text >M N `.data | ` R @ À.rsrc P p T @ @.reloc ø \ @ B F\ 2\ "\ \ \ ¼[ °[ Y ¨Y ´Y ÊY äY üY Z Z ,Z <Z LZ \Z lZ Z Z °Z ¾Z ÐZ ÞZ êZ üZ [ ([ B[ and so on... I'm not gonna post the entire file contents... but I am sure you get the picture. Edit: What I am trying to accomplish is I want to detect if the string '#;tHARDWARE' exists or not. I don't need it to be in the msgbox but I do need to be able to read it from the $string variable. Edited June 19, 2007 by Proph Link to comment Share on other sites More sharing options...
Proph Posted June 19, 2007 Author Share Posted June 19, 2007 (edited) I almost found my answer. It is caused by a difference with the new Binary stuff.For anyone else looking for an answer read this thread:http://www.autoitscript.com/forum/index.ph...eread&st=15 Edited June 19, 2007 by Proph Link to comment Share on other sites More sharing options...
Proph Posted June 19, 2007 Author Share Posted June 19, 2007 hmmm... well it seems there is still an issue. even if I use FileOpen($file, 16) it still doesn't work correctly. Once I use the BinaryToString($string) it still only shows "MZ". I was able to do a FileWrite which showed the entire file string... but then when I tried to use a StringInStr to find a string within it... it fails. CODE$file = ("PIDGEN.DLL") $open = FileOpen($file, 16) $size = FileGetSize ( $file ) $string = FileRead ($open, $size) FileWrite('Testit.txt', $string) $string = StringReplace($string, chr(0), "?") FileWrite('Testitagain.txt', $string) FileClose($open) If StringInStr ($string, '#;tHARDWARE') Then msgbox(0, 'Failed', 'Did not find it') And is there a reason that Testit.txt and Testitagain.txt are so different in this example? Link to comment Share on other sites More sharing options...
mrbond007 Posted June 19, 2007 Share Posted June 19, 2007 hmmm... well it seems there is still an issue.even if I use FileOpen($file, 16) it still doesn't work correctly. Once I use the BinaryToString($string) it still only shows "MZ". I was able to do a FileWrite which showed the entire file string... but then when I tried to use a StringInStr to find a string within it... it fails.CODE$file = ("PIDGEN.DLL")$open = FileOpen($file, 16)$size = FileGetSize ( $file )$string = FileRead ($open, $size)FileWrite('Testit.txt', $string)$string = StringReplace($string, chr(0), "?")FileWrite('Testitagain.txt', $string)FileClose($open)If StringInStr ($string, '#;tHARDWARE') Then msgbox(0, 'Failed', 'Did not find it')And is there a reason that Testit.txt and Testitagain.txt are so different in this example?That's right, when you use version higher than 3.2.2.0 you get this problem. Only the AutoIt team might be able to help you with this. Projects : Space Regain - Memory Fusion - PWGT - Chip-ITGames : BrainPain - BrainPain Director's Cut - ProSpeed Games Pack (New)Vista vs XP : the forbidden fight Link to comment Share on other sites More sharing options...
Siao Posted June 19, 2007 Share Posted June 19, 2007 (edited) And is there a reason that Testit.txt and Testitagain.txt are so different in this example?If you perform string operation such as StringReplace on a binary string, it becomes string of chars.Before writing to file, convert it back with Binary(). Edited June 19, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
jpm Posted June 19, 2007 Share Posted June 19, 2007 To summarize. now you need to FileOpen a file you want to read in binary mode FileRead will return a Binary data that can be used with BinaryMid if you want to extract a part of it. There is no StringReplace/StringInstr equivalent on Binary data. 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