Skip to content

constants Protection , has an exception in the Target framework4.5 #270

@andywu188

Description

@andywu188

My code, after constant protection, has an exception, but in the. Net framework 4.0, there are no exceptions.
The sample program and configuration file are included in the attachment.

ConfuserEx 1.5.0

Target framework: .net 4.5 \ .net 4.6.1 \ .net 4.7.2

exception information:

System.ArgumentException: Object must be an array of primitives.
Parameter name: dest
at System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)
at ?????????????????????????????????????????-
at ConsoleApplication1.Program.Main(String[] args)

source code:

`

    static void Main(string[] args)
    {
        try
        {
            var data = new StringBuilder();
            data.Append(Get(Level.A, Level.E, Level.D)); 
            Console.WriteLine(data);
        }
        catch (Exception e)
        {
            Console.WriteLine(e);
        }
        Console.ReadKey();
    }

    private static string Get(params Level[] level)
    {
        return "OK";
    }
    public enum Level : long
    {
        A = 1,
        B = 2,
        C = 4,
        D = 8,
        E = 1073741824
    }

`

The original code with exception is:
data.Append(Get(Level.A, Level.E, Level.D));

The code after protection is:
data.Append(Program.Get(.\u202B\u200B\u206B\u206F\u200E\u206B\u202E\u202B\u206E\u202B\u206F\u206D\u206E\u202C\u206C\u206D\u206C\u206D\u202E\u206B\u202C\u200D\u200D\u200E\u202D\u200C\u202D\u202A\u206E\u206E\u200B\u202C\u200C\u206A\u202C\u206B\u200C\u202A\u206E\u206A\u202E<Program.Level[]>(620873299U)));

In. Net4.0, this code will not be protected, so there will be no exception

attachment: Confused.zip

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinggood first issueGood for newcomers

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions