20260727

0339睡到1056睡到1120,就算有点困了还是会想继续熬夜..

夜里群里看到人在讨论闪耀星骑士的auto机制,想起之前写了个hook ai pattern来主动设置选技能偏好的脚本但其实自己理解也是一知半解,今天打开Ghidra再看看,发现这代码还是好难看,IL2CPP 反编译 + C++ 指针展开看的很反胃,只能看出大约是从预设的aiPatternList里选一个?如果能让llm根据GhidraCPP2IL\diffable_cs来生成c#的伪代码或许会更舒服?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
你是Unity IL2CPP逆向专家。

下面有:
1. CPP2IL生成的C#结构
2. Ghidra反编译的native代码

请生成接近原始Unity C#源码风格的伪代码。

要求:
- 保留原函数名和参数
- 使用diffable_cs中的类型
- 不要猜不存在的字段
- native中的FUN_xxx请根据上下文标记可能含义
- 对不确定部分加注释
- 优先还原控制流程,而不是追求100%准确

输出:
1. C#伪代码
2. 函数逻辑说明
3. 关键未知调用列表

下辈子再用。现在是Ghidra + Il2CppDumper,因为用了Il2CppDumper 生成的 script.json才让代码更可读一点。Il2CppDecompiler好像可以通过 GPT-4 将 Ghidra 的反编译结果翻译成 C#,但不很想试,上次commit是2 years ago,而且Note that this script is for Unix systems. You're probably using Windows so you'll have to convert it to a .bat script or something. Please open a PR if you do. 😄

还是好好看看c吧。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
List<TSKBattleNote>

+0x00 Il2CppObject
       klass
       monitor

+0x10 _items
+0x18 _size       <----
+0x1c _version
+0x20 ...

第一次见对一个List取0x18时真是唬到我了。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Il2CppArray

+0x00 klass
+0x08 monitor
+0x10 bounds
+0x18 max_length   <----
+0x20 data[0]
+0x28 data[1]
+0x30 data[2]
...

取_items后再判断一次^^

1
2
3
4
	[SerializeField]
	private CharacterSpineObject leaderSelectSpine; //Field offset: 0x90
	[CompilerGenerated]
	private TSKBattleUnit <UnitData>k__BackingField; //Field offset: 0x98

对应

1
2
3
4
[SerializeField]
private CharacterSpineObject leaderSelectSpine;

public TSKBattleUnit UnitData { get; private set; }

感觉frida什么都能做到..

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
[13:33:23] enter TSKBattleAI.LotterySkill
[13:33:23] skillEffectList size = 70
[13:33:23] ===== Effect Summary =====
[13:33:23] SubRace: 1
[13:33:23] AtkUp: 1150960
[13:33:23] CrtUp: 6460
[13:33:23] SealedResistance: 1
[13:33:23] PassiveExUp: 27
[13:33:23] EnchantStunDamgeRateUp: 4100
[13:33:23] AtkUpTypeOut: 2000
[13:33:23] CrtUpTypeOut: 400
[13:33:23] AdvantagDamageUpType: 5000
[13:33:23] AtkUpExDrainRate: 12500
[13:33:23] AddRushNormalAttack: 2
[13:33:23] SpdUp: 9500
[13:33:23] UnisonDamageRateUp: 10000
[13:33:23] Charge: 0
[13:33:23] 星を見るもの フィオナ《魔王》: hp=7494 attack=3644 critical=1950
[13:33:23] set 星を見るもの skillId=2
[13:33:23] return: 0x1

下次看看这些Buff具体对应的是哪些吧。。

Licensed under CC BY-NC-SA 4.0
使用 Hugo 构建
主题 StackJimmy 设计