Skip to content

Commit

Permalink
fix init path detect
Browse files Browse the repository at this point in the history
  • Loading branch information
13584452567 committed Jul 19, 2024
1 parent f440f94 commit effe965
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
18 changes: 15 additions & 3 deletions UotanToolbox/Common/BootPatchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using UotanToolbox.Features.Components;

Expand Down Expand Up @@ -174,7 +175,7 @@ public static void dtb_detect()
/// <summary>
/// 检测Boot文件夹下是否存在kernel文件
/// </summary>
public static async Task kernel_detect()
public static void kernel_detect()
{
if (File.Exists(Path.Combine(BootInfo.tmp_path, "kernel")))
{
Expand Down Expand Up @@ -212,9 +213,20 @@ public static async Task<bool> ramdisk_detect()
Directory.CreateDirectory(workpath);
}
(string outputcpio, Global.cpio_exitcode) = await CallExternalProgram.MagiskBoot($"cpio \"{cpio_file}\" extract", workpath);
string initPath = await CheckInitPath(ramdisk_path);
string initPath = Path.Combine(ramdisk_path,"init");
string init_info = await CallExternalProgram.File($"\"{initPath}\"");
(BootInfo.userful, BootInfo.arch) = ArchDetect(init_info);
if (!BootInfo.userful)
{
string tmp_initPath = await read_symlink(initPath);
initPath = Path.Join(ramdisk_path,tmp_initPath);
init_info = await CallExternalProgram.File($"\"{initPath}\"");
(BootInfo.userful, BootInfo.arch) = ArchDetect(init_info);
if (!BootInfo.userful)
{
return false;
}
}
}
return true;
}
Expand Down Expand Up @@ -342,7 +354,7 @@ public static bool CleanBoot(string path)
}
}
/// <summary>
/// 检查路径下的init文件的实际路径,跳读字节流实现软连接读取
/// 检查路径下的init文件的实际路径,跳读字节流实现软连接读取,在Linux和Darwin平台上貌似无法正常运行,暂时弃置
/// </summary>
/// <param name="filePath">ramdisk解包路径</param>
/// <returns>如果前9个字节与目标序列匹配则返回true,否则返回false。</returns>
Expand Down
2 changes: 1 addition & 1 deletion UotanToolbox/Features/Dashboard/DashboardView.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ private async void OpenBootFile(object sender, RoutedEventArgs args)
BootInfo.os_version = StringHelper.StringRegex(mb_output, osVersionPattern, 1);
BootInfo.patch_level = StringHelper.StringRegex(mb_output, osPatchLevelPattern, 1);
BootPatchHelper.dtb_detect();
await BootPatchHelper.kernel_detect();
BootPatchHelper.kernel_detect();
await BootPatchHelper.ramdisk_detect();
SukiHost.ShowDialog(new PureDialog($"{GetTranslation("Basicflash_DetectdBoot")}\nArch:{BootInfo.arch}\nOS:{BootInfo.os_version}\nPatch_level:{BootInfo.patch_level}\nRamdisk:{BootInfo.have_ramdisk}\nKMI:{BootInfo.kmi}"), allowBackgroundClose: true);
ArchList.SelectedItem = BootInfo.arch;
Expand Down

0 comments on commit effe965

Please sign in to comment.