Replaces the body of this method.
(block)
| 131 | |
| 132 | /** Replaces the body of this method. */ |
| 133 | set implementation(block) { |
| 134 | const startIndex = +!this.isStatic | +Il2Cpp.unityVersionIsBelow201830; |
| 135 | const callback = (...args) => { |
| 136 | const parameters = this.parameters.map((e, i) => utils_2.fromFridaValue(args[i + startIndex], e.type)); |
| 137 | return utils_2.toFridaValue(block.call(this.isStatic ? this.class : new Il2Cpp.Object(args[0]), ...parameters)); |
| 138 | }; |
| 139 | try { |
| 140 | this.revert(); |
| 141 | Interceptor.replace(this.virtualAddress, new NativeCallback(callback, this.returnType.fridaAlias, this.fridaSignature)); |
| 142 | } catch (e) { |
| 143 | switch (e.message) { |
| 144 | case "access violation accessing 0x0": |
| 145 | console.raise(`cannot implement method ${this.name}: it has a NULL virtual address`); |
| 146 | case `unable to intercept function at ${this.virtualAddress}; please file a bug`: |
| 147 | console.warn(`cannot implement method ${this.name}: it may be a thunk`); |
| 148 | break; |
| 149 | case "already replaced this function": |
| 150 | console.warn(`cannot implement method ${this.name}: already replaced by a thunk`); |
| 151 | break; |
| 152 | default: |
| 153 | throw e; |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | /** Creates a generic instance of the current generic method. */ |
| 159 | inflate(...classes) { |