> 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/setup-project/qpapelpacker.md).

# qPapelPacker

`qPapelPacker` is an automated post-compilation binary injection tool. It embeds the native `qPapelEasyAuth.dll` security engine directly into the target `.NET` assembly as an encrypted in-memory section without saving raw native DLL files to disk.

***

## Why Packaging Is Required

.NET applications compiled with the C# SDK communicate with the native security engine through standard P/Invoke signatures. Rather than requiring you to ship a vulnerable standalone `qPapelEasyAuth.dll` alongside your executable, `qPapelPacker` injects the native core directly into the binary:

* **Zero Disk Footprint**: The native core is decrypted and mapped directly into private virtual memory (`VirtualAlloc` / `NtAllocateVirtualMemory`) during process startup.
* **PE Header Hardening**: Modifies Section Headers, aligns relocation tables, and hides the reflective loader entry point.
* **Direct Import Resolution**: Hooks standard export pointers in memory so managed C# P/Invoke calls resolve automatically without modifying the system `PATH`.

***

## Command-Line Usage

```powershell
qPapelPacker.exe --dll <PathToNativeDll> --input <PathToCompiledExe> --output <PathToPackedExe>
```

### Parameters

| Argument   | Required | Description                                                                           |
| ---------- | -------- | ------------------------------------------------------------------------------------- |
| `--dll`    | Yes      | Path to the obfuscated `qPapelEasyAuth.dll` native core library.                      |
| `--input`  | Yes      | Path to your compiled managed executable (e.g. `bin/x64/Release/net8.0/YourApp.exe`). |
| `--output` | Yes      | Target path where the final packed binary will be generated.                          |

***

## Automated Post-Build Integration

You can automate the packaging step directly inside your `.csproj` file using an MSBuild target:

```xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Platforms>x64</Platforms>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>

  <!-- Automated qPapelPacker Post-Build Event -->
  <Target Name="PackWithEasyAuth" AfterTargets="Build" Condition="'$(Configuration)' == 'Release'">
    <Message Importance="High" Text="Injecting qPapel EasyAuth native core into output executable..." />
    <Exec Command="$(ProjectDir)qPapelTools\qPapelPacker.exe --dll $(ProjectDir)qPapelTools\qPapelEasyAuth.dll --input $(TargetPath) --output $(TargetDir)$(TargetName)_packed.exe" />
  </Target>
</Project>
```

{% hint style="warning" %}
Do not sign or obfuscate the managed executable before running `qPapelPacker`. Run tools such as Obfuscar or ConfuserEx on your managed assembly first, and run `qPapelPacker` as the final build step.
{% endhint %}
