What I want to do is insert a set of bytes in between 2 bytes so like, I have a array like this (this array starts at offset 0x28
) :
0F 00 00 0F
and what I want to do is insert a set of bytes (0A D8 77 64 3A 2B 95 D1 AA B9 CD 41
) between the 2 00
so it would look like this:
0F 00 0A D8 77 64 3A 2B 95 D1 AA B9 CD 41 00 0F
How would I do that?
I wrote this to see what would happen but it doesn't even work:
Stream fs = new FileStream(ofd.FileName, FileMode.Append);
BinaryWriter bw = new BinaryWriter(fs);
bw.BaseStream.Position = 0x29; //this doesn't work
byte[] appendMe = new byte[10];
bw.Write(appendMe, 0, appendMe.Length); //should append at offset 0x29, 10 bytes
bw.Close();
BinaryWriter bw2 = new BinaryWriter(File.OpenWrite(ofd.FileName));
bw2.BaseStream.Position = 0x29;
bw2.Write(0x0AD87764);
bw2.Write(0x3A2B95D1);
bw2.Write(0xAAB9CD41); //idk if this last part would even work. Don't think it would.
bw2.Close();