Map Resigning, Get Map Name & Signature [VB, C#, C++]

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
ugly-nerd





Posts: 23
Joined: Sat May 21, 2005 6:51 am

Map Resigning, Get Map Name & Signature [VB, C#, C++]

Post by ugly-nerd »

You will need to add an OpenFileDialog and 2 TextBoxes.

Visual Basic :

Map Resigning -

Code: Select all

        Dim BR As New BinaryReader(New FileStream(Open.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
        Dim BW As New BinaryWriter(New FileStream(Open.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
        Dim Signature As Int32 = 0
        Dim MapSize As Long = BR.BaseStream.Length
        BR.BaseStream.Position = 2048
        For i As Integer = 2048 To MapSize - 4 Step 4
            Signature = Signature Xor BR.ReadInt32
        Next
        BW.BaseStream.Position = 720
        BW.Write(Signature)
        BR.Close()
        BW.Close()
        MsgBox("Encryption signature fixed. New signature is 0x" & Hex(Signature))
Get Map Name & Signature-

Code: Select all

            Dim BR As New BinaryReader(New FileStream(Open.FileName, FileMode.Open, FileAccess.Read, FileShare.Read))
            BR.BaseStream.Position = 408
            MapName.Text = BR.ReadChars(32)
            BR.BaseStream.Position = 720
            MapSig.Text = "0x" & Hex(BR.ReadInt32)
            BR.Close()
Visual C# :

Map Resigning -

Code: Select all

            BinaryReader BR = new BinaryReader(new FileStream(Open.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite));
            BinaryWriter BW = new BinaryWriter(new FileStream(Open.FileName, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite));
            Int32 Signature = 0;
            long MapSize = BR.BaseStream.Length;
            BR.BaseStream.Position = 2048;
            for (int i = 2048; i <= MapSize - 4; i += 4)
            {
                Signature = Signature ^ BR.ReadInt32();
            }
            BW.BaseStream.Position = 720;
            BW.Write(Signature);
            BR.Close();
            BW.Close();
            MessageBox.Show("Encryption signature fixed. New signature is 0x" + Signature.ToString("X"));
Get Map Name & Signature -

Code: Select all

                BinaryReader BR = new BinaryReader(new FileStream(Open.FileName, FileMode.Open, FileAccess.Read, FileShare.Read));
                BR.BaseStream.Position = 408;
                char[] charBuf =  BR.ReadChars(32);
                MapName.Text = new string(charBuf);
                BR.BaseStream.Position = 720;
                Int32 int32Buf = BR.ReadInt32();
                MapSig.Text = int32Buf.ToString("X");
                BR.Close();
Visual C++ :

Map Resigning -

Code: Select all

			BinaryReader^ BR = gcnew BinaryReader( gcnew FileStream(open->FileName, FileMode::Open, FileAccess::ReadWrite, FileShare::ReadWrite));
			BinaryWriter^ BW = gcnew BinaryWriter( gcnew FileStream(open->FileName, FileMode::Open, FileAccess::ReadWrite, FileShare::ReadWrite));
			Int32 Signature = 0;
			long MapSize = BR->BaseStream->Length;
			BR->BaseStream->Position = 2048;
			for (int i = 2048; i <= MapSize - 4; i+=4 )
			{
			Signature ^= BR->ReadInt32();
			}
			BW->BaseStream->Position = 720;
			BW->Write(Signature);
			MessageBox::Show("Encryption signature fixed. New signature is 0x" + Signature.ToString("X"));
			BR->Close();
			BW->Close();
Get Map Name & Signature -

Code: Select all

		BinaryReader^ BR = gcnew BinaryReader( gcnew FileStream(open->FileName, FileMode::Open, FileAccess::ReadWrite, FileShare::ReadWrite));
		BR->BaseStream->Position = 408;
		MapName->Text = gcnew String( BR->ReadChars(32) );
		BR->BaseStream->Position = 720;
		Int32^ Signature = BR->ReadInt32();
		MapSig->Text = "0x" + Signature->ToString("X");
		BR->Close();
How does the map resigning work?

It opens the map for binary reading and writing. It starts at dec 2048 and xors each dec to the end of the map. Then it writes the xored variable to dec 720.

How does getting the map name and signature work?

It opens the map for binary reading, it reads the map name at dec 408. (Reading characters). Then it positions itself at dec 720 and reads the signature int32.

How can I find the map signature with a hex editor?
Image
-The blue is blank data
-The darker blue at the bottom is the dec/hex offset.
-The teal is non-blank data
-The red is the actual signature. When your reading the red with Int32, it will read it differently.

This couldnt have been possible without the help of Anthony, High6, and TfAv.
User avatar
0mfc0





Posts: 218
Joined: Sun May 07, 2006 11:10 am
Location: Indiana

Post by 0mfc0 »

I am sure just about everybody knows how to program a map resigner, But this will help ppl that don't know

nice post
Image
ugly-nerd





Posts: 23
Joined: Sat May 21, 2005 6:51 am

Post by ugly-nerd »

Yeah I kind of figured most would know how, but I just posted it for the hell of it.
h2h





Posts: 138
Joined: Mon Jul 10, 2006 9:57 pm
Contact:

Post by h2h »

Hey how do you add any type of dialog file? I've tried and just cant figure out. If you know please pm me.
User avatar
dos mes





Posts: 2158
Joined: Thu Dec 29, 2005 9:58 pm
Location: Syracuse, NY

Post by dos mes »

You can either create it as a temporary dialog via variables, or the easiest way is to just add the dialog from the toolbox... :roll:
h2h





Posts: 138
Joined: Mon Jul 10, 2006 9:57 pm
Contact:

Post by h2h »

Thats what i was saying. When i try to add a dialog file from the toolbox it drags it under the form not on it.
User avatar
dos mes





Posts: 2158
Joined: Thu Dec 29, 2005 9:58 pm
Location: Syracuse, NY

Post by dos mes »

Yea, because it's not an item like a button. You have to activate it...

let's rename the OpenFileDialog1 to ofd

VB.Net usage:

Code: Select all

ofd.Title = "Open a Map"
ofd.Filter = "Map (*.map)|*.map"
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
' Do your stuff here...
End If
C#.Net usage:

Code: Select all

ofd.Title = "Open a Map";
ofd.Filter = "Map (*.map)|*.map";
if (ofd.ShowDialog() == DialogResult.OK)
{
// Do your stuff here...
}
C++.Net usage:

Code: Select all

ofd->Title = "Open a Map";
ofd->Filter = "Map (*.map)|*.map";
if(ofd->ShowDialog() == DialogResult::OK)
{
// Do your stuff here...
}
And I saw your post in the FF about taking program requests, no offense, but I highly suggest you take that down considering you are just starting to learn, and you can't even use an openfiledialog... :roll:
h2h





Posts: 138
Joined: Mon Jul 10, 2006 9:57 pm
Contact:

Post by h2h »

Dos Thanks for your help but i know how to do alot of other things other than dialog stuff. You canopen a file with a button.
Post Reply