From e7112d6db677f3f1ce6f30901acb6b4a7dc8fe54 Mon Sep 17 00:00:00 2001 From: realdoomsboygaming <105606471+realdoomsboygaming@users.noreply.github.com> Date: Wed, 12 Mar 2025 20:33:02 -0500 Subject: [PATCH 1/3] Update JavaLauncher.m --- Natives/JavaLauncher.m | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/Natives/JavaLauncher.m b/Natives/JavaLauncher.m index c46bd5a4ca..274354bbf0 100644 --- a/Natives/JavaLauncher.m +++ b/Natives/JavaLauncher.m @@ -200,6 +200,24 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi NSString *librariesPath = [NSString stringWithFormat:@"%@/libs", NSBundle.mainBundle.bundlePath]; margv[++margc] = [NSString stringWithFormat:@"-javaagent:%@/patchjna_agent.jar=", librariesPath].UTF8String; + + // Load java + NSString *libjlipath8 = [NSString stringWithFormat:@"%@/lib/jli/libjli.dylib", javaHome]; // java 8 + NSString *libjlipath11 = [NSString stringWithFormat:@"%@/lib/libjli.dylib", javaHome]; // java 11+ + BOOL isJava8Path = [fm fileExistsAtPath:libjlipath8]; + + // Important: Add Java 9+ permissions before loading the Cosmetica agent + if(!isJava8Path) { + // Required by Cosmetica to inject DNS + margv[++margc] = "--add-opens=java.base/java.net=ALL-UNNAMED"; + // Additional permissions for Cosmetica to access internal InetAddress classes + margv[++margc] = "--add-exports=java.base/sun.net.dns=ALL-UNNAMED"; + margv[++margc] = "--add-exports=java.base/sun.net=ALL-UNNAMED"; + margv[++margc] = "--add-opens=java.base/sun.net=ALL-UNNAMED"; + margv[++margc] = "--add-opens=java.base/sun.net.dns=ALL-UNNAMED"; + } + + // Add Cosmetica agent after Java 9+ permissions are set if(getPrefBool(@"general.cosmetica")) { margv[++margc] = [NSString stringWithFormat:@"-javaagent:%@/arc_dns_injector.jar=23.95.137.176", librariesPath].UTF8String; } @@ -211,11 +229,7 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi // Disable Forge 1.16.x early progress window margv[++margc] = "-Dfml.earlyprogresswindow=false"; - // Load java - NSString *libjlipath8 = [NSString stringWithFormat:@"%@/lib/jli/libjli.dylib", javaHome]; // java 8 - NSString *libjlipath11 = [NSString stringWithFormat:@"%@/lib/libjli.dylib", javaHome]; // java 11+ - BOOL isJava8 = [fm fileExistsAtPath:libjlipath8]; - setenv("INTERNAL_JLI_PATH", (isJava8 ? libjlipath8 : libjlipath11).UTF8String, 1); + setenv("INTERNAL_JLI_PATH", (isJava8Path ? libjlipath8 : libjlipath11).UTF8String, 1); void* libjli = dlopen(getenv("INTERNAL_JLI_PATH"), RTLD_GLOBAL); if (!libjli) { @@ -232,14 +246,11 @@ int launchJVM(NSString *username, id launchTarget, int width, int height, int mi margv[++margc] = "-Dcacio.font.fontscaler=sun.font.FreetypeFontScaler"; margv[++margc] = [NSString stringWithFormat:@"-Dcacio.managed.screensize=%dx%d", width, height].UTF8String; margv[++margc] = "-Dswing.defaultlaf=javax.swing.plaf.metal.MetalLookAndFeel"; - if (isJava8) { + if (isJava8Path) { // Setup Caciocavallo margv[++margc] = "-Dawt.toolkit=net.java.openjdk.cacio.ctc.CTCToolkit"; margv[++margc] = "-Djava.awt.graphicsenv=net.java.openjdk.cacio.ctc.CTCGraphicsEnvironment"; } else { - // Required by Cosmetica to inject DNS - margv[++margc] = "--add-opens=java.base/java.net=ALL-UNNAMED"; - // Setup Caciocavallo margv[++margc] = "-Dawt.toolkit=com.github.caciocavallosilano.cacio.ctc.CTCToolkit"; margv[++margc] = "-Djava.awt.graphicsenv=com.github.caciocavallosilano.cacio.ctc.CTCGraphicsEnvironment"; @@ -266,8 +277,8 @@ 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:@"%@/libs_caciocavallo%s", NSBundle.mainBundle.bundlePath, isJava8 ? "" : "17"]; + NSString *cacio_classpath = [NSString stringWithFormat:@"-Xbootclasspath/%s", isJava8Path ? "p" : "a"]; + NSString *cacio_libs_path = [NSString stringWithFormat:@"%@/libs_caciocavallo%s", NSBundle.mainBundle.bundlePath, isJava8Path ? "" : "17"]; NSArray *files = [fm contentsOfDirectoryAtPath:cacio_libs_path error:nil]; for(NSString *file in files) { if ([file hasSuffix:@".jar"]) { From 4ccbd23bef988d9e7aebf75bf23fb03e5cb1fa3c Mon Sep 17 00:00:00 2001 From: realdoomsboygaming <105606471+realdoomsboygaming@users.noreply.github.com> Date: Thu, 13 Mar 2025 07:03:29 -0500 Subject: [PATCH 2/3] Fix PR Issues --- .github/workflows/development.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/development.yml b/.github/workflows/development.yml index e3e507fb39..4b25385d69 100644 --- a/.github/workflows/development.yml +++ b/.github/workflows/development.yml @@ -125,6 +125,7 @@ jobs: env: password: ${{ secrets.ELLIE_MINI_SECRET }} run: | + export BRANCH=${{ github.head_ref || github.ref_name }} export PATH=/opt/procursus/bin:/opt/homebrew/bin:$PATH export RUNNER=1 SLIMMED=1 if [ "${{ matrix.platform_name }}" == "ios" ]; then From 74c2d18b26d7b25ef360c0c0b399303a135cea42 Mon Sep 17 00:00:00 2001 From: realdoomsboygaming <105606471+realdoomsboygaming@users.noreply.github.com> Date: Thu, 13 Mar 2025 07:04:23 -0500 Subject: [PATCH 3/3] Fix PR Issues --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ba1737e85b..66e005033c 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ WORKINGDIR := $(SOURCEDIR)/Natives/build DETECTPLAT := $(shell uname -s) DETECTARCH := $(shell uname -m) VERSION := 3.0 -BRANCH := $(shell git branch --show-current) +BRANCH ?= $(shell git branch --show-current) COMMIT := $(shell git log --oneline | sed '2,10000000d' | cut -b 1-7) PLATFORM ?= 2 @@ -28,8 +28,8 @@ SLIMMED_ONLY ?= 0 # If not in a GitHub repository, default to these # so that compiling doesn't fail -BRANCH ?= "unknown" -COMMIT ?= "unknown" +BRANCH := $(if $(BRANCH),$(BRANCH),"unknown") +COMMIT := $(if $(COMMIT),$(COMMIT),"unknown") # Team IDs and provisioning profile for the codesign function # Default to -1 for check