-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracing an assembly seems to override all custom implementation of Il2cpp methods of said assembly #585
Comments
after some investigation the faulty code seems to be function trace(parameters = false) {
const applier = () => (method, state, threadId) => {
const paddedVirtualAddress = method.relativeVirtualAddress.toString(16).padStart(8, "0");
Interceptor.attach(method.virtualAddress, {
onEnter() {
state.buffer.push(`\x1b[2m0x${paddedVirtualAddress}\x1b[0m THREAD[${this.threadId}] ${`│ `.repeat(state.depth++)}┌─\x1b[35m${method.class.type.name}::\x1b[1m${method.name}\x1b[0m\x1b[0m`);
},
onLeave() {
// prettier-ignore
state.buffer.push(`\x1b[2m0x${paddedVirtualAddress}\x1b[0m THREAD[${this.threadId}] ${`│ `.repeat(--state.depth)}└─\x1b[33m${method.class.type.name}::\x1b[1m${method.name}\x1b[0m\x1b[0m`);
state.flush();
}
});
};
const applierWithParameters = () => (method, state, threadId) => {
const paddedVirtualAddress = method.relativeVirtualAddress.toString(16).padStart(8, "0");
const startIndex = +!method.isStatic | +Il2Cpp.unityVersionIsBelow201830;
const callback = function (...args) {
const thisParameter = method.isStatic ? undefined : new Il2Cpp.Parameter("this", -1, method.class.type);
const parameters = thisParameter ? [thisParameter].concat(method.parameters) : method.parameters;
// prettier-ignore
state.buffer.push(`\x1b[2m0x${paddedVirtualAddress}\x1b[0m THREAD[${this.threadId}] ${`│ `.repeat(state.depth++)}┌─\x1b[35m${method.class.type.name}::\x1b[1m${method.name}\x1b[0m\x1b[0m(${parameters.map(e => `\x1b[32m${e.name}\x1b[0m = \x1b[31m${Il2Cpp.fromFridaValue(args[e.position + startIndex], e.type)}\x1b[0m`).join(", ")})`);
const returnValue = method.nativeFunction(...args);
// prettier-ignore
state.buffer.push(`\x1b[2m0x${paddedVirtualAddress}\x1b[0m THREAD[${this.threadId}] ${`│ `.repeat(--state.depth)}└─\x1b[33m${method.class.type.name}::\x1b[1m${method.name}\x1b[0m\x1b[0m${returnValue == undefined ? "" : ` = \x1b[36m${Il2Cpp.fromFridaValue(returnValue, method.returnType)}`}\x1b[0m`);
state.flush();
return returnValue;
};
method.revert(); // <------ Reverts the original method implementation
const nativeCallback = new NativeCallback(callback, method.returnType.fridaAlias, method.fridaSignature);
Interceptor.replace(method.virtualAddress, nativeCallback);
};
return new Il2Cpp.Tracer(parameters ? applierWithParameters() : applier());
} Is this behaviour expected ? If not can the modified method behaviour be preserved in the tracing process |
Yes, it is expected. There is no way to have two implementations at the same time. Tracing with parameters requires |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this would result in the original implementation of Invoke being called in the execution flow
The text was updated successfully, but these errors were encountered: