From b98b26d32f25742cd0030a4ad4acf4b2c5a71131 Mon Sep 17 00:00:00 2001 From: van Date: Tue, 7 Feb 2023 22:05:35 +0800 Subject: [PATCH] fix * Fix bakc typo * Fix tcc path not found crash bug Signed-off-by: van --- WDBFontOverwrite/grant_full_disk_access.m | 12 +++++++++++- WDBFontOverwrite/vm_unaligned_copy_switch_race.c | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/WDBFontOverwrite/grant_full_disk_access.m b/WDBFontOverwrite/grant_full_disk_access.m index 300f018..4c5eab3 100644 --- a/WDBFontOverwrite/grant_full_disk_access.m +++ b/WDBFontOverwrite/grant_full_disk_access.m @@ -307,6 +307,16 @@ static void grant_full_disk_access_impl(void (^completion)(NSString* extension_t NSError* _Nullable error)) { char* targetPath = "/System/Library/PrivateFrameworks/TCC.framework/Support/tccd"; int fd = open(targetPath, O_RDONLY | O_CLOEXEC); + if (fd == -1) { + targetPath = "/System/Library/PrivateFrameworks/TCC.framework/tccd"; + fd = open(targetPath, O_RDONLY | O_CLOEXEC); + if (fd == -1) { + completion(nil, [NSError errorWithDomain:@"com.worthdoingbadly.fulldiskaccess" + code:5 + userInfo:@{NSLocalizedDescriptionKey : @"Can't patchfind."}]); + return; + } + } off_t targetLength = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); void* targetMap = mmap(nil, targetLength, PROT_READ, MAP_SHARED, fd, 0); @@ -397,4 +407,4 @@ void grant_full_disk_access(void (^completion)(NSError* _Nullable)) { error:&error]; completion(nil); }); -} \ No newline at end of file +} diff --git a/WDBFontOverwrite/vm_unaligned_copy_switch_race.c b/WDBFontOverwrite/vm_unaligned_copy_switch_race.c index c277c9a..dacb3c1 100644 --- a/WDBFontOverwrite/vm_unaligned_copy_switch_race.c +++ b/WDBFontOverwrite/vm_unaligned_copy_switch_race.c @@ -68,7 +68,7 @@ switcheroo_thread(__unused void *arg) T_QUIET; T_EXPECT_MACH_SUCCESS(kr, " vm_map() RW"); /* wait a little bit */ usleep(100); - /* switch bakc to original RO mapping */ + /* switch back to original RO mapping */ kr = vm_map(mach_task_self(), &ctx->e0, ctx->obj_size,