Skip to content

Commit

Permalink
Fix app preview images disappearing
Browse files Browse the repository at this point in the history
  • Loading branch information
opa334 committed May 2, 2024
1 parent b0dc4f5 commit 854057c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions BaseBin/rootlesshooks/SpringBoard.x
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@
#import <substrate.h>
#import <objc/objc.h>
#import <libroot.h>
#import <fcntl.h>

bool stringStartsWith(const char *str, const char* prefix)
{
if (!str || !prefix) {
return false;
}

size_t str_len = strlen(str);
size_t prefix_len = strlen(prefix);

if (str_len < prefix_len) {
return false;
}

return !strncmp(str, prefix, prefix_len);
}

@interface XBSnapshotContainerIdentity : NSObject <NSCopying>
@property (nonatomic, readonly, copy) NSString* bundleIdentifier;
Expand All @@ -21,6 +38,33 @@

%end

%hookf(int, fcntl, int fildes, int cmd, ...) {
if (cmd == F_SETPROTECTIONCLASS) {
char filePath[PATH_MAX];
if (fcntl(fildes, F_GETPATH, filePath) != -1) {
// Skip setting protection class on jailbreak apps, this doesn't work and causes snapshots to not be saved correctly
if (stringStartsWith(filePath, JBROOT_PATH_CSTRING("/var/mobile/Library/SplashBoard/Snapshots"))) {
return 0;
}
}
}

va_list a;
va_start(a, cmd);
const char *arg1 = va_arg(a, void *);
const void *arg2 = va_arg(a, void *);
const void *arg3 = va_arg(a, void *);
const void *arg4 = va_arg(a, void *);
const void *arg5 = va_arg(a, void *);
const void *arg6 = va_arg(a, void *);
const void *arg7 = va_arg(a, void *);
const void *arg8 = va_arg(a, void *);
const void *arg9 = va_arg(a, void *);
const void *arg10 = va_arg(a, void *);
va_end(a);
return %orig(fildes, cmd, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10);
}

void springboardInit(void)
{
%init();
Expand Down

0 comments on commit 854057c

Please sign in to comment.