> 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/csharp-document/other-func/session-init-hwid.md).

# Session Init Hwid

The session initialization phase generates the hardware fingerprint (HWID), executes initial environment checks, and synchronizes product policies with the authentication server.

## Hardware Fingerprint Generation (HWID)

The native engine computes hardware identifiers by combining low-level hardware attributes:

* **Physical Drive Serial**: Direct ATA/SCSI query (`IOCTL_STORAGE_QUERY_PROPERTY`) bypassing WMI.
* **CPU Microcode & Architecture**: Extracted via `__cpuid` assembly instructions.
* **SMBIOS / Motherboard UUID**: Scanned directly from physical memory tables.
* **MAC & Network Interface**: Query of primary network adapter hardware addresses.

```csharp
// Retrieve the local machine's derived hardware ID
string localHwid = qPapelEasyAuth.qPapelEasyAuth.GetHwid();
Console.WriteLine($"[+] Computed HWID: {localHwid}");
```

## Session Initialization API

```csharp
namespace qPapelEasyAuth
{
    public static class qPapelEasyAuth
    {
        // Initializes session with server, checks product status, and downloads remote settings
        public static SessionInitResult InitSession(string apiKey);
    }
}
```

### Usage Example

{% stepper %}
{% step %}

## Establish encrypted TCP channel

```csharp
if (!qPapelEasyAuth.qPapelEasyAuth.Connect())
{
    Console.WriteLine("[-] Network failure: Server is offline.");
    return false;
}
```

{% endstep %}

{% step %}

## Transmit session initialization payload

```csharp
var session = qPapelEasyAuth.qPapelEasyAuth.InitSession(apiKey);
if (!session.Success)
{
    Console.WriteLine($"[-] Session Error: {session.Message} ({session.ErrorName})");
    return false;
}
```

{% endstep %}

{% step %}

## Inspect remote settings sent by server

```csharp
if (session.Settings != null)
{
    Console.WriteLine($"[+] Server Enforced Mode : {session.Settings.QPAnalyzerMode}");
    Console.WriteLine($"[+] AI Scanning Active   : {session.Settings.QPAnalyzerEnabled}");
}
```

{% endstep %}
{% endstepper %}

```csharp
using System;
using qPapelEasyAuth;

public class AppBootstrap
{
    public static bool InitializeSecuritySession(string apiKey)
    {
        // 1. Establish encrypted TCP channel
        if (!qPapelEasyAuth.qPapelEasyAuth.Connect())
        {
            Console.WriteLine("[-] Network failure: Server is offline.");
            return false;
        }

        // 2. Transmit session initialization payload
        var session = qPapelEasyAuth.qPapelEasyAuth.InitSession(apiKey);
        if (!session.Success)
        {
            Console.WriteLine($"[-] Session Error: {session.Message} ({session.ErrorName})");
            return false;
        }

        // 3. Inspect remote settings sent by server
        if (session.Settings != null)
        {
            Console.WriteLine($"[+] Server Enforced Mode : {session.Settings.QPAnalyzerMode}");
            Console.WriteLine($"[+] AI Scanning Active   : {session.Settings.QPAnalyzerEnabled}");
        }

        return true;
    }
}
```

## `SessionInitResult` Fields

| Property      | Type              | Description                                                                |
| ------------- | ----------------- | -------------------------------------------------------------------------- |
| `Success`     | `bool`            | `true` if session was accepted; otherwise `false`.                         |
| `ErrorName`   | `string`          | Error code identifier on failure (e.g. `PRODUCT_DISABLED`, `BANNED_HWID`). |
| `Message`     | `string`          | Text message explaining the result.                                        |
| `Settings`    | `RemoteSettings?` | Dynamic configuration flags sent by the backend for this product.          |
| `RawResponse` | `string`          | Raw JSON string payload for custom parsing.                                |

{% hint style="warning" %}
`InitSession()` must be called after `Connect()` and before invoking `Authenticate()` or any server-side asset methods.
{% endhint %}
