Jump to content
Sign in to follow this  
kcd-clan

loading a big file ~40mb from chr to hex ? read plz

Recommended Posts

I need to do this fast.

So fair iv not even got to finish it cause it takes to long.

I know il find a way soon enuff.

Heres my code.

O yea its not 40 mb its 4 mb but it still takes while.

$i=0
    $files = FileOpen($location&$file, 0)
; Check if file opened for reading OK
If $files = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in 1 character at a time until the EOF is reached
While 1
    $i=$i+1
    ToolTip("Bytes: "&$i)
    $chars = FileRead($files,1)
    If @error = -1 Then ExitLoop
    $hex=Asc ( $chars )
    If $out<>"" Then
    $out=$out&" "&$hex
    EndIf
    If $out="" Then
    $out=$hex
EndIf
Wend
MsgBox(0,0,$out)
FileClose($files)
Edited by kcd-clan

Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()

Share this post


Link to post
Share on other sites

Try opening it in raw mode (4) and then doing FileRead() with no extra paramters. This will load the whole file in one command which is faster than byte by byte

Edit: curses...my post was foiled agian :D

Edited by evilertoaster

Share this post


Link to post
Share on other sites

You need the beta verion of autoit i think for raw mode. When you have it, use file open with a 4 as the second parameter.

Edit: also what raw mode does is read direct hex from the file so you won't have to manually convert it later

Edited by evilertoaster

Share this post


Link to post
Share on other sites

And how can i split sring if i dono where im splitting it cep that its ever chr

In beta this is done by:

Dim $result

$File = FileRead("C:\File.ext")
$SplitFile = StringSplit($File,'')

For $x = 0 to $SplitFile[0]
      $result &= Hex($SplitFile[$x])
Next

Edit: Nice thing to know eviltoaster! Thanks.

Edited by Manadar

Share this post


Link to post
Share on other sites

$path=FileOpenDialog("Choose a file",@ScriptDir,"All (*.*)")
$File=FileOpen($path,4)
$read=FileRead($file,FileGetSize($path))
;MsgBox(0,"",String($read))
MsgBox(0,"",StringReplace(String($read),"0x",""))

This will load a whole file and show it's hex string in a message box. Uncomment the first msgbox if you want the "0x" hex identifier to be there also

Edit: BTW there's no error checking on this so dont do anything foolish :D

Edited by evilertoaster

Share this post


Link to post
Share on other sites

I dono about you but that dont work for me.

It just returnes the value of 0

I need ALL the hex code.

And it shows the output of hex not the hex codes....

Edited by kcd-clan

Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()

Share this post


Link to post
Share on other sites

.......

I said it show what it would show if you open in notepad.

Cause im trying ith a normal text file.

It wont even work on a program type file with hex of 00-20 or whatever.


Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()

Share this post


Link to post
Share on other sites

I may be misunderstanding what you want.

This will read the raw Hex data from a file (for instance if you opened it in a hex editor) if you use this on a .txt file i dont see what the point is but it should still work (i've now tried this on 3 computers).

Is this not want you want?

Share this post


Link to post
Share on other sites

no

I am geting alot of problems with this il probly ahve to write it all and define all hex values.

When im reading hex in autoit it comes to a number when hex go from 0-f and autoit dose 0-9 because a declerations

If i have to i can get it cause i have the way to read it and know the number on autoit of the hex code.


Visit mEMy programs made.Iul - IulG-V Console - G-V Console_RandomLetter - _RandomLetter()Saftey Kill - Saftey Killcolorzone() = colorzone()

Share this post


Link to post
Share on other sites

When im reading hex in autoit it comes to a number when hex go from 0-f and autoit dose 0-9 because a declerations

If i have to i can get it cause i have the way to read it and know the number on autoit of the hex code.

I can't really tell what you're talking about...anyone want to translate?

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  

×
×
  • Create New...