SDKs
...
Tutorials
Best Practices

Virtual Machine Detection

12min

Node-locking's essence lies in associating a distinct, often hardware-based, identifier with each device. This unique marker, frequently derived from hardware IDs, serves to correlate licenses to devices. However, complexities arise in virtualized and containerized setups.

In these scenarios, the apparent hardware isn't the physical device's, but that of the generating virtual machine.

Fortunately, LicenseSpring tackles this challenge adeptly through methods tailored for containers and virtualization. These methods effectively discern various virtual contexts, ensuring precise environment identification and steadfast license-to-device locking.

This tutorial will introduce you to LicenseSpring's sophisticated techniques for distinguishing virtual machine instances and how they can reinforce your software security.

Prerequisites

  1. Completed the Getting Started Tutorial, specifically:
    • Initialized LicenseManager (or LicenseHandler) with your configuration using the appropriate settings.
    • Created a LicenseID using either LicenseID::fromKey or LicenseID::fromUser function, depending on the activation method you prefer.
    • Implemented basic license management, including license activations, deactivations, and both online and local license checks.

Working With Virtual Machines

The LicenseSpring SDKs offer a distinctive feature: the capability to detect virtual machine environments.

Supported VMs

VM name

Java

C++SDK

.Net SDK

Parallels Desktop







QEMU







VirtualBox







Windows Virtual PC







VMware







Wine







Xen Project







Docker







Microsoft Hyper-V







Microsoft Azure







bhyve







FreeBSD Jail







KVM







LXC







Lguest







Linux-VServer







OpenVZ







Project ACRN







Virtual Iron







QNX Hypervisor







Enabling Virtual Machine Detection

This functionality, designed to enhance software security, can be activated manually within your program through the SDK as shown below.

C++
C#


Note: Virtual machine detection is disabled by default. This feature must be enabled to make use of any features mentioned throughout this tutorial.

We provide a separate DLL for VM detection in the C++ SDK package. Make sure you put this library with the LicenseSpring DLL. If it is not found, a VMDNotAvailableException will occur.

Detecting Whether Virtual Machine Detection is Enabled

After the configuration has been initialized, developers are able to detect whether virtual machine detection is currently activated with:

C++
C#


Within the C++ SDK, this can also be checked through the ExtendedOptions object, as shown below:

C++


Detecting Whether a User is on a Virtual Machine

The SDKs can also check for whether a specific user currently using the application is on a virtual machine by using:

C++
C#


Retrieving Detected Virtual Machine Name

Developers can get the name of the user's hypervisor with the following:

C++
C#


VMDNotAvailableException (Windows only): Thrown in the C++ and .NET SDK in the case that VM detection dll is not found, tempered or detection failed.

Preventing Virtual Machine Access

You can also prevent users from activating their licenses on virtual machines by adjusting the license settings. Simply access the license and select the "prevent virtual machine" option. This straightforward step ensures that your product remains exclusively operational on the intended devices, aligning with your software's specifications.

Prevent Virtual Machine
Prevent Virtual Machine


When this feature is checked off, any actions involving our license, will result in an error/exception, making the license unusable on a VM.

Within the SDK, developers can check for whether a license is allowed to work under virtual machine or not with:

C++


VMIsNotAllowedException: Thrown on virtual machine when VM detection is enabled but product policy prohibits running on VM.



Updated 03 Nov 2023
Doc contributor
Did this page help you?