From what I understand, i take the 4 bytes i have, 00AC4988, and remove the first byte which points to which file the raw data is in (local, mainmenu, shared, and sp_shared). Now i get AC4988, is this the raw offset? What does he mean by "and with 0x3FFFFFFF" ? Thanks to anyone that can help.When referencing a raw offset, one should first determine the file being referenced, remove those two bits from the offset value (and with 0x3FFFFFFF), and then seek to that offset in the correct file to find the referenced data.
Interpreting Raw Offsets
-
- Posts: 552
- Joined: Thu May 12, 2005 4:12 am
Interpreting Raw Offsets
I'm having trouble figuring out how to get a raw offset out of 4 bytes in the hex. In the whitepaper it says:
-
- Posts: 552
- Joined: Thu May 12, 2005 4:12 am
Did you not read what I said? 8 bits are in a byte...Choking Victim wrote:That's exactly what I removed...two bits = one byte. I have 00AC4988, remove the first two bits to get AC4988. I don't understand what he means when he says "and with 0x3FFFFFFF".
Hence when using a binary Reader and your reading a short, its ReadInt16(16 bit integer)... A byte is half the size of a short... making it 8...
Bits = 0's and 1's.. Its the binary of the value being read...
Byte has 8
Short has 16
Long has 32
Quad has 64
You also asked me about JMAD Raw...
Add this method to determine where the raw is located:
Code: Select all
map.Open(HaloMap.MapType.Internal);
map.br.BaseStream.Position = meta.Offset + 172;
int count = map.br.ReadInt32();
int trans = map.br.ReadInt32() - map.secondaryMagic;
for (int i = 0; i < count; i++)
{
RawChunk raw = new RawChunk();
raw.offsetOfPointer = trans + (i * 20) + 8;
raw.type = RawType.jmad;
map.br.BaseStream.Position = raw.offsetOfPointer - 4;
raw.size = map.br.ReadInt32();
raw.offset = map.br.ReadInt32();
functions.GetRawLocation(ref raw.offset, ref raw.location);
if (raw.size != -1)
{
map.Open(raw.location);
map.br.BaseStream.Position = raw.offset;
raw.ms = new MemoryStream(raw.size);
raw.ms.Write(map.br.ReadBytes(raw.size), 0, raw.size);
map.Open(HaloMap.MapType.Internal);
}
chunks.Add(raw);
}
Code: Select all
public void GetRawLocation(ref int pointerOffset, ref HaloMap.MapType type)
{
long temp = pointerOffset & 0XC0000000;
pointerOffset = pointerOffset & (int)0X3FFFFFFF;
switch (temp)
{
case 0:
type = HaloMap.MapType.Internal;
break;
case 0X40000000:
type = HaloMap.MapType.MainMenu;
break;
case 0X80000000:
type = HaloMap.MapType.Shared;
break;
case 0XC0000000:
type = HaloMap.MapType.SpShared;
break;
}
}

-
- Posts: 151
- Joined: Mon Jun 13, 2005 12:45 pm
I have tried to convert that code to VB so that we could use it, but it keeps returning huge raw sizes and even some negative sizes like -874528752, the same goes for the raw offsets. Here is my code, maybe you guys can spot something I did wrong. Thanks.
Code: Select all
Private Sub GetRawOffset
reader.BaseStream.Position = JmadOffset + 172
Dim count As Integer = reader.ReadInt32()
Dim trans As Integer = reader.ReadInt32()
trans = trans - Me.HaloMap.mapSecondaryMagic
For x As Integer = 0 To count - 1
Dim offsetOfPointer As Integer
Dim RawSize As Integer
Dim RawOffset As Integer
Dim RawLocation As String
offsetOfPointer = trans + (x * 20) + 8
reader.BaseStream.Position = offsetOfPointer - 4
RawSize = reader.ReadInt32()
RawOffset = reader.ReadInt32()
GetRawLocation(RawOffset, RawLocation)
If RawSize <> -1 Then
End If
Next
End Sub
Sub GetRawLocation(ByRef pointerOffset As Integer, ByRef type As String)
Dim temp As Long = pointerOffset And 3221225472
pointerOffset = pointerOffset And CInt(1073741823)
Select Case temp
Case 0
type = "Internal"
Exit Select
Case 1073741824
type = "MainMenu"
Exit Select
Case 2147483648
type = "Shared"
Exit Select
Case 3221225472
type = "SpShared"
Exit Select
End Select
End Sub
-
- Posts: 151
- Joined: Mon Jun 13, 2005 12:45 pm
I believe that it is Anthony's classes but when I do what u said, with the offset + mapmagic, the program crashes. It gives me a really low negative number as the trans value.-DeToX- wrote:Are you using Anthony's classes? Because those use a different method of address modifying... His I beleive is offset + mapmagic.
Mine was - secondary Magic..
Nevermind anthony's class aswell is - MapMagic, its not secondary for his...ShadowSpartan wrote:I believe that it is Anthony's classes but when I do what u said, with the offset + mapmagic, the program crashes. It gives me a really low negative number as the trans value.-DeToX- wrote:Are you using Anthony's classes? Because those use a different method of address modifying... His I beleive is offset + mapmagic.
Mine was - secondary Magic..
Well did you fix the part for "FindTagIndexByPath"...
It will only find metas by that name... It doesnt look for the name and Class...
It should end up looking like this:
Code: Select all
Public Function FindTagIndexByPath(ByVal TagClass As String, ByVal TagPath As String) As Integer
Dim index As Integer = 0
'Loop through all the tags and if we find a matching path then we return then index of it
For i As Integer = 1 To objectCount Step 1
If H2Tag(i).TagPath = TagPath Then
If H2Tag(i).TagClass = TagClass Then
index = i
Exit For
End If
End If
Next
Return index
End Function
Seriously though... if you plan to make a larger scale app, you should definitely write your own code.

-
- Posts: 151
- Joined: Mon Jun 13, 2005 12:45 pm
When I changed it to Offset - mapmagic, everything came out positive but there is one thing I am unsure about. Is it possible for just one tag to have raw in multiple places, like for instance the MC tag having some raw in shared.map but others internal?
Also, I know I'm in the right tag, I've changed that function already.
Also, I know I'm in the right tag, I've changed that function already.
Yes it is. But if you followed the code there, it will determine where the raw is located for every raw block, aswell as the offset in that map at which it is located.ShadowSpartan wrote:When I changed it to Offset - mapmagic, everything came out positive but there is one thing I am unsure about. Is it possible for just one tag to have raw in multiple places, like for instance the MC tag having some raw in shared.map but others internal?
Also, I know I'm in the right tag, I've changed that function already.

!.. Doing that would mean that if no tag was 'found', 0 would still be returned :\-DeToX- wrote:Well did you fix the part for "FindTagIndexByPath"...
It will only find metas by that name... It doesnt look for the name and Class...
It should end up looking like this:
[...]
Fix..
Code: Select all
Public Function IndexOf(ByVal TagClass As String, ByVal TagPath As String) As Integer
For i As Integer = 1 To objectCount Step 1
If H2Tag(i).TagClass = TagClass And H2Tag(i).TagPath = TagPath Then
Return i
End If
Next
Return -1
End Function
Halo 2 Prophet - Skin with ease with the simple 3D point and click interface.
Halo 3 Research Thread - Contribute to the research into Halo 3.
Halo 3 Research Thread - Contribute to the research into Halo 3.