Skip to content

feat: HeaderProvider hook + KIOU-Hook A2 adoption + KF→KIOU rename#16

Merged
tkgstrator merged 9 commits into
developfrom
feat/header-provider-hook
Jul 1, 2026
Merged

feat: HeaderProvider hook + KIOU-Hook A2 adoption + KF→KIOU rename#16
tkgstrator merged 9 commits into
developfrom
feat/header-provider-hook

Conversation

@tkgstrator

@tkgstrator tkgstrator commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Accumulated feature branch that bundles three related deliveries so develop picks them up together:

  1. HeaderProvider hook for x-user-id swap — original goal of this branch. Wires the HeaderProvider.SetOrUpdateHeader entry slot in ChinlanDispatcher.m and bumps vendor/KIOU-Hook for the hook body.
  2. KIOU-Hook A2 adoption — bumps vendor/KIOU-Hook to 3079c5e (main HEAD after PR-A2 merge), picking up the 10 KiouEditor-derived hook bodies (Hook/AfkDisable.m, AssistEnable.m, AssistTune.m, Collection.m, MatchingPlayer.m, PremiumUnlock.m, SelectCharacter.m, SyncItemList.m, Version.m, VoiceUnlock.m), the shared Hook/Common.{h,m}, and KIOUSelfUserId in Account/Persistence. KiouForge doesn't install these hooks — the bump only tracks the shared library forward.
  3. KF → KIOU rename (KiouForge internals) — 13 files updated so every reference to the renamed shared surface resolves (KFSwitchAccountKIOUSwitchAccount, KFPendingDeviceIdKIOUPendingDeviceId, KFChinlanPublishKIOUChinlanPublish) plus the KiouForge-internal KF* sweep (dispatcher extern block, hook-body entry names, settings UI, gesture install). The whole tree drops the KiouForge-specific prefix in favour of the neutral KIOU* family. Matches the KIOU-Hook side rename shipped in KIOU-Hook#4.
  4. make deploy + BUNDLE_ID_SUFFIX — build → scptrollstorehelper install force → app launch. Kept separate from Theos's install:: so make deploy targets only the IPA path. BUNDLE_ID_SUFFIX=chinlan installs the patched build side-by-side with the App Store copy.

Dependencies (all merged)

Why the HeaderProvider site change

Hooking HttpMessageInvoker.SendAsync to swap x-user-id could not survive: touching self+0x10 or calling HttpHeaders.TryAdd/Remove from that hook body reliably crashed inside orig SendAsync's HttpHeaders.GetEnumerator on a 0x20025xxx truncated pointer, presumably because Cysharp Yaha borrows the request across the SendAsync boundary. HeaderProvider.SetOrUpdateHeader (Project.Network.dll, RVA 0x5BD9EE8) is managed-only code well before Yaha ever sees the request, with a (self, string, string, MethodInfo*) signature — no HTTP or Yaha types involved.

Test plan

  • make chinlan — all 27 files compile, link, sign clean.
  • make deploy completes end-to-end (chinlan → patch → scp → TrollStore force install → launch).
  • Settings → 切り替え → Confirm: [HEADER] x-user-id swapped → fires, no crash.
  • LoginReply returns target user's deviceId; SelfProfile openUserId changes across the switch.
  • No new .ips generated during account switch flows.
  • HttpMessageInvoker.SendAsync hook still installs (bare passthrough); cave / entry_slot wiring unchanged.
  • CI: Commit Lint + Build (substrate/jailed/chinlan) all green.

Follow-up

  • KIOU-Hook PR-A3 — FriendUnhide migration (replaces Hook/Common.m's sprite-helper stubs with the real il2cpp bridge).
  • KIOU-Hook PR-B (KiouEditor consumer migration) — adopts KIOU-Hook as a submodule.

Overrides for make deploy

  • TROLLSTORE_HELPER — path to trollstorehelper (default: /var/jb/Applications/TrollStorePersistenceHelper.app/trollstorehelper)
  • INSTALLED_IPA_BUNDLE_ID — auto-composed from TARGET_BUNDLE_ID + BUNDLE_ID_SUFFIX
  • DEVICE_USER — SSH user (default: root)

🤖 Generated with Claude Code

tkgstrator and others added 3 commits July 1, 2026 07:59
Wire the new HeaderProvider.SetOrUpdateHeader entry slot in KiouForge's
chinlan dispatcher and bump the KIOU-Hook submodule to carry the
catalog row and hook body.

Dispatcher gains one extern (KFHookHeaderProviderSetOrUpdate) and one
entry_slot assignment at KIOU_HOOK_SLOT_HEADER_PROVIDER_SET_OR_UPDATE_
HEADER. Nothing else in the dispatcher changes.

KIOU-Hook submodule bump brings:
  * Static-method typedef fix for BackToTitleSequence.RunAsync,
    RunResetUserDataSequenceAsync, and RunDeleteAccountSequenceAsync
    (previously (ct)-only, now (ct, mi) with fn(NULL, NULL) at call
    sites).
  * Catalog + recipe + Hook/GrpcLogging.m rewrite moving the x-user-id
    swap from HttpMessageInvoker.SendAsync to Project.Network.
    HeaderProvider.SetOrUpdateHeader — a managed-only site upstream
    of the Cysharp Yaha borrow that the SendAsync hook could not
    survive.

Verified end-to-end on 1.0.2 build 12 chinlan (jailbroken, TrollStore-
installed IPA): account switch completes without crash, [HEADER]
x-user-id swapped fires, and the follow-up LoginReply / SelfProfile
return the target user (openUserId changes from 1054-1001-0520-9241
to 2620-3831-5122-4152 across the switch).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add a make deploy target that builds the patched IPA, scps it to the
device, installs via trollstorehelper install force, and launches the
app. Kept separate from Theos's install:: so `make deploy` does not
also trigger the JB rootless .deb install as a side effect.

Introduce BUNDLE_ID_SUFFIX. Empty (default) leaves CFBundleIdentifier
untouched — the patched IPA overwrites the original app. Setting e.g.
BUNDLE_ID_SUFFIX=chinlan appends ".chinlan" to the bundle id at IPA
build time, so the patched IPA installs side-by-side with the
original App Store / Sideloadly copy of the same app.
INSTALLED_IPA_BUNDLE_ID composes the launch target from TARGET_BUNDLE_
ID + suffix automatically.

Related overrides (all .env-friendly):
  * TROLLSTORE_HELPER — /var/jb/Applications/TrollStorePersistenceHelper.
    app/trollstorehelper (stable rootless path)
  * INSTALLED_IPA_BUNDLE_ID — TARGET_BUNDLE_ID + optional suffix
  * DEVICE_USER — root

Requires the shared submodule bump so build_patched_ipa.sh honours
--bundle-id-suffix end-to-end.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add specialized Claude agents, a fix-tweak skill, and crash collection script for KIOU-Hook Tweak diagnosis and repair. Update the devcontainer to support the workflow dependencies and runtime setup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
tkgstrator and others added 6 commits July 1, 2026 08:39
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tkgstrator tkgstrator changed the title feat: HeaderProvider hook for x-user-id swap + make deploy target feat: HeaderProvider hook + KIOU-Hook A2 adoption + KF→KIOU rename Jul 1, 2026
@tkgstrator
tkgstrator merged commit db8c322 into develop Jul 1, 2026
8 checks passed
@tkgstrator
tkgstrator deleted the feat/header-provider-hook branch July 1, 2026 10:49
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.

1 participant