Add Entitlement Checker and Memory

This commit is contained in:
Stossy11 2025-02-16 17:29:09 +11:00
parent fd0ce75f67
commit e741039304
3 changed files with 26 additions and 10 deletions

View File

@ -29,29 +29,29 @@ func SecTaskCopyValuesForEntitlements(
_ error: UnsafeMutablePointer<Unmanaged<CFError>?>?
) -> CFDictionary?
func checkAppEntitlements(_ ents: [String]) -> [String: Any]? {
func checkAppEntitlements(_ ents: [String]) -> [String: Any] {
guard let task = SecTaskCreateFromSelf(nil) else {
print("Failed to create SecTask")
return nil
return [:]
}
guard let entitlements = SecTaskCopyValuesForEntitlements(task, ents as CFArray, nil) else {
print("Failed to get entitlements")
return nil
return [:]
}
return entitlements as? [String: Any]
return (entitlements as? [String: Any]) ?? [:]
}
func checkAppEntitlement(_ ent: String) -> Bool? {
func checkAppEntitlement(_ ent: String) -> Bool {
guard let task = SecTaskCreateFromSelf(nil) else {
print("Failed to create SecTask")
return nil
return false
}
guard let entitlements = SecTaskCopyValueForEntitlement(task, ent as NSString, nil) else {
print("Failed to get entitlements")
return nil
return false
}
return entitlements.boolValue != nil && entitlements.boolValue

View File

@ -385,7 +385,7 @@ struct SettingsView: View {
if let cpuInfo = getCPUInfo(), cpuInfo.hasPrefix("Apple M") {
if #available (iOS 16.4, *) {
Toggle(isOn: .constant(false)) {
labelWithIcon("Hypervisor", iconName: "bolt.fill")
labelWithIcon("Hypervisor", iconName: "bolt")
}
.tint(.blue)
.disabled(true)
@ -394,7 +394,7 @@ struct SettingsView: View {
}
} else if getEntitlementValue("com.apple.private.hypervisor") {
Toggle(isOn: $config.hypervisor) {
labelWithIcon("Hypervisor", iconName: "bolt.fill")
labelWithIcon("Hypervisor", iconName: "bolt")
}
.tint(.blue)
.onAppear() {
@ -511,10 +511,26 @@ struct SettingsView: View {
Text("Enable trace and debug logs for advanced troubleshooting (Note: This degrades performance),\nEnable Screenshot Button for better screenshots\nand Enable TrollStore for automatic TrollStore JIT.")
}
// Advanced
// Info
Section {
let totalMemory = ProcessInfo.processInfo.physicalMemory
labelWithIcon("JIT Acquisition: \(isJITEnabled() ? "Acquired" : "Not Acquired" )", iconName: "bolt.fill")
labelWithIcon("Increased Memory Limit Entitlement: \(checkAppEntitlement("com.apple.developer.kernel.increased-memory-limit") ? "Enabled" : "Disabled")", iconName: "memorychip")
labelWithIcon("Device Memory: \(String(format: "%.0f GB", Double(totalMemory) / 1_000_000_000))", iconName: "memorychip.fill")
} header: {
Text("Information")
.font(.title3.weight(.semibold))
.textCase(nil)
.headerProminence(.increased)
} footer: {
Text("Shows info about Memory, Entitlement and JIT.")
}
// Advanced
Section {
if #unavailable(iOS 17) {
Toggle(isOn: $windowCode) {
labelWithIcon("SDL Window", iconName: "macwindow.on.rectangle")