Sign in to follow this  
Followers 0
Andre

Find String in Binary File

6 posts in this topic

Hi,

Is there an way to find an String in an binary File ?

When so, it would then be nice to stop searching when found.

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites



Autoit does not manage binary files well. But can try to 'integrate' XVI that will do what you need.

More info in this old topic...

Share this post


Link to post
Share on other sites

Hi,

Thnx,

I'll give it a try.

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

Hi,

Too bad, is not what i want.

I want to search the header of an binary file and pass the result to AutoIt.

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

Share this post


Link to post
Share on other sites

Hi,

Too bad, is not what i want.

I want to search the header of an binary file and pass the result to AutoIt.

Andre

<{POST_SNAPBACK}>

As long as you are not looking for the null character you can loop through the binary file just like a text file. It would look something like this (untested):

Func SearchBinFile( $binFile, $strSearch )
   $file = FileOpen( $binFile )

   While 1

      $currText = FileRead( $file, StringLen($strSearch) )

      If( @error = -1 ) Then
         Return 0
      EndIf

      If( $currText = $strSearch ) Then
       ; Place code here to do when string is found 
        Return 1
      EndIf

   Wend

EndFunc

It only tells you if it is found, but you can change it to do whatever you need. It should work. Hope it helps!

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

Hi,

I Changed you're code a bit and now it's working like the way i want it.

If SearchBinFile('c:\tmp\renamemaster.exe','This',9) Then
   MsgBox(4096,'Found','Found it!')
EndIf


; ----------------------------------------------------------------------------
; Functions
; ----------------------------------------------------------------------------

Func SearchBinFile( $binFile, $strSearch,$Inputcounter )

 Dim $CurrText, $StrSearch
 Dim $File, $BinFile
 Dim $Counter, $InputCounter

  $file = FileOpen( $binFile,0 )

  While 1

     $currText = FileRead( $file, StringLen($strSearch) )
     $Counter = StringLen($strSearch) + $Counter
     
     If $Counter >= $InputCounter Then
        Return 0
     EndIf

     If( @error = -1 ) Then
        Return 0
     EndIf

     If( $currText = $strSearch ) Then
      Return 1
     EndIf

  Wend

EndFunc

Andre


What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!

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  
Followers 0