version 2025: RuntimeBinderException and InvalidProgramException

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

version 2025: RuntimeBinderException and InvalidProgramException

Post by weloveayaka »

Hello Admin.


This is my mistake, [assembly: Obfuscation(Feature = "renaming", Exclude = false)] should not be used.



-----------------
Compiled exe get Exception:
(Release Configuration, Renaming is enabled.)
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: “45BF23BC.E92BD6B0” does not contain a definition for “InvokeDynamicMethod”
CallSite.Target(Closure , CallSite , Type , Object , String )
System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
---
8E39D630.62302C06()
8E39D630.C0149A0C(Object A694F621, Int32 9F348F37)
8E39D630.2D8981A5()
8E39D630.C0149A0C(Object A694F621, Int32 9F348F37)
---
8E39D630.62302C06()
8E39D630.C0149A0C(Object A694F621, Int32 9F348F37)
6DB833A2.2A373C13()

Code: Select all

    [Obfuscation(Feature = "ultra", Exclude = false)]
 public static void test()
        {
            dynamic dynamicObject = new ExpandoObject();
            dynamicObject.SayHello = new Func<string>(() => "Hello from dynamic method!");
            string result = InvokeDynamicMethod<string>(dynamicObject, "SayHello");
            Console.WriteLine(result);
	}
	
	
 [Obfuscation(Feature ="ultra",Exclude =true)]
        private static T InvokeDynamicMethod<T>(dynamic obj, string methodName)
        {
            var binder = Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(
                Microsoft.CSharp.RuntimeBinder.CSharpBinderFlags.None, methodName,
                null, obj.GetType(),
                new[] { Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create(
                Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfoFlags.None, null)
                });
            var callSite = CallSite<Func<CallSite, object, object>>.Create(binder);
            return (T)callSite.Target(callSite, obj);
        }
 
Last edited by weloveayaka on Wed Mar 27, 2024 4:00 am, edited 3 times in total.
weloveayaka
Posts: 58
Joined: Wed Jul 05, 2023 6:21 am

Re: version 2025: RuntimeBinderException and InvalidProgramException

Post by weloveayaka »

To reproduce InvalidProgramException,
use ref keyword with class

Code: Select all

[Obfuscation(Feature = "ultra", Exclude = false)]

    static void testRefOut()
    {
        
        int x = 5;
        MyClass y = new MyClass();
        int z;
        int Z = 2;

        
        A(x, ref Z, ref y, out z);

        Console.WriteLine("After calling function A:");
        Console.WriteLine($"x: {x}, y: {y._int}, z: {z}, Z:{Z}");
    }

    [Obfuscation(Feature = "ultra", Exclude = false)]

    [Serializable] class MyClass
    {
        public int _int = 1;

    }
    
    static void A(int a, ref int V, ref MyClass b, out int c)          //  <---------- This one has no Obfuscation Attribute
    {
        Console.WriteLine("Inside function A");

        
        B(ref a, ref b, out c);

        b._int += 5;
    }
    [Obfuscation(Feature = "ultra", Exclude = false)]
    static void B(ref int a, ref MyClass BB,out int b)
    {
        Console.WriteLine("Inside function B");

        
        a *= 2;

        BB._int += 1;
        
        b = 20;
    }
    
weloveayaka
Posts: 58
Joined: Wed Jul 05, 2023 6:21 am

Re: version 2025: RuntimeBinderException and InvalidProgramException

Post by weloveayaka »

Could we use Obfuscation Attribute to set function level complexity?

since [assembly: Obfuscation(Feature = "renaming", Exclude = false)] is wrong way to use
Is [assembly: Obfuscation(Feature = "virtualization", Exclude = false)] (also ultra) safe to use ? ( To make all class, function to be virtualized )
and [assembly: Obfuscation(Feature = "strings", Exclude = false)] ( make all string to be encrypted )
Post Reply