[AltServer] Supports processName in EnableUnsignedCodeExecutionRequest

Process names will be used as a fallback if the processID cannot be determined, such as when enabling JIT for another app from within AltStore.
This commit is contained in:
Riley Testut
2021-09-02 16:03:21 -05:00
parent 3edd8d5ebe
commit e4b0b153e5
2 changed files with 22 additions and 6 deletions

View File

@@ -155,21 +155,35 @@ struct ServerRequestHandler: RequestHandler
case .success:
ALTDeviceManager.shared.startDebugConnection(to: device) { (connection, error) in
guard let connection = connection else { return completionHandler(.failure(error!)) }
connection.enableUnsignedCodeExecutionForProcess(withID: request.processID) { (success, error) in
func finish(success: Bool, error: Error?)
{
if let error = error, !success
{
print("Failed to enable unsigned code execution for process \(request.processID):", error)
print("Failed to enable unsigned code execution for process \(request.processID?.description ?? request.processName ?? "nil"):", error)
completionHandler(.failure(ALTServerError(error)))
}
else
{
print("Enabled unsigned code execution for process:", request.processID)
print("Enabled unsigned code execution for process:", request.processID ?? request.processName ?? "nil")
let response = EnableUnsignedCodeExecutionResponse()
completionHandler(.success(response))
}
}
if let processID = request.processID
{
connection.enableUnsignedCodeExecutionForProcess(withID: processID, completionHandler: finish)
}
else if let processName = request.processName
{
connection.enableUnsignedCodeExecutionForProcess(withName: processName, completionHandler: finish)
}
else
{
finish(success: false, error: ALTServerError(.invalidRequest))
}
}
}
}

View File

@@ -445,12 +445,14 @@ public struct EnableUnsignedCodeExecutionRequest: ServerMessageProtocol
public var identifier = "EnableUnsignedCodeExecutionRequest"
public var udid: String
public var processID: Int
public var processID: Int?
public var processName: String?
public init(udid: String, processID: Int)
public init(udid: String, processID: Int? = nil, processName: String? = nil)
{
self.udid = udid
self.processID = processID
self.processName = processName
}
}