Fix mono auto-version detection for Cuphead by skipping an unnecessary dereference in the class iteration logic #123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why this change?
Cuphead runs are done across many different versions (4 major versions). These use different versions of unity and such different versions of mono. The auto version detection does not work for Cuphead, it always picks V1, when some versions use V1Cattrs.
What changed?
The issue lies here. When iterating over class tables, we do an extra dereference at 0x0. This causes us to load Int32 from mscorlib.dll as the first class, which of course has a different address at it's image address than Assembly-CSharp.dll, so it detects it as not V1Cattrs (if you recall, the mono version detection works by checking if the first class in the default image's
imageoffset (using v1cattrs) matches the default image's address (bleh). if it does, v1cattrs, otherwise v1).Not doing the extra dereference (which, is what I've seen every other unity introspection library not do, including voxelse which is linked as a reference in code) causes it to load
ButtonIdentifier, which does have the Assembly-CSharp.dll as it's image, so it correctly identifies v1cattrs.I've manually set the version as V1Cattrs and printed out the list of classes that this function loads in order with and without this patch. I think it's pretty clear that this change is correct.
auto_splitter_logs without.txt
auto_splitter_logs with.txt
Without:
With: