Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subCacheUUID field should probably be subCachesOffset instead #49

Closed
mstange opened this issue Nov 7, 2021 · 11 comments
Closed

subCacheUUID field should probably be subCachesOffset instead #49

mstange opened this issue Nov 7, 2021 · 11 comments

Comments

@mstange
Copy link

mstange commented Nov 7, 2021

ipsw/hack/extras/Dyld.bt

Lines 116 to 117 in 05af7d2

uint32 subCacheUUID;
uint32 numSubCaches; // number of dyld_shared_cache .1,.2,.3 files

It seems like the field before the numSubCaches field is pointing at a list of subcache info structs which has length numSubCaches. The subcache info struct is 24 bytes big, 16 bytes UUID + 8 bytes something else.

This allows you to get the UUID for each subcache.

@mstange mstange changed the title subCacheUUID field should probably be subcachesOffset instead subCacheUUID field should probably be subCachesOffset instead Nov 7, 2021
@mstange
Copy link
Author

mstange commented Nov 7, 2021

Some evidence from /usr/lib/dsc_extractor.bundle:

Screen Shot 2021-11-07 at 10 37 45 AM

@blacktop
Copy link
Owner

blacktop commented Nov 7, 2021

Yes, it is definitely not a "UUID" I figured that out a month ago here:

// if ff.Headers[uuid].SubCachesUUID != ff.Headers[ff.UUID].SubCachesUUID { FIXME: what IS this field actually?

It appears to be an offset to the end of the imagesTextOffsetsection (the dylib path strings) in the subCaches, but in the "primary" cache you are right it seems to point to a small amount of data that the subCache's do not contain. Good find with respects to the UUIDs!

@blacktop
Copy link
Owner

blacktop commented Nov 7, 2021

The stuff that I thought looked like bit-field flags after progClosuresTrieWithSubCachesSize might tell you what kind of cache it is an how to interpret the (incorrect) subCacheUUID field perhaps? Or maybe one of these fields:

    uint32 unknown8;
    uint32 unknown9;

@blacktop
Copy link
Owner

blacktop commented Nov 7, 2021

What I was always MOST interested in what the mysterious unknown10Offset field. I see that it's an offset to a struct of what looks like large arrays of offsets? That might be where the patchInfo went.

@mstange
Copy link
Author

mstange commented Nov 7, 2021

Edit: this is wrong

The unknown10Offset field is already present in dyld 852.2, which is public:
https://opensource.apple.com/source/dyld/dyld-852.2/dyld3/shared-cache/dyld_cache_format.h.auto.html

Or are you saying that the existing header definition cannot be used for subcaches, and that the subcaches have other data in those places?

@mstange
Copy link
Author

mstange commented Nov 7, 2021

Oh, oops, never mind. I got confused because some fields later in the header look very similar to other fields earlier in the header.

@blacktop
Copy link
Owner

blacktop commented Nov 7, 2021

So you can tell how the field should be interpreted IF the numSubCaches is greater than 0. I have updated my 010 template to reflect it. Thank you for your help!

@blacktop
Copy link
Owner

blacktop commented Nov 7, 2021

Also the "8 bytes something else." is the "end offset" of the contamination of the sub caches (so far) or the totalSize. So for subCache.1 the field is it's size and for subCache.2 it's the size of subCache.1 + subCache.2 and so on.

@mstange
Copy link
Author

mstange commented Nov 8, 2021

Ah, nice. So cumulativeSize might be an appropriate name.

@blacktop
Copy link
Owner

Yes! That's perfect.

@mstange
Copy link
Author

mstange commented Feb 8, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants