Jump to content
Sign in to follow this  
Ashalshaikh

Read File As HEX

Recommended Posts

Ashalshaikh

Hi

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

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

I Just Want To Read !!

To search for the signature.

Thanks !!

:(

Edited by Ashalshaikh

Share this post


Link to post
Share on other sites
Yashied

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

Share this post


Link to post
Share on other sites
Ashalshaikh

Look at _WinAPI_ReadFile().

Thank you very much

I am very sorry

I did not understand the example in help book

Can you write a simple example of reading.

>_<

Share this post


Link to post
Share on other sites
Yashied

#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

Share this post


Link to post
Share on other sites
Ashalshaikh

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

>_<

Share this post


Link to post
Share on other sites
Rambo

This is very interesting for me too, thanks

Share this post


Link to post
Share on other sites
Yashied

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)

Share this post


Link to post
Share on other sites
trancexx

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.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites
Ashalshaikh

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

Share this post


Link to post
Share on other sites
Yashied

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  

×