FLEXTool / FLEX

An in-app debugging and exploration tool for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@available wasn't working properly

LNSSPsd opened this issue · comments

Environment

  • Platform+version: iOS 13.3
  • FLEX(libFLEX) version: 4.4.1

Bug Report

Apps that loaded FLEX crash with error message Cannot find property with name image on class UIAlertController.
The message mentioned image property so I tried to comment the line

[alertControllerProps insertObject:@"image" atIndex:4];

and FLEX works properly.
But this line shouldn't be executed because there's an @available before it and my system version is lower than iOS 14, so it seems that the @available doesn't work properly(it returns true even if my system version doesn't match the requirement).
I tried to change @available(iOS 14.0, *) to [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){14,0,0}] and uncomment the code previously mentioned and FLEX also works fine.

Are you using the tweak as your info suggests or are you using it as a cocoapod in a project?

Oh, I see. Which apps are crashing with this? All of them? Or just some?

All of them including SpringBoard.

I didn't release 4.4.1 yet, did you build it yourself? Are you sure you were on the same commit that FLEX/master:4.4.1 points to now? Because at first I didn't have that availability check at all, and then I added it the next day and forced pushed and silently changed the tag 😬

So if you unknowingly compiled the version without the check, that would explain what we're seeing here. There's no reason that check wouldn't work on iOS 13

I compiled it using the latest version,and I also saw the @available locally,but is doesn't work at all.

So now I think maybe something was configured wrongly in my compiler or other things.

Thanks for answering.

Well hey, no reason to close the issue yet, let's figure this out. Can you send me the dylib from your compiled version of the package?

Oh thanks, here's what I've attempted.
Dylib that built from version commit 258ec869 w/ my compiler: libFLEX_dylib.zip
Environment: Debian Linux,Theos 2.5.0,SDK: iPhoneOS14.0.sdk
I tried to debug it using IDA, and it seems that the availability check doesn't exist in the binary and the action which inserts
"image" into alertControllerProps will be called whatever.
Screenshot1
In the disassemble view there's a B command but it jumps to the next command directly so I think maybe that the @available check is replaced to true instead of a dynamic judgement when the code is compiling.
Screenshot2
And this is the code at that place.^
But when I replace the @available expression to [NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:] and the code can be compiled correctly.
(IDA:
Screenshot3
)
and the modified code's image:
Screenshot_4

I think this has to be a linux thing. Looking at your binary, I don't see any calls to ___isPlatformVersionAtLeast, while mine has a call to it. Yours just has a weird if ((0xff & 0x1) == 0x1) check (or no check at all in the arm64e slice).

Can you try compiling it on macOS? If not, just hang on and I'll update my package

I don't have a device with macOS installed.
But thank you for figuring out the cause of the problem.

The only other thing it could be is if you modified the makefile to use iOS 14 as the minimum deployment version