Jump to content

[SOLVED] Read file Hex mode help


Recommended Posts

?

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

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

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

×
×
  • Create New...