Filtering or patching assemblies #866
Replies: 3 comments 2 replies
-
"Basically", I'd like to swap a specific set of assembly dependencies for a different set, and ignore any remaining dependencies. |
Beta Was this translation helpful? Give feedback.
-
If something's in the metadata tables it (usually) means it's used in the CIL stream. If you simply remove something from the metadata tables, the metadata tokens referenced by the IL stream won't be valid anymore.
If you want to avoid having to update the IL, I suppose the "easiest" approach would be to change the Cecil doesn't expose the raw metadata tables directly. Instead, it provides a higher-level view of the assembly as an object graph. You work with object references instead of metadata tokens. I think you should be able to modify the Side note: while |
Beta Was this translation helpful? Give feedback.
-
Thanks, this is helpful. |
Beta Was this translation helpful? Give feedback.
-
Hey all,
I'm trying to extract some code that has non-system-dependent business logic from Xamarin binaries to run them on Linux.
What would be the best way to go about this?
I expect that I could just run the code from the original assembly directly, but the mono loader (understandably) complains if I try to remove the Android related assemblies, because the business logic assembly links against them. This seems to mean for example references in the AssemblyRef tables, and the AssemblyRef table data is used by the TypeRef table data and whatnot.
It would be fine with me if I could just remove all the information I want to avoid (the things referring to the android platform specific libraries) from the metadata tables, but if I understand correctly, I would still have to update the tokens referring to the table entries in the CIL asm.
Also some of the code uses System.IO for networking (IIRC), but I think I should just be able to swap in another platform specific .net standard library, if I can manage to somehow re-engineer the binary I have.
I guess I would also need to link in the new platform specific assemblies I want? - by updating the tables and the CIL asm.
I have several ideas, but without knowing how Cecil is put together, I'd just end up knee deep in the X-Y problem.
I wanted to avoid re-generating the entire binary to minimize the difference between my patch and the original library, but given that Cecil works by re-generating the entire binary, that doesn't really seem to be an option. So maybe I don't need to worry so much about low level details and just filter out/replace the things I don't want at a higher level?
xref: #865 (comment)
Beta Was this translation helpful? Give feedback.
All reactions