<< Click to Display Table of Contents >> Navigation: Code Virtualizer > Inserting Protection Macros > Inserting Protection Macros in Visual Basic Native |
If you want to protect sensible code areas in your Visual Basic applications using Code Virtualizer, you have to compile your applications in native mode. When the application is compiled in native mode, Visual Basic will generate x86 code that can be manipulated by Code Virtualizer.
Due to the nature of Visual Basic, we cannot insert inline assembly or directly call functions from an external library; we have to provide a different way to insert sensitive code areas in Visual Basic applications. The way to insert areas of code to protect is by inserting a special Visual Basic instruction that will be detected by Code Virtualizer during the protection phase.
The following code snippet will insert an area to protect by Code Virtualizer:
Call VarPtr("VIRTUALIZER_START")
// your code goes here
Call VarPtr("VIRTUALIZER_END") |
Note that the name of the macro must go in uppercase in order to be recognized by Code Virtualizer.
Example of real code in a Visual Basic application
In the following, we present a real example of how to use Code Virtualizer in your Visual Basic application.
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 |