Home
Can Themida/WinLicense macros protect switch statements and try-except clauses?
Reference Number: AA-00272 Views: 2357

Switch-Case statements and try-except clauses cannot work with Themida/WinLicense macros in most compilers.

Compilers generate a direct jump table in the data section which directly jumps to each "case" statement. When the code is virtualized, the jump goes into a virtualized (garbage) code and it produces exception. You can use a workaround to protect your switch-case statements with Themida/WinLicense macros, like:

switch (var) 
{

    case 0:

    VM_START

    // your code 

    VM_END

    case 1: 

    VM_START

    // your code 

    VM_END

    ...

} 


For try-except clauses: 

try 
{
    VM_START

     // your code 

     VM_END 

}

except
  
{

     VM_START

     // your code 

     VM_END 

}


Quick Jump Menu