Protection Macros

<< Click to Display Table of Contents >>

Navigation:  Themida > Protecting an application >

Protection Macros

 

ProtectionMacros_01

 

 

In the Protection Macros panel, you can see the assembly code that will be protected for each protection macro. You can also see if any ANSI or UNICODE strings are referenced inside each protection macro and decide if you want to protect those strings (see option Encrypt Strings in VM macros in the Protection Options panel)

 

You can also enable or disable specific blocks from being protected. Normally, disabling macros from being protected is only required to find a problematic block in the protected application, which makes the application behave in a different way or produce an application exception. In case that you have problems protecting a specific macro, you should check that there is not a current macro restriction.

 

Macro Restrictions

 

Switch-case statements and try-except clauses cannot work with SecureEngine macros 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. Switch-case and try-except clauses will be supported in a future version.

 

You can use a workaround to protect your switch-case statements with VM macros, like:

 

For switch-case:

 

switch (var)

{

   case 0:

 

   VM_START

 

   // your code

 

   VM_END

 

   case 1:

 

   VM_START

 

   // your code

 

   VM_END

 

   ...

}

 

For try-except:

 

try

{

   VM_START

 

   // your code

 

   VM_END

}

 

except

{

   VM_START

 

   // your code

 

   VM_END

}

 

 

Inserting Macros from a MAP file

 

To insert macros from a MAP file, just click on the Select from MAP file button. You can insert/remove macros by clicking on the name of the function.

 

ProtectionMacros_02

 

By default, the added MAP functions are handled by a "VM" macro. If you want to assign a specific virtual machine for each added MAP function, do the following steps:

 

In the Protection Macros panel, select the specific MAP function

 

Hold the [SHIFT] key and press the [LEFT_ARROW] or [RIGHT_ARROW] key to move between different machines