Fix[init]: unexpectedly preload LWJGL

Migrating token storage to keychain accidentally causes LWJGL to be
preloaded, making Fabric fails to init.
Add JNI library PojavAccountJNI to do the task of sending access token
from keychain to JVM space.
This commit is contained in:
khanhduytran0 committed 2024-04-09 13:37:55 +07:00
1 parent 41a0c8df2e
commit f7163ceb31
4 files changed
+23 -15

No files matched your search

@@ -44,7 +44,7 @@ public class MinecraftAccount
}
static {
System.load(System.getenv("BUNDLE_PATH") + "/PojavLauncher");
System.loadLibrary("PojavAccountJNI");
}
public static native String getAccessTokenFromKeychain(String xuid);
}
+6
View File
@@ -90,6 +90,12 @@ target_link_libraries(AFNetworking
"-framework UIKit"
)
# MinecraftAccount JNI
add_library(PojavAccountJNI SHARED
authenticator/MinecraftAccountJNI.m
)
target_link_libraries(PojavAccountJNI)
# PojavLauncher
add_executable(PojavLauncher
dyld_bypass_validation.m
@@ -289,17 +289,3 @@ typedef void(^XSTSCallback)(NSString *xsts, NSString *uhs);
}
@end
JNIEXPORT jstring JNICALL Java_net_kdt_pojavlaunch_value_MinecraftAccount_getAccessTokenFromKeychain(JNIEnv *env, jclass clazz, jstring xuid) {
// This function should only be called once
static BOOL called = NO;
if (called) {
abort();
}
called = YES;
const char *xuidC = (*env)->GetStringUTFChars(env, xuid, 0);
NSString *accessToken = [MicrosoftAuthenticator tokenDataOfProfile:@(xuidC)][@"accessToken"];
(*env)->ReleaseStringUTFChars(env, xuid, xuidC);
return (*env)->NewStringUTF(env, accessToken.UTF8String);
}
@@ -0,0 +1,16 @@
#import "BaseAuthenticator.h"
#include "jni.h"
JNIEXPORT jstring JNICALL Java_net_kdt_pojavlaunch_value_MinecraftAccount_getAccessTokenFromKeychain(JNIEnv *env, jclass clazz, jstring xuid) {
// This function should only be called once
static BOOL called = NO;
if (called) {
abort();
}
called = YES;
const char *xuidC = (*env)->GetStringUTFChars(env, xuid, 0);
NSString *accessToken = [NSClassFromString(@"MicrosoftAuthenticator") tokenDataOfProfile:@(xuidC)][@"accessToken"];
(*env)->ReleaseStringUTFChars(env, xuid, xuidC);
return (*env)->NewStringUTF(env, accessToken.UTF8String);
}