Can Themida macros protect switch statements and try-except clauses?

<< Click to Display Table of Contents >>

Navigation:  Themida > FAQ > Macros >

Can Themida macros protect switch statements and try-except clauses?

Switch-Case statements and try-except clauses cannot work with Themida 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 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

 

}