Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

DllStruct Dev


  • Please log in to reply
70 replies to this topic

#61 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 12 May 2005 - 05:25 PM

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







#62 layer

layer

    i love skateboarding

  • Active Members
  • PipPipPipPipPipPip
  • 2,470 posts

Posted 12 May 2005 - 06:25 PM

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

#63 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 12 May 2005 - 08:02 PM

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

#64 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 12 May 2005 - 09:08 PM

How would we modify binary data? I suppose creatively using DLLStructCreate to handle pointer info... hmmm

In 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 read

So you could
1) 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

#65 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 12 May 2005 - 09:33 PM

Added 2 new UDF's to DllStruct.au3
_FileReadToDllStruct($szFileName)
_FileWriteFromDllStruct($p,$szFileName)
See post #1

An example:
Plain Text         
#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 by Ejoc, 12 May 2005 - 10:27 PM.

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#66 jpm

jpm

    a Real GUI/debug lover

  • Developers
  • 9,770 posts

Posted 12 May 2005 - 10:19 PM

Added 2 new UDF's to DllStruct.au3
_FileReadToStruct($szFileName)
_StructWriteToFile($p,$szFileName)
See post #1

An example:

Plain Text         
#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 good
Better _FileReadToDLLStruct and _FileWriteFromDLLStruct :(

#67 layer

layer

    i love skateboarding

  • Active Members
  • PipPipPipPipPipPip
  • 2,470 posts

Posted 12 May 2005 - 10:29 PM

I always wanted to create a Hex Editor :( (Seriously though, lol)
FootbaG

#68 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 12 May 2005 - 10:30 PM

Very good
Better  _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

#69 Ejoc

Ejoc

    What's DllStruct?

  • Active Members
  • PipPipPipPipPipPip
  • 509 posts

Posted 16 May 2005 - 08:45 PM

Added 2 new functions, needed for Crypto.AU3 http://www.autoitscript.com/forum/index.php?showtopic=11513

Added _DllStructCreateFromString() Creat a struct that is a copy of a string
Added _GetLastErrorMessage() String containing system error message

Edited by Ejoc, 16 May 2005 - 08:54 PM.

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

#70 Psibernetic

Psibernetic

    Adventurer

  • Active Members
  • PipPip
  • 130 posts

Posted 16 January 2007 - 05:50 AM

it isnt working for me.... error at line 132 with the _
PsiberneticMy Creations:X-HideSecuracy

#71 SmOke_N

SmOke_N

    It's not what you know ... It's what you can prove!

  • Moderators
  • 15,730 posts

Posted 16 January 2007 - 06:23 AM

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 by SmOke_N, 16 January 2007 - 06:23 AM.

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.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users