Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 032a842

Browse files
committed
fix: start app failed after injection, fix #23
1 parent 1994531 commit 032a842

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

InjectGUI/Backend/Executor.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Executor: ObservableObject {
8888
task.arguments = ["-c", command]
8989
// task.arguments = ["-c", "echo 123"]
9090
#if DEBUG
91-
print("command: \(command)")
91+
print("[*] command: \(command)")
9292
#endif
9393

9494
let pipe = Pipe()
@@ -136,6 +136,9 @@ class Executor: ObservableObject {
136136

137137
let escapedCommand = command
138138
.replacingOccurrences(of: "\"", with: "\\\"")
139+
#if DEBUG
140+
print("[*] Escaped command: \(escapedCommand)")
141+
#endif
139142
task.arguments = ["-c", "echo \(self.password) | base64 --decode | sudo -S bash -c \"\(escapedCommand)\""]
140143
task.executableURL = URL(fileURLWithPath: "/bin/bash")
141144

InjectGUI/Backend/Injector.swift

+10-6
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class Injector: ObservableObject {
132132
guard let injectDetail = injectConfiguration.injectDetail(package: package) else {
133133
return
134134
}
135+
print("----------------------------")
135136
print("[*] Start inject \(package)")
136137
self.injectDetail = injectDetail
137138
self.appDetail = appDetail
@@ -340,11 +341,11 @@ class Injector: ObservableObject {
340341
let destination = source.appending(".backup")
341342

342343
if !FileManager.default.fileExists(atPath: source) {
343-
print("Source file not found: \(source)")
344+
print("[*] Source file not found: \(source)")
344345
return [("echo Source file not found: \(source.transformTo(to: .bash)) && exit 1", true)] // 借用一下 AppleScript 来弹窗
345346
}
346347
if FileManager.default.fileExists(atPath: destination) {
347-
print("Destination file already exists: \(destination)")
348+
print("[*] Destination file already exists: \(destination)")
348349
return []
349350
}
350351
return [
@@ -396,10 +397,13 @@ class Injector: ObservableObject {
396397
alert.informativeText = String(localized: "This should not happen here, please report to the developer (Area: MainInject)")
397398
alert.alertStyle = .warning
398399
alert.addButton(withTitle: String(localized: "OK"))
400+
alert.runModal()
401+
print("[*] Inject Tools Path Not Found.")
399402
return [("echo Inject Tools Path Not Found && exit 1", true)]
400403
}
401404

402405
if self.injectDetail?.needCopyToAppDir == true {
406+
print("[*] Copying 91Qiuchenly.dylib to app dir")
403407
// let copyedQiuchenly_URL = (self.appDetail?.path ?? "") + bridgeDir + "91Qiuchenly.dylib"
404408
let copyedQiuchenly_URL = self.genSourcePath(for: .none, file: "91Qiuchenly.dylib")
405409
let softLink = ("sudo ln -f -s '\(QiuchenlyDylib_URL!)' '\(copyedQiuchenly_URL)'", true) // 为了防止原神更新后导致的插件失效,这里使用软链接
@@ -441,17 +445,17 @@ class Injector: ObservableObject {
441445
sign_prefix_with_deep += " --entitlements \(entitlementsPath!)"
442446
}
443447

444-
let dest = self.genSourcePath(for: .bash)
448+
let dest = self.genSourcePath(for: .none)
445449

446450
if !(injectDetail?.noSignTarget ?? false) {
447-
shells.append((sign_prefix_with_deep + " '\(dest)'", false))
451+
shells.append((sign_prefix_with_deep + " '\(dest)'", true))
448452
}
449453
// shells.append((sign_prefix_with_deep + " '\(dest)'", false))
450454

451455
let deepSignApp = self.injectDetail?.deepSignApp // Bool
452456
if deepSignApp == true {
453-
let deepSignAppPath = self.genSourcePath(for: .bash, path: (self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: ""))
454-
shells.append((sign_prefix_with_deep + " '\(deepSignAppPath)'", false))
457+
let deepSignAppPath = self.genSourcePath(for: .none, path: (self.appDetail?.path ?? "").replacingOccurrences(of: "/Contents", with: ""))
458+
shells.append((sign_prefix_with_deep + " '\(deepSignAppPath)'", true))
455459
}
456460

457461
// let disableLibraryValidate = self.injectDetail?.dis

0 commit comments

Comments
 (0)