I need to write a program to patch a binary file. There are hex values that I need to find and replace in the file. I am somewhat familiar with FileStream, BinaryWriter and BinaryWriter. But I cannot for the life of me seem to write hex values to a file. Can someone point in the right direction? I feel that I am almost there... here is my code so far:
Of course this code does not work, if I open Test.bin the hex values written are: 18343836353643364336463230353736463732364336343231
VB.NET:
Dim fs As New FileStream("Test.bin", FileMode.OpenOrCreate)
Dim w As New BinaryWriter(fs)
Dim s As String
s = "48656C6C6F20576F726C6421"
'This would be: Hello World! in hex
w.Write(s)
w.Close()
fs.Close()
Of course this code does not work, if I open Test.bin the hex values written are: 18343836353643364336463230353736463732364336343231