No description
  • Logos 85.7%
  • Shell 12.7%
  • Makefile 1.6%
Find a file
2026-10-13 17:11:44 +00:00
.gitignore Add build-dylib.sh: compile the tweak to a standalone dylib 2026-10-10 10:11:26 +00:00
build-dylib.sh Update paths for /workspace/ios layout 2026-10-13 17:11:44 +00:00
CHANGELOG.md Freeze at 1.4.4; document injection reality and accepted gaps 2026-10-10 20:08:22 +00:00
control Calibrate MethodInfo.klass at runtime (1.4.4) 2026-10-10 12:10:26 +00:00
Makefile Log the package version (from control via -DPKG_VERSION) 2026-10-11 13:02:24 +00:00
README.md Freeze at 1.4.4; document injection reality and accepted gaps 2026-10-10 20:08:22 +00:00
rs.nyan.cytus2unlock.plist Cytus II unlock-all tweak 1.0.9 (verified working) 2026-10-10 00:46:47 +00:00
Tweak.x Log the package version (from control via -DPKG_VERSION) 2026-10-11 13:02:24 +00:00

rs.nyan.cytus2unlock — Cytus II unlock-all tweak

Target: Cytus II 5.2.21 (com.rayark.cytus2), Unity IL2CPP (metadata v31), arm64. Device: iPhone XS · iOS 16.1.1 · Dopamine 3.0 rootless (ElleKit). Scheme: rootless (iphoneos-arm64), installs to /var/jb/Library/MobileSubstrate/DynamicLibraries/.

How the game stores "unlocked"

All game logic is in UnityFramework.framework/UnityFramework (94.9 MB arm64 Mach-O, __TEXT vmaddr == 0 → runtime address = _dyld_get_image_vmaddr_slide() + dump VA).

Unlock state is expressed three different ways, so a single hook style is not enough:

Shape Example Hook returns
plain bool predicate PerDifficultyRecord.get_IsUnlocked true
bool "is locked" ResourceLock.get_IsLocked false
DisplayStatus enum UnlockStateResolver.GetFileState 2 (Unlocked)
IMonad<bool> IStore.IsPurchased, IsCharacterPurchased, SongStatusLookup.IsLocked a real monad, built by calling the game's own Monad.With<bool>(value) at 0x2336D48

The monad point matters: purchase checks do not return bool, so a naive "return 1" would hand back a fake object pointer. The tweak calls the game's own generic instantiation to construct a valid SimpleMonad<bool>.

Hooks (24)

Songs / charts

  • PerDifficultyRecord.get_IsUnlocked 0x19F5A4C → true
  • PerDifficultyRecordProxy.get_IsUnlocked 0x19F4ACC → true
  • ChartLockStateRecord.get_IsUnlocked 0x19BB934 → true
  • SongRecord.get_IsUnlocked 0x19FEB44 → true
  • SongStatusLookup.IsLocked 0x185D91C → monad(false)
  • HackedSongStatusLookup.IsLocked 0x185D264 → monad(false)
  • SongStatusLookup.IsMaxMasterModeUnlocked 0x185DB58 → true
  • HackedSongStatusLookup.IsMaxMasterModeUnlocked 0x185D3E8 → true

Song list filters (per-item availability predicates)

  • AvailableUnlockedFreeStorySongQuery.<Query>b__3_5 0x1859120 → true
  • AvailableUnlockedPaidStorySongQuery.<Query>b__4_8 0x1859C0C → true
  • AllPurchaseableExpansionPackSongQuery.<Query>b__2_0 0x1855F54 → true

Characters / titles / gallery

  • TitleInfoExtensions.IsUnlocked 0x18EF4B8 → true
  • GalleryItemDataExtension.IsUnlocked 0x16CE7E4 → true
  • CharacterIAPInformationHelper.IsCharacterPurchased 0x19DBAFC → monad(true)

Purchase layer (IStore implementations)

  • IapNativeStore.IsPurchased 0x16020BC → monad(true)
  • StorePlus.IsPurchased 0x160B890 → monad(true)
  • StoreWithCache.IsPurchased 0x160DEAC → monad(true)
  • StoreWithAnalytics.IsPurchased 0x160C5D0 → monad(true)
  • StoreWithMemoryCache.IsPurchased 0x161063C → monad(true)

Story / branching-OS gates

  • OASystemLevelLock.IsUnlock 0x1670AD0 → true
  • OASystemOSLock.IsUnlock 0x1670D9C → true
  • OASystemStoryLock.IsUnlock 0x1670F80 → true
  • UnlockStateResolver.GetFileState 0x16458A0 → Unlocked
  • ResourceLock.get_IsLocked 0x15C77D4 → false

Build notes

  • ARCHS = arm64 only — the app binary is arm64 (no arm64e slice).
  • Links $(THEOS)/vendor/lib/iphone/rootless/libsubstrate.tbd (install name @rpath/CydiaSubstrate.framework/CydiaSubstrate) with explicit -rpath /var/jb/Library/Frameworks and -rpath /var/jb/usr/lib; on Dopamine that framework path is a symlink to libellekit.dylib.
  • THEOS_SUDO_COMMAND=sudo is required for make install as mobile — Theos leaves it empty by default, which produces dpkg: error: requested operation requires superuser privilege.
  • Theos issues killall SpringBoard unprivileged, so it silently no-ops; respring with sudo /var/jb/usr/bin/killall SpringBoard.

Building a bare dylib

./build-dylib.sh compiles the tweak to a standalone .dylib in dist/ — no .deb, no install, no device contact.

./build-dylib.sh              # release: stripped + ldid-signed -> dist/<name>-<ver>-release.dylib
./build-dylib.sh --debug      # THEOS_DEBUG=1, symbols kept   -> dist/<name>-<ver>-debug.dylib
./build-dylib.sh --clean      # wipe .theos/ and dist/ first
./build-dylib.sh --run        # build, make install, respring

Notes:

  • Run as root it re-executes itself as dev, because Theos refuses to run as root.
  • Version in the output filename comes from ./control; dist/<name>.dylib is a symlink to the newest build.
  • Release dylib is 68640 B (stripped, signed); the debug one is 74880 B and keeps 105 local symbols, which is what you want for mapping a crash report's rs.nyan.cytus2unlock.dylib+0x6188 frame to a function.
  • The tweak exports no symbols by design; everything is static.

LiveContainer (jailed injection)

./build-dylib.sh --livecontainer emits dist/<name>-<ver>-livecontainer.dylib alongside the normal release dylib.

Why the rewrite is needed — the general recipe for converting a jailed tweak to LiveContainer injection:

  • A tweak built without theos-jailed links substrate at the absolute jailed path: /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate. Inside LiveContainer that path does not exist, so the dylib fails to load.
  • LiveContainer's TweakLoader supplies substrate from inside the container: LiveContainer.app/Frameworks.
  • So the dependency must be the relative, rpath-resolved form: @rpath/CydiaSubstrate.framework/CydiaSubstrate with an rpath of @executable_path/../Frameworks.

The script does exactly that with install_name_tool (-change for the dependency, -add_rpath for the search path) and then re-signs with ldid -S, because editing load commands invalidates the existing signature — a dylib left unsigned after the rewrite is rejected at load.

This repo's own rootless build already links the @rpath form, so it only needs the rpath added; a true jailed build needs both steps, which is why the script detects and applies each one conditionally.

Two hooking modes

The tweak picks a mode at load time from _NSGetExecutablePath() plus the loaded image list (LiveContainer rewrites _NSGetExecutablePath to the guest path, so the guest bundle location /Documents/Applications/ and any image path containing LiveContainer.app are the signals that work).

Inline mode (jailbroken). MSHookFunction patches the method's first instructions in UnityFramework __TEXT. Hooks install by VA at load, validated per hook by looks_like_prologue(); VAs that are not function starts are deferred and resolved by name once il2cpp_init reports metadata is registered.

Data-only mode (LiveContainer on iOS 26+, JIT off). LC signs the guest with its own certificate, so guest __TEXT pages are signature-verified: patching one makes the code-signing monitor strip execute permission and the first instruction fetched from it kills the process (CODESIGNING / Invalid Page). This mode patches no text at all. It resolves MethodInfo* and redirects the implementation pointer in writable runtime structures: MethodInfo.methodPointer when its region is writable, plus every word in the class struct and the arrays its pointer fields reach (vtable slots, interface shims, adjust thunks) equal to the original pointer.

Struct offsets are measured at runtime, not assumed: find_name_offset() locates MethodInfo.name by matching the method's own name string, and find_klass_offset() locates MethodInfo.klass by matching the class name. Every scan is bounded by writable_span() / readable_span(), which double as the read and write safety guards.

Verification

log stream --predicate 'eventMessage CONTAINS "Cytus2Unlock"'

Expected on launch (jailbroken):

[Cytus2Unlock] mode=inline hook (jailbreak)
[Cytus2Unlock] hooks applied: 14 ok, 0 failed, 10 deferred (of 24)
[Cytus2Unlock] il2cpp_init returned; metadata registered, validating resolver
[Cytus2Unlock] probe result: 4/4 match -> dynamic resolution IS ready
[Cytus2Unlock] deferred <name> -> 0x... (dynamic)

Expected on launch (LiveContainer):

[Cytus2Unlock] mode=data-only (LiveContainer)
[Cytus2Unlock] data-only: metadata ready after 1 attempt(s), patching pointers
[Cytus2Unlock] vtable <name>: 2 reference(s) redirected, orig=0x... | mi=... klass=...@0x20 kspan=... chased=... name_off=24
[Cytus2Unlock] data-only mode: 21 redirected, 0 no references, 3 missed (of 24)

Status (1.4.4)

Working on both targets: jailbroken iPhone XS (inline mode) and iPhone14,2 / iOS 27 / LiveContainer 3.8.10 with JIT off (data-only mode) — characters and songs unlock, no crash.

On the jailbroken path, hooks applied: 14 ok, 0 failed, 10 deferred: 10 of the 24 hardcoded 5.2.21 VAs are not function starts (0x19f5a4c holds 0x39404000, data), so they are deferred and resolved by name after readiness. On 1.2.1 those 10 were hooked at garbage addresses and were inert; they are effective for the first time from 1.3.0.

Known gaps: the 3 compiler-generated story-query lambdas (<>c__DisplayClass…) have no resolvable name in the dump and are missed in data-only mode. Opening the purchase UI under LiveContainer shows "Purchase record updated. Please purchase again." — the game's _RestoreBeforePurchaseAndCheckPurchased flow finds a purchase record with no StoreKit transaction (StoreKit is unusable in the container, 21102). Cosmetic.

The 8 monad-returning hooks are call-through wrappers: they invoke the game's own implementation and flip Result on the returned object. In practice every purchase/lock call returns BindMonad3`, whose result is produced by a coroutine, so the guard leaves it untouched and the hook is a no-op. That is intentional — the alternatives crash.

Dead ends, recorded so they are not retried:

  • Inline hooking a LiveContainer guest on iOS 26+ with JIT off is fatal. LC signs the guest with its own cert, so patched __TEXT pages lose execute permission and the process is killed with CODESIGNING / Invalid Page (1.3.0, at il2cpp_init, page listed rw-). Data-only mode is the answer; do not retry MSHookFunction against guest text there.
  • Assuming il2cpp struct offsets is not safe. MethodInfo.name measured at 0x18, not 0x10; the hardcoded klass offset read a string-heap pointer (unaligned values), so the vtable chase silently redirected nothing (1.4.2/1.4.3). Measure offsets at runtime.
  • Constructing a monad is not possible from the tweak. Monad.With<bool> (0x2336D48) is a shared generic taking Il2CppGenericMethod *ctx in x1; the game fills that pointer lazily, so the value in the image is an unresolved chained-fixup encoding (0xc0038751) and the call dereferences ctx+0x38 → SIGSEGV at 0xc0038789.
  • Hooking BindMonad<ValueTuple<bool,Purchase>, None, bool>.get_Result (0x2D948C4) to force "purchased" crashes the game (1.0.8, reverted in 1.0.9).
  • Calling the il2cpp metadata API from a background dispatch queue crashes the game (1.1.0, 1.2.0 — identical signature, SIGSEGV at 0x135 via UnityFramework+0x258edc -> +0x238b94 -> +0x276324). il2cpp builds its metadata cache on the main thread; call it from the main queue only.
  • Removing the 8 monad hooks re-locks the characters (1.1.2). They are not no-ops: purchase paths return SimpleMonad<bool> some of the time.
  • SimpleMonad<bool>.get_Result (0x27B4034) is a shared ldrb [x0,#16]; ret thunk used by both purchase checks and IsLocked, so forcing it true locks charts. Not hooked.

Current state: frozen at 1.4.4

Everything works on both targets, so development is stopped here. Nothing below is a to-do list; it is recorded so the next person does not re-derive it.

IPA injection (e.g. Sideloadly's dylib injection) does NOT make text patching legal. On non-jailbroken iOS every app is code-signed — App Store, or your Apple ID cert via Sideloadly — and the kernel validates executable pages on demand. The signature is what creates the page hashes, so signing the app yourself does not disable enforcement: patching __TEXT at runtime is the same CODESIGNING / Invalid Page kill seen under LiveContainer. That is why jailed tweaks only ever do ObjC swizzling, GOT/fishhook, and data patching.

What injection would buy: no LiveContainer dependency (the tweak loads as a normal linked dylib), and real StoreKit, which removes the 21102 and the "Purchase record updated" message. It buys no additional hooking capability.

It is cheap if ever wanted: data-only mode calls no substrate functions at all, so a substrate-free dylib is just a build-flag change (-undefined dynamic_lookup, drop the CydiaSubstrate dependency), plus LC_LOAD_DYLIB on CytusII and a re-sign of nested code.

Known gap, accepted: the 3 story/expansion query filter predicates. Two of them (0x1859120, 0x1859c0c) are not functions in 5.2.21 — they are data — so they have never been effective on any version, including the verified 1.2.1 build. Only 0x1855f54 (expansion pack) is a real function, and it works on the jailbroken path. They are VTABLE MISS under LiveContainer. They gate the free-story / paid-story / expansion-pack list screens; the main song-select and character paths are covered by the other 21 hooks, which is why unlock works.

Scope / limits

  • Local hooks only. Nothing is written to the game's files, save data, or receipts.
  • Online/multiplayer features that validate server-side are untouched; this affects the client's own unlock gates.
  • Addresses are build-specific (5.2.21). A game update shifts every RVA — re-dump with Il2CppDumper and re-derive from dump.cs before updating.
  • Private use on a device you own. Not published, not distributed.