Skip to content

Fix decryption for Riddle Joker#185

Merged
crskycode merged 1 commit into
crskycode:masterfrom
CBerJun:rj-key-fix
Apr 18, 2026
Merged

Fix decryption for Riddle Joker#185
crskycode merged 1 commit into
crskycode:masterfrom
CBerJun:rj-key-fix

Conversation

@CBerJun
Copy link
Copy Markdown

@CBerJun CBerJun commented Apr 13, 2026

If you dump the current Formats.dat, you'll see:

"Riddle Joker": {
  "m_key1": 0,
  "m_key2": 0,
  "YuzKey": [
    2660206490,
    3437206417,
    2258490061,
    2497682059,
    3184993560,
    3577860684
  ],
  "NamesSectionId": "yuz:",
  "HashAfterCrypt": false,
  "StartupTjsNotEncrypted": true,
  "ObfuscatedIndex": false
},

Notice that m_key1 and m_key2 are both 0 when they should've been 0xaaaaaaaa and 0x55555555 respectively. This is probably due to 01636ac which adds these two fields to RiddleCxCrypt (instead of having them hardcoded).

I fixed Formats.dat with the following:

using System.IO;
using System.Linq;

namespace SchemeTool
{
    class Program
    {
        static void Main(string[] args)
        {
            using (Stream stream = File.OpenRead(".\\GameData\\Formats.dat"))
            {
                GameRes.FormatCatalog.Instance.DeserializeScheme(stream);
            }
            GameRes.Formats.KiriKiri.Xp3Opener format = GameRes.FormatCatalog.Instance.ArcFormats
                .FirstOrDefault(a => a is GameRes.Formats.KiriKiri.Xp3Opener) as GameRes.Formats.KiriKiri.Xp3Opener;
            GameRes.Formats.KiriKiri.Xp3Scheme scheme = format.Scheme as GameRes.Formats.KiriKiri.Xp3Scheme;
            GameRes.Formats.KiriKiri.RiddleCxCrypt rjCrypt = scheme.KnownSchemes["Riddle Joker"] as GameRes.Formats.KiriKiri.RiddleCxCrypt;
            rjCrypt.m_key1 = 0xAAAAAAAA;
            rjCrypt.m_key2 = 0x55555555;
            using (Stream stream = File.Create(".\\GameData\\Formats.dat"))
            {
                GameRes.FormatCatalog.Instance.SerializeScheme(stream);
            }
        }
    }
}

To verify that this works, try unpacking the game's official patch available here (direct link). (This is an NSIS installer, you can either run it and find the patch manually or extract patch.xp3 from it directly with NanaZip)

Prior to the fix, the files extracted from the patch all have a few bytes broken (though most of the bytes are correct).

@crskycode crskycode merged commit 65368f2 into crskycode:master Apr 18, 2026
@CBerJun CBerJun deleted the rj-key-fix branch April 18, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants