吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1556|回复: 22
收起左侧

[其他原创] 【其他原创】基于.NET6.0的LSPatch UI界面

[复制链接]
creationwong 发表于 2025-1-31 15:32
本帖最后由 creationwong 于 2025-1-31 22:55 编辑

这个程序本来用来简化LSPatch给B站app添加Xposed插件而开发的界面,现在开放源代码供大家学习。
代码质量并不高,有问题的地方希望大神指正。
GitHub :https://github.com/CreationWong/LSPatchUI
屏幕截图 2025-01-31 152825.png
主要逻辑代码(命令组装&调用CMD执行):  
[C#] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
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
126
127
128
129
130
131
132
133
134
135
136
137
138
private void ButtonRUN_Click(object sender, EventArgs e)
        {
            bool useManager = checkBoxUseManager.Checked;
            bool newVersion = checkBoxNewVersion.Checked;
            bool APKDebug = checkBoxAPKDebug.Checked;
 
            int lvIndex = comboBoxLv.SelectedIndex;
 
            string javaPath = textBoxJavaPath.Text;
            string jarPath = textBoxJarPath.Text;
            string apkPath = textBoxAPKPath.Text;
            string outPath = textBoxOUTPath.Text;
 
            var modItems = listBoxMod.Items;
 
            if (string.IsNullOrWhiteSpace(javaPath))
            {
                MessageBox.Show("请选择 java.exe 文件路径!", "用户操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
 
            string command = $"{javaPath} -jar \"{jarPath}\" \"{apkPath}\"";
 
            if (string.IsNullOrWhiteSpace(jarPath))
            {
                MessageBox.Show("请选择 LSPatch.jar 文件路径!", "用户操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
 
            if (string.IsNullOrWhiteSpace(apkPath))
            {
                MessageBox.Show("请选择 APK 文件路径!", "用户操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
 
            if (modItems.Count == 0 && useManager == false)
            {
                MessageBox.Show("你没有启用本地模式,请添加模块。", "用户操作错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
 
            if (useManager)
            {
                command += " -manager";
            }
            else
            {
                foreach (var item in modItems)
                {
                    string itemText = item.ToString();
                    string filePath = ExtractFilePath(itemText); // 提取filePath
                    command += $" -m \"{filePath}\"";
                }
            }
 
            if (APKDebug)
            {
                command += " -debuggable";
            }
 
            if (newVersion)
            {
                command += " -allowdown";
            }
 
            command += $" -l {lvIndex}";
 
            if (string.IsNullOrWhiteSpace(outPath))
            {
                string TempOutPath = Path.GetDirectoryName(apkPath);
                DialogResult state = MessageBox.Show($"未指定保存路径! 输出文件将要保存到 {TempOutPath} 文件夹中。请确认!", "更改用户操作警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (state == DialogResult.No)
                {
                    return;
                }
                command += $" -o {TempOutPath}";
            }
            else
            {
                command += $" -o {outPath}";
            }
 
            ExecuteCommand(command);
 
        }
 
        private string ExtractFilePath(string itemText)
        {
            int startIndex = itemText.LastIndexOf('(') + 1;
            int endIndex = itemText.LastIndexOf(')');
 
            if (startIndex >= 0 && endIndex > startIndex)
            {
                return itemText.Substring(startIndex, endIndex - startIndex).Trim();
            }
 
            return itemText;
        }
 
        private void checkBoxUseManager_CheckedChanged(object sender, EventArgs e)
        {
            if (checkBoxUseManager.CheckState == 0)
            {
                listBoxMod.Enabled = true;
                ButtonAdd.Enabled = true;
                ButtonDelete.Enabled = true;
            }
            else
            {
                listBoxMod.Enabled = false;
                ButtonAdd.Enabled = false;
                ButtonDelete.Enabled = false;
            }
        }
 
        private void ExecuteCommand(string command)
        {
            try
            {
                ProcessStartInfo processStartInfo = new ProcessStartInfo
                {
                    FileName = "cmd.exe",
                    Arguments = $"/c {command}",
                };
 
                using (Process process = new Process())
                {
                    process.StartInfo = processStartInfo;
                    process.Start();
 
                    process.WaitForExit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show($"执行命令时出错: {ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }


编译版下载:
https://wwvk.lanzouq.com/b00b4cz1oj
密码:52pojie

免费评分

参与人数 1吾爱币 +7 热心值 +1 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| creationwong 发表于 2025-2-11 22:33
本帖最后由 creationwong 于 2025-2-11 22:34 编辑

V1.1.0 版本更新
  • 把 V1.0.1-alphaV1.0 更新合并。
  • 添加简单的配置文件,不用重新选择重复的配置了。
  • 优化部分代码逻辑.


编译版下载:
https://wwvk.lanzouq.com/b00b4cz1oj
密码:52pojie
 楼主| creationwong 发表于 2025-4-4 00:26
hanbazhen 发表于 2025-3-19 11:56
楼主楼主,有几个问题,望更新版本解决

1、.jar文件命名定死了,我备注了版本号,发现不能添加进去,建 ...

感谢反馈这些问题
关于.jar文件命名定死问题,可能到下个版本更改。(补充:由于用户可能误提交错误jar文件导致意外错误,程序开始设计时命名定死了。如果你有好的判断逻辑,欢迎提交相关代码。)
欢迎提供第三方内核的github链接,我测试完后如果没有问题后更新。
管理器模式就是使用LSPatch管理器模式。
相关代码:
[C#] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
if (useManager)
{
    command += " -manager";
}
else
{
    foreach (var item in modItems)
    {
        string itemText = item.ToString();
        string filePath = ExtractFilePath(itemText); // 提取filePath
        command += $" -m \"{filePath}\"";
    }
}

不勾选就是集成模式。
hanbazhen 发表于 2025-4-4 18:26
creationwong 发表于 2025-4-4 00:26
感谢反馈这些问题
关于.jar文件命名定死问题,可能到下个版本更改。(补充:由于用户可能误提交错误 ...

1、不勾选就是集成模式,集成之后能够增加或者删除吗,手机上用的是MT管理器改动安装包,建议支持该功能,方便对别人内嵌的包改动

2、多开需要,楼主能加个自定义包名多开功能嘛?本人发现NP管理器、MT管理器、apktool m多开的包文件名各不同,有的是_mod,有的是_clone,不知楼主能否支持多开+内嵌,这样俺就不用在手机上多开后再传到电脑上用你的软件进行内嵌了

3、第三方内核lsp我找下链接发给你
4、.jar我是标有备注的,比如“lsp原版0.6.398.jar”、“lsp第三方内核0.7版本.jar”,这样容易区分是哪个版本,什么版本使用会正常
hanbazhen 发表于 2025-1-31 19:56
楼主楼主,这个能直接拖拽到软件窗口进行添加吗?因为插件不是放在同一个文件夹,放在一起又要找

如果一层一层找文件夹,太麻烦
 楼主| creationwong 发表于 2025-1-31 21:24
hanbazhen 发表于 2025-1-31 19:56
楼主楼主,这个能直接拖拽到软件窗口进行添加吗?因为插件不是放在同一个文件夹,放在一起又要找

如果一 ...

谢谢你的建议,我会尝试添加类似功能。
hanbazhen 发表于 2025-1-31 21:27
creationwong 发表于 2025-1-31 21:24
谢谢你的建议,我会尝试添加类似功能。

直接拖拽比自己一层一层找来添加方便多了,因为本身就已经找到了插件在的文件夹位置,此时再一从软件里找到位置很麻烦
 楼主| creationwong 发表于 2025-1-31 22:53
本帖最后由 creationwong 于 2025-1-31 22:54 编辑
hanbazhen 发表于 2025-1-31 21:27
直接拖拽比自己一层一层找来添加方便多了,因为本身就已经找到了插件在的文件夹位置,此时再一从软件里找 ...

你好,根据您的建议已添加文件拖入功能。
测试版从GitHub上下载
LSPatchU V1.0.1-alphaV1.0
https://github.com/CreationWong/LSPatchUI/releases/tag/V1.0.1-alphaV1.0
如果有什么问题可以回复说明,代码改进可以在GitHub我的仓库中创建一个issues或fork后合并到主分支。
谢谢你的建议。
BrutusScipio 发表于 2025-2-1 13:44
一眼拼接字符串 不过有一些路径不用管理员权限能操作吗
 楼主| creationwong 发表于 2025-2-1 16:35
BrutusScipio 发表于 2025-2-1 13:44
一眼拼接字符串 不过有一些路径不用管理员权限能操作吗

就是通过拼接字符串来简化打命令行操作,大部分的路径都能访问。这个程序不用访问系统敏感路径,管理员权限没有必要
xiaohui13 发表于 2025-2-8 11:07
用起来真的有点麻烦啊
头像被屏蔽
qwq5555 发表于 2025-2-9 18:42
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-7-16 13:14

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表