opa334 / Dopamine

Dopamine is a semi-untethered jailbreak for iOS 15 and 16
MIT License
3.35k stars 1.91k forks source link

[suggestion] rootless libraries link against other rootless libraries #30

Closed H5GG closed 1 year ago

H5GG commented 1 year ago
image

exampes: the install name of the first rootless libraries is "@rpath/usr/lib/libA/libA.dylib" the install name of the second rootless libraries is "@rpath/usr/lib/libB/libB.dylib"

1: libA.dylib link against libB.dylib with "@rpath/usr/lib/libB/libB.dylib" 2: add rpath "@loader_path/../../../" to libA.dylib

so the rpath does not need to contain any fixed path, and we can use the complete subpath of the library in the jb root directory for the install name. And this method is also officially supported by Apple.

CRKatri commented 1 year ago

This was discussed when Procursus was first implementing rootless, but @loader_path works off of the symlink path, not the realpath, which means if you symlink a binary, it won't be able to find its dependencies.

H5GG commented 1 year ago

Thank you for your patience and answer, I will continue to look for a feasible way.

H5GG commented 1 year ago

I did a test on iphone11(15.1):

I built a test tweak and linked @rpath/CydiaSubstrate.framework/CydiaSubstrate, then I set its rpath to @loader_path/../../../Library/Frameworks .

image

then i symlink /Library/MobileSubstrate/DynamicLibraries/testweak.dylib to /Library/MobileSubstrate/DynamicLibraries/test/testweak.dylib.

rarleatenttestwaak ey11b -

In this way, whether using a real path or a symbol path, dyld can correctly load it and its dependencies (CydiaSubstrate).

Pasted Graphic 5

I went through the source code of dyld and found that it always resolves @loader_path to the real path:

bool LoaderexpandAtLoaderPath (Runt imeStates state, Pasted Graphic 12

I don't know how it used to be, but maybe Apple has fixed this problem in the past two years?

CRKatri commented 1 year ago

I just performed my own tests on this, and you're right, they seem to have fixed it since. In any case, this is not the place for issues like this to be opened, please move this to ProcursusTeam/Procursus#

H5GG commented 1 year ago

ok, thank you, i'm really interested in these.