Skip to content

Commit ac5472c

Browse files
committed
Improved Version Checking, More Offsets, RegionChanger & Revert DynamicIsland
1 parent a4e7d52 commit ac5472c

File tree

15 files changed

+9817
-1285
lines changed

15 files changed

+9817
-1285
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Binary file not shown.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Bucket
3+
uuid = "942DD93C-25D4-4006-8C9C-53EFCC87D891"
4+
type = "1"
5+
version = "2.0">
6+
<Breakpoints>
7+
<BreakpointProxy
8+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9+
<BreakpointContent
10+
uuid = "53D81559-6E45-4721-9710-4DC485DA8A36"
11+
shouldBeEnabled = "No"
12+
ignoreCount = "0"
13+
continueAfterRunningActions = "No"
14+
filePath = "kfd/libkfd/info.h"
15+
startingColumnNumber = "9223372036854775807"
16+
endingColumnNumber = "9223372036854775807"
17+
startingLineNumber = "47"
18+
endingLineNumber = "47"
19+
landmarkName = "unknown"
20+
landmarkType = "0">
21+
</BreakpointContent>
22+
</BreakpointProxy>
23+
</Breakpoints>
24+
</Bucket>

kfd/.DS_Store

0 Bytes
Binary file not shown.

kfd/ContentView.swift

Lines changed: 71 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ struct ContentView: View {
1616
private let kwriteMethodOptions = ["dup", "sem_open"]
1717
@State private var kwriteMethod = 1
1818

19+
@State private var extra_checks = true
20+
21+
@State private var errorAlert = false
22+
1923
@State private var res_y = 2796
2024
@State private var res_x = 1290
2125

@@ -29,6 +33,7 @@ struct ContentView: View {
2933
@State private var hideLSIcons = false
3034
@State private var enableCustomSysColors = false
3135
@State private var enableDynamicIsland = false
36+
@State private var changeRegion = false
3237

3338
var body: some View {
3439
NavigationView {
@@ -60,10 +65,10 @@ struct ContentView: View {
6065
// Resolution
6166
Toggle(isOn: $enableResSet) {
6267
HStack(spacing: 20) {
63-
Image(systemName: enableResSet ? "arrow.up.circle.fill" : "arrow.down.circle.fill")
68+
Image(systemName: enableResSet ? "arrowshape.up.circle.fill" : "arrowshape.up.circle")
6469
.foregroundColor(.purple)
6570
.imageScale(.large)
66-
Text("Enable 14 Pro Max Resolution").font(.headline)
71+
Text("Change Resolution").font(.headline)
6772
}
6873
}.frame(minWidth: 0, maxWidth: .infinity)
6974
.foregroundColor(.purple)
@@ -145,22 +150,43 @@ struct ContentView: View {
145150
}.frame(minWidth: 0, maxWidth: .infinity)
146151
.foregroundColor(.purple)
147152

148-
Spacer()
153+
// Region Changer
154+
Toggle(isOn: $changeRegion) {
155+
HStack(spacing: 20) {
156+
Image(systemName: changeRegion ? "globe.americas.fill" : "globe.americas")
157+
.foregroundColor(.purple)
158+
.imageScale(.large)
159+
Text("Change Region").font(.headline)
160+
}
161+
}.frame(minWidth: 0, maxWidth: .infinity)
162+
.foregroundColor(.purple)
149163

164+
Spacer()
165+
150166
Button("Apply Tweaks & Respring") {
151167
puafPages = puafPagesOptions[puafPagesIndex]
152-
kfd = do_kopen(UInt64(puafPages), UInt64(puafMethod), UInt64(kreadMethod), UInt64(kwriteMethod))
153-
let tweaks = enabledTweaks()
154-
var cTweaks: [UnsafeMutablePointer<CChar>?] = tweaks.map { strdup($0) }
155-
cTweaks.append(nil)
156-
cTweaks.withUnsafeMutableBufferPointer { buffer in
157-
do_fun(buffer.baseAddress, Int32(buffer.count - 1), res_y, res_x)
168+
kfd = do_kopen(UInt64(puafPages), UInt64(puafMethod), UInt64(kreadMethod), UInt64(kwriteMethod), extra_checks)
169+
if (kfd != 0) {
170+
let tweaks = enabledTweaks()
171+
var cTweaks: [UnsafeMutablePointer<CChar>?] = tweaks.map { strdup($0) }
172+
cTweaks.append(nil)
173+
cTweaks.withUnsafeMutableBufferPointer { buffer in
174+
do_fun(buffer.baseAddress, Int32(buffer.count - 1), Int32(res_y), Int32(res_x))
175+
}
176+
cTweaks.forEach { free($0) }
177+
do_kclose()
178+
backboard_respring()
179+
} else {
180+
errorAlert = true
158181
}
159-
cTweaks.forEach { free($0) }
160-
do_kclose()
161-
backboard_respring()
162182
}.frame(minWidth: 0, maxWidth: .infinity)
163183
.foregroundColor(.purple)
184+
.alert(isPresented: $errorAlert) {
185+
Alert(
186+
title: Text("Device Unsupported"),
187+
message: Text("Try without extra checks?")
188+
)
189+
}
164190

165191
}
166192
.listRowBackground(Color.clear)
@@ -179,7 +205,7 @@ struct ContentView: View {
179205
}
180206

181207
private var settingsView: some View {
182-
SettingsView(puafPagesIndex: $puafPagesIndex, puafMethod: $puafMethod, kreadMethod: $kreadMethod, kwriteMethod: $kwriteMethod, res_y: $res_y, res_x: $res_x)
208+
SettingsView(puafPagesIndex: $puafPagesIndex, puafMethod: $puafMethod, kreadMethod: $kreadMethod, kwriteMethod: $kwriteMethod, extra_checks: $extra_checks, res_y: $res_y, res_x: $res_x)
183209
.navigationBarTitle("Settings")
184210
}
185211

@@ -215,6 +241,9 @@ struct ContentView: View {
215241
if enableDynamicIsland {
216242
enabledTweaks.append("enableDynamicIsland")
217243
}
244+
if changeRegion {
245+
enabledTweaks.append("changeRegion")
246+
}
218247

219248
return enabledTweaks
220249
}
@@ -225,13 +254,21 @@ struct SettingsView: View {
225254
@Binding var puafMethod: Int
226255
@Binding var kreadMethod: Int
227256
@Binding var kwriteMethod: Int
257+
@Binding var extra_checks: Bool
228258
@Binding var res_y: Int
229259
@Binding var res_x: Int
230260

231261
private let puafPagesOptions = [16, 32, 64, 128, 256, 512, 1024, 2048]
232262
private let puafMethodOptions = ["physpuppet", "smith"]
233263
private let kreadMethodOptions = ["kqueue_workloop_ctl", "sem_open"]
234264
private let kwriteMethodOptions = ["dup", "sem_open"]
265+
266+
// Dyanmic Island Stuff
267+
private let ogDynamicOptions = ["Auto (iPhone X-14)", "569 (iPhone 8/SE2/SE3)", "570 (iPhone 8+)"]
268+
@State var ogDynamicOptions_num = [0, 569, 570]
269+
@State var ogDynamicOptions_sel = 0
270+
@State var ogsubtype = 0
271+
235272

236273
var body: some View {
237274
Form {
@@ -259,15 +296,34 @@ struct SettingsView: View {
259296
Text(self.kwriteMethodOptions[$0])
260297
}
261298
}
299+
300+
Toggle(isOn: $extra_checks) {
301+
Text("extra offset checks")
302+
}
262303
}
263304

264-
Section(header: Text("Tweak Settings")) {
305+
Section(header: Text("Resolution")) {
265306
Text("Resolution Width:")
266307
TextField("Resolution Width", value: $res_x, formatter: NumberFormatter())
267308
Text("Resolution Height:")
268309
TextField("Resolution Height", value: $res_y, formatter: NumberFormatter())
269310
}
270311

312+
Section(header: Text("Dynamic Island")) {
313+
Picker("Original SubType:", selection: $ogDynamicOptions_sel) {
314+
ForEach(0 ..< ogDynamicOptions.count, id: \.self) {
315+
Text(self.ogDynamicOptions[$0])
316+
}
317+
}
318+
Button("Revert SubType") {
319+
ogsubtype = ogDynamicOptions_num[ogDynamicOptions_sel]
320+
if (ogsubtype == 0) {
321+
ogsubtype = Int(UIScreen.main.nativeBounds.height)
322+
}
323+
DynamicKFD(Int32(ogsubtype))
324+
}
325+
}
326+
271327
Section(header: Text("Extras")) {
272328
Button(action: {
273329
respring()
@@ -291,8 +347,7 @@ struct SettingsView: View {
291347
.cornerRadius(10)
292348
}
293349
}
294-
}
295-
.navigationBarTitle("Settings", displayMode: .inline)
350+
}.navigationBarTitle("Settings", displayMode: .inline)
296351
}
297352
}
298353

kfd/fun/fun.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
void do_fun(char** enabledTweaks, int numTweaks, int res_y, int res_x);
1313
void backboard_respring(void);
1414
void respring(void);
15+
void DynamicKFD(int subtype);
1516
#endif /* fun_h */

kfd/fun/fun.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ u64 fun_ipc_entry_lookup(mach_port_name_t port_name) {
169169
return 0;
170170
}
171171

172+
void DynamicKFD(int subtype) {
173+
DynamicCOW(subtype);
174+
}
175+
172176
void do_fun(char** enabledTweaks, int numTweaks, int res_y, int res_x) {
173177
// funVnodeOverwrite2("/System/Library/Fonts/CoreUI/SFUI.ttf", [NSString stringWithFormat:@"%@%@", NSBundle.mainBundle.bundlePath, @"/SFUI.ttf"].UTF8String);
174178
// funVnodeOverwrite2("/System/Library/Fonts/Watch/ADTTime.ttc", [NSString stringWithFormat:@"%@%@", NSBundle.mainBundle.bundlePath, @"/ADTTime.ttc"].UTF8String);
@@ -247,7 +251,10 @@ void do_fun(char** enabledTweaks, int numTweaks, int res_y, int res_x) {
247251
funVnodeHide("/System/Library/PrivateFrameworks/CoreMaterial.framework/platters.materialrecipe");
248252
}
249253
if (strcmp(tweak, "enableDynamicIsland") == 0) {
250-
DynamicCOW();
254+
DynamicCOW(2796);
255+
}
256+
if (strcmp(tweak, "changeRegion") == 0) {
257+
regionChanger(@"h63QSdBCiT/z0WU6rdQv6Q", @"zHeENZu+wbg7PUprwNwBWg");
251258
}
252259
}
253260
}

kfd/fun/krw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212

1313
uint64_t _kfd = 0;
1414

15-
uint64_t do_kopen(uint64_t puaf_pages, uint64_t puaf_method, uint64_t kread_method, uint64_t kwrite_method)
15+
uint64_t do_kopen(uint64_t puaf_pages, uint64_t puaf_method, uint64_t kread_method, uint64_t kwrite_method, bool extra_checks)
1616
{
17-
_kfd = kopen(puaf_pages, puaf_method, kread_method, kwrite_method);
17+
_kfd = kopen(puaf_pages, puaf_method, kread_method, kwrite_method, extra_checks);
1818
return _kfd;
1919
}
2020

kfd/fun/krw.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
#define krw_h
1010
#include "fun.h"
1111
#include <stdio.h>
12+
#include <stdbool.h>
1213

13-
uint64_t do_kopen(uint64_t puaf_pages, uint64_t puaf_method, uint64_t kread_method, uint64_t kwrite_method);
14+
uint64_t do_kopen(uint64_t puaf_pages, uint64_t puaf_method, uint64_t kread_method, uint64_t kwrite_method, bool extra_checks);
1415
void do_kclose(void);
1516
void do_kread(uint64_t kaddr, void* uaddr, uint64_t size);
1617
void do_kwrite(void* uaddr, uint64_t kaddr, uint64_t size);

kfd/fun/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ int VarMobileRemoveTest(void);
1515
int setSuperviseMode(bool enable);
1616
int removeKeyboardCache(void);
1717
int regionChanger(NSString *country_value, NSString *region_value);
18-
void DynamicCOW(void);
18+
void DynamicCOW(int subtype);

0 commit comments

Comments
 (0)