Saturday, August 22, 2015

How Abiathar Uses GAMEMAPS Editor Signatures

If you've ever poked at Keen Galaxy levels in a hex editor, you've noticed that the first eight bytes are used to identify the level editor that created the maps file. (It's " FLEEXY " for Abiathar or "FleexRSA" for Abiathar with VeriMaps.) One might be inclined to think that this signature is entirely cosmetic. Though Abiathar won't have any problems if the signature is absent or unusual, it does check that space and make some use of that information.

Nitpick: Abiathar proper doesn't do any level loading. That's all handled by FleexCore2, also known as FMod.dll. "Abiathar" from here on in the context of level loading refers to FleexCore2's INextGenLevelSet implementers, usually GalaxyLevels.

Of course, in the case of VeriMaps, the FleexRSA signature signals that the maps are signed. Abiathar, upon encountering that fact, reads the author and signed hash, retrieves the alleged author's public key from the VeriMaps server, computes its own hash, and compares that with the one provided. The result of the check is displayed in the status bar.

Otherwise, the signature is checked against a list of editors known to be more or less well-behaved. At the moment, that list includes TED5 (TED5v1.0) and the various versions of TOM, plus of course the two possible Abiathar signatures. A "well-behaved editor" is one that never places a level header at the very beginning of the maps file. In that case, Abiathar knows that if the map header file points to zero for the first level, there really is no level there.

 If an unknown signature is there, a level header could conceivably start at zero. In that case, Abiathar has to perform some heuristics if the first level's header claims to be at zero to determine whether there is actually a level there. Even if Abiathar wrongly guesses that there is a level there, exceptions are swallowed for the first run of the loop, so finding a bogus level header that isn't actually there won't cause the entire load operation to fail. (It will still complain big-time if other levels are in a bad format.)

Editor writers who want to ensure compatibility with all other editors should be careful to never place level headers at the very beginning of the maps file. That issue can be easily avoided by signing the editor name in the first eight (or more) bytes.

No comments:

Post a Comment