Jump to content

Read File As HEX


Recommended Posts

Hi

First My English Is Very Bad ... So I'm Sorry >_<

I Want Read Some File As Hex ::: Like (Hex Workshop)

I Just Want To Read !!

To search for the signature.

Thanks !!

:(

Look at _WinAPI_ReadFile(). Edited by Yashied
Link to comment
Share on other sites

#Include <EditConstants.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Global $sFile, $hFile, $iSize, $sData, $tData, $iRead

$sFile = @WindowsDir & '\regedit.exe'
$iSize = FileGetSize($sFile)
$tData = DllStructCreate('byte[' & $iSize & ']')
$hFile = _WinAPI_CreateFile($sFile, 2, 2, 2)
_WinAPI_ReadFile($hFile, DllStructGetPtr($tData), $iSize, $iRead)
_WinAPI_CloseHandle($hFile)

MsgBox(0, '', Hex(DllStructGetData($tData, 1, 1), 2) & Hex(DllStructGetData($tData, 1, 2), 2) & ' (' & Chr(DllStructGetData($tData, 1, 1)) & Chr(DllStructGetData($tData, 1, 2)) & ') - signature for EXE fies.')

$sData = ''
For $i = 1 To $iSize
    $sData &= Hex(DllStructGetData($tData, 1, $i), 2)
    If Mod($i, 16) = 0 Then
        $sData &= @CRLF
    Else
        $sData &= ' '
    EndIf
Next
$sData = StringTrimRight($sData, 2)

Global $Edit

GUICreate('MyGUI', 422, 526)
$Edit = GUICtrlCreateEdit('', 10, 10, 402, 506, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 8.5, 400, 0, 'Courier')
GUICtrlSetData($Edit, $sData)
GUISetState()

Do
Until GUIGetMsg() = -3

Edited by Yashied
Link to comment
Share on other sites

#Include <EditConstants.au3>
#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Global $sFile, $hFile, $iSize, $sData, $tData, $iRead

$sFile = @WindowsDir & '\regedit.exe'
$iSize = FileGetSize($sFile)
$tData = DllStructCreate('byte[' & $iSize & ']')
$hFile = _WinAPI_CreateFile($sFile, 2, 2, 2)
_WinAPI_ReadFile($hFile, DllStructGetPtr($tData), $iSize, $iRead)
_WinAPI_CloseHandle($hFile)

MsgBox(0, '', Hex(DllStructGetData($tData, 1, 1), 2) & Hex(DllStructGetData($tData, 1, 2), 2) & ' (' & Chr(DllStructGetData($tData, 1, 1)) & Chr(DllStructGetData($tData, 1, 2)) & ') - signature for EXE fies.')

$sData = ''
For $i = 1 To $iSize
    $sData &= Hex(DllStructGetData($tData, 1, $i), 2)
    If Mod($i, 16) = 0 Then
        $sData &= @CRLF
    Else
        $sData &= ' '
    EndIf
Next
$sData = StringTrimRight($sData, 2)

Global $Edit

GUICreate('MyGUI', 422, 526)
$Edit = GUICtrlCreateEdit('', 10, 10, 402, 506, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL))
GUICtrlSetFont(-1, 8.5, 400, 0, 'Courier')
GUICtrlSetData($Edit, $sData)
GUISetState()

Do
Until GUIGetMsg() = -3

Thank you Very Much ..

I Like It,

It's very professional.

>_<

Link to comment
Share on other sites

By the way, if you need information on the ZIP archive only, it is not necessary to read the whole file. Just read the first 30 bytes of this file.

Local file header signature (4 bytes) - 0x504B0304

Version needed to extract (2 bytes)

General purpose bit flag (2 bytes)

Compression method (2 bytes)

Last mod file time (2 bytes)

Last mod file date (2 bytes)

CRC-32 (4 bytes)

Compressed size (4 bytes)

Uncompressed size (4 bytes)

File name length (2 bytes)

Extra field length (2 bytes)

Link to comment
Share on other sites

No Yashied, you are wrong about ZIP.

There is no central header inside ZIP file. Thing is more complex there.

This was discussed before on General help forum. The result was weaponx's script to read zip file (headers).

Though I would prefer DllStruct() solution his script is great for the job.

Search for it, you will see what I mean.

Link to comment
Share on other sites

By the way, if you need information on the ZIP archive only, it is not necessary to read the whole file. Just read the first 30 bytes of this file.

Local file header signature (4 bytes) - 0x504B0304

Version needed to extract (2 bytes)

General purpose bit flag (2 bytes)

Compression method (2 bytes)

Last mod file time (2 bytes)

Last mod file date (2 bytes)

CRC-32 (4 bytes)

Compressed size (4 bytes)

Uncompressed size (4 bytes)

File name length (2 bytes)

Extra field length (2 bytes)

It's wonderful informations :(

Thank you very much.

No Yashied, you are wrong about ZIP.

There is no central header inside ZIP file. Thing is more complex there.

This was discussed before on General help forum. The result was weaponx's script to read zip file (headers).

Though I would prefer DllStruct() solution his script is great for the job.

Search for it, you will see what I mean.

THanks !!

>_<

Edited by Ashalshaikh
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...