Skip to content

Fix GenericMethod_GetMethod_Hook on Unity 2020.3.41+#89

Merged
Kasuromi merged 1 commit intoBepInEx:masterfrom
limoka:fix_generic_method_get_method_hook
May 21, 2023
Merged

Fix GenericMethod_GetMethod_Hook on Unity 2020.3.41+#89
Kasuromi merged 1 commit intoBepInEx:masterfrom
limoka:fix_generic_method_get_method_hook

Conversation

@limoka
Copy link
Copy Markdown
Contributor

@limoka limoka commented May 7, 2023

This PR fixes a crash after call to GenericMethod::GetMethod() hook.
This issue appears on Unity version 2020.3.41+, and in some cases in 2021.3.12+, 2022.1.23+ because of this fix

In these versions Object::GetVirtualMethod() calls GenericMethod::GetGenericVirtualMethod() instead of GenericMethod::GetMethod()
This also has an annoying interaction with shims added in 2021.2.0, where they get inlined together.

I also removed targetTargets.Length == 1 check because it seems to be always true, due to early return in GenericMethod::GetMethod() that I noticed. Unfortunately because of this, problems on debug builds could emerge. I don't know if these are important though.

Tested on a custom test game built using 2020.3.46.
@decaprime also confirmed no issues on their beta version of the V Rising Unity 2020.3.46
Also tested on CoreKeeper 2021.3.14, no issues there.

For reference some relevant Unity libil2cpp versions are available here: link

@Kasuromi Kasuromi merged commit 1847230 into BepInEx:master May 21, 2023
@limoka limoka deleted the fix_generic_method_get_method_hook branch May 21, 2023 17:55
@ds5678 ds5678 added this to the 1.4.6 milestone Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants