Integrated JitStreamer attach on startup

This commit is contained in:
Duy Tran Khanh committed 2022-08-27 17:07:12 +07:00
1 parent bb5e42e2c0
commit ec1afe94ca
6 files changed
+76 -5

No files matched your search

+50
View File
@@ -1,6 +1,7 @@
#include <dirent.h>
#include <stdio.h>
#import "AFNetworking.h"
#import <AuthenticationServices/AuthenticationServices.h>
#import "authenticator/BaseAuthenticator.h"
@@ -188,6 +189,14 @@
technoNote.textAlignment = NSTextAlignmentCenter;
[scrollView addSubview:technoNote];
}
if (!getEntitlementValue(@"dynamic-codesigning")) {
if (isJITEnabled()) {
self.title = NSLocalizedString(@"login.jit.enabled", nil);
} else {
[self enableJITWithJitStreamer];
}
}
}
- (void)displayProgress:(NSString *)title {
@@ -375,6 +384,47 @@
[self presentViewController:vc animated:YES completion:nil];
}
- (void)enableJITWithJitStreamer
{
[self displayProgress:NSLocalizedString(@"login.jit.checking", nil)];
// TODO: customizable address
NSString *address = @"69.69.0.1";
AFHTTPSessionManager *manager = AFHTTPSessionManager.manager;
manager.requestSerializer.timeoutInterval = 10;
manager.responseSerializer = AFHTTPResponseSerializer.serializer;
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/plain", nil];
[manager GET:[NSString stringWithFormat:@"http://%@/version", address] parameters:nil headers:nil progress:nil success:^(NSURLSessionDataTask *task, NSData *response) {
NSString *version = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog(@"Found JitStreamer %@", version);
self.title = NSLocalizedString(@"login.jit.found.JitStreamer", nil);
manager.requestSerializer.timeoutInterval = 0;
manager.responseSerializer = AFJSONResponseSerializer.serializer;
[manager POST:[NSString stringWithFormat:@"http://%@/attach/%d/", address, getpid()] parameters:nil headers:nil progress:nil success:^(NSURLSessionDataTask *task, id response) {
self.title = NSLocalizedString(@"login.jit.enabled", nil);
self.navigationItem.leftBarButtonItem = nil;
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSData *errorData = error.userInfo[AFNetworkingOperationFailingURLResponseDataErrorKey];
NSDictionary *errorDict = [NSJSONSerialization JSONObjectWithData:errorData options:0 error:nil];
self.title = [NSString stringWithFormat:NSLocalizedString(@"login.jit.fail.JitStreamer", nil), errorDict[@"message"]];
self.navigationItem.leftBarButtonItem = nil;
showDialog(self, NSLocalizedString(@"Error", nil), errorDict[@"message"]);
// Request may fail if detach is unsuccessful
if (isJITEnabled()) {
self.title = NSLocalizedString(@"login.jit.enabled", nil);
} else {
// TODO: [self enableJITWithAltJIT];
}
}];
} failure:^(NSURLSessionDataTask *task, NSError *error) {
self.title = @"";
self.navigationItem.leftBarButtonItem = nil;
//showDialog(self, @"Error", [NSString stringWithFormat:@"%@", error]);
// TODO: [self enableJITWithAltJIT];
}];
}
- (void)aboutLauncher
{
AboutLauncherViewController *vc = [[AboutLauncherViewController alloc] init];
+5
View File
@@ -21,6 +21,11 @@
"login.alert.title" = "Login";
"login.alert.field.username" = "Username";
"login.jit.checking" = "Checking for JIT";
"login.jit.enabled" = "JIT has been enabled";
"login.jit.fail.JitStreamer" = "JitStreamer error: %@";
"login.jit.found.JitStreamer" = "Found JitStreamer, enabling JIT";
"login.menu.about" = "About PojavLauncher";
"login.menu.sendlogs" = "Send your logs";
"login.menu.updates" = "Recent updates";
+1 -1
View File
@@ -35,7 +35,7 @@ void internal_showDialog(UIViewController *viewController, NSString* title, NSSt
void showDialog(UIViewController *viewController, NSString* title, NSString* message) {
dispatch_async(dispatch_get_main_queue(), ^{
internal_showDialog(currentVC(), title, message);
internal_showDialog(viewController ? viewController : currentVC(), title, message);
});
}
+4
View File
@@ -41,6 +41,10 @@ JavaVM* runtimeJavaVMPtr;
JNIEnv* runtimeJNIEnvPtr;
//__weak UIViewController *viewController;
#define CS_DEBUGGED 0x10000000
int csops(pid_t pid, unsigned int ops, void *useraddr, size_t usersize);
BOOL isJITEnabled();
void* gbuffer; // OSMesa framebuffer
long showingWindow;
int savedWidth, savedHeight;
+10 -1
View File
@@ -5,9 +5,9 @@
#include <unistd.h>
#include "log.h"
#include "utils.h"
BOOL getEntitlementValue(NSString *key);
@implementation UIWindow(ext)
@@ -48,6 +48,15 @@ UIViewController* currentVC() {
return [delegate window].visibleViewController;
}
BOOL isJITEnabled() {
if (getEntitlementValue(@"dynamic-codesigning")) {
return YES;
}
int flags;
csops(getpid(), 0, &flags, sizeof(flags));
return (flags & CS_DEBUGGED) != 0;
}
NSMutableDictionary* parseJSONFromFile(NSString *path) {
NSError *error;
+6 -3
View File
@@ -24,10 +24,13 @@ The [PojavLauncher Website](https://pojav.ml) has extensive documentation on how
### Without jailbreak (sideload as IPA)
Note: This is experimental, although game works smoothly, you should not set Render distance too much.
1. Install [AltStore](https://altstore.io)
1. Install [AltStore](https://altstore.io). Others will also work.
2. Download an IPA build of PojavLauncher in the Actions tab.
3. Open the downloaded IPA in AltStore to install.
4. Launch PojavLauncher with JIT enabled.
3. Open the downloaded IPA in the sideload app to install.
4. For enabling JIT, choose one of these:
- Setup [JitStreamer](http://jitstreamer.com), then launch PojavLauncher. JIT will be automatically enabled on startup. This is the most convenient way.
- Launch PojavLauncher with `Enable JIT` option in AltStore. This requires the device to be plugged in the computer or have Wi-Fi syncing enabled.
- Setup and use others such as [Jitterbug](https://github.com/osy/Jitterbug).
### Procursus-bootstraps
*Note: This is currently unavailable. Will be fixed soon! For the meantime, you can follow the same way as [below](#bingnerelucubratus-bootstraps)*.