Jump to content
Sign in to follow this  
Ejoc

DllStruct Dev

Recommended Posts

Ejoc

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

Share this post


Link to post
Share on other sites
layer

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

Share this post


Link to post
Share on other sites
Ejoc

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

Share this post


Link to post
Share on other sites
Ejoc

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

Share this post


Link to post
Share on other sites
Ejoc

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

Share this post


Link to post
Share on other sites
jpm

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

Share this post


Link to post
Share on other sites
layer

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


FootbaG

Share this post


Link to post
Share on other sites
Ejoc

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

Share this post


Link to post
Share on other sites
Ejoc

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

Share this post


Link to post
Share on other sites
Psibernetic

it isnt working for me.... error at line 132 with the _


[sup]Psibernetic[/sup]My Creations:X-HideSecuracy

Share this post


Link to post
Share on other sites
SmOke_N

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.

Share this post


Link to post
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
Sign in to follow this  

×