Skip to content
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

il2cpp: couldn't invoke method .ctor as it needs 2 parameter(s), not 1 #579

Open
pfyy opened this issue Jan 2, 2025 · 4 comments
Open
Labels
needs triage This issue or pull request isn't verified yet

Comments

@pfyy
Copy link

pfyy commented Jan 2, 2025

i was doing the examples to create a new struct, however, i didn't succeed

error log:

il2cpp: couldn't invoke method .ctor as it needs 2 parameter(s), not 1
    at invokeRaw (/node_modules/frida-il2cpp-bridge/dist/index.js:2631)
    at maybeObjectHeaderSize (/node_modules/frida-il2cpp-bridge/dist/index.js:2794)
    at get (/node_modules/frida-il2cpp-bridge/dist/index.js:2705)
    at <eval> (<input>:1)

image

meanwhile, i found your code relies on the ctor signature of System.RuntimeTypeHandle:

        const struct = Il2Cpp.corlib.class("System.RuntimeTypeHandle").initialize().alloc();
        struct.method(".ctor").invokeRaw(struct, ptr(0xdeadbeef));

however, at least for this game, it is not the signature you are looking for:

il2cpp dump:

// mscorlib
struct System.RuntimeTypeHandle : System.ValueType, System.Runtime.Serialization.ISerializable
{
    System.IntPtr value; // 0x8
    System.Void .ctor(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context); // 0x03b5e995
    System.IntPtr get_Value(); // 0x03b5e9d9
    System.Void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context); // 0x03b5eb77
    System.Boolean Equals(System.Object obj); // 0x03b5ece0
    System.Int32 GetHashCode(); // 0x03b5ed0f
}

the signature requires an extra context args, which breaks the struct related calls

@pfyy
Copy link
Author

pfyy commented Jan 2, 2025

the same is still true even if you don't use the new fancy calls for unboxed structs:

image

@pfyy
Copy link
Author

pfyy commented Jan 2, 2025

the latest version of your project is used, which is 0.9.1 at the time of writing

and for clarity of error log, here is the #2794 of your code

image

@vfsfitvnm
Copy link
Owner

Thanks for reporting. I'll try to take a look at it, but it's unlikely to happen soon as I don't have much free time. What's the Unity version, game id and platform?

@vfsfitvnm
Copy link
Owner

But oh, did you try with:

vec.method(".ctor", 2)

?

@vfsfitvnm vfsfitvnm added the needs triage This issue or pull request isn't verified yet label Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue or pull request isn't verified yet
Projects
None yet
Development

No branches or pull requests

2 participants