Sharing
Anti-cheat and file protection
Everything here is set in Project Settings → Security and applies to exported games. All of it is on by default.
| Setting | What it does |
|---|---|
| Encrypt game files | Scenes, scripts, models, textures, sounds and animations ship inside one game.pak, encrypted with AES-256-CTR under the key in the project's keystore and authenticated with HMAC-SHA256 (encrypt-then-MAC): a file whose bytes were changed is refused, a changed index refuses the whole pak. Older ChaCha20 paks still load. |
| Protect scripts | Lua scripts are compiled to stripped bytecode: no source, no local variable names, no line numbers. |
| Tamper check | The exporter fingerprints the executable and every engine file (shaders, textures and so on). At launch, the game checks them in the background. Needs Encrypt game files, because the fingerprints are stored inside the pak. |
| Anti-cheat | Runtime checks: speed hacks, attached debuggers, edited files and memory edits of secure values. |
| Anti-cheat service | Ember built-in, Easy Anti-Cheat (EOS) or a plug-in library such as BattlEye. The built-in checks always run as well. |
| When cheating | Tell my scripts: only anticheat.on_violation runs. Kick: a multiplayer client reports itself to the host, which removes it (offline, the game closes). Close the game: shows a message, then quits. |
| Server checks | The host rejects impossible movement and puts the player back where it last accepted them. It kicks players who keep doing it, players who flood it with messages, and players whose own anti-cheat reported them. |
| Max speed / Max messages | Limits for the server checks. |
What gets detected
- Speed hacks. Tools like Cheat Engine's speedhack hook the timers a game reads, such as QueryPerformanceCounter or clock_gettime. Ember compares the game clock with a clock those hooks can't reach:
- Windows: the kernel's
KUSER_SHARED_DATAinterrupt time, read straight from memory. - Linux and Android: a raw
clock_gettimesystem call. - macOS:
CLOCK_UPTIME_RAW.
If the two disagree by more than 15% for two 2-second windows in a row, that is a violation.
The computer sleeping or a frame hitch doesn't count.
* Debuggers:
* Windows: IsDebuggerPresent and CheckRemoteDebuggerPresent.
* Linux and Android: TracerPid.
* macOS: P_TRACED.
This check runs every 2 seconds, and only in exported games, so you can still debug from the editor. * Edited files: * Pak entries are checked against their hashes on every read. * Loose engine files and the executable are checked against fingerprints the exporter put inside the encrypted pak.
macOS skips the executable check, because code signing changes the binary after export.
* Memory editors. Values stored with anticheat.secure are kept XOR-masked with a fresh random key
after every read, plus a checksum. A memory scanner can't find "100 coins", and changing the stored
bytes is detected.
Scripting
-- any script
anticheat.on_violation(function(kind, detail) -- kind: speed | debugger | integrity | memory | provider | <yours>
print("cheat?", kind, detail)
end)
anticheat.secure("coins", 0) -- store
anticheat.add("coins", 5) -- change (returns the new value)
local c = anticheat.get("coins") -- read
anticheat.report("aimbot", "snap > 170 deg in 1 frame") -- your own checks go through the same policy
anticheat.active() -- is it on?
anticheat.violations() -- { {kind=, detail=}, ... }
-- host / server
net.on("cheat", function(player, info) print(info.kind, info.detail) end) -- speed | flood | invalid | <reported kind>
net.on("player_kicked", function(player, info) print(info.reason) end)
net.kick(player_id, "reason")
net.allow_teleport(entity) -- accept the next position of a player-owned object, however far (respawns)
net.guard_stats() -- {rejected_moves=, kicks=, reports=}
-- client
net.on("corrected", function(_, pos) end) -- the server moved us back
net.on("kicked", function(_, info) print(info.reason) end)
net.kick_reason()
The movement check applies to objects a client owns. The host moves its own objects without limits.
Falling is never limited. Horizontal and upward movement share a distance budget that refills at
125% of Max speed, which allows for network jitter. If a client really does teleport its avatar,
for example on respawn, have the host call net.allow_teleport(avatar), for instance in a
net.command handler.
Easy Anti-Cheat
- Download the EOS SDK from the Epic Developer Portal and build Ember with
-DEMBER_WITH_EOS=ON -DEOS_SDK_DIR=<sdk>. - In the portal, enable Anti-Cheat for your product and download its integrity tool and bootstrapper.
- Project Settings: * Network: set the transport to EOS and fill in the EOS ids. * Security: set Anti-cheat service to Easy Anti-Cheat.
- Export, then run Epic's
anticheat_integritytoolover the export folder. Ship it so players startstart_protected_game.exe(the EAC bootstrapper), not the game executable.
Ember runs EAC in peer-to-peer mode, which fits Ember's host model where the host is also a player: * Every player runs the protected client. * EAC's messages travel over the game connection. * A player EAC says to remove is kicked by the host.
The adapter is engine/src/AntiCheatEos.cpp. It was written against EOS SDK 1.16 and has not been
compiled or run in Ember's own testing, because the SDK needs an Epic account. Expect to adjust field
names if your SDK version differs.
BattlEye and other services (plug-ins)
BattlEye only gives its SDK to licensed studios, under NDA, so Ember can't include a BattlEye client. Instead, Ember loads a small plug-in library next to the game executable. The same route works for BattlEye, EQU8, XIGNCODE3, nProtect GameGuard, mHydra or anything in-house.
Set Anti-cheat service to BattlEye (plug-in) or Other (plug-in). The library name defaults to
ember_battleye (ember_battleye.dll, libember_battleye.so, libember_battleye.dylib).
The library exports these C functions:
// required: 0 = started, otherwise write a reason into err
int ember_ac_start(const char* game_id, char* err, int err_len);
// optional
void ember_ac_tick(void); // every frame
void ember_ac_stop(void);
int ember_ac_poll_violation(char* kind, int kind_len, // return 1 and fill in one violation,
char* detail, int detail_len); // 0 when there are none
void ember_ac_set_send(void (*send)(uint32_t peer, const uint8_t* data, uint32_t size)); // send to a peer
void ember_ac_receive(uint32_t peer, const uint8_t* data, uint32_t size); // from a peer
- Messages sent with
sendreach the other side'sember_ac_receiveover the game's own connection. The server is peer 1; clients are 2 and up. - Violations you return go through the same When cheating policy as the built-in ones.
- For BattlEye, the shim starts the BE client in
ember_ac_startand relays BE's packets throughsend/receive. BEServer runs on your host or dedicated server. tools/test_anticheat.pybuilds a tiny test plug-in this way.
Limits
Anything that runs on a player's computer can be patched by someone determined enough. * The pak key has to be inside the game for the game to read its files. * Bytecode can be decompiled into working, but unnamed, Lua. * A skilled reverser can remove the checks.
These measures stop asset rippers, trainers, speed hacks, memory scanners and casual file edits. Unity and Unreal pak encryption give the same guarantee. The server checks are the part you can rely on: whatever a client does to itself, the host still refuses impossible movement and floods. For kernel-level protection, use a service such as Easy Anti-Cheat or BattlEye.