|
|
@@ -7,6 +7,7 @@
|
|
|
//
|
|
|
|
|
|
#import "FLEXHeapEnumerator.h"
|
|
|
+#import "FLEXObjcInternal.h"
|
|
|
#import <malloc/malloc.h>
|
|
|
#import <mach/mach.h>
|
|
|
#import <objc/runtime.h>
|
|
|
@@ -84,26 +85,14 @@ static kern_return_t reader(__unused task_t remote_task, vm_address_t remote_add
|
|
|
block(object, actualClass);
|
|
|
lock_zone(zone);
|
|
|
};
|
|
|
-
|
|
|
- // The largest realistic memory address varies by platform.
|
|
|
- // Only 48 bits are used by 64 bit machines while
|
|
|
- // 32 bit machines use all bits.
|
|
|
- //
|
|
|
- // __LP64__ is defined as 1 for both arm64 and x86_64
|
|
|
- // via: clang -dM -arch [arm64|x86_64] -E -x c /dev/null | grep LP
|
|
|
-#if __LP64__
|
|
|
- static uintptr_t MAX_REALISTIC_ADDRESS = 0x0000FFFFFFFFFFFF;
|
|
|
- BOOL lockZoneValid = lock_zone != nil && (uintptr_t)lock_zone < MAX_REALISTIC_ADDRESS;
|
|
|
- BOOL unlockZoneValid = unlock_zone != nil && (uintptr_t)unlock_zone < MAX_REALISTIC_ADDRESS;
|
|
|
-#else
|
|
|
- BOOL lockZoneValid = lock_zone != nil;
|
|
|
- BOOL unlockZoneValid = unlock_zone != nil;
|
|
|
-#endif
|
|
|
+
|
|
|
+ BOOL lockZoneValid = FLEXPointerIsReadable(lock_zone);
|
|
|
+ BOOL unlockZoneValid = FLEXPointerIsReadable(unlock_zone);
|
|
|
|
|
|
// There is little documentation on when and why
|
|
|
// any of these function pointers might be NULL
|
|
|
// or garbage, so we resort to checking for NULL
|
|
|
- // and impossible memory addresses at least
|
|
|
+ // and whether the pointer is readable
|
|
|
if (introspection->enumerator && lockZoneValid && unlockZoneValid) {
|
|
|
lock_zone(zone);
|
|
|
introspection->enumerator(TASK_NULL, (void *)&callback, MALLOC_PTR_IN_USE_RANGE_TYPE, (vm_address_t)zone, reader, &range_callback);
|