Context
CheatEngine.Client is an in-process, dependency-injection-first layer for plugins loaded by Cheat Engine. It builds on
CheatEngine.SDK and turns its low-level host bindings into
bounded, typed, fluent C# operations for the lifetime of one plugin activation.
The aggregate ICheatEngineClient gives an enabled plugin access to runtime facts and capabilities, main-thread
dispatch, process selection, typed memory, AOB scans, inspection, address tables, and protected Lua operations. It
never exposes a LuaState, CE object handle, raw native pointer, or SDK ownership wrapper to plugin code.
Building with an SDK source checkout
Repository builds and tests use the SDK Git submodule pinned at externals/CheatEngine.SDK. Clone with
git clone --recurse-submodules, or run git submodule update --init --recursive in an existing checkout.
Keep its full history and tags for MinVer. Updating the SDK means reviewing and committing a new gitlink;
ordinary builds never follow a moving branch or download the SDK from NuGet.
A parent workspace can override the submodule by placing CheatEngine.Source.props beside the Client checkout:
<Project>
<PropertyGroup>
<CheatEngineSdkSourceRoot>$(MSBuildThisFileDirectory)CheatEngine.SDK</CheatEngineSdkSourceRoot>
<CheatEngineSourceLockFileDirectory>$(MSBuildThisFileDirectory)locks</CheatEngineSourceLockFileDirectory>
</PropertyGroup>
</Project>
The SDK root must contain its Engine and Hosting runtime projects. Source dependency locks live in eng/locks/source/
unless the parent selects another directory. Parent-workspace settings are read during both restore and build;
CheatEngineImportSourceSettings=false disables that import and selects the nested submodule instead.
Command-line properties can select an explicit SDK checkout.
Source consumers reference the Client facade project. A plugin also directly references the SDK Engine and Hosting
projects, imports the SDK and Client consumer build assets, and references their plugin generators as analyzers;
project references do not propagate NuGet build assets or analyzers. The SDK's checked-in native bridge remains part
of the plugin output. Source mode reads the consumed Engine PE metadata without executing it and requires that exact
version and commit at runtime. It does not claim a NuGet package hash or native qualification.
NuGet is reserved for production releases. Set CheatEngineSdkSourceMode=false consistently for release restore,
build, pack and package-consumer tests. CHEATENGINECLIENT9051 refuses source-mode packing or an invalid SDK source
root. Production packages retain their separate SDK NuGet dependency and require a published SDK containing every
API Client uses; a passing source build does not establish release readiness.
Why this project exists
CheatEngine.SDK deliberately owns the difficult boundary: the generated Cheat Engine entry point, Lua protection,
native bridge, host object model, and compile-time plugin/Lua diagnostics. Those are SDK concerns and
CheatEngine.Client does not reimplement them.
The Client exists for the application layer above that boundary. It makes recurring plugin concerns explicit and
testable:
| SDK boundary |
Client policy above it |
| Plugin bootstrap and protected Lua calls |
One activation-scoped ICheatEngineClient; no raw Lua lifetime escapes |
| Host-owned temporary objects and main-thread affinity |
Synchronous dispatcher boundary, copied results, and deterministic cleanup |
| Primitive Lua/host operations |
Typed memory codecs, bounded strings and pointer chains, immutable AOB builders |
| Plugin construction |
One validated DI provider per enable epoch; explicit modules and configuration |
| Host failures and capability differences |
Try... methods with CheatEngineFailure, convenience methods that throw, and runtime capability observations |
This separation lets a plugin stay ordinary, DI-friendly C# while retaining the SDK as the sole authority for ABI and
Lua safety. It also keeps the high-level surface honest: a contract is not presented as a working Cheat Engine feature
until its ownership, thread-affinity, and lifecycle path are established.
How it helps improve Cheat Engine plugin projects
The Client centralizes lifecycle, ownership, dispatch, options, and capability policy once, rather than requiring each
plugin to reproduce them around low-level SDK calls. This lowers the cost of adding a feature, gives tests a stable
contract boundary, and keeps the generated plugin template focused on application code. It also makes the supported
surface reviewable: high-level APIs remain fluent for consumers while the Core remains the only SDK mapper.
Requirements
A plugin project that consumes the packages needs:
| Plugin project requirement |
Value |
| Target framework |
net10.0 |
| Language |
C# 14 (<LangVersion>14.0</LangVersion>) |
| .NET SDK |
10.0.402 or later: the Lua generator packed in Hosting is compiled against Roslyn 5.9.0; an older compiler does not run it and reports only warning CS9057 |
| Platform |
Windows x64; PlatformTarget is x64 or AnyCPU |
| Cheat Engine host |
7.7.0.10621 x64 (cheatengine-x86_64.exe), loading the plugin through its managed .NET host |
| Plugin form |
Framework-dependent managed plugin output folder, never a Native AOT DLL |
CheatEngine.SDK |
A direct PackageReference in [2.0.0, 3.0.0): a 3.x SDK fails the build with CECLIENT017, a version below 2.0.0 fails the restore with NU1605 |
Building this repository needs:
| Repository build requirement |
Value |
| Operating system |
Windows x64 |
| .NET SDK |
10.0.403 exactly (global.json rollForward: disable); install it with winget install Microsoft.DotNet.SDK.10 --version 10.0.403 |
CheatEngine.SDK |
The Git commit pinned by externals/CheatEngine.SDK; production packages separately retain the reviewed 2.0.0 NuGet pin until the release dependency is updated |
| Tools |
PowerShell 7.4 or later and Git, to run the CI checks locally (CONTRIBUTING) |
| Cheat Engine |
Only for the opt-in live qualification tests, never for an ordinary build or test run |
Cheat Engine remains the compatibility authority. The Client is not an IPC client, a remote-process service, or a
standalone executable; it runs only in process inside an enabled Cheat Engine plugin. It is neither Cheat Engine's
luaclient library nor an RPC client of ceserver.
Quick start
The maintained starting point is the ceplugin template. It is both a usable project and the repository's executable
example of the required plugin shape.
dotnet new install CheatEngine.Client.Templates
dotnet new ceplugin --name MyPlugin
cd MyPlugin
dotnet build --configuration Release
The generated project intentionally retains these direct dependencies:
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<LangVersion>14.0</LangVersion>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PlatformTarget>x64</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CheatEngineClientPluginProject>true</CheatEngineClientPluginProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CheatEngine.Client" Version="X.Y.Z" />
<PackageReference Include="CheatEngine.SDK" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="10.0.12" />
</ItemGroup>
Replace X.Y.Z with the CheatEngine.Client version you install; the ceplugin template writes it for you. Keep
CheatEngine.SDK on 2.x: this Client release is built and tested against CheatEngine.SDK 2.0.0 and declares
[2.0.0, 3.0.0). A 3.x SDK fails the build with CECLIENT017, and a version below 2.0.0 fails the restore with
NU1605. Do not upgrade to 3.x until a Client release says so.
CheatEngine.SDK must be referenced directly by the plugin project. Its build assets generate the Cheat Engine
entry point and provide the native Lua bridge; NuGet transitivity is not sufficient at that host boundary. Setting
CheatEngineClientPluginProject opts the project into the Hosting package's plugin profile checks, which fail the
build if the direct SDK reference is removed (CECLIENT001); the
Hosting README lists every CECLIENT build
diagnostic.
Start with the template rather than copying this fragment into an existing plugin: it also demonstrates module
registration, generated Lua exports, validated options, bounded AOB and typed-memory access, and an Address List
snapshot. See the template guide and the generated
plugin README.
Minimal plugin shape
The SDK still owns the plugin annotation. The Client base owns the activation-scoped composition, and an activation
module receives the scoped client in OnEnabled and OnDisabling. Fluent calls remain bounded and handle-free:
using CheatEngine.Client;
using CheatEngine.Client.Hosting;
using CheatEngine.Client.Memory;
using CheatEngine.Client.Modules;
using CheatEngine.Client.Results;
using CheatEngine.Client.Scanning;
using CheatEngine.SDK.Annotations.Plugin;
using CheatEngine.SDK.Engine.Values;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
namespace MyPlugin;
[CheatEnginePlugin("My Plugin")]
public sealed class Plugin : CheatEngineClientPlugin
{
protected override void Configure(CheatEnginePluginBuilder builder)
{
builder.Configuration
.SetBasePath(builder.PluginDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
builder.Client.AddModule<ScoreModule>();
}
}
public sealed class ScoreModule(ILogger<ScoreModule> logger) : ICheatEngineClientModule
{
public void OnEnabled(ICheatEngineClient client)
{
// A Try form returns an expected failure, such as no selected process, instead of throwing it.
if (!client.Patterns.Aob("48 8B ?? ?? ?? 89")
.InModule("game.exe")
.Executable()
.RequireSingle()
.TryExecute(out Address address, out CheatEngineFailure failure))
{
logger.LogDebug("Score probe skipped: {Failure}", failure);
return;
}
client.Memory.At(address + 0x14).Write(999);
}
public void OnDisabling(ICheatEngineClient client)
{
}
}
InModule(...) and InRange(...) scope the scan with one rule on every route (a match lies entirely inside the module
and starts inside the range): on a qualified local target Cheat Engine scans only the module intersected with the range
(an exhaustive MemScan that blocks its main thread and cannot be interrupted once started); on a CEServer or
file-as-process target it runs one global AOBScan and Core applies the same rule while copying. Take(n),
FirstOrNone() and RequireSingle() bound only how many addresses Core copies; they never stop Cheat Engine early, and
FirstOrNone() follows Cheat Engine's unspecified result-list order. null and NotFound mean that the scan succeeded
without a match inside the request: a factual zero of the bounded route, or a global result list without any address
inside the module or range. A global scan for which Cheat Engine returns no result list is reported as
IndeterminateHostResult (that route cannot tell zero matches from a host failure), never as null or NotFound.
Use the Try... terminal operations when absence of a process, scan result, or runtime capability is an expected
condition. Do not make a worker wait for the Cheat Engine thread if that worker can call back into the Client.
The plugin lifecycle
The parameterless plugin instance is created by the SDK, but every enable creates new managed state:
OnEnable
-> Configure a new builder (explicit configuration, services, modules, codecs)
-> Build and validate a new provider and scope
-> Resolve options and ICheatEngineClient
-> Enable modules in registration order
-> OnClientEnabled
OnDisable
-> Stop admitting the active client
-> OnClientDisabling
-> Disable modules in reverse order
-> Drain Client-owned CE resources while the SDK context is valid
-> Dispose scope, provider, and configuration
ICheatEngineClient.Epoch and ICheatEngineClient.Stopping identify that activation. Never retain the client, a
resource lease, a Lua reference, a cancellation token, or a target-bound value across disable/re-enable. Constructors,
field initializers, and static initialization must not call Cheat Engine; the SDK binding is valid only after enable.