| 12693 | return this; |
| 12694 | } |
| 12695 | attach(mode = "full") { |
| 12696 | let count = 0; |
| 12697 | for (const target of this.targets) { |
| 12698 | if (target.virtualAddress.isNull()) { |
| 12699 | continue; |
| 12700 | } |
| 12701 | const offset = `\x1b[2m0x${target.relativeVirtualAddress.toString(16).padStart(8, `0`)}\x1b[0m`; |
| 12702 | const fullName = `${target.class.type.name}.\x1b[1m${target.name}\x1b[0m`; |
| 12703 | if (mode == "detailed") { |
| 12704 | const startIndex = +!target.isStatic | +Il2Cpp.unityVersionIsBelow201830; |
| 12705 | const callback = (...args) => { |
| 12706 | const thisParameter = target.isStatic ? undefined : new Il2Cpp.Parameter("this", -1, target.class.type); |
| 12707 | const parameters = thisParameter ? [thisParameter].concat(target.parameters) : target.parameters; |
| 12708 | (0, console_1.inform)(`\ |
| 12709 | ${offset} ${`│ `.repeat(count++)}┌─\x1b[35m${fullName}\x1b[0m(\ |
| 12710 | ${parameters.map(e => `\x1b[32m${e.name}\x1b[0m = \x1b[31m${(0, utils_1.fromFridaValue)(args[e.position + startIndex], e.type)}\x1b[0m`).join(`, `)});`); |
| 12711 | const returnValue = target.nativeFunction(...args); |
| 12712 | (0, console_1.inform)(`\ |
| 12713 | ${offset} ${`│ `.repeat(--count)}└─\x1b[33m${fullName}\x1b[0m\ |
| 12714 | ${returnValue == undefined ? `` : ` = \x1b[36m${(0, utils_1.fromFridaValue)(returnValue, target.returnType)}`}\x1b[0m;`); |
| 12715 | return returnValue; |
| 12716 | }; |
| 12717 | try { |
| 12718 | target.revert(); |
| 12719 | const nativeCallback = new NativeCallback(callback, target.returnType.fridaAlias, target.fridaSignature); |
| 12720 | Interceptor.replace(target.virtualAddress, nativeCallback); |
| 12721 | } |
| 12722 | catch (e) { } |
| 12723 | } |
| 12724 | else { |
| 12725 | try { |
| 12726 | Interceptor.attach(target.virtualAddress, { |
| 12727 | onEnter: () => (0, console_1.inform)(`${offset} ${`│ `.repeat(count++)}┌─\x1b[35m${fullName}\x1b[0m`), |
| 12728 | onLeave: () => (0, console_1.inform)(`${offset} ${`│ `.repeat(--count)}└─\x1b[33m${fullName}\x1b[0m${count == 0 ? `\n` : ``}`) |
| 12729 | }); |
| 12730 | } |
| 12731 | catch (e) { } |
| 12732 | } |
| 12733 | } |
| 12734 | } |
| 12735 | } |
| 12736 | Il2Cpp.Tracer = Il2CppTracer; |
| 12737 | |