tonyatcodeleakers Posted May 7, 2013 Share Posted May 7, 2013 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,.Thanks in advanced Link to comment Share on other sites More sharing options...
Nessie Posted May 7, 2013 Share Posted May 7, 2013 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 More sharing options...
KaFu Posted May 8, 2013 Share Posted May 8, 2013 (edited) Maybe is what you're looking for. Edited May 8, 2013 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
tonyatcodeleakers Posted May 8, 2013 Author Share Posted May 8, 2013 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. Link to comment Share on other sites More sharing options...
Nessie Posted May 8, 2013 Share Posted May 8, 2013 (edited) 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 expandcollapse popup#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 May 8, 2013 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 More sharing options...
tonyatcodeleakers Posted May 8, 2013 Author Share Posted May 8, 2013 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 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now