vfsfitvnm / frida-il2cpp-bridge

A Frida module to dump, trace or hijack any Il2Cpp application at runtime, without needing the global-metadata.dat file.
https://github.com/vfsfitvnm/frida-il2cpp-bridge/wiki
MIT License
1.03k stars 202 forks source link

Modify and return Boolean on implementation #187

Closed Jnetops closed 2 years ago

Jnetops commented 2 years ago

Sorry to bother, but I have a general question. Upon overwriting a function, I am attempting to modify it's return value (which is a boolean).

I can't quite figure out how to achieve this. I can't return a simple true, or ptr(1) or 1 or a series of other things I have tried. How do you go about doing the equivalent of Il2cpp.String.from("true") but for a boolean?

Thanks in advance.

ChuJiani commented 2 years ago

If I did not misunderstand, you can modify the return value of a boolean function with this:

// Dll: DllName.dll
const DllName = Il2Cpp.Domain.assembly("DllName").image;
// Namespace: NamespaceName
// Class: ClassName
const ClassName = DllName.class("NamespaceName.ClassName");
// private static Boolean funcName(string str) { }
const funcName = ClassName.method<boolean>("funcName");
funcName.implementation = function(str: Il2cpp.String){
    res = funcName.invoke(str);
    // make no changes
    return res;
    // or return true
    return true;
}

This works for me, and you can try referring to WIKI first if your problem is not solved :D

Jnetops commented 2 years ago

ya... that was a late night and could have benefitted from some rest before asking that question. As soon as I got up and my head was clear, I was immediately able to get it working by just returning true like you showed.. lmao. Dunno wth was going on last night. Thanks again.

vfsfitvnm commented 2 years ago

Closing! Thanks @ChuJiani