Does a VM macro also virtualize functions called from inside it?¶
No. It virtualizes the call to Function2(), including parameter passing, but not the code inside Function2():
void MyMainFunction()
{
VIRTUALIZER_START
// some code
Function2(1, 2, 3)
// some code
VIRTUALIZER_END
}
To virtualize the code inside Function2(), place another macro inside that function:
If both functions are protected, they remain separate virtualized regions. The call instruction in MyMainFunction() is virtualized, but execution still passes through the callable entry point of Function2(), which redirects into its own virtualized code. When Function2() returns, execution resumes in the virtualized flow of MyMainFunction().
Using the same Virtual Machine type for both regions does not turn the call into one continuous VM-to-VM flow. If you must eliminate the intermediate callable entry point, keep Function2() inline. Code Virtualizer users can also protect complete out-of-line functions with the Protect Function macro; the same separate-region behavior applies.
If the compiler inlines Function2(), the macro in MyMainFunction() already covers its inlined code, so no separate macro is required.