Jump to content

Hex editor


Recommended Posts

Try this:

#include <String.au3>

$sHex = _FileToHex("") ;Your file path here

ConsoleWrite($sHex & @CRLF)

; #FUNCTION# ====================================================================================================================
; Name ..........: _FileToHex
; Description ...: Show the hex code of the file
; Syntax ........: _FileToHex($sPath)
; Parameters ....: $sPath               - The path of the file
; Return values .: On Success - Return the hex code of the file
;                  On Failure -
;                               @error = 1 The file doesn't exist
;                               @error = 2 Unable to open the file
;                               @error = 3 Unable to read the file
;                               @error = 4 Unable to retrive the hex code of the file
; Author ........: Nessie
; Example .......: _FileToHex("C:\myfile.exe")
; ===============================================================================================================================
Func _FileToHex($sPath)
    If Not FileExists($sPath) Then Return SetError(1, 0, "")

    $hOpen = FileOpen($sPath)
    If @error Then Return SetError(2, 0, "")

    $sRead = FileRead($hOpen)
    If @error Then Return SetError(3, 0, "")
    FileClose($hOpen)

    $sHex = _StringToHex($sRead)
    If @error Then SetError(4, @extended, "")

    Return $sHex
EndFunc   ;==>_FileToHex

Hi!

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

Link to comment
Share on other sites

Usually we don't code for you, even if you don't show to you some piece of code. But this time i will make an exception.

it's an ungly code...but hey it's 3.30 AM here my mind in holiday :D

#include <String.au3>

$sHex = _FileToHex("") ;Your file path here
$split = StringRegExp($sHex, "(?s).{1,2}", 3)

$k = 0
$add = ""
$txt = ""


For $i = 0 To UBound($split) - 1
    $k += 1
    If $k < 16 Then
        $add = "  "
        $txt &= $split[$i] & $add
    ElseIf $k = 16 Then
        $add = @CRLF
        $txt &= $split[$i] & $add
        $k = 0
    EndIf
Next

ConsoleWrite($txt)

; #FUNCTION# ====================================================================================================================
; Name ..........: _FileToHex
; Description ...: Show the hex code of the file
; Syntax ........: _FileToHex($sPath)
; Parameters ....: $sPath               - The path of the file
; Return values .: On Success - Return the hex code of the file
;                  On Failure -
;                               @error = 1 The file doesn't exist
;                               @error = 2 Unable to open the file
;                               @error = 3 Unable to read the file
;                               @error = 4 Unable to retrive the hex code of the file
; Author ........: Nessie
; Example .......: _FileToHex("C:\myfile.exe")
; ===============================================================================================================================
Func _FileToHex($sPath)
    If Not FileExists($sPath) Then Return SetError(1, 0, "")

    $hOpen = FileOpen($sPath)
    If @error Then Return SetError(2, 0, "")

    $sRead = FileRead($hOpen)
    If @error Then Return SetError(3, 0, "")
    FileClose($hOpen)

    $sHex = _StringToHex($sRead)
    If @error Then SetError(4, @extended, "")

    Return $sHex
EndFunc   ;==>_FileToHex
Edited by Nessie

My UDF: NetInfo UDF Play with your network, check your download/upload speed and much more! YTAPI Easy to use YouTube API, now you can easy retrive all needed info from a video. NavInfo Check if a specific browser is installed and retrive other usefull information. YWeather Easy to use Yahoo Weather API, now you can easily retrive details about the weather in a specific region. No-IP UDF Easily update your no-ip hostname(s).

My Script: Wallpaper Changer Change you wallpaper dinamically, you can also download your wallpaper from your website and share it with all!   My Snippet: _ImageSaveToBMPConvert an image to bmp format. _SciteGOTO Open a file in SciTE at specific fileline. _FileToHex Show the hex code of a specified file

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