VM complexity scripting function

Issues related to VMProtect
Post Reply
lach
Posts: 33
Joined: Sat Mar 23, 2019 1:18 pm

VM complexity scripting function

Post by lach »

It is possible to set virtualization complexity on per-function basis using GUI, but there is no method to control that in LUA class IntelFunction
Admin
Site Admin
Posts: 2733
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: VM complexity scripting function

Post by Admin »

Added in the 2377 build.
lach
Posts: 33
Joined: Sat Mar 23, 2019 1:18 pm

Re: VM complexity scripting function

Post by lach »

IntelFunction:setComplexity, I see, thanks!
vmenter
Posts: 2
Joined: Mon Sep 08, 2025 2:21 pm

Re: VM complexity scripting function

Post by vmenter »

Hey, I just discovered this function, so far it wasn't documented.
I went ahead and tried it, it seems to set a numeric value to the lua bound function variable, but the value has absolutely no impact on the actual complexity. Regardless of what I set the value to, the function runs at the same speed, 1 or 100 doesn't matter.
Doing so in the UI has a drastic affect on the speed so that seems to work (Using 3.9.6).
In case Im using it wrong, heres the 3 lines:

Code: Select all

local Func = File:functions():addByAddress(MapFunc:address(), CompilationType.Virtualization)
assert(Func)
Func:setComplexity(1)
Last edited by vmenter on Mon Sep 08, 2025 2:36 pm, edited 2 times in total.
Admin
Site Admin
Posts: 2733
Joined: Mon Aug 21, 2006 8:19 pm
Location: Russia, E-burg
Contact:

Re: VM complexity scripting function

Post by Admin »

The Complexity only affects the size of virtualized code and doesn't affect its speed.
vmenter
Posts: 2
Joined: Mon Sep 08, 2025 2:21 pm

Re: VM complexity scripting function

Post by vmenter »

Admin wrote: Thu Sep 11, 2025 4:06 am The Complexity only affects the size of virtualized code and doesn't affect its speed.
Thanks for your answer!
After some debugging I figured out that you are right, the reason the VM is so much slower is that the Import Protection feature is enabled.
Apparently, that makes the vmenter/exit much much slower which leads to bad performance in my code as the function is called VERY frequently but doesn't have much code to execute.
Do you think it would be possible to add an option to generate a different VM for certain functions that doesn't bother with import protection?
The current workaround is to simply apply VMP twice in a row which doesn't feel very robust...
Post Reply