Skip to content

Fix ArgumentOutOfRangeExecption with 0xffff parameters - #977

Open
ItsZil wants to merge 1 commit into
jbevain:masterfrom
Unity-Technologies:proper-param0xffff-fix
Open

Fix ArgumentOutOfRangeExecption with 0xffff parameters#977
ItsZil wants to merge 1 commit into
jbevain:masterfrom
Unity-Technologies:proper-param0xffff-fix

Conversation

@ItsZil

@ItsZil ItsZil commented Mar 10, 2026

Copy link
Copy Markdown

This PR fixes #913 and improves the original unmerged fix in PR #914.


The fix provided in PR #914 is insufficient in certain cases due to this condition:
current_index + 1 == current_table.Length

The above condition causes the fix to apply only when the overflow is on the second-to-last row of the method metadata table. But if there are additional parameterless methods at the end of the table, the parameter metadata table does not grow together with the method table. This causes the overflow to occur further from the end of the table.

The fix is simple: remove the above condition altogether. This is safe because next_index can never be 0 when the parameters table is exactly 0xffff.


Note that the same issue also applies to dnlib, as it also checks for tableSourceRid + 1 == tableSource.Rows.

I added a test which uses the same module as param0xffff.dll, but adds a couple of extra parameterless methods on top, which move the overflow away from the second-to-last row.

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.

Possible ArgumentOutOfRangeException when there are 65535 params in metadata table

1 participant