forked from wh1te4ever/kfund
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathContentView.swift
125 lines (109 loc) · 5.48 KB
/
ContentView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
* Copyright (c) 2023 Félix Poulin-Bélanger. All rights reserved.
*/
import SwiftUI
struct ContentView: View {
@State private var kfd: UInt64 = 0
@State private var puafPagesIndex = 7
@State private var puafPages = 0
@State private var puafMethod = 2
@State private var kreadMethod = 1
@State private var kwriteMethod = 1
@State private var installationStatus = false
@State private var kopenStatus = false
private let puafPagesOptions = [16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 32768]
private let puafMethodOptions = ["physpuppet", "smith", "landa"]
private let kreadMethodOptions = ["kqueue_workloop_ctl", "sem_open"]
private let kwriteMethodOptions = ["dup", "sem_open"]
var body: some View {
NavigationView {
Form {
Section(header: Text("Configuration")) {
Picker("puaf pages:", selection: $puafPagesIndex) {
ForEach(0 ..< puafPagesOptions.count, id: \.self) {
Text("\(self.puafPagesOptions[$0])")
}
}.disabled(kfd != 0)
Picker("puaf method:", selection: $puafMethod) {
ForEach(0 ..< puafMethodOptions.count, id: \.self) {
Text(self.puafMethodOptions[$0])
}
}.disabled(kfd != 0)
Picker("kread method:", selection: $kreadMethod) {
ForEach(0 ..< kreadMethodOptions.count, id: \.self) {
Text(self.kreadMethodOptions[$0])
}
}.disabled(kfd != 0)
Picker("kwrite method:", selection: $kwriteMethod) {
ForEach(0 ..< kwriteMethodOptions.count, id: \.self) {
Text(self.kwriteMethodOptions[$0])
}
}.disabled(kfd != 0)
}
Section(header: Text("Actions")) {
//HStack {
Button("Click here to start!") {
UIApplication.shared.alert(title: "Exploiting Kernel...", body: "well, waiting for kopen...", withButton: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
puafPages = puafPagesOptions[puafPagesIndex]
kfd = do_kopen(UInt64(puafPages), UInt64(puafMethod), UInt64(kreadMethod), UInt64(kwriteMethod))
do_fun()
// Show kopen status and reset installationStatus
kopenStatus = true
installationStatus = false
UIApplication.shared.dismissAlert(animated: true)
}
}.disabled(kfd != 0)
//.buttonStyle(.bordered)
.frame(minWidth: 0, maxWidth: .infinity)
//}
}
Section(header: Text("Utilities")) {
Button("Install TrollStore Helper to Tips") {
UIApplication.shared.alert(title: "Installing TrollHelper...", body: "imagine how the Tips app is useful in its own way...", withButton: false)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
processDirectories()
// Show installation log messages and reset kopenStatus
installationStatus = true
kopenStatus = false
}
}.disabled(kfd == 0)
Button("Respring to Apply") {
do_kclose()
backboard_respring()
}.disabled(kfd == 0)
}
Section(header: Text("Status")) {
VStack {
if kopenStatus {
Text("kopen success!").foregroundColor(.green)
Text("Now press on \"Install Trollstore Helper to Tips\"")
}
if installationStatus {
Text("Please press \"Respring to Apply\".\n\nIf Tips still not TrollHelper, reinstall Tips from AppStore (do not open) then reboot and try again")
}
if !(installationStatus || kopenStatus) {
HStack(alignment: .center) {
VStack {
Text("Made by Little34306 and straight-tamago")
.font(.caption)
Text("\nv" + (Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String))
.font(.caption)
}
//Spacer()
}
}
}
.foregroundColor(.yellow)
.frame(minWidth: 0, maxWidth: .infinity)
}
}
.navigationBarTitle(Text("TrollStore Installer Helper"), displayMode: .inline)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}