[AltJIT] Adds AltJIT CLI tool to enable JIT on devices running iOS 17+

Commands:

altjit enable [app/pid] --udid [udid]
* Enables JIT for given app/process

altjit mount --udid [udid]
* Mounts personalized developer disk
This commit is contained in:
Riley Testut
2023-09-07 18:00:53 -05:00
parent 1a42aaeae8
commit d846445448
20 changed files with 1503 additions and 7 deletions

View File

@@ -0,0 +1,14 @@
//
// ALTErrorKeys.h
// AltJIT
//
// Created by Riley Testut on 9/1/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
@import Foundation;
// Can't import AltSign (for reasons), so re-declare these constants here instead.
extern NSErrorUserInfoKey const ALTSourceFileErrorKey;
extern NSErrorUserInfoKey const ALTSourceLineErrorKey;
extern NSErrorUserInfoKey const ALTAppNameErrorKey;

View File

@@ -0,0 +1,13 @@
//
// ALTErrorKeys.m
// AltJIT
//
// Created by Riley Testut on 9/1/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
#import "ALTErrorKeys.h"
NSErrorUserInfoKey const ALTSourceFileErrorKey = @"ALTSourceFile";
NSErrorUserInfoKey const ALTSourceLineErrorKey = @"ALTSourceLine";
NSErrorUserInfoKey const ALTAppNameErrorKey = @"appName";

View File

@@ -0,0 +1,58 @@
//
// PythonCommand.swift
// AltJIT
//
// Created by Riley Testut on 9/6/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import ArgumentParser
protocol PythonCommand: AsyncParsableCommand
{
var pythonPath: String? { get set }
}
extension PythonCommand
{
var processEnvironment: [String: String] {
var environment = ProcessInfo.processInfo.environment
if let pythonPath
{
environment["PYTHONPATH"] = pythonPath
}
return environment
}
mutating func prepare() async throws
{
let pythonPath = try await self.readPythonPath()
self.pythonPath = pythonPath.path(percentEncoded: false)
}
}
private extension PythonCommand
{
func readPythonPath() async throws -> URL
{
let processOutput: String
do
{
processOutput = try await Process.launchAndWait(.python3, arguments: ["-m", "site", "--user-site"])
}
catch let error as ProcessError where error.exitCode == 2
{
// Ignore exit code 2.
guard let output = error.output else { throw error }
processOutput = output
}
let sanitizedOutput = processOutput.trimmingCharacters(in: .whitespacesAndNewlines)
let pythonURL = URL(filePath: sanitizedOutput)
return pythonURL
}
}

View File

@@ -0,0 +1,41 @@
//
// RemoteServiceDiscoveryTunnel.swift
// AltJIT
//
// Created by Riley Testut on 9/3/23.
// Copyright © 2023 Riley Testut. All rights reserved.
//
import Foundation
final class RemoteServiceDiscoveryTunnel
{
let ipAddress: String
let port: Int
let process: Process
var commandArguments: [String] {
["--rsd", self.ipAddress, String(self.port)]
}
init(ipAddress: String, port: Int, process: Process)
{
self.ipAddress = ipAddress
self.port = port
self.process = process
}
deinit
{
self.process.terminate()
}
}
extension RemoteServiceDiscoveryTunnel: CustomStringConvertible
{
var description: String {
"\(self.ipAddress) \(self.port)"
}
}