My SoffishLib Bitch n' Moan Thread

Discuss your Halo 2 mod project here.
Post Reply
User avatar
JacksonCougar
Huurcat
Posts: 2460
Joined: Thu Dec 06, 2007 11:30 pm
Location: Somewhere in Canada

My SoffishLib Bitch n' Moan Thread

Post by JacksonCougar »

  • The purpose of this thread is to serve as a vent, an outlet if you will, for me in my programming venture of SoffishLib.
  • It shall be a place I go to make long a boring posts about vague problems in SoffishLib that I am not 100% sure how to implement, understand, or undertake.
  • It shall not be a place where you moan n' bitch to me about SoffishLib however, because that just will not help me feel motivated to do any work on SoffishLib at all.
  • This thread serves to serve me, so that you can help me with problems I have whilst programming: k? Thank you.
Let us begin.

I have run into a problem of understanding whilst programming my meta sections class for SoffishLib. The error in understanding comes from pointers, virtual offsets, and magic values.

I have come to understand that there are file-based offsets, and memory-based offsets: those memory-based offsets are the pointers in a meta table, and are translated into a file-based offset using a value called Magic. Okay, elementary stuff. My lack of understanding comes when I got the stupid idea that I had to go about rebuilding the memory-based offsets in the maps that SoffishLib makes so that there are no holes or overlaps in memory when the map loads (weee, no holes guys!). Now I have been made to understand that the memory-based offsets start at a constant location, known as the PrimaryMagicConstant UInt32, located in the Index at offset 0. So what I have done is decided to make a method to reclaculate the memory-based offsets.

I start by taking the PrimaryMagicConstant(PMC) value and adding to it the Index size - 32. This should leave us with a memory-based offset that is at the end of the Index information in memory.
Next I take this calculated memory-based offset and simply go through every reflexive in the sbsp/ltmp meta tables and add it to the file-based offset that I have previously calculated, writing the result to the map, at the reflexive's pointer location.

It occurs to me that by doing just that I have created a fairly huge fucking hole in memory: I suppose I have to subtract the TableStart offset from the new memory-offset to bring it back to contiguity. So Pointer = ReflexiveFileOffset + CalculatedMagicValue - MetaTableStartValue, should be correct?

So now it would be my understanding that PMC + (Index.Size - 32) would be the first sbsp/ltmp meta table's magic.

Is this correct? And will this hold to be correct as I go onwards through the rest of the sbsp/ltmp meta tables and the tag meta-table?

tl;dr: PrimaryMagicConstant+ (Index.Size - 32) would be the first sbsp/ltmp meta table's magic?

Update: Solved my own problem.

Code: Select all

public void CalculateMemoryPointers()
        {
            uint Magic;
            uint VirtualOffset = (uint)(Index.PrimaryMagicConstant + Index.Size - 32);
            foreach (SbspMetaTable Table in SbspMetaCollection)
            {
                Magic = (uint)(VirtualOffset - Table.Offset);
                Table.UpdateVirtualOffsets(Magic);
                VirtualOffset += (uint)Table.Size;
            }
            Magic = (uint)(VirtualOffset - MetaTable.Offset);
            MetaTable.UpdateVirtualOffsets(Magic);
        }
Post Reply