Skip to content

Commit

Permalink
Merge branch 'develop' into MaaTools
Browse files Browse the repository at this point in the history
  • Loading branch information
hguandl committed Jun 18, 2023
2 parents 7675e34 + 2745ce3 commit 504a8df
Show file tree
Hide file tree
Showing 33 changed files with 1,590 additions and 237 deletions.
16 changes: 16 additions & 0 deletions PlayCover.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
AA71964B287A0EA800623C15 /* PlayRules.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA71964A287A0EA800623C15 /* PlayRules.swift */; };
AA71964D287A35F400623C15 /* com.nexon.bluearchive.yaml in Resources */ = {isa = PBXBuildFile; fileRef = AA71964C287A35F400623C15 /* com.nexon.bluearchive.yaml */; };
AA818CB5287ABEC3000BEE9D /* Yams in Frameworks */ = {isa = PBXBuildFile; productRef = AA818CB4287ABEC3000BEE9D /* Yams */; };
AB00EB5229A7BF17006F3225 /* KeyCover.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB00EB5129A7BF17006F3225 /* KeyCover.swift */; };
AB6F21EB299B7FA20078ADEC /* URLHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = AB6F21EA299B7FA20078ADEC /* URLHandler.swift */; };
ABDAD80629893CF900DC164F /* KeyCoverSetupViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABDAD80529893CF900DC164F /* KeyCoverSetupViews.swift */; };
ABDAD80A29893EA300DC164F /* KeyCoverSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABDAD80929893EA300DC164F /* KeyCoverSettings.swift */; };
ABDAD80C298A1E3E00DC164F /* KeyCoverViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABDAD80B298A1E3E00DC164F /* KeyCoverViews.swift */; };
ABED59832887A32F004D782B /* MenuBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = ABED59822887A32F004D782B /* MenuBarView.swift */; };
B1084E1F28AA80F400E399FA /* AppSettingsVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1084E1E28AA80F400E399FA /* AppSettingsVM.swift */; };
B1419FB628BA82EE000CB69F /* DiscordActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = B1419FB528BA82EE000CB69F /* DiscordActivity.swift */; };
Expand Down Expand Up @@ -170,7 +174,11 @@
AA71964A287A0EA800623C15 /* PlayRules.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayRules.swift; sourceTree = "<group>"; };
AA71964C287A35F400623C15 /* com.nexon.bluearchive.yaml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.yaml; path = com.nexon.bluearchive.yaml; sourceTree = "<group>"; };
AA970FD228793A310099A5D0 /* PlayCoverRelease.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = PlayCoverRelease.entitlements; sourceTree = "<group>"; };
AB00EB5129A7BF17006F3225 /* KeyCover.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyCover.swift; sourceTree = "<group>"; };
AB6F21EA299B7FA20078ADEC /* URLHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLHandler.swift; sourceTree = "<group>"; };
ABDAD80529893CF900DC164F /* KeyCoverSetupViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyCoverSetupViews.swift; sourceTree = "<group>"; };
ABDAD80929893EA300DC164F /* KeyCoverSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyCoverSettings.swift; sourceTree = "<group>"; };
ABDAD80B298A1E3E00DC164F /* KeyCoverViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyCoverViews.swift; sourceTree = "<group>"; };
ABED59822887A32F004D782B /* MenuBarView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MenuBarView.swift; sourceTree = "<group>"; };
ABF0BA1A285F9ED200FC5259 /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/Localizable.strings; sourceTree = "<group>"; };
B1084E1E28AA80F400E399FA /* AppSettingsVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppSettingsVM.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -211,6 +219,7 @@
B6603E1028E206A300DEFA3F /* UninstallSettings.swift */,
6ED6379C28DAAAC100B506FA /* IPASourceSettings.swift */,
B6825C3428F3D23600E3015A /* InstallSettings.swift */,
ABDAD80929893EA300DC164F /* KeyCoverSettings.swift */,
);
path = Settings;
sourceTree = "<group>";
Expand All @@ -230,6 +239,8 @@
6E66B0CA289F55180099B907 /* App Views */,
36B26B95288C722500859EFD /* Settings */,
B6603E1228E2257800DEFA3F /* Uninstaller.swift */,
ABDAD80529893CF900DC164F /* KeyCoverSetupViews.swift */,
ABDAD80B298A1E3E00DC164F /* KeyCoverViews.swift */,
);
path = Views;
sourceTree = "<group>";
Expand Down Expand Up @@ -314,6 +325,7 @@
B17FD04628C7B0D900B1D4CA /* AssetsExtractor.swift */,
6EB4B57328C93E0600630890 /* LegacySettings.swift */,
B17FD03F28C70C7300B1D4CA /* CoreUI.h */,
AB00EB5129A7BF17006F3225 /* KeyCover.swift */,
AB6F21EA299B7FA20078ADEC /* URLHandler.swift */,
);
path = Utils;
Expand Down Expand Up @@ -660,11 +672,13 @@
68E48B97295704A600C39879 /* Downloader.swift in Sources */,
28361D5E2892781200B35EDB /* RestoreGenshinUserData.swift in Sources */,
36B26B97288C724600859EFD /* UpdateSettings.swift in Sources */,
ABDAD80A29893EA300DC164F /* KeyCoverSettings.swift in Sources */,
8783CFFB26B8C52D00171041 /* PlayCoverApp.swift in Sources */,
AB6F21EB299B7FA20078ADEC /* URLHandler.swift in Sources */,
6ED6379D28DAAAC100B506FA /* IPASourceSettings.swift in Sources */,
5314D1EE26C402EC00A0A727 /* Shell.swift in Sources */,
6E7CA16528B4D02900216CD8 /* ITunesResponse.swift in Sources */,
ABDAD80C298A1E3E00DC164F /* KeyCoverViews.swift in Sources */,
6EF893D528F34CD1004AB6D9 /* NetworkVM.swift in Sources */,
8783D00B26B8C9E600171041 /* URLExtensions.swift in Sources */,
6EB4B57428C93E0600630890 /* LegacySettings.swift in Sources */,
Expand All @@ -673,8 +687,10 @@
92EE06D4274EA604002C907B /* PlayAppView.swift in Sources */,
6E21233128F65F7600B4D75D /* GenshinUserDataURLs.swift in Sources */,
B17FD04728C7B0D900B1D4CA /* AssetsExtractor.swift in Sources */,
ABDAD80629893CF900DC164F /* KeyCoverSetupViews.swift in Sources */,
6EE8265028E8AB2B003935BC /* DownloadVM.swift in Sources */,
6E06193A28B3C42E0012C771 /* DeleteGenshinAccountView.swift in Sources */,
AB00EB5229A7BF17006F3225 /* KeyCover.swift in Sources */,
68E48B9C295709C000C39879 /* Cacher.swift in Sources */,
28361D662892800200B35EDB /* DeleteStoredGenshinUserData.swift in Sources */,
53D9DAF326C1849D0071959E /* PlayCoverError.swift in Sources */,
Expand Down
10 changes: 6 additions & 4 deletions PlayCover/Model/AppSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import UniformTypeIdentifiers

struct AppSettingsData: Codable {
var keymapping = true
var mouseMapping = true
var sensitivity: Float = 50

var disableTimeout = false
Expand All @@ -23,12 +22,14 @@ struct AppSettingsData: Codable {
var bypass = false
var discordActivity = DiscordActivity()
var version = "3.0.0"
var playChain = false
var playChain = true
var playChainDebugging = false
var inverseScreenValues = false
var metalHUD = false
var windowFixMethod = 0
var injectIntrospection = false
var rootWorkDir = true
var noKMOnInput = true

var maaTools = false
var maaToolsPort = 1717
Expand All @@ -39,7 +40,6 @@ struct AppSettingsData: Codable {
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
keymapping = try container.decodeIfPresent(Bool.self, forKey: .keymapping) ?? true
mouseMapping = try container.decodeIfPresent(Bool.self, forKey: .mouseMapping) ?? true
sensitivity = try container.decodeIfPresent(Float.self, forKey: .sensitivity) ?? 50
disableTimeout = try container.decodeIfPresent(Bool.self, forKey: .disableTimeout) ?? false
iosDeviceModel = try container.decodeIfPresent(String.self, forKey: .iosDeviceModel) ?? "iPad13,8"
Expand All @@ -53,12 +53,14 @@ struct AppSettingsData: Codable {
discordActivity = try container.decodeIfPresent(DiscordActivity.self,
forKey: .discordActivity) ?? DiscordActivity()
version = try container.decodeIfPresent(String.self, forKey: .version) ?? "3.0.0"
playChain = try container.decodeIfPresent(Bool.self, forKey: .playChain) ?? false
playChain = try container.decodeIfPresent(Bool.self, forKey: .playChain) ?? true
playChainDebugging = try container.decodeIfPresent(Bool.self, forKey: .playChainDebugging) ?? false
inverseScreenValues = try container.decodeIfPresent(Bool.self, forKey: .inverseScreenValues) ?? false
metalHUD = try container.decodeIfPresent(Bool.self, forKey: .metalHUD) ?? false
windowFixMethod = try container.decodeIfPresent(Int.self, forKey: .windowFixMethod) ?? 0
injectIntrospection = try container.decodeIfPresent(Bool.self, forKey: .injectIntrospection) ?? false
rootWorkDir = try container.decodeIfPresent(Bool.self, forKey: .rootWorkDir) ?? true
noKMOnInput = try container.decodeIfPresent(Bool.self, forKey: .noKMOnInput) ?? true

maaTools = try container.decodeIfPresent(Bool.self, forKey: .maaTools) ?? false
maaToolsPort = try container.decodeIfPresent(Int.self, forKey: .maaToolsPort) ?? 1717
Expand Down
60 changes: 58 additions & 2 deletions PlayCover/Model/PlayApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class PlayApp: BaseApp {
var searchText: String {
info.displayName.lowercased().appending(" ").appending(info.bundleName).lowercased()
}
var sessionDisableKeychain: Bool = false

func launch() async {
do {
Expand All @@ -35,6 +36,9 @@ class PlayApp: BaseApp {
sign()
}

// call unlockKeyCover() and WAIT for it to finish
await unlockKeyCover()

// If the app does not have PlayTools, do not install PlugIns
if hasPlayTools() {
try PlayTools.installPluginInIPA(url)
Expand Down Expand Up @@ -91,7 +95,10 @@ class PlayApp: BaseApp {
}
sleep(1)
}
sleep(1)
}
// Things that are ran after the app is closed
self.lockKeyCover()
}
})
}
Expand Down Expand Up @@ -121,6 +128,53 @@ class PlayApp: BaseApp {
}
}

func unlockKeyCover() async {
if KeyCover.shared.isKeyCoverEnabled() {
// Check if the app have any keychains
let keychain = KeyCover.shared.listKeychains()
.first(where: { $0.appBundleID == self.info.bundleIdentifier })
// Check the status of that keychain
if let keychain = keychain, keychain.chainEncryptionStatus {
// If the keychain is encrypted, unlock it
try? await KeyCover.shared.unlockChain(keychain)

if KeyCover.shared.keyCoverPlainTextKey == nil {
// Pop an alert telling the user that keychain was not unlocked
// and keychain is disabled for the session
Task { @MainActor in
let alert = NSAlert()
alert.messageText = NSLocalizedString("keycover.alert.title", comment: "")
alert.informativeText = NSLocalizedString("keycover.alert.content", comment: "")
alert.alertStyle = .warning
alert.addButton(withTitle: NSLocalizedString("button.OK", comment: ""))
alert.runModal()
}
settings.settings.playChain = false
sessionDisableKeychain = true
}

}
}
}

func lockKeyCover() {
if KeyCover.shared.isKeyCoverEnabled() {
if sessionDisableKeychain {
settings.settings.playChain = true
sessionDisableKeychain = false
return
}
// Check if the app have any keychains
let keychain = KeyCover.shared.listKeychains()
.first(where: { $0.appBundleID == self.info.bundleIdentifier })
// Check the status of that keychain
if let keychain = keychain, !keychain.chainEncryptionStatus {
// If the keychain is encrypted, lock it
try? KeyCover.shared.lockChain(keychain)
}
}
}

var name: String {
if info.displayName.isEmpty {
return info.bundleName
Expand Down Expand Up @@ -176,6 +230,7 @@ class PlayApp: BaseApp {

func clearPlayChain() {
FileManager.default.delete(at: playChainURL)
FileManager.default.delete(at: playChainURL.appendingPathExtension("keyCover"))
}

func createAlias() {
Expand Down Expand Up @@ -230,13 +285,14 @@ class PlayApp: BaseApp {
static let PROHIBITED_APPS = [
"com.activision.callofduty.shooter",
"com.ea.ios.apexlegendsmobilefps",
"com.garena.game.codm",
"com.tencent.tmgp.cod",
"com.tencent.ig",
"com.pubg.newstate",
"com.tencent.tmgp.pubgmhd",
"com.dts.freefireth",
"com.dts.freefiremax"
"com.dts.freefiremax",
"vn.vng.codmvn",
"com.ngame.allstar.eu"
]

static let MALICIOUS_APPS = [
Expand Down
Loading

0 comments on commit 504a8df

Please sign in to comment.