Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Binary Search  (Read 3423 times)

0 Members and 1 Guest are viewing this topic.

almn

  • Guest
Binary Search
« on: January 13, 2007, 11:26:37 AM »
Hello,

I would like to know how to perform a search that looks for the following Hex code in the file c:\test.exe and return the path of thsi file if it is found
58354f2150254041505b345c505a58353428505 e2937434329377d2445494341522d5354414e44 4152442d414e544956495255532d544553542d4 6494c452124482b482a

This code would be part of a larger program so I would help in vb.net. If anyone could point me to a tutorial where there is information on hat it would be very much appreciated.

Thank You

Al968

Neil



    Expert
  • Fear me Track. Noone can escape my wrath.
  • Thanked: 3
    Re: Binary Search
    « Reply #1 on: January 13, 2007, 12:04:34 PM »
    Not sure the commands you will need to use, but I'd use a procedure like this.

    1. Store the string to be found in a variable, and create a found variable whose value is false.
    2. Open the file as a text document.
    3. Set a variable to track the current character of the string we have found so far. I will call this track (no pun intended)
    4. Whilst you have not reached the end of file...
      4a. If the character you have just read is the same as the "track-th" character in the string to be found, increase track by one,
            else track becomes zero.
      4b. If track equals the size of the string to be found (or probably the size -1) then set the found variable to true and break from the loop (unless you which to count the number of instances perhaps?).
    5. Close the file. For completeness ;)
    6. Perform whatever instructions based upon the result of the found variable.

    There are probably more efficent ways of doing this, but try to find if this works first and we can improve it later.

    You probably can't find tutorials on this as tutorials only cover general aspects, or very popular tasks. This is rather a specific problem. Try reading tutorials on handling strings and file management. I haven't used vb.net in a long time so I can't give you any code sorry.

    Good luck.

    almn

    • Guest
    Re: Binary Search
    « Reply #2 on: January 13, 2007, 12:46:10 PM »
    Thanks for the Pseudo Code, I too don't know the commands to do that but know very well like you do what the pseudo code would be.
    I'll look into strings and file management tutorials.
    Thanks
    Al968
    P.S: Still looking for the code  ;D if you have an idea  :)