I want to make a program which allows users to search for a specific hex code within a file and the output would be the offset or not found . The code that i have so far is :
namespace search
{
class Program
{
static void Main(string[] args)
{
System.IO.BinaryWriter bw = new BinaryWriter(File.OpenWrite("C:\\1.txt"));
bw.BaseStream.Position = 3;
bw.Write((byte)0x01);
bw.Close();
Console.WriteLine("Wrote the byte 01 at offset 3!");
}
}
}
I have looked everywhere on the web and did not found anything usefull , is it possible to search for hex code and have an output with the offset ?
EDIT1:
Lets say we have this file 1.txt and at this offset 0x1300 we have this hex code 0120 / 0x01 0x20 / "0120" ( i dont know how to write it ) . After opening the program it will ask you with a console.readline what hex code to search for and the output will be 0x1300
EDIT2: my question is similar to this one VB.Net Get Offset Address and it have a solution but in vb.net