Page 1 of 1

Hexing map

Posted: Sat Dec 15, 2007 2:29 am
by spikes122
hey

ive made alot of apps that run by side a game and edit it(trainers like 3rd person)

but i want to make a app that would hex a map file
so when the user presses a button at ofset 0x00000 it would be 01

jus a example

so where would i start?
i use vb 6

Posted: Sat Dec 15, 2007 11:23 pm
by Patrickh
do you want to do it during runtime? if so, i dont think that's possible

otherwise, do something like this:

Code: Select all

Dim bw As New IO.BinaryWriter(New IO.FileStream(p, 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()
correct me if I'm wrong

to get the map path do something like this:

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
Thats .net but should be easy to understand
once again im a noob programming so feel free to point out my mistakes

Posted: Sun Dec 16, 2007 6:55 am
by spikes122
Could u explain some more please

Thanks alot

Posted: Sun Dec 16, 2007 9:26 am
by Patrickh

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

Posted: Sun Dec 16, 2007 10:52 am
by spikes122
ok thanks alot im starting to get it

i can do the opening map file

but when i try and do ur example
bw.BaseStream.Seek(&H4, SeekOrigin.Begin)
bw.Write(&H61)
bw.BaseStream.Seek(&H5, SeekOrigin.Begin)
bw.Write(&H2)
i get lots of delcarations errors

Ive always used vb mostly for mem edit

but if u could help me do this ill be very grateful

thanks patrickH

Posted: Sun Dec 16, 2007 12:59 pm
by Patrickh
spikes122 wrote:ok thanks alot im starting to get it

i can do the opening map file

but when i try and do ur example
bw.BaseStream.Seek(&H4, SeekOrigin.Begin)
bw.Write(&H61)
bw.BaseStream.Seek(&H5, SeekOrigin.Begin)
bw.Write(&H2)
i get lots of delcarations errors

Ive always used vb mostly for mem edit

but if u could help me do this ill be very grateful

thanks patrickH
did you declare the binary writer?

Dim bw As New IO.BinaryWriter(New IO.FileStream(map_path, IO.FileMode.Open, IO.FileAccess.Write))

Posted: Fri Dec 21, 2007 3:16 am
by spikes122
yes i still need help with this
ur never on xfire lol