dnlib icon indicating copy to clipboard operation
dnlib copied to clipboard

Should IsGreaterAssemblyRefVersion ignore 65535.65535.65535.65535?

Open CreateAndInject opened this issue 4 years ago • 4 comments

I don't know why, but sometimes there's a reference mscorlib, 65535.65535.65535.65535, should IsGreaterAssemblyRefVersion ignore it? And what's the meaning of this version?

CreateAndInject avatar Mar 27 '20 11:03 CreateAndInject

It's a valid value in metadata. C# (and probably VB.NET) don't allow any of the fields to have the max value (65535), possibly because of a Windows OS limitation. Those values are copied to other parts of the PE file which Windows checks.

Partition II 22.2 page 130 "3. MajorVersion, MinorVersion, BuildNumber, and RevisionNumber can each have any value"

So to answer your question, I don't see a reason to update the code.

0xd4d avatar Mar 28 '20 16:03 0xd4d

If you can show that CLR and/or CoreCLR have special checks for that version then the code will be updated though.

0xd4d avatar Mar 28 '20 16:03 0xd4d

If there're references of mscorlib 2.0.0.0 4.0.0.0 and 65535.65535.65535.65535 in an assembly. When someome call GetAssemblyRef("mscorlib"), I think he want to pick mscorlib 4.0.0.0 rather than 65535.65535.65535.65535 And I find this in ILSpy: image

CreateAndInject avatar Mar 28 '20 20:03 CreateAndInject

https://github.com/0xd4d/dnlib/blob/5a3927395c4ea7452d1844e74e7f4702dca8775e/src/DotNet/TypeDef.cs#L582 Don't include abstract since value types can be abstract without throwing at runtime Don't include or don't check?

CreateAndInject avatar Apr 04 '20 20:04 CreateAndInject