全自动电棍 发表于 2025-10-11 22:47:44

一种基于relauncher思想和classloader逃逸技巧启发的CoreMod框架安装设想

本帖最后由 全自动电棍 于 2025-10-12 00:34 编辑

AI Twekas is perhaps the worst mod to learn Starsector modding from, because of the complexity and hacks required to access obfuscated symbols.

The important part is the division into two jars: lanucher and core. Launcher is the normal, modding-API compliant part, loaded by Starsector. It's responsible for analyzing the game binary, finding the correct obfuscated symbols for the given game version and injecting them into ai tweaks core.

The core, once injected with obf symbols, is launched with a custom class loader. The class loader, among other things, circumvents the game reflection ban.

You'll find all the features inside core jar. The jar is divided mostly into two parts: player assist and ship AI. If you want to modify the ship AI, just look at the CustomShipAI class and find your way from there.
——Genir

从上文可知,AITweak通过以Loader/Core形式使用自定义classloader加载敏感操作逻辑从而绕过了游戏类加载器的文件读写与反射限制。

基于上述启发,我们融入隔壁MC模组Cleanroom Relauncher中的思想大胆设想一下
——更进一步,直接中断游戏生命周期,并使用我们的类加载器(LaunchWrappr)重新启动游戏。
通过LaunchWrappr,我们可以使用IClassTransformer以及ITweak获取无限制操纵游戏类的能力。

而这一切只需要包装一下游戏主方法确保classpath正确,并保存重写后的类到文件系统完成持久化即可。

并且令人惊喜的是,fabric到如今依旧有方法可以通过LaunchWrapper启动,只是需要对GameProvider做一些调整。
这意味着你可以全都要,ASM和Mixin齐上阵😋

该做的cpw和lex已经替我们做过了,我们只需要享受成果就行了。


不过这真的很蠢,等于给launchwrapper前面又加了个launchwrapper,只是为了不用改启动参数,欢迎聪明人来指点一下😰



起个名字好难 发表于 2025-10-11 23:26:31

这是不是意味着可以绕过ALEX的史山依赖(如果有的话),从而达到定期清理游戏缓存的效果呢?

全自动电棍 发表于 2025-10-12 00:08:04

起个名字好难 发表于 2025-10-11 23:26
这是不是意味着可以绕过ALEX的史山依赖(如果有的话),从而达到定期清理游戏缓存的效果呢? ...

这意味着你可以做几乎任何java可以做到的事情。
我只是因为不想写安装器或者启动器什么的所以觉得这个思路可行,而且这个做出来也符合远神的'Mod'定义(使用api^^)。

理论上这套流程稍作修改便能做到自动安装好需要修改游戏类文件的CoreMod。
就像安装普通mod那样,往mods文件夹里放丢一个mod再启用就行,并且依旧能恢复原始游戏行为。

起个名字好难 发表于 2025-10-12 01:18:52

崇拜大佬

SR.com 发表于 2025-10-12 05:39:38

otto你真的是天才!

006379 发表于 2025-10-13 13:24:25

如果这个办法真能行的话,电棍哥,你就是拯救SS内存溢出导致存档over 的天字第一号大神了!

冷鸢 发表于 2025-11-6 22:33:12

甜菜
页: [1]
查看完整版本: 一种基于relauncher思想和classloader逃逸技巧启发的CoreMod框架安装设想