Jump to content

How read hex data from file?


ancp
 Share

Recommended Posts

First, sorry for my bad english. Can anybody help me with this problem?

I need read part of strings between specific hex char from few big files (more than 1GB).

e.g.: i need get strings between A7 23 01 01 22 ... and ... A7 23 01 02 hex part.

How find (get position) first part (A7 23 01 01 22)?

Thanks for help!

Link to comment
Share on other sites

  • Moderators

Had you looked at _StringBetween()?... and I'm sure it wouldn't have spaces :whistle:.

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

Had you looked at _StringBetween()?... and I'm sure it wouldn't have spaces :).

SmOke_N, thanks for reply, but...

My problem is that i don't know how to search bin data :whistle: How to obtain first (and next) occurrence specified hex values from bin data?

Is FileRead a convert from bin to hex right way? Because, searched files is very long (e.g. 3,6GB) and read file per line is very slow or not? Further, lenght of searched string can be more than on 1 line.

Link to comment
Share on other sites

  • Moderators

SmOke_N, thanks for reply, but...

My problem is that i don't know how to search bin data :whistle: How to obtain first (and next) occurrence specified hex values from bin data?

Is FileRead a convert from bin to hex right way? Because, searched files is very long (e.g. 3,6GB) and read file per line is very slow or not? Further, lenght of searched string can be more than on 1 line.

There's nothing that's going to read 3.6 gb fast like you want it in AutoIt... that's kind of rediculous... what is it a couple of movies?

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

ok, i tried write this, but is this right way for big files?

Dim $file, $hexstr, $result
Dim $pos, $mytmp

$file   = FileOpen("C:\mpdd.ig", 0)
$hexstr = "A723010122" ; find 14 chars after this hexadecimal

; convert all from bin to hex
$mytmp  = Hex(BinaryString(FileRead($file)))
$mytmp  = BinaryString($mytmp)
$mytmp  = String($mytmp)

; position after hexstr
$pos = StringInStr ($mytmp, $hexstr) + StringLen($hexstr)

; get next 14 chars
$myvalue = StringMid ($mytmp, $pos, 14)

$result = ConvertHexToString($myvalue)

MsgBox (0, "",$result)

FileClose($file)

; Converting from hexadecimal to string
Func ConvertHexToString($myHex)
  Local $i, $myText="", $mytmp

     For $i=1 to StringLen($myHex) Step 2
        $mytmp = Dec(StringMid ($myHex, $i ,2))
        $mytmp = Chr($mytmp)
        $myText = $myText & $mytmp
     Next

    Return $myText
EndFunc
Link to comment
Share on other sites

cant you just use some sort of memory patcher?

Sort of memory patcher? Sorry, i don't understant... What do you mean by it? ... However, when i apply my script (above) to large file, my memory collapsing. This my script isn't useful :whistle:

Edited by ancp
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...