Skip to content

Inserting Protection Macros in Visual Basic Native

To protect sensitive code in a Visual Basic application, compile it in native mode. Visual Basic then generates x86 code that Code Virtualizer can process.

Visual Basic cannot use inline assembly or directly call functions from an external library for these markers. Instead, insert a special Visual Basic instruction that Code Virtualizer detects during protection.

The following code marks an area for protection:

Visual Basic Example

Call VarPtr("VIRTUALIZER_START")

// your code goes here

Call VarPtr("VIRTUALIZER_END")

The macro name must be uppercase so Code Virtualizer can recognize it.

Example of real code in a Visual Basic application

The following example shows how to use Code Virtualizer in a Visual Basic application.

Visual Basic Example

Private Sub CheckStatusButton_Click()
  If AppStatus <> 1 Then

      Call VarPtr("VIRTUALIZER_START")

       TrialDaysLeftLabel.Caption = WLTrialDaysLeft
       TrialExecLeftLabel.Caption = WLTrialExecutionsLeft
       MinutesLabel.Caption = WLTrialGlobalTimeLeft
       RuntimeLabel.Caption = WLTrialRuntimeLeft

      Call VarPtr("VIRTUALIZER_END")

   Else

      Call VarPtr("VIRTUALIZER_START")

       WLRegGetLicenseInfo RegName, RegCompany, RegCustom

       NameEdit.Text = RegName
       CompanyEdit.Text = RegCompany
       CustomEdit.Text = RegCustom
       RegDaysLeftLabel.Caption = WLRegDaysLeft
       RegExecLeftLabel.Caption = WLRegExecutionsLeft

      Call VarPtr("VIRTUALIZER_END")

   End If

End Sub