473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

open binary file and search hex string

Hi... I would like to search for a hex string (for example: "E903") inside a
binary file...
Although I open the file correctly, how do I search hex values?
Thanks in advance!
Nikos

Nov 17 '05 #1
4 6452
Nikos,

Are you looking for the character string "E903" or for the two-byte
value 59651? Either way, once you know what bytes you are looking for, you
need to open the file with a FileStream, and cycle through all of the bytes,
looking one-by-one for a match.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nikos" <nk******@freemail.gr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi... I would like to search for a hex string (for example: "E903") inside
a binary file...
Although I open the file correctly, how do I search hex values?
Thanks in advance!
Nikos

Nov 17 '05 #2
Thanks for the reply... I am actually looking for character string "E903"...
I am stuck with the search routine. How to search hex values?
Should I load all file contents to an array and search? Or, is it possible
to just read the file byte after byte and examine the offset of the search
string?
Nikos

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2****************@TK2MSFTNGP10.phx.gbl...
Nikos,

Are you looking for the character string "E903" or for the two-byte
value 59651? Either way, once you know what bytes you are looking for,
you need to open the file with a FileStream, and cycle through all of the
bytes, looking one-by-one for a match.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nikos" <nk******@freemail.gr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi... I would like to search for a hex string (for example: "E903")
inside a binary file...
Although I open the file correctly, how do I search hex values?
Thanks in advance!
Nikos


Nov 17 '05 #3
Nikos,

I would just read the file byte by byte, keeping a buffer of the last n
bytes read, where n is the length of the bytes you want to search for. If
you are looking for that character string, then you should use the GetBytes
method on the AsciiEncoder class in the System.Text namespace to get the
bytes that the string actually is comprised of.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nikos" <nk******@freemail.gr> wrote in message
news:uv*************@TK2MSFTNGP12.phx.gbl...
Thanks for the reply... I am actually looking for character string
"E903"...
I am stuck with the search routine. How to search hex values?
Should I load all file contents to an array and search? Or, is it
possible to just read the file byte after byte and examine the offset of
the search string?
Nikos

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote
in message news:%2****************@TK2MSFTNGP10.phx.gbl...
Nikos,

Are you looking for the character string "E903" or for the two-byte
value 59651? Either way, once you know what bytes you are looking for,
you need to open the file with a FileStream, and cycle through all of the
bytes, looking one-by-one for a match.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Nikos" <nk******@freemail.gr> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi... I would like to search for a hex string (for example: "E903")
inside a binary file...
Although I open the file correctly, how do I search hex values?
Thanks in advance!
Nikos



Nov 17 '05 #4
Thanks... I 'll check it now...

Nikos,

I would just read the file byte by byte, keeping a buffer of the last n
bytes read, where n is the length of the bytes you want to search for. If
you are looking for that character string, then you should use the
GetBytes method on the AsciiEncoder class in the System.Text namespace to
get the bytes that the string actually is comprised of.

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Mike Austin | last post by:
It's the most annoying thing, and causes hours of frustration. Why can't it be resolved? Regards, Mike Austin Example: #include <iostream> #include <string>
4
by: Tarique Jawed | last post by:
Alright I needed some help regarding a removal of a binary search tree. Yes its for a class, and yes I have tried working on it on my own, so no patronizing please. I have most of the code working,...
4
by: Thomas Scheiderich | last post by:
The following code works fine. It opens file reads the data and then closes. **************************************************************************** **************** Dim objFileInfo As...
1
by: Nikos | last post by:
Hi... I would like to search for a hex string (for example: "E903") inside a binary file... Although I open the file correctly, how do I search hex values? Thanks in advance! Nikos
1
by: Andrew | last post by:
Hi, im trying to create a small function which can create a binary tree from the entries in a text file and after that we can perform all the usual operations like search, insert and delete etc....
10
by: Antoine De Groote | last post by:
Hi there, I have a word document containing pictures and text. This documents holds several 'ABCDEF' strings which serve as a placeholder for names. Now I want to replace these occurences with...
7
by: Rudi Menter | last post by:
Hi, I would like to store binary data (as data-type blob) in a (MySql-) database, so I require functionality that allows a mapping from and back into the filesystem. Now, is there a library for...
1
by: hn.ft.pris | last post by:
I have the following code: Tree.h defines a simple binary search tree node structure ########## FILE Tree.h ################ #ifndef TREE_H #define TREE_H //using namespace std; template...
4
by: Hunk | last post by:
Hi I have a binary file which contains records sorted by Identifiers which are strings. The Identifiers are stored in ascending order. I would have to write a routine to give the record given...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.