Skip to content

Commit

Permalink
GP-4457: The dyld_shared_cache loader no longer throws an exception when
Browse files Browse the repository at this point in the history
importing newer versions that use dyld_cache_slide_info5
  • Loading branch information
ryanmkurtz committed Mar 25, 2024
1 parent 914d3ef commit 2aea201
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ else if (cacheMappingAndSlideInfoList.size() > 0) {
DyldCacheSlideInfoCommon slideInfo = DyldCacheSlideInfoCommon.parseSlideInfo(reader,
info.getSlideInfoFileOffset(), info.getAddress(), info.getSize(),
info.getFileOffset(), log, monitor);
slideInfoList.add(slideInfo);
if (slideInfo != null) {
slideInfoList.add(slideInfo);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public short[] getPageExtras() {
}

/**
* Create a new {@link DyldCacheSlideInfo3}.
* Create a new {@link DyldCacheSlideInfo4}.
*
* @param reader A {@link BinaryReader} positioned at the start of a DYLD slide info 3
* @param mappingAddress The base address of where the slide fixups will take place
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ public static DyldCacheSlideInfoCommon parseSlideInfo(BinaryReader reader, long

monitor.setMessage("Parsing DYLD slide info...");
monitor.initialize(1);
String errorMessage = "Failed to parse dyld_cache_slide_info";
try {
reader.setPointerIndex(slideInfoOffset);
int version = reader.readInt(reader.getPointerIndex());
errorMessage += version;
DyldCacheSlideInfoCommon returnedSlideInfo = switch (version) {
case 1 -> new DyldCacheSlideInfo1(reader, mappingAddress, mappingSize,
mappingFileOffset);
Expand All @@ -79,15 +81,14 @@ public static DyldCacheSlideInfoCommon parseSlideInfo(BinaryReader reader, long
mappingFileOffset);
case 4 -> new DyldCacheSlideInfo4(reader, mappingAddress, mappingSize,
mappingFileOffset);
default -> throw new IOException("Unrecognized slide info version: " + version);
default -> throw new IOException(); // will be caught and version will be added to message
};
monitor.incrementProgress(1);
returnedSlideInfo.slideInfoOffset = slideInfoOffset;
return returnedSlideInfo;
}
catch (IOException e) {
log.appendMsg(DyldCacheSlideInfoCommon.class.getSimpleName(),
"Failed to parse dyld_cache_slide_info.");
log.appendMsg(DyldCacheSlideInfoCommon.class.getSimpleName(), errorMessage);
return null;
}
}
Expand Down

0 comments on commit 2aea201

Please sign in to comment.