Results 1 to 4 of 4

Thread: Search for a hex byte in a file?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    16

    Search for a hex byte in a file?

    Hi, it's me again, sorry for asking another question, but I had made an app that opens a file and changes a hex byte then when I click another button it saves it.

    I am now thinking of making an app that will change some hex bytes to something else, but the catch is that not every file will have some of the hex bytes that others will. Like I want it to search for 71, 13, 31, and 11, and change them to 15, but not all files will have say a 71 or some might not have a 13 or a 31... So I was thinking that I would need the app do a search for a hex byte in the file, is this possible? Thanks for any help!

    Also, if there was a couple of bytes in a row that I needed to change, say F132, would I be able to search for all of that at once, and then change it to something like F133?
    Last edited by iambowling247; Aug 17th, 2009 at 09:59 PM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Search for a hex byte in a file?

    What is this for?

  3. #3
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: Search for a hex byte in a file?

    Have a look at the System.IO.BinaryReader and System.IO.BinaryWriter classes. You use the 1st to read the file in binary mode, and the later to write a file in binary mode. There are plenty of examples on using these classes in this forum. Just do a search and you should be able to get started.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Search for a hex byte in a file?

    From what you stated, it also sounds like there is no shortcut to just plodding through the files. If there was any pattern to where things were found, there might be an easier search, but it sounds like there is no particular pattern.
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width