Created
February 25, 2018 20:36
-
-
Save DerekSelander/b2863e971159718339a354d6a8da082e to your computer and use it in GitHub Desktop.
Display UIDebuggingInformationOverlay on iOS 11 without swizzling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)load { | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
int imageCount = _dyld_image_count(); | |
const struct mach_header* UIKitHeader = nil; | |
for (int i = 0; i < imageCount; i++) { | |
if (strcmp(basename((char *)_dyld_get_image_name(i)), "UIKit") == 0) { | |
UIKitHeader = _dyld_get_image_header(i); | |
break; | |
} | |
} | |
if (!UIKitHeader) { | |
return; | |
} | |
unsigned long size =0; | |
uintptr_t * ptr = (uintptr_t *)getsectiondata((const struct mach_header_64 *)UIKitHeader, "__DATA", "__bss", &size); | |
for (int i = 0; i < size / sizeof(uintptr_t); i++) { | |
Dl_info info; | |
dladdr(&ptr[i], &info); | |
if (strcmp("__hasCachedDebuggingOverlayEnabled", info.dli_sname) == 0) { | |
memset(info.dli_saddr, 255, sizeof(BOOL)); | |
} | |
else if (strcmp("__cachedDebuggingOverlayEnabled", info.dli_sname) == 0) { | |
NSLog(@"woot 2"); | |
} | |
else if (strcmp("__UIGetDebuggingOverlayEnabledAssumingInternal.onceToken", info.dli_sname) == 0) { | |
memset(info.dli_saddr, 255, sizeof(uintptr_t *)); | |
void * offset = info.dli_saddr + 8; | |
memset(offset, 255, sizeof(uintptr_t *)); | |
memset(offset, 1, 1); | |
} | |
else if (strcmp("__isInternalDevice", info.dli_sname) == 0) { | |
memset(info.dli_saddr, 255, sizeof(uintptr_t *)); | |
} | |
else if (strcmp("UIDebuggingOverlayIsEnabled.onceToken", info.dli_sname) == 0) { | |
memset(info.dli_saddr, 255, sizeof(uintptr_t *)); | |
} | |
else if (strcmp("UIDebuggingOverlayIsEnabled.__overlayIsEnabled", info.dli_sname) == 0) { | |
memset(info.dli_saddr, 255, sizeof(uintptr_t *)); | |
} | |
else if (strcmp("__fetchedInternalDeviceOnceToken", info.dli_sname) == 0) { | |
memset(info.dli_saddr, 255, sizeof(uintptr_t *)); | |
} | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment