Skip to content

Class PackKeySlot

Namespace: Apogee.Export
Assembly: Apogee.Export.dll

A reserved place in the engine's executable for the key of the game's packs, so that an exported game opens its packs without the environment variable. The executable holds (68 bytes in its read-only data: a 16 byte magic, a format byte, a "used" byte, 2 reserved bytes, a 16 byte salt, and 32 bytes for the key); an export finds every copy of the template in the copy of the executable it makes, and writes the key into each, masked: key XOR SHA-256(salt + magic) (the same salt and bytes in all). The running game reads it back with .

There is normally one copy, but a compiler may emit the data twice (the NativeAOT compiler does in the arm64 macOS executable), and the game reads whichever copy its code refers to: so every copy is patched.

This is obfuscation, not protection. The key is in the file, one XOR from anyone who reads this code or finds the magic; and a running game has the key in memory. It keeps the key out of strings, out of a quick look in a hex editor, and out of the packs' reach, nothing more. It stops nobody who wants the game's files.

public static class PackKeySlot

Inheritance

object ← PackKeySlot

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Methods

TryRead()

The key an export wrote into this executable, or null when it has none (the program was not exported with a key: a development run, or an export without one).

public static PackKey? TryRead()

Returns

PackKey?

Exceptions

InvalidDataException

The slot holds a key in a format this version does not know.

Write(string, PackKey)

Writes key into every copy of the slot of the executable at executable, the same masked bytes (and salt) in each: the running game reads whichever copy its code refers to.

public static int Write(string executable, PackKey key)

Parameters

executable string

key PackKey

Returns

int

How many copies of the slot were written (at least one).

Exceptions

ExportException

The file has no slot, or more than (so it is not this engine's executable), ends inside a slot, or cannot be written.