

# 2026-11-23/24 — ROOT CAUSE #2 FOUND: the inherited patch set neuters the REAL app launch path

## The real launch path (verified statically)
- Driver `main` (file off 0x80e0) -> UIApplicationMain(argc, argv, principal=nil,
  delegate=<class object at Driver+0x1fa11f0>).
- That class object IS `_TtC6Driver11AppDelegate` = `Driver.AppDelegate`
  (verified: its class_ro_t name pointer -> 0x19dc380 '_TtC6Driver11AppDelegate').
- Info.plist UIApplicationSceneManifest: UISceneDelegateClassName = 'Driver.SceneDelegate',
  configuration name 'Default Configuration'.
- Real app chain: `Driver.AppDelegate application:didFinishLaunchingWithOptions:` = Driver+0x3bb014
  -> helper Driver+0x3b8da4 (creates engine/UI); `Driver.SceneDelegate scene:willConnectToSession:options:`
  = Driver+0x31e9c -> Driver+0x3271c (the real UI entry).
- 0x3271c does NOT use self: 0x31e9c only retains self then calls 0x3271c(scene, options).

## THE BUG: 17 diff regions in the Driver binary (orig vs shipped)
All are 'neuters' from the inherited patch set. The four stub rewrites + six call-site NOPs
are the crash source:

    stubs (all -> c0035fd6 'ret'):    0x18FC6E8 (adrp x0)   0x18FE118 (adrp x16)
                                      0x18FE484 (adrp x16)  0x190C47C (adrp x16)
    call sites (all -> 1f2003d5 nop): 0x031FA8  bl 0x18FE484
                                      0x03281C  bl 0x18FE118   <-- inside 0x3271c
                                      0x032BF8  cbz x0,#0x3336c (null guard removed)
                                      0x0333CC  bl 0x18FE484
                                      0x035E4B4 bl 0x18FE118
                                      0x03B8E0C bl 0x18FE484   <-- inside 0x3b8da4
                                      0x05DE9C8 bl 0x18FC6E8
    remaining neuters kept: 0x22C740 (stp->ret), 0x1709780 (sub sp->mov w0,#0; ret),
                            0x170867C/0x1708684/0x17086BC/0x17086C0 (orr -> mov x0,xzr)

- These are **Swift value-type metadata accessors**. Idiom at each call site:
      `mov x0,#0 ; bl <accessor> ; ldur xN,[x0,#-8] ; ldr x,[xN,#0x40]`
  [x0-8] = Swift **value witness table** pointer, [vwt+0x40] = `size` (stack alloc).
  NOPing the call leaves x0 = 0 -> `ldur x,[x0,#-8]` -> **EXC_BAD_ACCESS at 0xfffffffffffffff8**.
- This is EXACTLY the SIGSEGV seen when the real SceneDelegate was allowed to run
  (crash Driver+0x32824, thread 0, via -[UIApplication _connectUISceneFromFBSScene:])
  and the abort seen when the real AppDelegate didFinishLaunching was invoked.
- Verified: Driver symtab/strtab are fully zeroed (7798 syms, n_strx=0) so import names
  are NOT recoverable statically; LC_DYLD_INFO_ONLY bind/lazy offsets are garbage (0x29/0x1d);
  no LC_DYLD_CHAINED_FIXUPS. Import identification must be done at runtime.

## Runtime verification (Frida, build 44 on the X)
- Returning nil from the shield's `application:configurationForConnectingSceneSession:options:`
  (build-info+0x292198) makes UIKit fall back to Info.plist -> **real Driver.SceneDelegate runs**
  (REAL_SD_willConnect + REAL_SCENE_FN fired) -> crashed at Driver+0x32824 (the neutered accessor).
- Restoring 0x3281c in memory removes the SIGSEGV; the real willConnect then runs further
  and hits a Swift trap ('abort was called') - likely a force-cast of
  `UIApplication.shared.delegate as! Driver.AppDelegate`, which fails because the shield
  is still the delegate.
- The real Driver.AppDelegate is NEVER instantiated (its init is never called);
  `object_setClass` is only used by CF internally (no AppDelegate morph).
- The shield's instance is created during **dyld initializer / +load** (backtraces contain
  dyld frames) via Foundation+libdispatch, then installed with -[UIApplication setDelegate:].
  Blocking that call in memory kills the app; swapping it for a real Driver.AppDelegate
  caused a stack overflow (alloc inside the setter).
- **UIKit does NOT consult the app delegate scene-config method on a normal (uiopen) launch**
  (verified twice: method_setImplementation and a byte patch both ignored; runtime manifest
  is intact and still says Driver.SceneDelegate). On a Frida *spawn* it DID get called once.
- Clearing the app data container's 'Saved Application State' + Caches + prefs did NOT change
  the outcome -> it is not an archived-scene-session issue.

## Build 45 (built, verified, installed on X, normally launched)
- apply_patch45.py: restores the 11 launch-path-critical Driver sites byte-identical to
  pristine + patches build-info 0x292198 -> `000080d2 c0035fd6` (mov x0,#0; ret).
- make_unsigned.py OUT=GSMDriver-3.19.0-patched45-unsigned.ipa, 65 patch sites verified.
  sha256 2c0a34f9b531b037c0e00d95fa0e3a18c52c776b43283d91ae96b2e60dff837a
- Installed in place on the X (only Driver + build-info replaced, ldid -S re-signed,
  backups at Driver.bak44 / build-info.bak44). Bundle:
  /var/containers/Bundle/Application/DE63FD5B-A21F-4487-9921-882DEDFA8DE9/Driver.app
- **Normal launch (uiopen, no Frida): app runs, NO crash, NO black screen; ban screen renders
  with ZERO rows.** Same as build 44 -> the restored sites do not destabilise anything.
- jbroot hash after rejailbreak = .jbroot-B23459BE77770263 (glob it, never hardcode).
- runsh.py added: runs a shell script FILE as root (avoids PowerShell mangling);
  output must go to /var/mobile/Media/<name> (NOT /rootfs/... - that path ENOENTs).
  AFC root == /var/mobile/Media. DDI must be re-mounted after each rejailbreak
  (pymobiledevice3 mounter auto-mount) before DVT screenshots work.
  root_exec.py must run under fv17 (system python's frida is too old for the new server).

## Remaining blocker (single point)
The shield's app delegate (Function_UmcOPEDGyT) + its scene delegate (Function_JgvFbyFH)
stay in control, so the real app never starts.

## Next moves (in order)
1. On a normally-launched build 45, attach Frida *after* launch and resolve
   NSClassFromString('Driver.SceneDelegate') **on the main thread** (calling it from the
   Frida thread access-violates). If it returns Function_JgvFbyFH, the shield re-binds
   NSClassFromString (fishhook) -> find and patch that rebind; that alone should let the
   real scene delegate run.
2. If (1) is clean, the static fix is: restore the 11 Driver sites (done) + neutralise the
   NSClassFromString rebind + keep build-info 0x292198 -> nil (harmless).
3. Alternative if the rebind is not the mechanism: patch build-info's shield scene
   `scene:willConnectToSession:options:` (0x298158) to hand off. Requires constructing a
   Driver.SceneDelegate - not expressible as a small byte patch; prefer (1).
4. Re-verify on the X with a normal launch + DVT screenshot; only then package for LCSign.
