icsharpcode / ILSpy

.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
21.23k stars 3.33k forks source link

Export C# code containing IL that can be re-assembled with InlineIL.Fody (https://github.com/ltrzesniewski/InlineIL.Fody) #3270

Closed H-A-M-G-E-R closed 1 week ago

H-A-M-G-E-R commented 2 weeks ago

The first step to making a bytematching decomp... the second step is to gradually replace the IL code with C# code decompiled by hand so that the recompiled IL matches the original IL, just like how you make a matching decomp of a game by gradually replacing assembly code with C/C++ code.

ltrzesniewski commented 2 weeks ago

While I'm sure this would be fun to code, I think it would be a lot of work, so I suppose the core team wouldn't be eager to add something so specific (but maybe I'm wrong).

Here are a couple issues I see with making something round-trippable and compilable, off the top of my head:

Those are a few examples which make round-tripping difficult, and I'm sure there would be other surprises.

christophwille commented 2 weeks ago

We did discuss this superficially - it is on the far, far edge feature-wise (after all, we are decompiling from IL to C#) and it kind of borders on what obfuscators do to IL code... where we also do not reverse the patterns (you'd have to apply a deobfuscator first).

H-A-M-G-E-R commented 2 weeks ago

I think most C# games don't obfuscate their code to ease modding.

christophwille commented 1 week ago

This is something we do not intend to build, closing.