Skip to content

Commit 0d8e9f3

Browse files
committed
Revert "Add KsuAssetExtractor and improve KernelSU patching"
1 parent dd95f66 commit 0d8e9f3

3 files changed

Lines changed: 4 additions & 228 deletions

File tree

UotanToolbox/Common/PatchHelper/KernelSUPatch.cs

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,11 @@ public static async Task<string> LKM_Patch(PatchInfo zipInfo, BootInfo bootInfo)
4242
{
4343
throw new Exception("unsupported arch" + bootInfo.Arch);
4444
}
45-
46-
string koPath = Path.Combine(zipInfo.TempPath, "kernelsu.ko");
47-
if (!File.Exists(koPath))
48-
{
49-
if (zipInfo.Path.EndsWith(".apk", StringComparison.OrdinalIgnoreCase))
50-
{
51-
string extractedKo = KsuAssetExtractor.ExtractKoFromApk(zipInfo.Path, zipInfo.TempPath, bootInfo.Arch, bootInfo.KMI);
52-
if (!string.IsNullOrEmpty(extractedKo))
53-
{
54-
koPath = extractedKo;
55-
}
56-
}
57-
}
58-
59-
if (!File.Exists(koPath))
60-
{
61-
throw new Exception("kernelsu.ko not found in patch source.");
62-
}
63-
64-
File.Copy(koPath, Path.Combine(bootInfo.TempPath, "kernelsu.ko"), true);
45+
File.Copy(Path.Combine(zipInfo.TempPath, "kernelsu.ko"), Path.Combine(bootInfo.TempPath, "kernelsu.ko"), true);
6546
string archSubfolder = bootInfo.Arch switch
6647
{
6748
"aarch64" => "arm64-v8a",
68-
//"X86-64" => "x86_64",
49+
"X86-64" => "x86_64",
6950
_ => throw new ArgumentException($"{GetTranslation("Basicflash_UnknowArch")}{bootInfo.Arch}")
7051
};
7152
File.Copy(Path.Combine(Global.bin_path, "ksud", archSubfolder, "init"), Path.Combine(bootInfo.TempPath, "init"));

UotanToolbox/Common/PatchHelper/KsuAssetExtractor.cs

Lines changed: 0 additions & 195 deletions
This file was deleted.

UotanToolbox/Common/PatchHelper/PatchDetect.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ public static async Task<PatchInfo> Patch_Detect(string path)
4242
entry.WriteToDirectory(Patchinfo.TempPath, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true });
4343
}
4444
}
45-
catch (Exception ex)
46-
{
47-
throw new Exception(GetTranslation("Basicflash_ZipError") + ex.Message);
48-
}
49-
5045
bool isMagisk = Directory.Exists(Path.Combine(Patchinfo.TempPath, "assets")) && File.Exists(Path.Combine(Patchinfo.TempPath, "assets", "util_functions.sh"));
5146
if (!isMagisk)
5247
{
@@ -59,11 +54,7 @@ public static async Task<PatchInfo> Patch_Detect(string path)
5954
string[] imageFiles = Directory.GetFiles(Patchinfo.TempPath, "Image", SearchOption.AllDirectories);
6055
isGki = imageFiles.Length > 0;
6156
}
62-
string[] ksuFiles = Directory.GetFiles(Patchinfo.TempPath, "libksud.so", SearchOption.AllDirectories);
63-
if (ksuFiles.Length == 0)
64-
{
65-
ksuFiles = Directory.GetFiles(Patchinfo.TempPath, "libksud.so", SearchOption.AllDirectories);
66-
}
57+
string[] ksuFiles = Directory.GetFiles(Patchinfo.TempPath, "libkernelsu.so", SearchOption.AllDirectories);
6758
bool isksu_apk = ksuFiles.Length > 0;
6859
if (isMagisk)
6960
{
@@ -77,8 +68,7 @@ public static async Task<PatchInfo> Patch_Detect(string path)
7768
}
7869
else if (isksu_apk)
7970
{
80-
Patchinfo.Mode = PatchMode.LKM;
81-
Patchinfo.IsUseful = true;
71+
throw new Exception(GetTranslation("Basicflash_CantKSU"));
8272
}
8373
else
8474
{

0 commit comments

Comments
 (0)