v3.8.6 .NET6 problems

Issues related to VMProtect
Post Reply
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

v3.8.6 .NET6 problems

Post by AusterX »

Hello,
v3.8.5 worked flawless so far, i upgraded to 3.8.6 (build 192x something, the one released 20december), protected the same application using the verysame vmpprojectfile.vmp, and i get:
- 2minutes of cpu 60% usage before application start
- crashes like this:

Code: Select all

<<20231230 004353.440>> Severe Application Thread Error: 
<<20231230 004353.442>> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ArgumentException: Token 0xd24f5c0c is not a valid MethodBase token in the scope of module MyApp.dll. (Parameter 'metadataToken')
   at System.Reflection.RuntimeModule.ResolveMethod(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at 441C87B5.113DC937(Object[] 549AECAF, Int32 0D0B063B)
   at E4A09B26.F52C5531()
   at E4A09B26..ctor()
   --- End of inner exception stack trace ---
   at 441C87B5.013CF107()
   at 441C87B5.113DC937(Object[] 549AECAF, Int32 0D0B063B)
   at 8005A382.03B0F528()
   at 8005A382.7B2B2D9F()
   at 5E0E98BB.28ADB4B4(ABBE1B94 82AF1936)
   at C11EE58F.43B0A32C(Object BD0C650B, EventArgs 34BD98BD)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
  

Code: Select all

<<20231230 004506.138>> Severe Application Thread Error: 
<<20231230 004506.141>> System.ArgumentException: Token 0xd24f5c0c is not a valid MethodBase token in the scope of module MyApp.dll. (Parameter 'metadataToken')
   at System.Reflection.RuntimeModule.ResolveMethod(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at 441C87B5.113DC937(Object[] 549AECAF, Int32 0D0B063B)
   at E4A09B26.F52C5531()
   at E4A09B26..ctor()
Don't know how to help you to help me, without giving you the application, so i throw here some random infos:
- vmpproject is a pretty empty project, just the default vm with default complexity=20. All the protection stuff done in src code with obfuscation attributes. 9 net dll embedded into vmprotected file (dll box, renamed also)
- [assembly: Obfuscation(Feature = "strings", Exclude = false)] // all string encrypted (is this attribute still valid nowaday?)
- [assembly: Obfuscation(Feature = "mutation", Exclude = false)] // mutation enable by default to all
- main form, before calling initializecomponents, it runs a task to dislay splashscreen which shows only after 2minutes of 60% cpu
- after app started, the vmp license is loaded/checked later, and this takes a bit longer than before (ultralockbykey functions called also)
- then the thread errors comes later when some task are run, they execute also ultralockbykey function, but i've not investigated deeply.

Thanks for any hint or suggestion
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: v3.8.6 .NET6 problems

Post by Admin »

Please try the 1935 build.
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

Re: v3.8.6 .NET6 problems

Post by AusterX »

Hello,
tried 1935:
- VMP gui compiler sometimes gets stuck at 99-100% compiling (moreless stuck 20seconds, sometimes more and i killed it)
- overall my application (at least the only thing i can do without incurring in this crash) is much more slower (maybe 3x) than 3.8.5
- the second error i posted before does not happen anymore
- the first error changed and i disabled strip debug info to see something more

Code: Select all

Severe Application Thread Error: 
System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at 4000A835.23913C86() // should be a call to mydevice.isconnected()
   at 4000A835.6828C72A(Object[] F2317623, Int32 C00D289A)// call to OnTimedEvent(null, null) which is virtualized
   at MyStuff.otherstuff.MycustomControl.Open(myparamsstruct_s myparams)
   at MyApp.Form1.buttonOpen_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)
about mydevice.isconnected()
mydevice is an instance of USBdevice, which is an implementation of a generic abstract class Idevice, i create mydevice like this:

Code: Select all

mydevice = devivestuff.get_device_handler(wantedhwdev);

 public static Idevice? get_device_handler(hwdev_s hwdev)
 {
     if(hwdev.type== hw_type.USB)
     {
         return new USBdevice(hwdev); // <<<--- not sure, gets destroyed after return?!?! problem is here?
     }
     return null;
 }
Thanks again
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: v3.8.6 .NET6 problems

Post by Admin »

Could you provide us very simple example (original EXE+VMP files) that shows your problem?
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

Re: v3.8.6 .NET6 problems

Post by AusterX »

Unfortunally it's not easy for me to strip out things from my app to leave only the problematic part, it's less effort for me to try to find out which is the exact problematic point, then redo in a separate dummy exe.
Since the exception error tells about "Operation is not valid due to the current state of the object", my first thought was about that static method that returns a "new" instance of a class, maybe the "current state of the object" refers to this created instance.
Afaik it's legit to return a new instance of whatever object, garbage collector will be triggered only when that obj gets disposed, so my suspect went about VMP maybe destroying it.
I'll make some test next days, in meantime i'll stay with 3.8.5 also for the less slowdown on virtualized functions.
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: v3.8.6 .NET6 problems

Post by Admin »

Please try the 1977 build.
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

Re: v3.8.6 .NET6 problems

Post by AusterX »

Hello,
build 1977 gives same error, furthermore it took 2minutes to compile instead of few seconds (3.8.5), for the same 800KB NET6 dll (+9 dll into dllbox)
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: v3.8.6 .NET6 problems

Post by Admin »

Just change Options-Virtual Machine-Version to “Compact” and it will work like 3.8.5, but will not use the new “Complexity” feature.
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

Re: v3.8.6 .NET6 problems

Post by AusterX »

VM compact (VMVersion="1") compiles fast as before, but then:
- it takes 2minutes to start the application
- application makes same crash

but at least now i've spot the point, it's about a private volatile bool variable of a class, once accessed from a class function (VMP virtualized) it throws such error. Without the volatille keyword it works.

I'll digg a bit more about the slow startup and i'll let you know
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

Re: v3.8.6 .NET6 problems

Post by AusterX »

I've sent you by mail and example for the volatile bool issue
Admin
Site Admin
Posts: 2586
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: v3.8.6 .NET6 problems

Post by Admin »

Fixed in the 1988 build.
AusterX
Posts: 19
Joined: Sun Mar 05, 2023 9:29 am

Re: v3.8.6 .NET6 problems

Post by AusterX »

thank you, now it works good, also the startup time is back to normal (i was using volatile structs on the splashscreen task).

BTW, is there a way to set VM complexity somehow within the Obfuscation attribute, to set different % for each virtualized function directly in code? I see it can be specified in the .vmp xml file created by GUI, but I only use the obfuscation attribute.
Post Reply