Code: Select all
Dim bw As New IO.BinaryWriter(New IO.FileStream(map_path, IO.FileMode.Open, IO.FileAccess.Write))
bw.BaseStream.Position = 0 (for dec) or &H0 (for hex) <- the offset at which to write
bw.BaseStream.WriteByte(1) <- the value you write at that byte
bw.close()
Dim bw As New IO.BinaryWriter(New IO.FileStream(p, IO.FileMode.Open, IO.FileAccess.Write)) is creting a new binary writer object that will open a file at location "map_path" which is a string you'll recieve below.
bw.BaseStream.Position = 0 means that you are setting the binary writer to a position at the offset 0. You can also use &H0 for hex offsets.
bw.BaseStream.WriteByte(1) This writes a value of 1 to the position you are at. writing 255 would put FF at that byte, and writing 1 would put 01.
bw.close() that's just a good idea to do when done with the binary writer
now this opens the map and recieves its location map_path
Code: Select all
Dim map_path As String
Dim ofd As New OpenFileDialog
ofd.Filter = "Halo Map Files (*.map)|*.map"
If ofd.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
map_path = ofd.FileName
End If
[/quote]
First you create your map_path string variable
Then You create an Open File Dialog, naming it ofd
Then you set it's filter to only view/open halo maps
Then, you show the dialog, and say that if it doesn't return cancel, then set map_path to equal the location of the file you opened. That's it. So as practice instead of writing at offset 0, try writing at bytes 4 and 5, and make a simple ce/pc header converter.
to CE:
Code: Select all
bw.BaseStream.Seek(&H4, SeekOrigin.Begin)
bw.Write(&H61)
bw.BaseStream.Seek(&H5, SeekOrigin.Begin)
bw.Write(&H2)
^^^please critique my post if necessary