Skip to content

Return and parameter types of methods is not entirelly correct. #44

@ElektroKill

Description

@ElektroKill

Describe the bug
When a method does not have a physical counterpart, the return type and parameter types are unknown and need to be inferred. In my testing, it looks like the return type of these methods is not inferred at all and is just set to System.Object. This causes many boxing issues to occur when these methods are used.

In this method, we see that the parameter was inferred but the return type is System.Object.
image
If we look at the IL code we see that the return value is boxed as System.UInt32.
image
However, if we look at the usage of this method we see that the return value is unboxed as System.Int32.
image
This leads to an exception at runtime since the types do not match. The return type should be inferred so that hopefully casts can be inferred at later stages of recompilation.
Furthermore, this is a bit more nitpicky but the parameter of __VMFUNCTION__07F2 could also be inferred as System.Byte[] instead of System.Array for greater accuracy.

To Reproduce
Attempt to devirtualize the sample provided in the zip below.
NOTE: there are other methods in this unrelated to the problem.
sample.zip

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions