Fix(iOS 12): fatal issues: dlopen, entitlement

* dlopening the main executable fails
* dlopening dylib fails due to codesign
* Installing PojavLauncher with AppSync causing
extended-virtual-addressing entitlement to be checked improperly

Current issue: it seems that Java 8 is broken on iOS 12
This commit is contained in:
Duy Tran Khanh committed 2023-01-20 21:42:51 +07:00
1 parent a08563ee36
commit fcc7d8b2d4
4 files changed
+18 -11

No files matched your search

+2
View File
@@ -228,6 +228,7 @@ package: native java jre assets
@cp -R $(SOURCEDIR)/Natives/*.lproj $(WORKINGDIR)/PojavLauncher.app/ || exit 1
$(call DIRCHECK,$(OUTPUTDIR))
@cp -R $(WORKINGDIR)/PojavLauncher.app $(OUTPUTDIR)
ldid -S $(OUTPUTDIR)/PojavLauncher.app; \
ldid -S$(SOURCEDIR)/entitlements.xml $(OUTPUTDIR)/PojavLauncher.app/PojavLauncher; \
rm -f $(OUTPUTDIR)/*.ipa; \
cd $(OUTPUTDIR); \
@@ -260,6 +261,7 @@ dsym: package
deploy:
@echo '[PojavLauncher v$(VERSION)] deploy - start'
@ldid -S $(WORKINGDIR)/PojavLauncher.app; \
@ldid -S$(SOURCEDIR)/entitlements.xml $(WORKINGDIR)/PojavLauncher.app/PojavLauncher; \
if [ '$(NOSTDIN)' = '1' ]; then \
echo '$(SUDOPASS)' | sudo -S mv $(WORKINGDIR)/*.dylib /Applications/PojavLauncher.app/Frameworks/; \
+2 -1
View File
@@ -257,7 +257,8 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
}
margv[++margc] = cacio_classpath.UTF8String;
if (!getEntitlementValue(@"com.apple.developer.kernel.extended-virtual-addressing")) {
if (UIDevice.currentDevice.systemVersion.floatValue < 14 ||
!getEntitlementValue(@"com.apple.developer.kernel.extended-virtual-addressing")) {
// In jailed environment, where extended virtual addressing entitlement isn't
// present (for free dev account), allocating compressed space fails.
// FIXME: does extended VA allow allocating compressed class space?
+12 -8
View File
@@ -2,6 +2,7 @@
#import "SurfaceViewController.h"
#import "utils.h"
#include <dlfcn.h>
#include "external/fishhook/fishhook.h"
void (*orig_abort)();
@@ -32,7 +33,14 @@ void hooked_abort() {
}
void* hooked_dlopen(const char* path, int mode) {
if (path && [@(path) hasSuffix:@"/libawt_xawt.dylib"]) {
// iOS 12 refuses to dlopen executables, so here we put a workaround
if (path == NULL || [@(path) hasSuffix:@"/PojavLauncher"]) {
return orig_dlopen(NULL, mode);
}
if (getenv("POJAV_PREFER_EXTERNAL_JRE") && [@(path) hasSuffix:@"/libawt_xawt.dylib"]) {
// In this environment, libawt_xawt is not available/X11 only.
// hook dlopen to use our libawt_xawt
return orig_dlopen([NSString stringWithFormat:@"%s/Frameworks/libawt_xawt.dylib", getenv("BUNDLE_PATH")].UTF8String, mode);
}
@@ -67,14 +75,10 @@ int hooked_open(const char *path, int oflag, ...) {
}
void init_hookFunctions() {
if (getenv("POJAV_PREFER_EXTERNAL_JRE")) {
// In this environment, libawt_xawt is not available/X11 only.
// hook dlopen to use our libawt_xawt
rebind_symbols((struct rebinding[1]){{"dlopen", hooked_dlopen, (void *)&orig_dlopen}}, 1);
}
rebind_symbols((struct rebinding[3]){
rebind_symbols((struct rebinding[4]){
{"abort", hooked_abort, (void *)&orig_abort},
{"dlopen", hooked_dlopen, (void *)&orig_dlopen},
{"exit", hooked_exit, (void *)&orig_exit},
{"open", hooked_open, (void *)&orig_open}
}, 3);
}, 4);
}
+2 -2
View File
@@ -73,9 +73,9 @@ PojavLauncher is amazing, and surprisingly stable, and it wouldn't be this way w
- [LWJGLX](https://github.com/PojavLauncherTeam/lwjglx) (LWJGL2 API compatibility layer for LWJGL3): unknown license.
- [Alderis](https://github.com/hbang/Alderis) (color picker for iOS < 14): [Apache 2.0 License](https://github.com/hbang/Alderis/blob/master/LICENSE.md).
- [DBNumberedSlider](https://github.com/khanhduytran0/DBNumberedSlider): [Apache 2.0 License](https://github.com/immago/DBNumberedSlider/blob/master/LICENSE)
- [fishhook](https://github.com/khanhduytran0/fishhook) (jailed environment usage only): [BSD-3 License](https://github.com/facebook/fishhook/blob/main/LICENSE).
- [fishhook](https://github.com/khanhduytran0/fishhook): [BSD-3 License](https://github.com/facebook/fishhook/blob/main/LICENSE).
- [Java Native Access](https://github.com/java-native-access/jna): [Apache 2.0 License](https://github.com/java-native-access/jna/blob/master/LICENSE).
- [shaderc](https://github.com/khanhduytran0/shaderc) (used by mods that uses Vulkan for rendering): [Apache 2.0 License](https://github.com/google/shaderc/blob/main/LICENSE).
- [shaderc](https://github.com/khanhduytran0/shaderc) (used by Vulkan rendering mods): [Apache 2.0 License](https://github.com/google/shaderc/blob/main/LICENSE).
- [TOInsetGroupedTableView](https://github.com/TimOliver/TOInsetGroupedTableView): [MIT License](https://github.com/TimOliver/TOInsetGroupedTableView/blob/master/LICENSE).
- [AltKit](https://github.com/rileytestut/AltKit)
- Thanks to [MCHeads](https://mc-heads.net) for providing Minecraft avatars.