This commit is contained in:
khanhduytran0 committed 2023-11-11 17:38:58 +07:00
1 parent 0862f32f5e
commit b48cecad94
26 files changed
+121 -527

No files matched your search

@@ -28,71 +28,34 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
import net.kdt.pojavlaunch.uikit.UIKit;
import net.kdt.pojavlaunch.utils.DownloadUtils;
import net.kdt.pojavlaunch.utils.JSONUtils;
import net.kdt.pojavlaunch.value.DependentLibrary;
import net.kdt.pojavlaunch.value.MinecraftAccount;
import net.kdt.pojavlaunch.value.MinecraftLibraryArtifact;
import org.lwjgl.glfw.GLFW;
public final class Tools
{
public static final boolean ENABLE_DEV_FEATURES = true; // BuildConfig.DEBUG;
public static String APP_NAME = "PojavLauncher";
public final class Tools {
public static final Gson GLOBAL_GSON = new GsonBuilder().setPrettyPrinting().create();
public static final String URL_HOME = "https://pojav.ml";
public static String DIR_BUNDLE = System.getenv("BUNDLE_PATH"); // path to "PojavLauncher.app"
public static String CURRENT_ARCHITECTURE;
public static final String DIR_BUNDLE = System.getenv("BUNDLE_PATH"); // path to "PojavLauncher.app"
public static final String DIR_GAME_HOME = System.getenv("POJAV_HOME");
public static final String DIR_GAME_NEW = System.getenv("POJAV_GAME_DIR"); // path to "Library/Application Support/minecraft"
public static final String DIR_GAME_PROFILE = System.getProperty("user.dir");
public static final String DIR_APP_DATA = System.getenv("POJAV_HOME");
public static final String DIR_ACCOUNT_NEW = DIR_APP_DATA + "/accounts";
// New since 3.0.0
public static String DIR_HOME_JRE = System.getProperty("java.home");
public static String DIRNAME_HOME_JRE = "lib";
// New since 2.4.2
public static final String DIR_HOME_VERSION = DIR_GAME_NEW + "/versions";
public static final String DIR_HOME_LIBRARY = DIR_GAME_NEW + "/libraries";
public static final String DIR_HOME_CRASH = DIR_GAME_NEW + "/crash-reports";
public static final String ASSETS_PATH = DIR_GAME_NEW + "/assets";
public static final String OBSOLETE_RESOURCES_PATH=DIR_GAME_NEW + "/resources";
public static final String CTRLMAP_PATH = DIR_GAME_NEW + "/controlmap";
public static final String CTRLDEF_FILE = DIR_GAME_NEW + "/controlmap/default.json";
public static final String NATIVE_LIB_DIR = DIR_BUNDLE + "/Frameworks";
public static final String NATIVE_LIB_DIR = "@executable_path/Frameworks";
public static void launchMinecraft(MinecraftAccount profile, final JMinecraftVersionList.Version versionInfo) throws Throwable {
String javaVersion = System.getProperty("java.version");
if (javaVersion.startsWith("1.")) {
javaVersion = javaVersion.substring(2);
}
int splitIndex = javaVersion.indexOf('.');
if (splitIndex == -1) {
splitIndex = javaVersion.indexOf('-');
}
if (splitIndex != -1) {
javaVersion = javaVersion.substring(0, splitIndex);
}
if (versionInfo.javaVersion != null && versionInfo.javaVersion.majorVersion > Integer.parseInt(javaVersion)) {
throw new UnsupportedOperationException("Minecraft " + versionInfo.id + " requires Java " + versionInfo.javaVersion.majorVersion + " in order to run. Please switch to Java " + versionInfo.javaVersion.majorVersion + " in launcher settings.");
}
String[] launchArgs = getMinecraftArgs(profile, versionInfo);
// System.out.println("Minecraft Args: " + Arrays.toString(launchArgs));
final String launchClassPath = generateLaunchClassPath(versionInfo);
@@ -533,98 +496,4 @@ createLibraryInfo(libItem);
public static void write(String path, String content) throws IOException {
write(path, content.getBytes());
}
public static void downloadFile(String urlInput, String nameOutput) throws IOException {
File file = new File(nameOutput);
DownloadUtils.downloadFile(urlInput, file);
}
public abstract static class DownloaderFeedback {
public abstract void updateProgress(int curr, int max);
}
public static void downloadFileMonitored(String urlInput,String nameOutput, DownloaderFeedback monitor) throws IOException {
if(!new File(nameOutput).exists()){
new File(nameOutput).getParentFile().mkdirs();
}
HttpURLConnection conn = (HttpURLConnection) new URL(urlInput).openConnection();
InputStream readStr = conn.getInputStream();
FileOutputStream fos = new FileOutputStream(new File(nameOutput));
int cur = 0; int oval=0; int len = conn.getContentLength(); byte[] buf = new byte[65535];
while((cur = readStr.read(buf)) != -1) {
oval += cur;
fos.write(buf,0,cur);
monitor.updateProgress(oval,len);
}
fos.close();
conn.disconnect();
}
public static class ZipTool
{
private ZipTool(){}
public static void zip(List<File> files, File zipFile) throws IOException {
final int BUFFER_SIZE = 2048;
BufferedInputStream origin = null;
ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
try {
byte data[] = new byte[BUFFER_SIZE];
for (File file : files) {
FileInputStream fileInputStream = new FileInputStream( file );
origin = new BufferedInputStream(fileInputStream, BUFFER_SIZE);
try {
ZipEntry entry = new ZipEntry(file.getName());
out.putNextEntry(entry);
int count;
while ((count = origin.read(data, 0, BUFFER_SIZE)) != -1) {
out.write(data, 0, count);
}
}
finally {
origin.close();
}
}
} finally {
out.close();
}
}
public static void unzip(File zipFile, File targetDirectory) throws IOException {
final int BUFFER_SIZE = 1024;
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(new FileInputStream(zipFile)));
try {
ZipEntry ze;
int count;
byte[] buffer = new byte[BUFFER_SIZE];
while ((ze = zis.getNextEntry()) != null) {
File file = new File(targetDirectory, ze.getName());
File dir = ze.isDirectory() ? file : file.getParentFile();
if (!dir.isDirectory() && !dir.mkdirs())
throw new FileNotFoundException("Failed to ensure directory: " +
dir.getAbsolutePath());
if (ze.isDirectory())
continue;
FileOutputStream fout = new FileOutputStream(file);
try {
while ((count = zis.read(buffer)) != -1)
fout.write(buffer, 0, count);
} finally {
fout.close();
}
/* if time should be restored as well
long time = ze.getTime();
if (time > 0)
file.setLastModified(time);
*/
}
} finally {
zis.close();
}
}
}
}
@@ -1,88 +0,0 @@
package net.kdt.pojavlaunch.utils;
import java.io.*;
import java.net.*;
import java.nio.charset.*;
import net.kdt.pojavlaunch.*;
public class DownloadUtils {
public static final String USER_AGENT = Tools.APP_NAME;
public static final Charset utf8 = Charset.forName("UTF-8");
public static void download(String url, OutputStream os) throws IOException {
download(new URL(url), os);
}
public static void download(URL url, OutputStream os) throws IOException {
InputStream is = null;
try {
// System.out.println("Connecting: " + url.toString());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent", USER_AGENT);
conn.setConnectTimeout(10000);
conn.setDoInput(true);
conn.connect();
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new IOException("Server returned HTTP " + conn.getResponseCode()
+ ": " + conn.getResponseMessage());
}
is = conn.getInputStream();
Tools.copy(is, os);
} catch (IOException e) {
throw new IOException("Unable to download from " + url.toString(), e);
} finally {
if (is != null) {
try {
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
public static String downloadString(String url) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
download(url, bos);
bos.close();
return new String(bos.toByteArray(), utf8);
}
public static void downloadFile(String url, File out) throws IOException {
out.getParentFile().mkdirs();
File tempOut = File.createTempFile(out.getName(), ".part", out.getParentFile());
BufferedOutputStream bos = null;
try {
OutputStream bos2 = new BufferedOutputStream(new FileOutputStream(tempOut));
try {
download(url, bos2);
tempOut.renameTo(out);
if (bos2 != null) {
bos2.close();
}
if (tempOut.exists()) {
tempOut.delete();
}
} catch (IOException th2) {
if (bos != null) {
bos.close();
}
if (tempOut.exists()) {
tempOut.delete();
}
throw th2;
}
} catch (IOException th3) {
if (bos != null) {
bos.close();
}
if (tempOut.exists()) {
tempOut.delete();
}
throw th3;
}
}
}
-8
View File
@@ -8,14 +8,6 @@
#import "ios_uikit_bridge.h"
#import "utils.h"
@interface ATableViewCell : UITableViewCell
@end
@implementation ATableViewCell
@end
@interface AccountListViewController()<ASWebAuthenticationPresentationContextProviding>
@property(nonatomic, strong) NSMutableArray *accountList;
+3 -11
View File
@@ -56,15 +56,7 @@ set(CMAKE_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}/resources/Frameworks")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
add_library(OSMesaOverride SHARED gl_mesa3d_patch.m)
target_link_libraries(OSMesaOverride
"${GLOBAL_LDFLAGS}"
"-L${CMAKE_FRAMEWORK_PATH}"
"-lOSMesa.8"
)
# ANGLE wrapper for 1.17+
add_library(tinygl4angle SHARED
external/gl4es/string_utils.c
external/gl4es/tinygl4angle.c
@@ -76,7 +68,7 @@ target_link_libraries(tinygl4angle
"-framework libGLESv2"
)
# AFNetworking
add_library(AFNetworking SHARED
external/AFNetworking/AFNetworking/AFSecurityPolicy.m
external/AFNetworking/AFNetworking/AFHTTPSessionManager.m
@@ -98,7 +90,7 @@ target_link_libraries(AFNetworking
"-framework UIKit"
)
# PojavLauncher
add_executable(PojavLauncher
dyld_bypass_validation.m
main.m
+18 -50
View File
@@ -8,13 +8,9 @@
#import "customcontrols/ControlJoystick.h"
#import "customcontrols/CustomControlsUtils.h"
#include <dlfcn.h>
#include "glfw_keycodes.h"
#include "utils.h"
BOOL shouldDismissPopover = YES;
@implementation ControlHandleView
// Nothing
@end
@@ -102,8 +98,8 @@ BOOL shouldDismissPopover = YES;
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
isControlModifiable = NO;
if (isInGame) {
isControlModifiable = NO;
[self.presentingViewController performSelector:@selector(loadCustomControls)];
}
}
@@ -215,19 +211,9 @@ BOOL shouldDismissPopover = YES;
- (void)showControlPopover:(UIGestureRecognizer *)sender {
self.currentGesture = sender;
switch (sender.state) {
case UIGestureRecognizerStateBegan:
if (![sender isKindOfClass:[UILongPressGestureRecognizer class]]) {
return;
}
break;
case UIGestureRecognizerStateEnded:
if ([sender isKindOfClass:[UILongPressGestureRecognizer class]]) {
return;
}
break;
default:
return;
if (sender.state != UIGestureRecognizerStateBegan &&
sender.state != UIGestureRecognizerStateEnded) {
return;
}
UIMenuController *menuController = [UIMenuController sharedMenuController];
@@ -468,7 +454,6 @@ BOOL shouldDismissPopover = YES;
}
- (void)actionMenuBtnEdit {
shouldDismissPopover = NO;
CCMenuViewController *vc = [[CCMenuViewController alloc] init];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
vc.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
@@ -602,22 +587,9 @@ BOOL shouldDismissPopover = YES;
return UIModalPresentationNone;
}
- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController
{
return shouldDismissPopover;
}
- (BOOL)presentationControllerShouldDismiss:(UIPresentationController *)presentationController
{
return shouldDismissPopover;
}
@end
#define TAG_SLIDER_STROKEWIDTH 10
#define TAG_SLIDER_CORNERRADIUS 11
#define TAG_SLIDER_OPACITY 12
#define TAG_SWITCH_DYNAMICPOS 13
#define VISIBILITY_ALWAYS 0
#define VISIBILITY_IN_GAME 1
@@ -641,7 +613,7 @@ CGFloat currentY;
@property(nonatomic) UIPickerView* pickerMapping;
@property(nonatomic) UISegmentedControl *ctrlOrientation, *ctrlVisibility;
@property(nonatomic) UISwitch *switchFwdLock, *switchToggleable, *switchMousePass, *switchSwipeable;
@property(nonatomic) UIColorWell *colorWellINTBackground, *colorWellINTStroke;
@property(nonatomic) UIColorWell *colorWellBackground, *colorWellStroke;
@property(nonatomic) DBNumberedSlider *sliderStrokeWidth, *sliderCornerRadius, *sliderOpacity;
@end
@@ -825,10 +797,10 @@ CGFloat currentY;
// Property: Background color
UILabel *labelBGColor = [self addLabel:localize(@"custom_controls.button_edit.bg_color", nil)];
self.colorWellINTBackground = [[UIColorWell alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)];
[self.colorWellINTBackground addTarget:self action:@selector(colorWellChanged) forControlEvents:UIControlEventValueChanged];
self.colorWellINTBackground.selectedColor = convertARGB2UIColor([self.targetButton.properties[@"bgColor"] intValue]);
[self.scrollView addSubview:self.colorWellINTBackground];
self.colorWellBackground = [[UIColorWell alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)];
[self.colorWellBackground addTarget:self action:@selector(colorWellChanged) forControlEvents:UIControlEventValueChanged];
self.colorWellBackground.selectedColor = convertARGB2UIColor([self.targetButton.properties[@"bgColor"] intValue]);
[self.scrollView addSubview:self.colorWellBackground];
currentY += labelBGColor.frame.size.height + 15.0;
// Property: Stroke width
@@ -845,10 +817,10 @@ CGFloat currentY;
// Property: Stroke color
UILabel *labelStrokeColor = [self addLabel:localize(@"custom_controls.button_edit.stroke_color", nil)];
self.colorWellINTStroke = [[UIColorWell alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)];
[self.colorWellINTStroke addTarget:self action:@selector(colorWellChanged) forControlEvents:UIControlEventValueChanged];
self.colorWellINTStroke.selectedColor = convertARGB2UIColor([self.targetButton.properties[@"strokeColor"] intValue]);
[self.scrollView addSubview:self.colorWellINTStroke];
self.colorWellStroke = [[UIColorWell alloc] initWithFrame:CGRectMake(width - 42.0, currentY - 5.0, 30.0, 30.0)];
[self.colorWellStroke addTarget:self action:@selector(colorWellChanged) forControlEvents:UIControlEventValueChanged];
self.colorWellStroke.selectedColor = convertARGB2UIColor([self.targetButton.properties[@"strokeColor"] intValue]);
[self.scrollView addSubview:self.colorWellStroke];
currentY += labelStrokeColor.frame.size.height + 15.0;
@@ -858,7 +830,6 @@ CGFloat currentY;
self.sliderCornerRadius = [[DBNumberedSlider alloc] initWithFrame:CGRectMake(labelCornerRadius.frame.size.width + 5.0, currentY - 5.0, width - labelCornerRadius.frame.size.width - 5.0, 30.0)];
self.sliderCornerRadius.continuous = YES;
self.sliderCornerRadius.maximumValue = 100;
self.sliderCornerRadius.tag = TAG_SLIDER_CORNERRADIUS;
self.sliderCornerRadius.value = [self.targetButton.properties[@"cornerRadius"] intValue];
[self.sliderCornerRadius addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.scrollView addSubview:self.sliderCornerRadius];
@@ -872,7 +843,6 @@ CGFloat currentY;
self.sliderOpacity.continuous = YES;
self.sliderOpacity.minimumValue = 1;
self.sliderOpacity.maximumValue = 100;
self.sliderOpacity.tag = TAG_SLIDER_OPACITY;
self.sliderOpacity.value = [self.targetButton.properties[@"opacity"] floatValue] * 100.0;
[self.sliderOpacity addTarget:self action:@selector(sliderValueChanged:) forControlEvents:UIControlEventValueChanged];
[self.scrollView addSubview:self.sliderOpacity];
@@ -913,11 +883,11 @@ CGFloat currentY;
lastPoint = point;
}
#pragma mark - Alderis functions
#pragma mark - Color picker functions
- (void)colorWellChanged {
self.targetButton.properties[@"bgColor"] = @(convertUIColor2ARGB(self.colorWellINTBackground.selectedColor));
self.targetButton.properties[@"strokeColor"] = @(convertUIColor2ARGB(self.colorWellINTStroke.selectedColor));
self.targetButton.properties[@"bgColor"] = @(convertUIColor2ARGB(self.colorWellBackground.selectedColor));
self.targetButton.properties[@"strokeColor"] = @(convertUIColor2ARGB(self.colorWellStroke.selectedColor));
[self.targetButton update];
}
@@ -932,7 +902,6 @@ CGFloat currentY;
- (void)actionEditCancel {
self.targetButton.properties = self.oldProperties;
[self.targetButton update];
shouldDismissPopover = YES;
[self dismissViewControllerAnimated:YES completion:nil];
}
@@ -955,7 +924,6 @@ CGFloat currentY;
[(CustomControlsViewController *)self.presentingViewController
doUpdateButton:self.targetButton from:self.oldProperties to:newProperties];
self.oldProperties = nil;
shouldDismissPopover = YES;
[self dismissViewControllerAnimated:YES completion:nil];
}
@@ -967,7 +935,7 @@ CGFloat currentY;
- (void)sliderValueChanged:(DBNumberedSlider *)sender {
if (sender.tag == TAG_SLIDER_STROKEWIDTH) {
self.colorWellINTStroke.enabled = sender.value != 0;
self.colorWellStroke.enabled = sender.value != 0;
self.targetButton.properties[@"strokeWidth"] = @((NSInteger) self.sliderStrokeWidth.value);
} else {
[sender setValue:(NSInteger)sender.value animated:NO];
@@ -1019,7 +987,7 @@ CGFloat currentY;
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [self.keyCodeMap objectAtIndex:row];
return self.keyCodeMap[row];
}
- (void)closeTextField {
-6
View File
@@ -2,11 +2,5 @@
#import <UIKit/UIKit.h>
@interface GameSurfaceView : UIView
{
CALayer* layer;
CGColorSpaceRef colorSpace;
CGDataProviderDirectCallbacks callbacks;
}
- (void)displayLayer;
@end
+7 -7
View File
@@ -3,11 +3,15 @@
#import "PLProfiles.h"
#import "utils.h"
@interface GameSurfaceView()
@property(nonatomic) CGColorSpaceRef colorSpace;
@end
@implementation GameSurfaceView
- (void)displayLayer {
CGDataProviderRef bitmapProvider = CGDataProviderCreateWithData(NULL, gbuffer, windowWidth * windowHeight * 4, NULL);
CGImageRef bitmap = CGImageCreate(windowWidth, windowHeight, 8, 32, 4 * windowWidth, colorSpace, kCGImageAlphaNoneSkipLast | kCGBitmapByteOrderDefault, bitmapProvider, NULL, FALSE, kCGRenderingIntentDefault);
CGImageRef bitmap = CGImageCreate(windowWidth, windowHeight, 8, 32, 4 * windowWidth, _colorSpace, kCGImageAlphaNoneSkipLast | kCGBitmapByteOrderDefault, bitmapProvider, NULL, FALSE, kCGRenderingIntentDefault);
self.layer.contents = (__bridge id) bitmap;
CGImageRelease(bitmap);
CGDataProviderRelease(bitmapProvider);
@@ -20,18 +24,14 @@
self.layer.opaque = YES;
if ([[PLProfiles resolveKeyForCurrentProfile:@"renderer"] hasPrefix:@"libOSMesa"]) {
colorSpace = CGColorSpaceCreateDeviceRGB();
self.colorSpace = CGColorSpaceCreateDeviceRGB();
}
return self;
}
+ (Class)layerClass {
if ([[PLProfiles resolveKeyForCurrentProfile:@"renderer"] hasPrefix:@"libOSMesa"]) {
return CALayer.class;
} else {
return CAMetalLayer.class;
}
return CAMetalLayer.class;
}
@end
+1 -5
View File
@@ -1,10 +1,6 @@
#import <UIKit/UIKit.h>
@interface SurfaceView : UIView {
CGColorSpaceRef colorSpace;
CGDataProviderDirectCallbacks callbacks;
}
@interface SurfaceView : UIView
- (void)displayLayer;
@end
+8 -17
View File
@@ -75,14 +75,14 @@ void AWTInputBridge_sendKey(int keycode) {
AWTInputBridge_nativeSendData(EVENT_TYPE_KEY, ' ', keycode, 0, 0);
}
@interface SurfaceView()
@property(nonatomic) CGColorSpaceRef colorSpace;
@end
@implementation SurfaceView
const void * _CGDataProviderGetBytePointerCallbackAWT(void *info) {
return (const void *)rgbArray;
}
- (void)displayLayer {
CGDataProviderRef bitmapProvider = CGDataProviderCreateDirect(NULL, windowWidth * windowHeight * 4, &callbacks);
CGImageRef bitmap = CGImageCreate(windowWidth, windowHeight, 8, 32, 4 * windowWidth, colorSpace, kCGImageAlphaFirst | kCGBitmapByteOrder32Little, bitmapProvider, NULL, FALSE, kCGRenderingIntentDefault);
CGDataProviderRef bitmapProvider = CGDataProviderCreateWithData(NULL, rgbArray, windowWidth * windowHeight * 4, NULL);
CGImageRef bitmap = CGImageCreate(windowWidth, windowHeight, 8, 32, 4 * windowWidth, _colorSpace, kCGImageAlphaFirst | kCGBitmapByteOrder32Little, bitmapProvider, NULL, FALSE, kCGRenderingIntentDefault);
self.layer.contents = (__bridge id) bitmap;
CGImageRelease(bitmap);
@@ -90,19 +90,10 @@ const void * _CGDataProviderGetBytePointerCallbackAWT(void *info) {
// CGColorSpaceRelease(colorSpace);
}
- (id)initWithFrame:(CGRect)frame
{
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
self.layer.opaque = YES;
colorSpace = CGColorSpaceCreateDeviceRGB();
callbacks.version = 0;
callbacks.getBytePointer = _CGDataProviderGetBytePointerCallbackAWT;
callbacks.releaseBytePointer = _CGDataProviderReleaseBytePointerCallback;
callbacks.getBytesAtPosition = NULL;
callbacks.releaseInfo = NULL;
self.colorSpace = CGColorSpaceCreateDeviceRGB();
return self;
}
@end
+5 -5
View File
@@ -146,7 +146,7 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
// Symlink libawt_xawt.dylib
NSString *dest = [NSString stringWithFormat:@"%@/lib/libawt_xawt.dylib", javaHome];
NSString *source = [NSString stringWithFormat:@"%s/Frameworks/libawt_xawt.dylib", getenv("BUNDLE_PATH")];
NSString *source = [NSString stringWithFormat:@"%@/Frameworks/libawt_xawt.dylib", NSBundle.mainBundle.bundlePath];
NSError *error;
[fm createSymbolicLinkAtPath:dest withDestinationPath:source error:&error];
if (error) {
@@ -174,8 +174,8 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
margv[++margc] = "-Djava.system.class.loader=net.kdt.pojavlaunch.PojavClassLoader";
margv[++margc] = "-Xms128M";
margv[++margc] = [NSString stringWithFormat:@"-Xmx%dM", allocmem].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Djava.library.path=%1$s/Frameworks", getenv("BUNDLE_PATH")].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Djna.boot.library.path=%s/Frameworks", getenv("BUNDLE_PATH")].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Djava.library.path=%@/Frameworks", NSBundle.mainBundle.bundlePath].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Djna.boot.library.path=%@/Frameworks", NSBundle.mainBundle.bundlePath].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Duser.dir=%@", gameDir].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Duser.home=%s", getenv("POJAV_HOME")].UTF8String;
margv[++margc] = [NSString stringWithFormat:@"-Duser.timezone=%@", NSTimeZone.localTimeZone.name].UTF8String;
@@ -195,7 +195,7 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
margv[++margc] = [NSString stringWithFormat:@"-Dorg.lwjgl.opengl.libname=%s", glLibName].UTF8String;
}
NSString *librariesPath = [NSString stringWithFormat:@"%s/libs", getenv("BUNDLE_PATH")];
NSString *librariesPath = [NSString stringWithFormat:@"%@/libs", NSBundle.mainBundle.bundlePath];
if(getPrefBool(@"general.cosmetica")) {
margv[++margc] = [NSString stringWithFormat:@"-javaagent:%@/arc_dns_injector.jar=23.95.137.176", librariesPath].UTF8String;
}
@@ -264,7 +264,7 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi
// Add Caciocavallo bootclasspath
NSString *cacio_classpath = [NSString stringWithFormat:@"-Xbootclasspath/%s", isJava8 ? "p" : "a"];
NSString *cacio_libs_path = [NSString stringWithFormat:@"%s/libs_caciocavallo%s", getenv("BUNDLE_PATH"), isJava8 ? "" : "17"];
NSString *cacio_libs_path = [NSString stringWithFormat:@"%@/libs_caciocavallo%s", NSBundle.mainBundle.bundlePath, isJava8 ? "" : "17"];
NSArray *files = [fm contentsOfDirectoryAtPath:cacio_libs_path error:nil];
for(NSString *file in files) {
if ([file hasSuffix:@".jar"]) {
+1 -1
View File
@@ -45,7 +45,7 @@ UIEdgeInsets insets;
[webView loadRequest:request];
[self.view addSubview:webView];
if(!getenv("POJAV_DETECTEDJB") && getPrefBool(@"warnings.limited_ram_warn") && (roundf(NSProcessInfo.processInfo.physicalMemory / 1048576) < 3900)) {
if(!isJailbroken && getPrefBool(@"warnings.limited_ram_warn") && (roundf(NSProcessInfo.processInfo.physicalMemory / 0x1000000) < 3900)) {
// "This device has a limited amount of memory available."
[self showWarningAlert:@"limited_ram" hasPreference:YES];
}
@@ -69,7 +69,7 @@ static WFWorkflowProgressView* currentProgressView;
self.selectedRTTags = @[@"1_16_5_older", @"1_17_newer", @"install_jar"];
self.selectedRuntimes = getPrefObject(@"java.java_homes");
NSString *internalPath = [NSString stringWithFormat:@"%s/java_runtimes", getenv("BUNDLE_PATH")];
NSString *internalPath = [NSString stringWithFormat:@"%@/java_runtimes", NSBundle.mainBundle.bundlePath];
NSString *externalPath = [NSString stringWithFormat:@"%s/java_runtimes", getenv("POJAV_HOME")];
[self listJREInPath:internalPath markInternal:YES];
[self listJREInPath:externalPath markInternal:NO];
@@ -235,8 +235,8 @@ static WFWorkflowProgressView* currentProgressView;
// Display size
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
unsigned long long folderSize = 0;
NSString *directory = [NSString stringWithFormat:@"%s/java_runtimes/%@",
getenv(isInternal ? "BUNDLE_PATH" : "POJAV_HOME"),
NSString *directory = [NSString stringWithFormat:@"%@/java_runtimes/%@",
isInternal ? NSBundle.mainBundle.bundlePath : @(getenv("POJAV_HOME")),
name];
[NSFileManager.defaultManager nr_getAllocatedSize:&folderSize ofDirectoryAtURL:[NSURL fileURLWithPath:directory] error:nil];
dispatch_async(dispatch_get_main_queue(), ^{
+1 -1
View File
@@ -103,7 +103,7 @@ NSString* getSelectedJavaHome(NSString* defaultJRETag, int minVersion) {
id selectedDir = pref[selectedVer];
if ([selectedDir isEqualToString:@"internal"]) {
selectedDir = [NSString stringWithFormat:@"%s/java_runtimes/java-%@-openjdk", getenv("BUNDLE_PATH"), selectedVer];
selectedDir = [NSString stringWithFormat:@"%@/java_runtimes/java-%@-openjdk", NSBundle.mainBundle.bundlePath, selectedVer];
} else {
selectedDir = [NSString stringWithFormat:@"%s/java_runtimes/%@", getenv("POJAV_HOME"), selectedDir];
}
+4 -3
View File
@@ -1,6 +1,7 @@
#import <Foundation/Foundation.h>
#import "DBNumberedSlider.h"
#import "HostManagerBridge.h"
#import "LauncherNavigationController.h"
#import "LauncherMenuViewController.h"
#import "LauncherPreferences.h"
@@ -329,7 +330,7 @@
@"type": self.typeSwitch,
@"enableCondition": whenNotInGame,
@"warnCondition": ^BOOL(){
return getenv("POJAV_DETECTEDJB") == NULL;
return !isJailbroken;
},
@"warnKey": @"auto_ram_warn",
@"requestReload": @YES
@@ -398,10 +399,10 @@
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
if (section == 0) { // Add to general section
return [NSString stringWithFormat:@"PojavLauncher %@-%s (%s/%s)\niOS %s on %s (%s)\nPID: %d",
return [NSString stringWithFormat:@"PojavLauncher %@-%s (%s/%s)\n%@ on %@ (%s)\nPID: %d",
NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"],
CONFIG_TYPE, CONFIG_BRANCH, CONFIG_COMMIT,
getenv("POJAV_DETECTEDSW"), getenv("POJAV_DETECTEDHW"), getenv("POJAV_DETECTEDINST"), getpid()];
UIDevice.currentDevice.completeOSVersion, [HostManager GetModelName], getenv("POJAV_DETECTEDINST"), getpid()];
}
NSString *footer = NSLocalizedStringWithDefaultValue(([NSString stringWithFormat:@"preference.section.footer.%@", self.prefSections[section]]), @"Localizable", NSBundle.mainBundle, @" ", nil);
+1 -1
View File
@@ -16,7 +16,7 @@ extern NSMutableDictionary *prefDict;
- (void)viewDidLoad {
[super viewDidLoad];
UIApplication.sharedApplication.idleTimerDisabled = YES;
setViewBackgroundColor(self.view);
self.view.backgroundColor = UIColor.systemBackgroundColor;
if ([getPrefObject(@"control.control_safe_area") length] == 0) {
setPrefObject(@"control.control_safe_area", NSStringFromUIEdgeInsets(getDefaultSafeArea()));
}
+2
View File
@@ -3,6 +3,8 @@
#define realUIIdiom UIDevice.currentDevice.hook_userInterfaceIdiom
@interface UIDevice(hook)
- (NSString *)buildVersion;
- (NSString *)completeOSVersion;
- (UIUserInterfaceIdiom)hook_userInterfaceIdiom;
@end
+4
View File
@@ -32,6 +32,10 @@ void init_hookUIKitConstructor(void) {
@implementation UIDevice(hook)
- (NSString *)completeOSVersion {
return [NSString stringWithFormat:@"%@ %@ (%@)", self.systemName, self.systemVersion, self.buildVersion];
}
- (UIUserInterfaceIdiom)hook_userInterfaceIdiom {
if (getPrefBool(@"debug.debug_ipad_ui")) {
return UIUserInterfaceIdiomPad;
+9 -25
View File
@@ -105,38 +105,22 @@ void *getDyldBase(void) {
}
void* hooked_mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset) {
char filePath[PATH_MAX];
memset(filePath, 0, sizeof(filePath));
// Check if the file is our "in-memory" file
if (fd && __fcntl(fd, F_GETPATH, filePath) != -1) {
const char *homeDir = getenv("POJAV_HOME");
if (!strncmp(filePath, homeDir, strlen(homeDir))) {
int newFlags = MAP_PRIVATE | MAP_ANONYMOUS;
if (addr != 0) {
newFlags |= MAP_FIXED;
}
void *alloc = __mmap(addr, len, PROT_READ | PROT_WRITE, newFlags, 0, 0);
void *memoryLoadedFile = __mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, offset);
memcpy(alloc, memoryLoadedFile, len);
munmap(memoryLoadedFile, len);
//vm_protect(mach_task_self(), (vm_address_t)alloc, len, false, prot);
mprotect(alloc, len, prot);
return alloc;
}
void *map = __mmap(addr, len, prot, flags, fd, offset);
if (map == MAP_FAILED && fd && (prot & PROT_EXEC)) {
map = __mmap(addr, len, PROT_READ | PROT_WRITE, flags | MAP_PRIVATE | MAP_ANON, 0, 0);
void *memoryLoadedFile = __mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, offset);
memcpy(map, memoryLoadedFile, len);
munmap(memoryLoadedFile, len);
mprotect(map, len, prot);
}
// If for another file, we pass through
return __mmap(addr, len, prot, flags, fd, offset);
return map;
}
int hooked___fcntl(int fildes, int cmd, void *param) {
if (cmd == F_ADDFILESIGS_RETURN) {
const char *homeDir = getenv("POJAV_HOME");
char filePath[PATH_MAX];
memset(filePath, 0, sizeof(filePath));
bzero(filePath, sizeof(filePath));
// Check if the file is our "in-memory" file
if (__fcntl(fildes, F_GETPATH, filePath) != -1) {
+10 -63
View File
@@ -32,7 +32,6 @@ struct PotatoBridge {
*/
};
EGLConfig config;
pid_t mainThreadID;
struct PotatoBridge potatoBridge;
/* OSMesa functions */
@@ -73,8 +72,7 @@ void* egl_make_current(void* window);
#define RENDERER_MTL_ANGLE 1
#define RENDERER_VK_ZINK 2
#define RENDERER_VIRGL 3
#define RENDERER_VULKAN 4
#define RENDERER_VULKAN 3
typedef jint RegalMakeCurrent_func(EGLContext context);
@@ -126,7 +124,6 @@ void* pojavGetCurrentContext() {
case RENDERER_MTL_ANGLE:
return (void *)eglGetCurrentContext_p();
case RENDERER_VIRGL:
case RENDERER_VK_ZINK:
return (void *)OSMesaGetCurrentContext_p();
@@ -171,10 +168,10 @@ void loadSymbols(int renderer) {
char fileName[2048];
switch (renderer) {
case RENDERER_VK_ZINK:
sprintf((char *)fileName, "%s/Frameworks/%s", getenv("BUNDLE_PATH"), getenv("POJAV_RENDERER"));
sprintf((char *)fileName, "@rpath/%s", getenv("POJAV_RENDERER"));
break;
case RENDERER_MTL_ANGLE:
sprintf((char *)fileName, "%s/Frameworks/libtinygl4angle.dylib", getenv("BUNDLE_PATH"));
sprintf((char *)fileName, "@rpath/libtinygl4angle.dylib");
break;
}
void* dl_handle = dlopen(fileName,RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
@@ -193,26 +190,9 @@ void loadSymbols(int renderer) {
}
}
void loadSymbolsVirGL() {
loadSymbols(RENDERER_MTL_ANGLE);
loadSymbols(RENDERER_VK_ZINK);
char fileName[2048];
sprintf((char *)fileName, "%s/Frameworks/libvirgl_test_server.dylib", getenv("BUNDLE_PATH"));
void *handle = dlopen(fileName, RTLD_LAZY);
NSLog(@"VirGL: libvirgl_test_server = %p", handle);
if (!handle) {
NSLog(@"VirGL: %s", dlerror());
return;
}
vtest_main_p = dlsym(handle, "vtest_main");
vtest_swap_buffers_p = dlsym(handle, "vtest_swap_buffers");
}
int pojavInit(BOOL useStackQueue) {
isInputReady = 1;
isUseStackQueueCall = useStackQueue;
mainThreadID = gettid();
return JNI_TRUE;
}
@@ -222,11 +202,7 @@ jboolean pojavInitOpenGL() {
NSString *renderer = @(getenv("POJAV_RENDERER"));
BOOL isAuto = [renderer isEqualToString:@"auto"];
BOOL angleDesktopGL = NO;
/* if ([renderer isEqualToString:@"libOSMesa.8.dylib"]) {
config_renderer = RENDERER_VIRGL;
setenv("GALLIUM_DRIVER", "virpipe", 1);
loadSymbolsVirGL();
} else */ if (isAuto || [renderer isEqualToString:@ RENDERER_NAME_GL4ES]) {
if (isAuto || [renderer isEqualToString:@ RENDERER_NAME_GL4ES]) {
// At this point, if renderer is still auto (unspecified major version), pick gl4es
angleDesktopGL = NO;
config_renderer = RENDERER_MTL_ANGLE;
@@ -242,7 +218,7 @@ jboolean pojavInitOpenGL() {
JNI_LWJGL_changeRenderer(renderer.UTF8String);
loadSymbols(config_renderer);
if (config_renderer == RENDERER_MTL_ANGLE || config_renderer == RENDERER_VIRGL) {
if (config_renderer == RENDERER_MTL_ANGLE) {
if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
potatoBridge.eglDisplay = eglGetDisplay_p((void *)EGL_DEFAULT_DISPLAY);
if (potatoBridge.eglDisplay == EGL_NO_DISPLAY) {
@@ -313,27 +289,10 @@ jboolean pojavInitOpenGL() {
potatoBridge.eglDisplay,
potatoBridge.eglSurface
);
if (config_renderer != RENDERER_VIRGL) {
return JNI_TRUE;
}
// } else if (strcmp(renderer, "vulkan_zink") == 0) {
return JNI_TRUE;
}
if (config_renderer == RENDERER_VIRGL) {
// Init EGL context and vtest server
const EGLint ctx_attribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 3,
EGL_NONE
};
EGLContext* ctx = eglCreateContext_p(potatoBridge.eglDisplay, config, NULL, ctx_attribs);
NSLog(@"VirGL: created EGL context %p", ctx);
pthread_t t;
pthread_create(&t, NULL, egl_make_current, (void *)ctx);
usleep(100*1000); // need enough time for the server to init
}
if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) {
if (config_renderer == RENDERER_VK_ZINK) {
if(OSMesaCreateContext_p == NULL) {
NSLog(@"OSMDroid: %s",dlerror());
return JNI_FALSE;
@@ -403,11 +362,6 @@ void pojavSwapBuffers() {
}
} break;
case RENDERER_VIRGL: {
glFinish_p();
vtest_swap_buffers_p();
} break;
case RENDERER_VK_ZINK: {
glFinish_p();
dispatch_async(dispatch_get_main_queue(), ^{
@@ -431,12 +385,6 @@ void* egl_make_current(void* window) {
NSDebugLog(@"EGLBridge: eglMakeCurrent() succeed!");
}
if (config_renderer == RENDERER_VIRGL) {
NSDebugLog(@"VirGL: vtest_main = %p", vtest_main_p);
NSDebugLog(@"VirGL: Calling VTest server's main function");
vtest_main_p(3, (const char*[]){"vtest", "--no-loop-or-fork", "--use-gles", NULL, NULL});
}
return NULL;
}
@@ -467,7 +415,7 @@ void pojavMakeCurrent(void* window) {
}
}
if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) {
if (config_renderer == RENDERER_VK_ZINK) {
NSLog(@"OSMDroid: making current");
OSMesaMakeCurrent_p((OSMesaContext)window,gbuffer,GL_UNSIGNED_BYTE,windowWidth,windowHeight);
if (config_renderer == RENDERER_VK_ZINK) {
@@ -514,7 +462,7 @@ void* pojavCreateContext(void* contextSrc) {
return (void *)ctx;
}
if (config_renderer == RENDERER_VK_ZINK || config_renderer == RENDERER_VIRGL) {
if (config_renderer == RENDERER_VK_ZINK) {
NSDebugLog(@"OSMDroid: generating context");
void* ctx = OSMesaCreateContext_p(OSMESA_RGBA,contextSrc);
NSDebugLog(@"OSMDroid: context=%p",ctx);
@@ -549,8 +497,7 @@ Java_org_lwjgl_opengl_GL_getNativeWidthHeight(JNIEnv *env, jobject thiz) {
void pojavSwapInterval(int interval) {
switch (config_renderer) {
case RENDERER_MTL_ANGLE:
case RENDERER_VIRGL: {
case RENDERER_MTL_ANGLE: {
eglSwapInterval_p(potatoBridge.eglDisplay, interval);
} break;
+1 -1
View File
@@ -46,7 +46,7 @@ jmethodID method_SystemClipboardDataReceived;
double cursorX, cursorY, cLastX, cLastY;
//jmethodID method_accessAndroidClipboard;
//jmethodID method_onGrabStateChanged;
jmethodID method_glfwSetWindowAttrib;
//jmethodID method_glfwSetWindowAttrib;
jmethodID method_internalWindowSizeChanged;
jclass bridgeClazz;
jclass vmGlfwClass;
-25
View File
@@ -1,25 +0,0 @@
#include <assert.h>
#include <dlfcn.h>
// #include "log.h"
#include "GL/gl.h"
void (*glDrawArrays_p) (GLenum mode, GLint first, GLsizei count);
GLAPI void GLAPIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count) {
if (!glDrawArrays_p) {
glDrawArrays_p = dlsym(RTLD_NEXT, "glDrawArrays");
}
// NSDebugLog(@"func=%p, next=%p", glDrawArrays, glDrawArrays_real);
// NSDebugLog(@"glDrawArrays mode=%p", mode);
if (mode == GL_TRIANGLE_FAN) {
// NSDebugLog(@"ERROR: GL_TRIANGLE_FAN unsupported!");
// this is wrong but idk how to deal with it yet...
// minecraft stills works with this for unknown reason
glDrawArrays_p(GL_TRIANGLE_STRIP, first, count);
} else {
glDrawArrays_p(mode, first, count);
}
}
-1
View File
@@ -197,7 +197,6 @@ void registerOpenHandler() {
// JNI_OnLoad
void JNI_OnLoadGLFW() {
vmGlfwClass = (*runtimeJNIEnvPtr)->NewGlobalRef(runtimeJNIEnvPtr, (*runtimeJNIEnvPtr)->FindClass(runtimeJNIEnvPtr, "org/lwjgl/glfw/GLFW"));
method_glfwSetWindowAttrib = (*runtimeJNIEnvPtr)->GetStaticMethodID(runtimeJNIEnvPtr, vmGlfwClass, "glfwSetWindowAttrib", "(JII)V");
method_internalWindowSizeChanged = (*runtimeJNIEnvPtr)->GetStaticMethodID(runtimeJNIEnvPtr, vmGlfwClass, "internalWindowSizeChanged", "(JII)V");
jfieldID field_keyDownBuffer = (*runtimeJNIEnvPtr)->GetStaticFieldID(runtimeJNIEnvPtr, vmGlfwClass, "keyDownBuffer", "Ljava/nio/ByteBuffer;");
jobject keyDownBufferJ = (*runtimeJNIEnvPtr)->GetStaticObjectField(runtimeJNIEnvPtr, vmGlfwClass, field_keyDownBuffer);
+2 -8
View File
@@ -10,12 +10,6 @@
#include "ios_uikit_bridge.h"
#include "utils.h"
jclass class_CTCScreen;
jmethodID method_GetRGB;
jclass class_CTCAndroidInput;
jmethodID method_ReceiveInput;
void internal_showDialog(NSString* title, NSString* message) {
NSLog(@"[UI] Dialog shown: %@: %@", title, message);
@@ -159,11 +153,11 @@ void UIKit_returnToSplitView() {
void launchInitialViewController(UIWindow *window) {
window.rootViewController = [[LauncherSplitViewController alloc] initWithStyle:UISplitViewControllerStyleDoubleColumn];
/*
#if 0
if (getPrefBool(@"internal.internal_launch_on_boot")) {
window.rootViewController = [[SurfaceViewController alloc] init];
} else {
window.rootViewController = [[LauncherSplitViewController alloc] initWithStyle:UISplitViewControllerStyleDoubleColumn];
}
*/
#endif
}
+36 -53
View File
@@ -1,15 +1,16 @@
#import <mach-o/dyld.h>
#import <mach/mach.h>
#import <mach/mach_host.h>
#import <spawn.h>
#import <sys/sysctl.h>
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "customcontrols/CustomControlsUtils.h"
#import "HostManagerBridge.h"
#import "JavaLauncher.h"
#import "LauncherPreferences.h"
#import "PLProfiles.h"
#import "SurfaceViewController.h"
#import "UIKit+hook.h"
#import "config.h"
#include <libgen.h>
@@ -17,15 +18,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include "JavaLauncher.h"
#include "utils.h"
#include "codesign.h"
#include "HostManagerBridge.h"
#define CS_PLATFORM_BINARY 0x4000000
#define PT_TRACE_ME 0
@@ -79,38 +74,29 @@ bool init_checkForsubstrated() {
return false;
}
void init_checkForJailbreak() {
bool jbDyld = false;
bool jbFlag = false;
bool jbProc = init_checkForsubstrated();
bool jbFile = false;
int imageCount = _dyld_image_count();
uint32_t flags = CS_PLATFORM_BINARY;
for (int i=0; i < imageCount; i++) {
bool init_checkForJailbreak() {
if (NSProcessInfo.processInfo.macCatalystApp) {
// macOS doesn't automatically enable JIT.
return false;
} else if (init_checkForsubstrated()) {
return true;
}
// Check if posix_spawn is hooked
for (int i=0; i < _dyld_image_count(); i++) {
if (strcmp(_dyld_get_image_name(i),"/usr/lib/pspawn_payload-stg2.dylib") == 0) {
jbDyld = true;
return true;
}
}
if (csops(0, CS_OPS_STATUS, &flags, sizeof(flags)) != -1) {
if ((flags & CS_PLATFORM_BINARY) != 0) {
jbFlag = true;
}
// Check if we have platform bit set
uint32_t flags;
csops(0, CS_OPS_STATUS, &flags, sizeof(flags));
if ((flags & CS_PLATFORM_BINARY) != 0) {
return true;
}
DIR *apps = opendir("/Applications");
if(apps != NULL) {
jbFile = true;
}
if (jbDyld || jbFlag || jbProc || jbFile) {
if (!NSProcessInfo.processInfo.macCatalystApp) {
// macOS doesn't automatically enable JIT.
setenv("POJAV_DETECTEDJB", "1", 1);
}
}
return opendir("/Applications") != NULL;
}
void init_logDeviceAndVer(char *argument) {
@@ -118,23 +104,20 @@ void init_logDeviceAndVer(char *argument) {
NSLog(@"[Pre-Init] PojavLauncher INIT!");
NSLog(@"[Pre-Init] Version: %@-%s", NSBundle.mainBundle.infoDictionary[@"CFBundleShortVersionString"], CONFIG_TYPE);
NSLog(@"[Pre-Init] Commit: %s (%s)", CONFIG_COMMIT, CONFIG_BRANCH);
// Hardware + Software
setenv("POJAV_DETECTEDSW", [HostManager GetPlatformVersion].UTF8String, 1);
setenv("POJAV_DETECTEDHW", [HostManager GetModelName].UTF8String, 1);
NSString *tsPath = [NSString stringWithFormat:@"%s/../_TrollStore", getenv("BUNDLE_PATH")];
const char *type = "Unjailbroken";
NSString *tsPath = [NSString stringWithFormat:@"%@/../_TrollStore", NSBundle.mainBundle.bundlePath];
const char *type;
if ([fm fileExistsAtPath:tsPath]) {
type = "TrollStore";
} else if (getenv("POJAV_DETECTEDJB")) {
} else if (isJailbroken) {
type = "Jailbroken";
} else {
type = "Unjailbroken";
}
setenv("POJAV_DETECTEDINST", type, 1);
NSLog(@"[Pre-Init] Device: %s", getenv("POJAV_DETECTEDHW"));
NSLog(@"[Pre-Init] iOS %s (%s)", getenv("POJAV_DETECTEDSW"), getenv("POJAV_DETECTEDINST"));
NSLog(@"[Pre-Init] Device: %@", [HostManager GetModelName]);
NSLog(@"[Pre-Init] %@ (%s)", UIDevice.currentDevice.completeOSVersion, type);
NSLog(@"[Pre-init] Entitlements availability:");
printEntitlementAvailability(@"com.apple.developer.kernel.extended-virtual-addressing");
@@ -181,8 +164,9 @@ void init_migrateToPlist(char* prefKey, char* filename) {
void init_redirectStdio() {
NSLog(@"[Pre-init] Starting logging STDIO to latestlog.txt\n");
NSString *currName = [@(getenv("POJAV_HOME")) stringByAppendingPathComponent:@"latestlog.txt"];
NSString *oldName = [@(getenv("POJAV_HOME")) stringByAppendingPathComponent:@"latestlog.old.txt"];
NSString *home = @(getenv("POJAV_HOME"));
NSString *currName = [home stringByAppendingPathComponent:@"latestlog.txt"];
NSString *oldName = [home stringByAppendingPathComponent:@"latestlog.old.txt"];
[fm removeItemAtPath:oldName error:nil];
[fm moveItemAtPath:currName toPath:oldName error:nil];
@@ -260,10 +244,11 @@ void init_setupMultiDir() {
NSLog(@"[Pre-init] Restored game directory preference (%@)\n", multidir);
}
NSString *jvmPath = [NSString stringWithFormat:@"%s/java_runtimes", getenv("POJAV_HOME")];
NSString *lasmPath = [NSString stringWithFormat:@"%s/Library/Application Support/minecraft", getenv("POJAV_HOME")];
NSString *multidirPath = [NSString stringWithFormat:@"%s/instances/%@", getenv("POJAV_HOME"), multidir];
NSString *demoPath = [NSString stringWithFormat:@"%s/.demo", getenv("POJAV_HOME")];
const char *home = getenv("POJAV_HOME");
NSString *jvmPath = [NSString stringWithFormat:@"%s/java_runtimes", home];
NSString *lasmPath = [NSString stringWithFormat:@"%s/Library/Application Support/minecraft", home];
NSString *multidirPath = [NSString stringWithFormat:@"%s/instances/%@", home, multidir];
NSString *demoPath = [NSString stringWithFormat:@"%s/.demo", home];
[fm createDirectoryAtPath:jvmPath withIntermediateDirectories:YES attributes:nil error:nil];
[fm createDirectoryAtPath:demoPath withIntermediateDirectories:YES attributes:nil error:nil];
@@ -314,7 +299,6 @@ int main(int argc, char *argv[]) {
return pJLI_Launch(argc, (const char **)argv,
0, NULL, // sizeof(const_jargs) / sizeof(char *), const_jargs,
0, NULL, // sizeof(const_appclasspath) / sizeof(char *), const_appclasspath,
// PojavLancher: fixme: are these wrong?
"1.8.0-internal",
"1.8",
@@ -332,8 +316,7 @@ int main(int argc, char *argv[]) {
}
setenv("BUNDLE_PATH", dirname(argv[0]), 1);
init_checkForJailbreak();
isJailbroken = init_checkForJailbreak();
init_migrateDirIfNecessary();
init_setupHomeDirectory();
init_redirectStdio();
+1 -2
View File
@@ -49,7 +49,7 @@
#define SPECIALBTN_MENU -9
#define NSDebugLog(...) if (debugLogEnabled) { NSLog(__VA_ARGS__); }
BOOL debugLogEnabled;
BOOL debugLogEnabled, isJailbroken;
//__weak UIViewController *viewController;
@@ -83,7 +83,6 @@ CGFloat MathUtils_map(CGFloat x, CGFloat in_min, CGFloat in_max, CGFloat out_min
CGFloat dpToPx(CGFloat dp);
CGFloat pxToDp(CGFloat px);
void setButtonPointerInteraction(UIButton *button);
void setViewBackgroundColor(UIView* view);
void _CGDataProviderReleaseBytePointerCallback(void *info,const void *pointer);
jboolean attachThread(bool isAndroid, JNIEnv** secondJNIEnvPtr);
+1 -9
View File
@@ -23,7 +23,7 @@ BOOL getEntitlementValue(NSString *key) {
}
BOOL isJITEnabled(BOOL checkCSFlags) {
if (!checkCSFlags && (getEntitlementValue(@"dynamic-codesigning") || getenv("POJAV_DETECTEDJB"))) {
if (!checkCSFlags && (getEntitlementValue(@"dynamic-codesigning") || isJailbroken)) {
return YES;
}
@@ -132,9 +132,6 @@ CGFloat MathUtils_map(CGFloat x, CGFloat in_min, CGFloat in_max, CGFloat out_min
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
void _CGDataProviderReleaseBytePointerCallback(void *info,const void *pointer) {
}
CGFloat dpToPx(CGFloat dp) {
CGFloat screenScale = [[UIScreen mainScreen] scale];
return dp * screenScale;
@@ -152,8 +149,3 @@ void setButtonPointerInteraction(UIButton *button) {
return [UIPointerStyle styleWithEffect:[UIPointerHighlightEffect effectWithPreview:preview] shape:proposedShape];
};
}
void setViewBackgroundColor(UIView* view) {
view.backgroundColor = UIColor.systemBackgroundColor;
}