Skip to content

Commit

Permalink
objc: remove pac from arm64e pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Sep 11, 2023
1 parent ca89859 commit 1103206
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
10 changes: 8 additions & 2 deletions hilda/get_objectivec_class_description.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
unsigned int outCount = 0;
unsigned int i = 0, j = 0;

#ifdef __ARM_ARCH_ISA_A64
#define STRIP_PAC(x) (((uintptr_t)x) & 0x0000000fffffffff)
#else
#define STRIP_PAC(x) ((uintptr_t)x)
#endif

Class objcClass = (Class)__class_address__;
if (!objcClass) {
objcClass = objc_getClass("__class_name__");
Expand Down Expand Up @@ -76,7 +82,7 @@
methodReturnType = method_copyReturnType(methods[i]);
[classDescription[@"methods"] addObject:@{
@"name": [NSString stringWithCString:sel_getName(method_getName(methods[i])) encoding:NSUTF8StringEncoding],
@"address": [NSNumber numberWithLong:(uintptr_t)method_getImplementation(methods[i])],
@"address": [NSNumber numberWithLong:STRIP_PAC(method_getImplementation(methods[i]))],
@"is_class": @YES,
@"type": [NSString stringWithCString:method_getTypeEncoding(methods[i]) encoding:NSUTF8StringEncoding],
@"return_type": [NSString stringWithCString:methodReturnType encoding:NSUTF8StringEncoding],
Expand Down Expand Up @@ -104,7 +110,7 @@
methodReturnType = method_copyReturnType(methods[i]);
[classDescription[@"methods"] addObject:@{
@"name": [NSString stringWithCString:sel_getName(method_getName(methods[i])) encoding:NSUTF8StringEncoding],
@"address": [NSNumber numberWithLong:(uintptr_t)method_getImplementation(methods[i])],
@"address": [NSNumber numberWithLong:STRIP_PAC(method_getImplementation(methods[i]))],
@"is_class": @NO,
@"type": [NSString stringWithCString:method_getTypeEncoding(methods[i]) encoding:NSUTF8StringEncoding],
@"return_type": [NSString stringWithCString:methodReturnType encoding:NSUTF8StringEncoding],
Expand Down
11 changes: 9 additions & 2 deletions hilda/get_objectivec_symbol_data.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
@import ObjectiveC;
@import Foundation;

#ifdef __ARM_ARCH_ISA_A64
#define STRIP_PAC(x) (((uintptr_t)x) & 0x0000000fffffffff)
#else
#define STRIP_PAC(x) ((uintptr_t)x)
#endif

unsigned int outCount = 0;
unsigned int i = 0, j = 0;
id objcObject = (id)__symbol_address__;
Expand Down Expand Up @@ -114,7 +121,7 @@
methodReturnType = method_copyReturnType(methods[i]);
[objectData[@"methods"] addObject:@{
@"name": [NSString stringWithCString:sel_getName(method_getName(methods[i])) encoding:NSUTF8StringEncoding],
@"address": [NSNumber numberWithLong:(uintptr_t)method_getImplementation(methods[i])],
@"address": [NSNumber numberWithLong:STRIP_PAC(method_getImplementation(methods[i]))],
@"is_class": @YES,
@"type": [NSString stringWithCString:method_getTypeEncoding(methods[i]) encoding:NSUTF8StringEncoding],
@"return_type": [NSString stringWithCString:methodReturnType encoding:NSUTF8StringEncoding],
Expand Down Expand Up @@ -142,7 +149,7 @@
methodReturnType = method_copyReturnType(methods[i]);
[objectData[@"methods"] addObject:@{
@"name": [NSString stringWithCString:sel_getName(method_getName(methods[i])) encoding:NSUTF8StringEncoding],
@"address": [NSNumber numberWithLong:(uintptr_t)method_getImplementation(methods[i])],
@"address": [NSNumber numberWithLong:STRIP_PAC(method_getImplementation(methods[i]))],
@"is_class": @NO,
@"type": [NSString stringWithCString:method_getTypeEncoding(methods[i]) encoding:NSUTF8StringEncoding],
@"return_type": [NSString stringWithCString:methodReturnType encoding:NSUTF8StringEncoding],
Expand Down

0 comments on commit 1103206

Please sign in to comment.