BadImageException when override generic type

Issues related to VMProtect
Post Reply
weloveayaka
Posts: 58
Joined: Wed Jul 05, 2023 6:21 am

BadImageException when override generic type

Post by weloveayaka »

Hello Admin,
I'm sorry to bother you again, but we have encountered a new issue.
If you have fixed these issues, please send a new build to me and my company. We have both purchased licenses.
Especially the previous "catch" issue has been very troublesome for us.

Thank you, I'm extremely grateful!

Minimal Code:

Code: Select all


    internal class Program
    {
        static void Main(string[] args)
        {
            var a = new Sub<string, int>();
            a.A();
            Console.Read();
        }   
    }

    class GenericType<I, M>
    {
        [Obfuscation(Feature ="virtualization",Exclude = false)]
        public virtual void A()
        {
            var a = new Dictionary<I, M>();
            Console.WriteLine("OK");
        }
        
    }
    class Sub<I,M> : GenericType<I, M>
    {

        public override void A()
        {
            base.A();
        }
    }

Before:
"OK"

After:
BadImageException
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: BadImageException when override generic type

Post by Admin »

Method with generic parameters can't be virtualized.
weloveayaka
Posts: 58
Joined: Wed Jul 05, 2023 6:21 am

Re: BadImageException when override generic type

Post by weloveayaka »

hello Admin, It's not method with generic parameters, but class with generic parameters.

( A() not A<T>())

Is this unsupported too?
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: BadImageException when override generic type

Post by Admin »

instance void catch.GenericType`2<0, 1>::A() ("!0" and "!1" are generic parameters):

Code: Select all

.maxstack 8
newobj 0A000016 → instance void class [mscorlib]System.Collections.Generic.Dictionary`2<!0, !1>::.ctor() // <- here
pop
ldstr 70000001 → "OK"
call 0A000017 → void [mscorlib]System.Console::WriteLine(string)
ret
weloveayaka
Posts: 58
Joined: Wed Jul 05, 2023 6:21 am

Re: BadImageException when override generic type

Post by weloveayaka »

ah. Thank you. so we can't call method /class with current unsure generic parameters like !0 !1

this may including static method inside generic type or something.

I see.
weloveayaka
Posts: 58
Joined: Wed Jul 05, 2023 6:21 am

Re: BadImageException when override generic type

Post by weloveayaka »

TargetException when use Nullable Operator

I'm not sure wheather it is the "method with generic parameter" issue
but Nullable Operator is unusable

Code: Select all

 static void Main(string[] args)
        {
            A();
            Console.Read();
        }

        static void A()   <---- virtualized
        {
            int? a = null;
            Console.WriteLine(a?.ToString());   <---- 004020BB 28 1100000A	call 0A000011 → instance !0 valuetype [mscorlib]System.Nullable`1<int32>::GetValueOrDefault()

        }
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: BadImageException when override generic type

Post by Admin »

weloveayaka wrote: Wed Nov 29, 2023 3:42 pm TargetException when use Nullable Operator
Fixed in the 1911 build.
Post Reply