Ejoc Posted May 12, 2005 Author Share Posted May 12, 2005 I'm not sure how I would do it using UDFs since the FileRead and FileWrite are dealing with text files. I know I could whip up a dll to handle it. Oh well maybe I'll get a good idea on the subject. Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
layer Posted May 12, 2005 Share Posted May 12, 2005 How bout modifying FileWrite/Read in the source code of autoit with whatever idea you had to edit binaries or whatever... And add like maybe an optional paremeter to specify if it's binary, or anything else? Does this make sense...? FootbaG Link to comment Share on other sites More sharing options...
Ejoc Posted May 12, 2005 Author Share Posted May 12, 2005 Ah, Microsoft already wrote the read/write functions for me, so I can just make a UDF. Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Ejoc Posted May 12, 2005 Author Share Posted May 12, 2005 How would we modify binary data? I suppose creatively using DLLStructCreate to handle pointer info... hmmmIn particular, for example, I am wondering how we would edit the "exif" info of a JPEG file?Lar.<{POST_SNAPBACK}>I'm 1/2 way done, I have the read working. So right now it will read the file and create a DllStruct that is:DllStructCreate("byte[" & FileGetSize() & "];int"); where the int is the bytes readSo you could1) Modify byte by byte with DllStructSetData($p,1,$newByte,$ByteNumber)2) If you know a struct at a certain location in the file, ie there is a jpeg header you could after reading the file do a $header = DLLStructCreate("int;int",DllStructGetPtr($p) + $offsettoheader) Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Ejoc Posted May 12, 2005 Author Share Posted May 12, 2005 (edited) Added 2 new UDF's to DllStruct.au3 _FileReadToDllStruct($szFileName) _FileWriteFromDllStruct($p,$szFileName) See post #1 An example: expandcollapse popup#cs vi:ts=4 sw=4: Example, displays first 4k of a binary file in hex Ejoc #ce #include <GUIConstants.au3> #include <DllStruct.au3> GUICreate("HexView",400,400) $hBrowse = GUICtrlCreateButton("Browse",200,3) $hEdit = GUICtrlCreateEdit("",0,30,400,370) GUICtrlSetFont(-1,9,400,0,"Lucida Console") GUISetState() while 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $hBrowse $file = FileOpenDialog("Open File","","ALL (*.*)",1) If Not @Error Then $p = _FileReadToDllStruct($file) If @error Then MsgBox(0,"error","Read Failed") exit EndIf $s = "" $iLen = DllStructGetData($p,2) If $iLen > 4096 Then $iLen = 4096 for $i = 1 To $iLen $s &= HEX(DllStructGetData($p,1,$i),2) & " " If NOT MOD($i,8) Then $s &= " " If NOT MOD($i,16) Then $s &= @CRLF Next GUICtrlSetData($hEdit,$s) DllStructDelete($p) EndIf EndSelect wend Edited May 12, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
jpm Posted May 12, 2005 Share Posted May 12, 2005 Added 2 new UDF's to DllStruct.au3_FileReadToStruct($szFileName)_StructWriteToFile($p,$szFileName)See post #1An example:expandcollapse popup#cs vi:ts=4 sw=4: Example, displays first 4k of a binary file in hex Ejoc #ce #include <GUIConstants.au3> #include <DllStruct.au3> GUICreate("HexView",400,400) $hBrowse = GUICtrlCreateButton("Browse",200,3) $hEdit = GUICtrlCreateEdit("",0,30,400,370) GUICtrlSetFont(-1,9,400,0,"Lucida Console") GUISetState() while 1 $msg = GUIGetMsg() Select case $msg = $GUI_EVENT_CLOSE ExitLoop case $msg = $hBrowse $file = FileOpenDialog("Open File","","ALL (*.*)",1) If Not @Error Then $p = _FileReadToStruct($file) If @error Then MsgBox(0,"error","Read Failed") exit EndIf $s = "" $iLen = DllStructGetData($p,2) If $iLen > 4096 Then $iLen = 4096 for $i = 1 To $iLen $s &= HEX(DllStructGetData($p,1,$i),2) & " " If NOT MOD($i,8) Then $s &= " " If NOT MOD($i,16) Then $s &= @CRLF Next GUICtrlSetData($hEdit,$s) DllStructDelete($p) EndIf EndSelect wend<{POST_SNAPBACK}>Very goodBetter _FileReadToDLLStruct and _FileWriteFromDLLStruct Link to comment Share on other sites More sharing options...
layer Posted May 12, 2005 Share Posted May 12, 2005 I always wanted to create a Hex Editor (Seriously though, lol) FootbaG Link to comment Share on other sites More sharing options...
Ejoc Posted May 12, 2005 Author Share Posted May 12, 2005 Very goodBetter _FileReadToDLLStruct and _FileWriteFromDLLStruct <{POST_SNAPBACK}>Done Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Ejoc Posted May 16, 2005 Author Share Posted May 16, 2005 (edited) Added 2 new functions, needed for Crypto.AU3 http://www.autoitscript.com/forum/index.php?showtopic=11513Added _DllStructCreateFromString() Creat a struct that is a copy of a stringAdded _GetLastErrorMessage() String containing system error message Edited May 16, 2005 by Ejoc Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Psibernetic Posted January 16, 2007 Share Posted January 16, 2007 it isnt working for me.... error at line 132 with the _ [sup]Psibernetic[/sup]My Creations:X-HideSecuracy Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 16, 2007 Moderators Share Posted January 16, 2007 (edited) This thread is near 20 months old. There have been many versions (of AutoIt) in those 20 months. If you know anything about continuation of a line with '_' you'll know that with the latest versions you must have a space ' _' after the last character and before the underscore of that line. Edited January 16, 2007 by SmOke_N 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