Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions StikJIT/Utilities/Security.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Created by s s on 2025/4/6.
//
import Security
import Foundation


typealias SecTaskRef = OpaquePointer
Expand All @@ -30,6 +31,17 @@ func checkAppEntitlement(_ ent: String) -> Bool {
print("Failed to get entitlements")
return false
}

return entitlements.boolValue != nil && entitlements.boolValue

// CFTypeRef can be either a CFBoolean or CFNumber representing a boolean
let typeID = CFGetTypeID(entitlements)
if typeID == CFBooleanGetTypeID() {
let value = unsafeBitCast(entitlements, to: CFBoolean.self)
return CFBooleanGetValue(value)
} else if typeID == CFNumberGetTypeID() {
// Bridge to NSNumber for convenience
let number = unsafeBitCast(entitlements, to: CFNumber.self) as NSNumber
return number.boolValue
} else {
return false
}
}
6 changes: 3 additions & 3 deletions StikJIT/Utilities/mountDDI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func isMounted() -> Bool {
let listError = image_mounter_copy_devices(client, &devices, &devicesLen)
if listError == IdeviceSuccess {
let deviceList = devices?.assumingMemoryBound(to: plist_t.self)
var devices: [String] = []
var deviceIdentifiers: [String] = []
for i in 0..<devicesLen {
let device = deviceList?[i]
var xmlData: UnsafeMutablePointer<CChar>?
Expand All @@ -101,14 +101,14 @@ func isMounted() -> Bool {
// Use libplist function to convert to XML
plist_to_xml(device, &xmlData, &xmlLength)
if let xml = xmlData {
devices.append("\(xml)")
deviceIdentifiers.append("\(xml)")
}
plist_mem_free(xmlData)
plist_free(device)
}

image_mounter_free(client)
return devices.count != 0
return deviceIdentifiers.count != 0
} else {
print("Failed to get device list: \(listError)")
return false
Expand Down
11 changes: 7 additions & 4 deletions StikJIT/idevice/JITEnableContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ + (instancetype)shared {
}

- (instancetype)init {
NSFileManager* fm = [NSFileManager defaultManager];
NSURL* docPathUrl = [fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].firstObject;
NSURL* logURL = [docPathUrl URLByAppendingPathComponent:@"idevice_log.txt"];
idevice_init_logger(Debug, Debug, (char*)logURL.path.UTF8String);
self = [super init];
if (self) {
NSFileManager* fm = [NSFileManager defaultManager];
NSURL* docPathUrl = [fm URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask].firstObject;
NSURL* logURL = [docPathUrl URLByAppendingPathComponent:@"idevice_log.txt"];
idevice_init_logger(Debug, Debug, (char*)logURL.path.UTF8String);
}
return self;
}

Expand Down