-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Support loading compressed Xamarin assemblies, see #2137 #2471
Support loading compressed Xamarin assemblies, see #2137 #2471
Conversation
Extend class LoadedAssembly to detect and load compressed Xamarin assemblies if direct loading of assembly fails. Requires Nuget pkg K4os.Compression.LZ4 for LZ4 decompression.
ILSpy/LoadedAssembly.cs
Outdated
var descIdx = fileReader.ReadUInt32(); | ||
var uncLen = fileReader.ReadUInt32(); | ||
// fileReader stream position is now at compressed module data | ||
var src = fileReader.ReadBytes((int)uncLen); // compressed length must be smaller than uncompressed length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would read the complete rest of the file instead of relying on an assumption here. Like using fileStream.Length - 12
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, now using fileStream.Length
to read all remaining data. Not accounting for compressed header length since ReadBytes()
will stop at stream end anyway. We also save us from having a new constant and checking for (theoretical case) fileStream.Length
< 12
The K4os.Compression.LZ4 license should be added to doc/third-party-notices.txt |
Added license notice for K4os.Compression.LZ4. |
Thank you for your contribution! |
Fixes #2137.
Problem
Assemblies included in mobile Android apps created with Xamarin can be compressed. This PR detects compressed assemblies and attempts to decompress them in order to correctly load the assembly. This is handy when analyzing mobile apps created with Xamarin using ILSpy.
Solution
LoadedAssembly
to detect and load compressed Xamarin assemblies if direct loading of assembly fails.