Memory Management (USE/fREe)

From Wulinshu
Jump to navigation Jump to search

Static Storage

The static memory storage is 322 entries big and located at 0x142A760C0 (v1.07).
The entries have a max content size of 32 bytes.
Due to this restriction the memory de/allocation in this storage is way faster than in the dynamic storage.

Dynamic Storage

The dynamic storage is allocated with the function at 0x140361A40 (v1.07).
Two HLib entries will be added, one at the start and one at the end of the allocated memory.
After the first HLib entry a new fREe entry will be added and looks like this.
This entry has the previous entry pointer set to the first HLib entry and the next entry pointer set to the HLib entry at the end.

Free Storage

To free storage the function 0x14049CDD0 (v1.07) is used.

Allocate Storage

To allocate storage the function 0x14049CB40 (v1.07) is used.

Storage entry

Position Length Type Description
0x00 0x04 string Memory type token
0x04 0x04 ? Padding?
0x08 0x08 uint64_t Content size
0x10 0x08 uint64_t* Previous storage entry pointer
0x18 0x08 uint64_t* Next storage entry pointer
0x20 0x04 string USE/fREe token (determines if the space is being used)
0x40 Content size ? Storage data

Storage tokens

Identified

Name Description
HLib Root storage entry type
TASK Contains various data for a task
MDL MT7 model
INFO Mapinfo
CHID Character ID

Unidentified

Name Description
MAI Model data?
SHDM Model data
SCNC Scene stuff?
WNDB ?
SHAD Textures?
WARN Warning (uses textures?)
WARP (uses textures?)
ITPH (uses textures?)
SNCT (uses textures?)
PAWN Pawnshop?
FLDD Collision data
ACPH ?
ACPD ?
DOME Skybox dome?
CVIX Indexing?
ADFS ?
MODL Model info?
MAIX Model info?
PAKT ?
PAKa ?
PAKM ?
CLIP ?
WALL ?
WALC ?
FLAG FLAG.BIN?
HMDL Model?
STCH NPC related