@@ -68,7 +68,7 @@ bool redirectFunctionDirect(char *name, void *patchAddr, void *target) {
6868}
6969// redirectFunction for iOS 26+ (TXM)
7070bool redirectFunctionMirrored (char *name, void *patchAddr, void *target) {
71- if (DeviceRequiresTXMWorkaround ( )) {
71+ if (DeviceHasJITFlags ( JIT_FLAG_FORCE_MIRRORED | JIT_FLAG_HAS_TXM )) {
7272 JIT26PrepareRegionForPatching (patchAddr, sizeof (patch));
7373 }
7474 // mirror `addr` (rx, JIT applied) to `mirrored` (rw)
@@ -160,8 +160,9 @@ bool searchAndPatch(char *name, char *base, char *signature, int length, void *t
160160
161161 void *map = __mmap (addr, len, prot, flags, fd, offset);
162162 if (map == MAP_FAILED && fd && (prot & PROT_EXEC )) {
163+ printf (" [DyldLVBypass] mmap(prot=%d , flags=%d , fd=%d )\n " , prot, flags, fd);
163164 map = __mmap (addr, len, prot, flags | MAP_PRIVATE | MAP_ANON , 0 , 0 );
164- if (DeviceRequiresTXMWorkaround ( )) {
165+ if (DeviceHasJITFlags ( JIT_FLAG_FORCE_MIRRORED | JIT_FLAG_HAS_TXM )) {
165166 JIT26PrepareRegion (map, len);
166167 }
167168
@@ -192,7 +193,11 @@ int hooked___fcntl(int fildes, int cmd, void *param) {
192193#if !(TARGET_OS_MACCATALYST || TARGET_OS_SIMULATOR)
193194 // attempt to attach code signature on iOS only as the binaries may have been signed
194195 // on macOS, attaching on unsigned binaries without CS_DEBUGGED will crash
195- orig_fcntl (fildes, cmd, param);
196+ // ignoreFcntl is a special case for vphone or dev unit with TXM JIT enforcement disabled
197+ BOOL ignoreFcntl = DeviceHasJITFlags (JIT_FLAG_IS_IOS_26 | JIT_FLAG_HAS_TXM ) && !DeviceHasJITFlags (JIT_FLAG_FORCE_MIRRORED );
198+ if (!ignoreFcntl) {
199+ orig_fcntl (fildes, cmd, param);
200+ }
196201#endif
197202 fsignatures_t *fsig = (fsignatures_t *)param;
198203 // called to check that cert covers file.. so we'll make it cover everything ;)
@@ -218,21 +223,23 @@ void init_bypassDyldLibValidation() {
218223
219224 NSDebugLog (@" [DyldLVBypass] init" );
220225
221- if (@ available (iOS 26.0 , * )) {
222- if ( DeviceRequiresTXMWorkaround ()) {
226+ switch (( int ) DeviceGetJITFlags ( YES )) {
227+ case JIT_FLAG_FORCE_MIRRORED | JIT_FLAG_HAS_TXM :
223228 NSDebugLog (@" [DyldLVBypass] Using redirectFunctionMirrored" );
224229 redirectFunction = redirectFunctionMirrored;
225- } else {
230+ break ;
231+ case JIT_FLAG_FORCE_MIRRORED :
226232 // Special special case for non-TXM iOS 26+
227233 // We can JIT without script, but we cannot modify existing code in dsc without it.
228234 // Therefore, we choose a hook method that avoids patching code in dsc completely, using hardware breakpoint.
229235 // The function only stashes the original function pointers, and the breakpoint handler will redirect to our hook
230236 NSDebugLog (@" [DyldLVBypass] Using redirectFunctionHWBreakpoint" );
231237 redirectFunction = redirectFunctionHWBreakpoint;
232- }
233- } else {
234- NSDebugLog (@" [DyldLVBypass] Using redirectFunctionDirect" );
235- redirectFunction = redirectFunctionDirect;
238+ break ;
239+ default :
240+ NSDebugLog (@" [DyldLVBypass] Using redirectFunctionDirect" );
241+ redirectFunction = redirectFunctionDirect;
242+ break ;
236243 }
237244
238245 // Modifying exec page during execution may cause SIGBUS, so ignore it now
0 commit comments