Unity曲线hook 以及动画时间
曲线和动画时间
import "frida-il2cpp-bridge";
declare const console: any;
Il2Cpp.perform(() => {
console.log("🔥 DOTween Full Hook Start");
// =========================
// Ease 解析
// =========================
function getEaseName(e: number) {
const map: any = {
0: "Unset",
1: "Linear",
2: "InSine",
3: "OutSine",
4: "InOutSine",
5: "InQuad",
6: "OutQuad",
7: "InOutQuad",
8: "InCubic",
9: "OutCubic",
10: "InOutCubic",
26: "OutBounce"
};
return map[e] ?? ("Unknown(" + e + ")");
}
// =========================
// AnimationCurve dump
// =========================
function dumpCurve(curve: any) {
try {
const keys = curve.keys;
console.log("📈 AnimationCurve:");
for (let i = 0; i < keys.length; i++) {
const k = keys[i];
console.log(
` key[${i}] time=${k.time} value=${k.value} inT=${k.inTangent} outT=${k.outTangent}`
);
}
} catch (e) {
console.log("❌ Curve parse failed");
}
}
// =========================
// 找 ShortcutExtensions
// =========================
let klass: any = null;
for (const asm of Il2Cpp.domain.assemblies) {
try {
klass = asm.image.class("DG.Tweening.ShortcutExtensions");
console.log("✅ Found in:", asm.name);
break;
} catch (e) {}
}
if (!klass) {
console.log("❌ ShortcutExtensions not found");
return;
}
// =========================
// Hook 方法
// =========================
function hook(method: any) {
console.log("🎯 Hook:", method.name);
method.implementation = function (...args: any[]) {
console.log("\n======================");
console.log("🔥 DOTween:", method.name);
// 打印参数 + 识别曲线
for (let i = 0; i < args.length; i++) {
const a = args[i];
// 👉 Ease(通常是 number)
if (typeof a === "number") {
console.log(`arg[${i}] Ease =>`, getEaseName(a));
continue;
}
// 👉 AnimationCurve
if (a && a.keys) {
console.log(`arg[${i}] AnimationCurve detected`);
dumpCurve(a);
continue;
}
console.log(`arg[${i}] =`, a);
}
// ⚠️ static method
const ret = method.invoke(...args);
console.log("======================\n");
return ret;
};
}
// =========================
// Hook list
// =========================
const targets = [
"DOMove",
"DOLocalMove",
"DOLocalMoveY",
"DORotate",
"DOLocalRotate",
"DOScale",
"DOColor",
"DOFade",
"DOShakePosition",
"DOShakeRotation",
"DOShakeScale",
"DOPath",
"DOLocalPath",
"DOKill"
];
klass.methods.forEach((m: any) => {
if (targets.includes(m.name)) {
hook(m);
}
});
});
曲线,准确的说是曲线的值,需要自己腻和一下,变为需要的曲线
import "frida-il2cpp-bridge";
Il2Cpp.perform(() => {
const AnimationCurve = Il2Cpp.domain
.assembly("UnityEngine.CoreModule")
.image
.class("UnityEngine.AnimationCurve");
const Evaluate = AnimationCurve.method("Evaluate");
Evaluate.implementation = function (...args: any[]) {
const time = args[0];
const self = this as Il2Cpp.Object;
const result = this.method("Evaluate").invoke(time);
console.log("🔥 curve time:", time, "result:", result);
return result;
};
});