> For the complete documentation index, see [llms.txt](https://easyauth.papelship.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easyauth.papelship.com/documentation/best-practies/vmprotect-integration.md).

# Vmprotect Integration

EasyAuth provides native integration with commercial code virtualizers such as **VMProtect 3.x** and **Themida**.

## VMProtect Mode Configuration

Enable VMProtect checks in `easyauth::config`:

```cpp
easyauth::config cfg;
cfg.vmp_mode = true;                 // Enables VMProtect SDK integration
cfg.vmp_enforce_protected = true;    // If true, terminates immediately if binary is not virtualized
easyauth::set_config(cfg);
```

## Recommended Virtualization Macros

To maximize protection against unpackers and dumpers, wrap sensitive EasyAuth initialization and authentication routines inside VMProtect virtualization markers:

```cpp
#include "qPapelEasyAuth.h"
#include "VMProtectSDK.h"
#include <iostream>

void AuthenticateUser() {
    // 🛡️ Virtualize the authentication verification block
    VMProtectBeginUltra("EasyAuth_AuthVerification");

    std::string user_key = "EASY-USER-KEY";
    auto auth_res = easyauth::authenticate(user_key);

    if (!auth_res.success) {
        VMProtectEnd();
        exit(0);
    }

    // Decrypt sensitive game offsets inside the virtualized boundary
    std::string offset = easyauth::get_variable("dwLocalPlayer", user_key);

    VMProtectEnd();
}
```

## VMProtect Runtime Introspection

EasyAuth includes built-in functions to verify the virtualizer state:

### `easyauth::is_vmp_protected`

Checks if the current executable has been processed by VMProtect.

```cpp
bool is_vmp_protected();
```

### `easyauth::is_vmp_valid_crc`

Verifies VMProtect's internal image CRC checksum.

```cpp
bool is_vmp_valid_crc();
```

### `easyauth::is_vmp_debugger_present`

Queries VMProtect's kernel and user-mode debugger detection traps.

```cpp
bool is_vmp_debugger_present(bool check_kernel = true);
```
