dyld-shared-cache-big-sur icon indicating copy to clipboard operation
dyld-shared-cache-big-sur copied to clipboard

Fix data rebasing

Open zcutlip opened this issue 5 years ago • 2 comments

Per discussion in #2 here are the changes I've made. I don't know if its useful or not, but feel free to disregard if it isn't. I think it should fix up the objective-c things you were already doing, but should more generically fix up pointers found in __DATA as well as symbols.

Here are some notes:

  • My c++ is terrible; I'm really sorry
  • This is an adaptation of the work done in https://github.com/zhuowei/dsc_extractor_badly
  • The important, but not obvious parts are changes made to structures in launch-cache/dyld_cache_format.h, especially location of undocumented mapping structs that point to slide info structs
  • There is a bunch of stuff that this doesn't do correctly, including:
    • There are broken references from __TEXT to __DATA
    • Some libraries, such as libswiftSceneKit are almost complete nonsense
  • It would be worth looking at the objective-c stuff in dsc_extractor_badly, as I didn't integrate that. The specific library I cared about wasn't obj-c

Let me know if I can help or if there are things here I can help explain

zcutlip avatar Aug 05 '20 20:08 zcutlip

Thank you! Excited to finally take a look at this.

antons avatar Aug 12 '20 18:08 antons

This will segfault while parsing libraries with no __DATA section, of which there are a few.

A fix:

//dsc_extractor.cpp

-- auto ret = slideOneSegment(dataSeg, 1, saved_vmaddrs[1], section_adjustments);

++ const macho_segment_command<P> *dataSeg = mh->getSegment("__DATA");
++ if(!dataSeg) {
++    return static_cast<std::vector<uint8_t>>(NULL);
++ }
++ auto ret = slideOneSegment(dataSeg, 1, saved_vmaddrs[1], section_adjustments);

jslegendre avatar Aug 20 '20 17:08 jslegendre