Jump to content

DllStruct Dev


Ejoc
 Share

Recommended Posts

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

  • Replies 70
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

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
Link to comment
Share on other sites

Added 2 new UDF's to DllStruct.au3

_FileReadToDllStruct($szFileName)

_FileWriteFromDllStruct($p,$szFileName)

See post #1

An example:

#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
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

Added 2 new UDF's to DllStruct.au3

_FileReadToStruct($szFileName)

_StructWriteToFile($p,$szFileName)

See post #1

An example:

#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 :(

Link to comment
Share on other sites

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

  • 1 year later...
  • Moderators

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...