Yes, this is definitely a problem:
for (int x = 0; x < byErr.Length; x++) { offset = System.Convert.ToInt64(b[x].ToString()); }
You convert each byte of the index individually into a string, then parse it and assign it offset . Thus, only the last byte will actually be used.
You can try:
long offset = br.ReadInt32();
instead of calling ReadBytes(4) to start. If this uses the wrong orientation, you can use my EndianBinaryReader class from MiscUtil .
You need to register some diagnostic information to show which index you read and compare it with what you expect.
I also advise you to change the search code:
fileStream.Position = offset - 60;
for simplicity. In addition, flushing the stream of the files you are reading and setting b to null is unnecessary, and you must use the using statement for your FileStream , after which you do not need to manually close anything.
source share