Jump to content

Recommended Posts

Posted (edited)

I need help to read one file in a HEX mode and go to one offset and than read the value. THX

Cattura.JPG

Edited by rootx
Posted (edited)

?

Func _Offset2String($my_file, $start, $end)
  Local $file = FileOpen($my_file, 16)  ;$FO_BINARY
  Local $chars = StringRegExp(FileRead($file), '[[:xdigit:]]{2}', 3)
  FileClose($file)
  Local $txt = "offset " & $start & "-" & $end & " :" &@crlf&@crlf
  For $i = $start to $end
    $txt &= Chr("0x" & $chars[$i])
  Next
  Return $txt
EndFunc

Edit
Certainly much easier using FileSetPos  :)

Edited by mikell
Posted

Alternative.
 

#include <FileConstants.au3>

ConsoleWrite(_ReadOffSet("1.txt",0,3) & @CRLF)
Func _ReadOffSet($sFilePath,$iOffset,$iLen=1)
    Local $sRet=""
    Local $hFile=FileOpen($sFilePath,$FO_BINARY)
    FileSetPos($hFile,$iOffset,$FILE_BEGIN)
    $sRet=FileRead($hFile,$iLen)
    FileClose($hFile)
    Return $sRet
EndFunc
 


Saludos

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
×
×
  • Create New...