sunnamed434 / BitMono

Obfuscator for .NET and Mono, with a customizable engine for building your own obfuscators.
https://bitmono.readthedocs.io/en/latest/
MIT License
316 stars 26 forks source link

CreateDelegate fails on Linux with "Parameter count mismatch" #160

Closed snovvcrash closed 8 months ago

snovvcrash commented 8 months ago

When trying to run on Linux (tested on Kali 2022.4, Ubuntu 22.04.3 LTS), BitMono.Utilities fails at CreateDelegate here.

1

If I recompile the project omitting the following if block, everything seems fine:

if (hasMono)
{
    var displayName = monoType.GetMethod(KnownMonoRuntimes.GetDisplayName, BindingFlags.NonPublic | BindingFlags.Static);
    if (displayName != null)
    {
        var displayNameDelegate = (Func<string>)displayName.CreateDelegate(typeof(Func<string>), monoType);
        monoDisplayName = displayNameDelegate.Invoke();
    }
}

Tested with Mono 6.12.0.200 and 6.8.0.105 (crashes on both).

sunnamed434 commented 8 months ago

Hi, nice catch, If you want you can make PR (if you do, don't forget to use the dev branch)

snovvcrash commented 8 months ago

@sunnamed434 Nah, afraid not, I've just commented the whole code block, may be there's a better solution?

sunnamed434 commented 8 months ago

It can be done this way :

monoDisplayName = (string)displayNameMethod.Invoke(null, null);