Skip to content

Commit cc51bcd

Browse files
LessicaCopilot
andauthored
Update TrollFools/InjectorV3+Inject.swift
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8a832b4 commit cc51bcd

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

TrollFools/InjectorV3+Inject.swift

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,36 @@ extension InjectorV3 {
210210
DDLogInfo("Mach-O scan: \(allMachOs.count) candidates in \(bundleURL.lastPathComponent)", ddlog: logger)
211211

212212
var selectedMachO: URL?
213+
var encryptedCount = 0
214+
var unreadableCount = 0
213215
for (index, machO) in allMachOs.enumerated() {
214-
let isProtected = (try? isProtectedMachO(machO)) ?? true
215216
let fileSize = (try? machO.resourceValues(forKeys: [.fileSizeKey]).fileSize) ?? 0
216217
let sizeStr = ByteCountFormatter.string(fromByteCount: Int64(fileSize), countStyle: .file)
217218

218-
if isProtected {
219-
DDLogInfo(" [\(index + 1)/\(allMachOs.count)] ENCRYPTED \(machO.lastPathComponent) (\(sizeStr))", ddlog: logger)
220-
} else {
221-
DDLogInfo(" [\(index + 1)/\(allMachOs.count)] AVAILABLE \(machO.lastPathComponent) (\(sizeStr))", ddlog: logger)
222-
if selectedMachO == nil {
223-
selectedMachO = machO
219+
do {
220+
let isProtected = try isProtectedMachO(machO)
221+
if isProtected {
222+
encryptedCount += 1
223+
DDLogInfo(" [\(index + 1)/\(allMachOs.count)] ENCRYPTED \(machO.lastPathComponent) (\(sizeStr))", ddlog: logger)
224+
} else {
225+
DDLogInfo(" [\(index + 1)/\(allMachOs.count)] AVAILABLE \(machO.lastPathComponent) (\(sizeStr))", ddlog: logger)
226+
if selectedMachO == nil {
227+
selectedMachO = machO
228+
}
224229
}
230+
} catch {
231+
unreadableCount += 1
232+
DDLogError(" [\(index + 1)/\(allMachOs.count)] UNREADABLE \(machO.lastPathComponent) (\(sizeStr)): \(error)", ddlog: logger)
225233
}
226234
}
227235

228236
if let selected = selectedMachO {
229237
DDLogInfo("Selected Mach-O: \(selected.lastPathComponent)", ddlog: logger)
230238
} else {
231-
DDLogError("No available Mach-O found, all \(allMachOs.count) candidates are encrypted", ddlog: logger)
239+
DDLogError(
240+
"No available Mach-O found: \(encryptedCount) encrypted, \(unreadableCount) unreadable, \(allMachOs.count - encryptedCount - unreadableCount) unavailable",
241+
ddlog: logger
242+
)
232243
}
233244

234245
return selectedMachO

0 commit comments

Comments
 (0)