2020-09-22 15:11:42 -07:00
|
|
|
//
|
|
|
|
|
// NSXPCConnection+MachServices.swift
|
|
|
|
|
// AltStore
|
|
|
|
|
//
|
|
|
|
|
// Created by Riley Testut on 9/22/20.
|
|
|
|
|
// Copyright © 2020 Riley Testut. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
2023-03-01 00:48:36 -05:00
|
|
|
@objc private protocol XPCPrivateAPI {
|
2020-09-22 15:11:42 -07:00
|
|
|
init(machServiceName: String)
|
|
|
|
|
init(machServiceName: String, options: NSXPCConnection.Options)
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 00:48:36 -05:00
|
|
|
public extension NSXPCConnection {
|
|
|
|
|
class func makeConnection(machServiceName: String) -> NSXPCConnection {
|
2020-09-22 15:11:42 -07:00
|
|
|
let connection = unsafeBitCast(self, to: XPCPrivateAPI.Type.self).init(machServiceName: machServiceName, options: .privileged)
|
|
|
|
|
return unsafeBitCast(connection, to: NSXPCConnection.self)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-01 00:48:36 -05:00
|
|
|
public extension NSXPCListener {
|
|
|
|
|
class func makeListener(machServiceName: String) -> NSXPCListener {
|
2020-09-22 15:11:42 -07:00
|
|
|
let listener = unsafeBitCast(self, to: XPCPrivateAPI.Type.self).init(machServiceName: machServiceName)
|
|
|
|
|
return unsafeBitCast(listener, to: NSXPCListener.self)
|
|
|
|
|
}
|
|
|
|
|
}
|