> 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/overview/configuration-lifecycle.md).

# Configuration Lifecycle

This page documents the initialization, configuration structures, and protection flags that govern the EasyAuth runtime environment.

## Configuration Structure (`easyauth::config`)

Before calling `initialize()`, customize the SDK behavior using the `easyauth::config` structure.

```cpp
struct config {
    uint32_t flags = flag_all;              // Active protection flags bitmask
    uint32_t honeypot_delay_ms = 5000;       // Delay in milliseconds before triggering honeypot ban
    bool vmp_mode = false;                   // Enable VMProtect SDK marker checks
    bool vmp_enforce_protected = false;      // Terminate if VMProtect virtualization is missing
    std::string default_api_key = "";        // Default Product API key fallback
    std::string client_version = "2.0.0";    // Client build version for update policies
    uint32_t watchdog_interval_ms = 500;     // Background threat monitoring tick interval
};
```

## Protection Flags (`easyauth::protection_flags`)

Protection flags allow granular control over individual security modules:

| Flag Name                | Hex Value | Description                                                                                |
| ------------------------ | :-------: | ------------------------------------------------------------------------------------------ |
| `flag_none`              |  `0x0000` | No protection modules enabled.                                                             |
| `flag_crc32`             |  `0x0001` | Validates `.text` section integrity against memory patches.                                |
| `flag_injection_monitor` |  `0x0002` | Detects unauthorized DLLs and remote thread injections.                                    |
| `flag_network_hooks`     |  `0x0004` | Scans for inline hooks on Winsock and HTTP APIs (e.g. Fiddler, HTTP Debugger).             |
| `flag_loader_hooks`      |  `0x0008` | Scans Windows loader and `LdrLoadDll` hooks.                                               |
| `flag_manual_map`        |  `0x0010` | Hardens memory against unauthorized manual mapping attempts.                               |
| `flag_antidebug`         |  `0x0020` | Active user-mode & kernel-mode debugger checks (PEB, Hardware Breakpoints, Thread Hiding). |
| `flag_vmp_checks`        |  `0x0040` | Checks VMProtect SDK integrity and virtualization state.                                   |
| `flag_honeypot`          |  `0x0080` | Arms decoy memory regions that silently ban attackers upon write/read.                     |
| `flag_all`               |  `0x00FF` | **(Recommended)** Enables all security modules simultaneously.                             |

## Core Lifecycle Functions

### `easyauth::set_config`

Applies a configuration structure to the SDK.

```cpp
void set_config(const config& cfg);
```

#### Parameters

* `cfg`: An initialized `easyauth::config` instance.

### `easyauth::get_config`

Retrieves the currently active configuration.

```cpp
config get_config();
```

### `easyauth::initialize`

Initializes internal cryptographic pipelines, registers background monitoring hooks, and prepares function remapping tables.

```cpp
void initialize();
```

{% hint style="danger" %}
**Execution Order**: Always call `set_config()` and `register_protected_function()` **before** `initialize()`.
{% endhint %}

### `easyauth::enable_protection_flag` / `disable_protection_flag`

Dynamically toggle individual security flags at runtime without reinitializing the entire SDK.

```cpp
void enable_protection_flag(protection_flags flag);
void disable_protection_flag(protection_flags flag);
bool is_protection_enabled(protection_flags flag);
```

#### Example

```cpp
// Disable CRC32 check temporarily
easyauth::disable_protection_flag(easyauth::flag_crc32);

// Check if antidebug is active
if (easyauth::is_protection_enabled(easyauth::flag_antidebug)) {
    std::cout << "[+] Anti-debug module active.\n";
}
```
