Skip to content

Commit

Permalink
Recognize the low bit of the data pointer as marking a Swift class.
Browse files Browse the repository at this point in the history
  • Loading branch information
nygard committed Oct 1, 2015
1 parent 978d177 commit 7acf1f0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Source/CDDataCursor.m
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ - (uint64_t)readLittleInt64;
uint64_t result;

if (_offset + sizeof(result) <= [_data length]) {
// uint8_t *ptr = [_data bytes] + _offset;
// NSLog(@"%016llx: %02x %02x %02x %02x %02x %02x %02x %02x", _offset, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7]);
result = OSReadLittleInt64([_data bytes], _offset);
_offset += sizeof(result);
} else {
Expand Down
1 change: 1 addition & 0 deletions Source/CDOCClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
@property (copy, readonly) NSString *superClassName;
@property (strong) NSArray *instanceVariables;
@property (assign) BOOL isExported;
@property (assign) BOOL isSwiftClass;

@end
6 changes: 5 additions & 1 deletion Source/CDObjectiveC2Processor.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ - (CDOCClass *)loadClassAtAddress:(uint64_t)address;
objc2Class.superclass = [cursor readPtr];
objc2Class.cache = [cursor readPtr];
objc2Class.vtable = [cursor readPtr];
objc2Class.data = [cursor readPtr];

uint64_t value = [cursor readPtr];
class.isSwiftClass = (value & 0x1) != 0;
objc2Class.data = value & ~7;

objc2Class.reserved1 = [cursor readPtr];
objc2Class.reserved2 = [cursor readPtr];
objc2Class.reserved3 = [cursor readPtr];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
</CommandLineArgument>
<CommandLineArgument
argument = "/Applications/Utilities/Grab.app --arch x86_64"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "/Users/nygard/Downloads/p/Principle.app"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
Expand Down

0 comments on commit 7acf1f0

Please sign in to comment.