oooh! PW you came! 83
and awesome with Module editor 3 >w<
also, I need to ask you! do you know something about how the Relocation are linked to Objects and Assembly?
and do you possible know exactly how NameOffset, PrologOffset, EpilogOffset and Unresolved Offset are linked? I just dont find it out how D:
A huge thanks for the gift
Hmm, a lot of questions here. I guess I'll start from the beginning.
When the module is first loaded into memory, the first thing the game does is call a function on it that links the module to each of the other modules loaded into memory. In the Revolution SDK, this function is called OSLink. When called on a module, it resolves all relocations inside the module and checks all existing modules for dependencies on it resolving them in the process.
I won't go into too much detail on how the relocations are stored as you can find that in the Module Viewer 3 Source code, but one important thing to know is the relocation types:
Value = SectionOffset + Addend
0x00 nop
0x01 Write Word ( target u32 = Value )
0x02 Set Long Branch Offset ( target u32 = (target u32 & ~0x03FFFFFC) | (Addend & 0x03FFFFFC) )
0x03 Write Lower Half ( target u16 = Value & 0xFFFF )
0x04 == 0x03
0x05 Write Upper Half ( target u16 = (Value >> 16) & 0xFFFF )
0x06 == 0x05
0x07 Set Short Branch Offset ( target u32 = (target u32 & ~0xFFFC) | (Addend & 0xFFFC) )
0x08 == 0x07
0x09 == 0x07
0x0A Set Long Branch Destination ( target long branch destination = Addend )
0x0B Set Short Branch Destination ( target short branch destination = Addend )
0x0C == 0x0B
0x0D == 0x0B
Once the module is linked, the _prolog function may be optionally called. In Brawl, the _prolog function is always called. The assembly code for the _prolog function can be found by going to the PrologOffset inside the section specified by PrologSection (
the PrologSection is almost always the Section[1]). When called, it invokes the constructor for each of the top level objects inside the module. The pointers to these constructor functions are usually found in Section[2] of the module.
Objects exist in multiple parts. All object declarations, inheritance values and virtual function tables are usually stored in Section[5]. There isn't a whole lot of organization to the data, but there are a few basic structures that can be found if you know what to look for:
(because all pointers only exist once the module has been linked, you won't be able to see these values inside a regular hex viewer.
They can be found using the Module Viewer 3's memory viewer though)
Declaration (8 bytes)
0x00 Name ptr
0x04 Inheritance[] ptr
Inheritance (8 bytes)
0x00 Declaration ptr
0x04 Unknown
Virtual Function Table (8 bytes + 4 * numFunctions)
0x00 Declaration ptr
0x04 Blank
0x08 Function[0] ptr
0x__ Function[...] ptr
Because everything is so unorganized, the only way you can really parse this section is if you use a code crawler like the Module Viewer 2 used. For the time being, Module Viewer 3 supports simple tagging, but hopefully there'll be a way to automate the process soon.
As for the actual objects themselves; they are created by the constructor functions into the Bss Memory which in turn is created at runtime. The Bss Memory is accessed like the rest of the module sections and is usually found at Section[6] - while you can open it in the memory viewer, the actual section doesn't exist in the module and is only created at runtime.
Beyond that, the _epilog function does the opposite of the _prolog function and is called right before the module is unlinked (
The destructor function pointers are found in Section[3]). As for the _unresolved function; all external functions calls in the module are initially directed towards this function. That way, if a function doesn't get linked, the _unresolved function is called instead. For the most part, it does something along the lines of throwing an exception while reporting the module's source file (
e.g. mo_fighter.cpp)
That's about as much as I know about the module files - the rest of it you already posted in the link in the opening post.
I'll be around, so if you have any other questions, go ahead and ask away.