Skip to content

Conversation

@y0soro
Copy link
Contributor

@y0soro y0soro commented Dec 22, 2025

The current RunFinalizer signatures can not reliably matches address of RunFinalizer, so fallback to xref scan as a last resort.

RunFinalizer is used in RegisterFinalizer and RegisterFinalizer is used in icall GC._ReRegisterForFinalize, which is relatively simple compared to other users of RegisterFinalizer. So we can traversal into GC._ReRegisterForFinalize to find address of RunFinalizer.

The xref scan handles both inlined and not inlined cases.


Tested and verified the found RunFinalizer address to be actual RunFinalizer for both inlined and not inlined cases.

The current `RunFinalizer` signatures can not reliably matches address of `RunFinalizer`, so fallback to xref scan as a last resort.

`RunFinalizer` is used in `RegisterFinalizer`, and `RegisterFinalizer` is used in icall GC._ReRegisterForFinalize which is relatively simple compared to other users of `RegisterFinalizer`.
So we can traversal into `GC._ReRegisterForFinalize` to find address of `RunFinalizer`.

The xref scan handles both inlined and not inlined cases.
Copy link
Member

@ManlyMarco ManlyMarco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed working, required for Aicomi patch 2025-12-19.

@ds5678
Copy link
Collaborator

ds5678 commented Jan 5, 2026

@ManlyMarco I disagree with these changes. The entire patch can be removed.

@ManlyMarco
Copy link
Member

ManlyMarco commented Jan 5, 2026

@ds5678 What do you mean? This is much more robust than the current byte matching, currently we have to fix those every few game patches. Unless there's a cleaner solution that is less likely to break in the future I think this is good enough.

@ds5678
Copy link
Collaborator

ds5678 commented Jan 5, 2026

ds5678@9d09abe

@ManlyMarco
Copy link
Member

ManlyMarco commented Jan 5, 2026

It appears that removing the patch as in ds5678@9d09abe does work correctly, at least I don't see any obvious side effects.

Here's a build of master with the patch removed if anyone wants to test it Il2CppInterop.Runtime.dll.zip

ManlyMarco added a commit that referenced this pull request Jan 5, 2026
@ManlyMarco
Copy link
Member

Closing in favor of #247

@ManlyMarco ManlyMarco closed this Jan 5, 2026
ManlyMarco added a commit that referenced this pull request Jan 5, 2026
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