Jotun Posted January 8, 2006 Share Posted January 8, 2006 (edited) Don't know if this has been done before but here's a very simple script to veiw any file in hex like a hex editor would. Could use alot of improvements (especially speed ). #include <GuiConstants.au3> Dim $FileHandle = FileOpen(FileOpenDialog("", "", "All files (*.*)", 1), 4) If $FileHandle = -1 Then Exit Dim $GUI_Handle = GUICreate("HexVeiw", 400, 400) Dim $Edit_1 = GUICtrlCreateEdit("", 10, 10, 260, 380, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL) Dim $Edit_2 = GUICtrlCreateEdit("", 280, 10, 110, 380, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL) While 1 Local $FileByte = FileRead($FileHandle, 1) If @error = -1 Then ExitLoop Local $Asc = Asc($FileByte) Local $Chr = Chr($Asc) Local $Hex = Hex($Asc, 2) If $Chr < ' ' Or $Chr > '~' Then GUICtrlSetData($Edit_1, '.', 1) Else GUICtrlSetData($Edit_1, $Chr, 1) EndIf GUICtrlSetData($Edit_2, $Hex, 1) WEnd GUISetState() While 1 If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit Sleep(25) WEnd Edited January 8, 2006 by Jotun Link to comment Share on other sites More sharing options...
w0uter Posted January 9, 2006 Share Posted January 9, 2006 (edited) this was my attempt: expandcollapse popupProcessSetPriority(@AutoItPID, 5) GUICreate("Hex View", 550, 430) GUISetFont(10, 400, 0, "Courier") Dim $i_Chr Dim $i_Hex Dim $s_Hex = ' ' Dim $s_Chr = ' ' Dim $s_File = FileOpenDialog("", "", "All files (*.*)", 1) Dim $i_Size = FileGetSize($s_File) Dim $ai_File = StringRegExp(StringMid(String(BinaryString(FileRead($s_File, $i_Size) & Chr(0))), 3, $i_Size * 2), '(..)*', 1) Dim $h_Hex = GUICtrlCreateEdit("", 10, 10, 350, 380, 2099204) Dim $h_Chr = GUICtrlCreateEdit("", 370, 10, 170, 380, 2099204) Dim $h_Pro = GUICtrlCreateProgress(10, 400, 530, 20) GUICtrlSendMsg($h_Hex, 197, $i_Size * 4, 0) GUICtrlSendMsg($h_Chr, 197, $i_Size * 3, 0) GUISetState() Dim $MAX = UBound($ai_File) - 1 For $i = 0 To $MAX $i_Hex = $ai_File[$i] $i_Chr = '0x' & $i_Hex $s_Hex &= $i_Hex If $i_Chr < 32 Or $i_Chr > 126 Then $s_Chr &= '.' Else $s_Chr &= Chr($i_Chr) EndIf If (($i + 1) / 2) = Int(($i + 1) / 2) Then $s_Hex &= ' ' GUICtrlSetData($h_Pro, $i / $MAX * 100) EndIf If (($i + 1) / 16) = Int(($i + 1) / 16) And $i <> $MAX Then $s_Hex &= @CRLF & ' ' $s_Chr &= @CRLF & ' ' EndIf Next GUICtrlSetData($h_Hex, $s_Hex) GUICtrlSetData($h_Chr, $s_Chr) While GUIGetMsg() <> - 3 WEnd Edited January 9, 2006 by w0uter My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll 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