Skip to content

How can I reduce the performance impact of VM macros?

A VM or CodeReplace macro converts native code into complex virtual instructions. The protected application executes these instructions through an embedded virtual machine, so virtualized code is slower than the original native code.

Avoid placing these macros around:

  1. Functions called many times per second.

  2. Tight for, while, or do-while loops.

  3. Performance-critical code.

If a function contains a tight loop, keep the loop outside the protected regions:

void MyFunction( )
{
    VIRTUALIZER_START

    // your code goes here

    VIRTUALIZER_END

    for(i = 0; i < 0x100000; i++)
    {
        // your code
    }

    VIRTUALIZER_START

    // your code goes here

    VIRTUALIZER_END
}