I was thinking of making a program with Windows Form, which reads hex files. It can be opened with this same program called HxD.
For example, you can see this in an image file but I only put a piece that is long.
I want to make a program in C#, at least have an idea that when opening and reading the hex file, it searches in a specific address. For example, the one indicated below. At address 7006, in which in hex it has the value 56 and in ASCII next to it is a capital letter V.
If you press a button on the form, one textBox shows the value 56 and the other textBox shows the letter V.
So far so good.
You have to make a kind of dictionary full of if, in which if it detects 56, in a third textBox it shows a message, Spanish. If it detects 57, show Italy, if it is 58, show Portugal. If in those if there is another value that is not included, display UNKNOWN in the third textBox.
Speaking seems easy.
Is it very complicated to do?
I also don’t want to spend half my life figuring out how to do it.
Remember that we are talking about a single Byte, not several. If it’s possible, it’s fine for me too.
Rate this question
Like: This question is useful and clear Dislike: This question is not clear or useful
Yes, that should be a pretty easy task. I suggest reading the whole file into a long byte array, at which point you can index into the array by the various addresses you’re interested in looking at.
A note on terminology: This isn’t a “hex file”, it is a regular binary file with single 8-bit bytes representing the data, in this case of a png image. The HxD program is displaying the file in both hex and ascii (where reasonable) output for you; it is doing that by converting the binary data to those formats. So unless you also plan on converting the binary data to hex, you won’t be fiddling with hex formatting to do what you’ve outlined above, if that was part of your exercise.
If you want to understand the methodology for how to solve such a problem, then a good place to start is the System.IO Namespace. If you look at the classes in that namespace then you will be more likely to find a relevant class when you need one.
In that namespace is the BinaryReader Class. Using that you can use the BinaryReader.Read Method to read just one byte at the location you specify. That is probably the best way.
Alternatively you could use the FileStream Class.
I think the problem is easy to solve by looking at the IO classes.
Spanish is a language (and can refer to people and things from Spain) and Italy and Portugal are countries.
It’s also worth pointing out that most hex values in things are not single-byte values. “57” (which in decimal is actually 87) may be Italy, but 00 57 (87) is Italy and 01 57 (343) is Turkey.
You’ll need an understanding of the structure of the thing you’re reading.
In a hexadecimal file, called 24LC24.hex or 24LC24.bin that comes from a 24LC24 EEPROM, for example.
Means nothing to me, but i’m not the one decoding the hex. So if you know what it means, and what the bytes refer to, and how many bytes it uses, good.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.