sandin Posted June 13, 2008 Posted June 13, 2008 FileRead() can read content of a textual based files, but what I need is to read content of any file (.exe .jpg .mp3, etc...) I found in help: _WinAPI_ReadFile () and _WinAPI_CreateFile () but in the help there aren't any examples, so I couldn't really understand them. I also found some topics on this forum, but couldn't figure from them how to read file's content. Can anyone give me a simple example of reading any file's content? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll
ProgAndy Posted June 13, 2008 Posted June 13, 2008 You can read all files with FileOPen, FileREad and FileClose, but only in binary mode. Example: $file = FileOPen("C:\test.exe",16) $src = FileRead($file) FileClose($file) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
sandin Posted June 13, 2008 Author Posted June 13, 2008 (edited) I tried, but I get first several characters of file, and not the entire file: $file1 = FileOpenDialog("choose file", "", "ALL (*.*)") $file = FileOPen($file1,16) $src = BinaryToString(FileRead($file)) MsgBox(0, "wtf, is this?", $src) FileClose($file) edit: P.S. anyway, tnx for reply Edited June 13, 2008 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll
ReaImDown Posted June 13, 2008 Posted June 13, 2008 I tried, but I get first several characters of file, and not the entire file: $file1 = FileOpenDialog("choose file", "", "ALL (*.*)") $file = FileOPen($file1,16) $src = BinaryToString(FileRead($file)) MsgBox(0, "wtf, is this?", $src) FileClose($file) edit: P.S. anyway, tnx for reply 90% of a file...is to automate the .exe... .mp3 or .mpeg etc... therefore you will not be able to read the biggest chunk of coding, but if theres 'english' in there, you will be able to read it [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
dcer Posted June 13, 2008 Posted June 13, 2008 Hmm... if you just want raw code/text out of it, you could try to use FileMove to rename the file to .txt and then read it
ReaImDown Posted June 13, 2008 Posted June 13, 2008 Hmm... if you just want raw code/text out of it, you could try to use FileMove to rename the file to .txt and then read itjust use HexEdit [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]
d4rk Posted June 13, 2008 Posted June 13, 2008 But then, what can we see from them ? somethings like this : }♂▐MÜ▌ [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys
dcer Posted June 13, 2008 Posted June 13, 2008 (edited) just use HexEdit HexEdit? Not recognized with my autoit , are you sure there's a function with that name? EDIT: Doh... ofc you're talking about the program HexEdit... my bad xD Edited June 13, 2008 by dcer
d4rk Posted June 13, 2008 Posted June 13, 2008 no, maybe it's mentioning about an external program [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys
ProgAndy Posted June 13, 2008 Posted June 13, 2008 I tried, but I get first several characters of file, and not the entire file: $file1 = FileOpenDialog("choose file", "", "ALL (*.*)") $file = FileOPen($file1,16) $src = BinaryToString(FileRead($file)) MsgBox(0, "wtf, is this?", $src) FileClose($file) edit: P.S. anyway, tnx for reply You mustn't convert it with BinaryToString. You CAN READ IT ONLY IN BINARY MODE ! Just remove BinaryToString and it works fine. *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
sandin Posted June 13, 2008 Author Posted June 13, 2008 You mustn't convert it with BinaryToString. You CAN READ IT ONLY IN BINARY MODE ! Just remove BinaryToString and it works fine. I see.... so there is no way to get file's content like the one I get when I open any file in notepad, cause I can't convert binary to string anymore? p.s. I tried hex: $file1 = FileOpenDialog("choose file", "", "ALL (*.*)") $file = FileOPen($file1,16) $src = Hex(FileRead($file)) MsgBox(0, "wtf is this?", BinaryToString("0x" & $src)) FileClose($file)oÝ÷ Ù©Ýjëh×6#include <string.au3> $file1 = FileOpenDialog("choose file", "", "ALL (*.*)") $file = FileOPen($file1,16) $src = _StringToHex(FileRead($file)) MsgBox(0, "wtf is this?", BinaryToString(_HexToString($src))) FileClose($file) and both giving me same results (only first part of the file), but if binaryToString is not working, then how can I convert read binary code into file I read in the first place? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll
ProgAndy Posted June 13, 2008 Posted June 13, 2008 (edited) What happens, if you open a file in Notepad, save it and close it again? Right. the executable is changed and you can't run it anymore. Why? I think Notepad changes all Chr(0) ( in Hex/Binary: 00 ) to Space. You could do that, too, but then you can't save the file anymore properly. e.g.: $file = FileOpen("C:\WINDOWS\Notepad.exe",16) $str = FileRead($file) FileClose($file) $x = StringRegExpReplace($str,"((?:.{2})*?)00","$1.20"); Workaround, because $120 in replace doesn't work: $1.20 $x = StringReplace($x,".","")) ; remove the points from Workaround. $x = BinaryToString($x) MsgBox(0, '', $x) Edited June 13, 2008 by ProgAndy *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
sandin Posted June 13, 2008 Author Posted June 13, 2008 oh... I see what you mean. :/ tnx, that was very informative. I wanted to know if I can read file's content, so I can split a file into several smaller files, and then recreate the original file from those small files. I thought I can read file's content, then split it into smaller pieces, save each one in a different file, and eventually read those small file's parts, and recreate the original file again. Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll
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