Skip to content

Commit

Permalink
Only inject into likely UI processes
Browse files Browse the repository at this point in the history
  • Loading branch information
NSExceptional committed Feb 19, 2020
1 parent 3c6816a commit 1b318da
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Tweak.xm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,17 @@ static id (*FLXGetManager)();
static SEL (*FLXRevealSEL)();
static Class (*FLXWindowClass)();

/// This isn't perfect, but works for most cases as intended
inline bool isLikelyUIProcess() {
NSString *executablePath = NSProcessInfo.processInfo.arguments[0];

return [executablePath hasPrefix:@"/var/containers/Bundle/Application"] ||
[executablePath hasPrefix:@"/Applications"] ||
[executablePath hasSuffix:@"CoreServices/SpringBoard.app/SpringBoard"];
}

inline bool isSnapchatApp() {
// See: near line 31 below
// See: near line 44 below
return [NSBundle.mainBundle.bundleIdentifier isEqualToString:@"com.toyopagroup.picaboo"];
}

Expand All @@ -32,7 +41,7 @@ inline bool isSnapchatApp() {
if ([disk fileExistsAtPath:standardPath]) {
// Hey Snapchat / Snap Inc devs,
// This is so users don't get their accounts locked.
if (!isSnapchatApp()) {
if (isLikelyUIProcess() && !isSnapchatApp()) {
handle = dlopen(standardPath.UTF8String, RTLD_LAZY);
}
} else {
Expand Down

0 comments on commit 1b318da

Please sign in to comment.