The Realm Files - Vol 3 - The Realm Header
In the previous installment of The Realm Files, I discussed how a Realm database maintains two top nodes as a direct result of its copy on write architecture. To start decoding these two distinct nodes, we need a reliable anchor point, and that anchor is the file header. The file header occupies the first 24 bytes of a Realm database file and contains seven informational entries, as shown in the table below. Note: All integer values in the header are stored in little endian byte order. Offset Size (Bytes) Description 0 8 Top Reference 0 – Offset to Top-Level Node 8 8 Top Reference 1 – Offset to Top-Level Node 16 4 Mnemonic (File Signature) – 54 2D 44 42 (TB-D) 20 1 File Format (Top Ref 0) 21 1 File Format (Top Ref 1) 22 1 Reserved Byte (Currently Not Used) 23 1 Flag – Determines which Root Node is currently active The first 16 bytes of the Realm file header consist of two 8-byte integers known as Top Reference 0 and Top Reference 1. Each value points to the file offset of ea...