Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate dead, unreachable code #766

Closed
ChlorideCull opened this issue Oct 2, 2016 · 3 comments
Closed

Eliminate dead, unreachable code #766

ChlorideCull opened this issue Oct 2, 2016 · 3 comments

Comments

@ChlorideCull
Copy link

It would be great if an additional "simple" dead code elimination step could be enabled. Certain obfuscators tend to like inserting blocks of code which will break compilation as-is, like

if (!true)
{
    RuntimeMethodHandle arg_43_0 = methodof(CP.V(int)).MethodHandle;
}

Obviously, !true will never be true, but the presence of the code is enough to throw off Microsoft's C# compiler, since methodof doesn't exist.

Slightly harder, but still doable, is something like

while (true)
{
    switch (2)
    {
    case 0:
        continue;
    }
    break;
}

As the switch will never hit a case (no default, only case is not the same as the constant), it can be completely removed, only leaving a while (true) { break; }, which could also be removed.

@akyryz
Copy link

akyryz commented Dec 3, 2016

What about a plugin for this kind of stuff?

@dgrunwald
Copy link
Member

I don't think it's a good idea for us to start an arms race with obfuscators. But I'm open to the possibility of allowing plugins to add passes to the decompiler pipeline.

@siegfriedpammer
Copy link
Member

If anyone is interested in contributing such a feature, we'll be glad to help providing an plugin interface. But for now we are closing this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants