Skip to content
This repository was archived by the owner on Aug 17, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions WDBRemoveThreeAppLimit/grant_full_disk_access.m
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ static void grant_full_disk_access_impl(void (^completion)(NSString* extension_t
completion(nil, [NSError errorWithDomain:@"com.worthdoingbadly.fulldiskaccess"
code:5
userInfo:@{NSLocalizedDescriptionKey : @"Can't patchfind."}]);
close(fd);
return;
}

Expand All @@ -345,6 +346,7 @@ static void grant_full_disk_access_impl(void (^completion)(NSString* extension_t
NSLocalizedDescriptionKey : @"Can't overwrite file: your device may "
@"not be vulnerable to CVE-2022-46689."
}]);
close(fd);
return;
}
munmap(targetMap, targetLength);
Expand Down Expand Up @@ -374,6 +376,7 @@ static void grant_full_disk_access_impl(void (^completion)(NSString* extension_t
}
completion(extension_token, returnError);
});
close(fd);
}

void grant_full_disk_access(void (^completion)(NSError* _Nullable)) {
Expand Down Expand Up @@ -596,6 +599,7 @@ bool patch_installd() {
if (!overwrite_file(fd, sourceData)) {
overwrite_file(fd, originalData);
munmap(targetMap, targetLength);
close(fd);
NSLog(@"can't overwrite");
return false;
}
Expand All @@ -606,5 +610,6 @@ bool patch_installd() {
// TODO(zhuowei): for now we revert it once installd starts
// so the change will only last until when this installd exits
overwrite_file(fd, originalData);
close(fd);
return true;
}
7 changes: 6 additions & 1 deletion WDBRemoveThreeAppLimit/helpers.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include <string.h>
#include <mach/mach.h>
#include <dirent.h>
#include <unistd.h>
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif

char* get_temp_file_path(void) {
return strdup([[NSTemporaryDirectory() stringByAppendingPathComponent:@"AAAAs"] fileSystemRepresentation]);
Expand All @@ -20,7 +24,8 @@
char* buf = malloc(PAGE_SIZE*10);
memset(buf, 'A', PAGE_SIZE*10);
fwrite(buf, PAGE_SIZE*10, 1, f);
//fclose(f);
free(buf);
fclose(f);
return path;
}

Expand Down