Jump to content
Sign in to follow this  
tonyatcodeleakers

Hex editor

Recommended Posts

tonyatcodeleakers

I was wondering if there were any udf's available to retrieve the hex of a file, much like hxd.

I did some research and nothing came up. All im looking to do is let say, select a file and have it return the hex information shown in a format like so,.

Posted Image

Thanks in advanced

Share this post


Link to post
Share on other sites
Nessie

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

Share this post


Link to post
Share on other sites
KaFu
tonyatcodeleakers

Thanks nessie, exactly what i needed, just to make it look cleaner how should i go about formatting it so that the texts adds a space in between every 2 digits and only allows 16 columns.

Share this post


Link to post
Share on other sites
Nessie

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

Share this post


Link to post
Share on other sites
tonyatcodeleakers

Thanks again nellie but to be fair i did ask how to go about it, not for you to code it for me. But regardless thank you

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  

×