GP-1548: Fixed a bug with recovering Objective-C method names

This commit is contained in:
Ryan Kurtz
2021-11-30 18:38:37 -05:00
parent 16871e1eb6
commit bfc65888e0
2 changed files with 7 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ public class ObjectiveC2_Class implements StructConverter {
private ObjectiveC2_Class superclass;
private ObjectiveC2_Cache cache;
private ObjectiveC2_Implementation vtable;
private ObjectiveC2_ClassRW data;
private ObjectiveC2_ClassRW data; // class_rw_t * plus custom rr/alloc flags
public ObjectiveC2_Class(ObjectiveC2_State state, BinaryReader reader) {
this._state = state;
@@ -115,6 +115,10 @@ public class ObjectiveC2_Class implements StructConverter {
//Trying to read uninitialized memory
return;
}
// Fix pointer by applying Swift FAST_DATA_MASK (see objc-runtime-new.h for details)
index &= _state.is64bit ? ~0x7L : ~0x3L;
if (index != 0 && reader.isValidIndex(index)) {
long originalIndex = reader.getPointerIndex();
reader.setPointerIndex(index);

View File

@@ -38,7 +38,8 @@ public class ObjectiveC2_Method extends ObjectiveC_Method {
if (isSmallList) {
int nameOffset = (int)ObjectiveC1_Utilities.readNextIndex(reader, true);
int namePtr = reader.readInt(_index + nameOffset);
name = reader.readAsciiString(namePtr);
long imagebase = state.program.getImageBase().getOffset(); // When we support dyld_shared_cache, this base will likely have to change
name = reader.readAsciiString(imagebase + namePtr);
int typesOffset = (int)ObjectiveC1_Utilities.readNextIndex(reader, true);
types = reader.readAsciiString(_index + 4 + typesOffset);