Native escape hatch¶
Section notes in abi.h
Native escape hatch (native_*); its section near the top of this file is the
contract. Filled on every host. While config.json leaves native_detour off, each slot but native_enabled answers PIER_NATIVE_DISABLED. Call them on the thread the host calls the mod on: the server thread, or the client thread on a client host. Every out is set to NULL or 0 first and written on PIER_NATIVE_OK only.
Slots¶
native_enabled¶
| C | |
|---|---|
Whether native_detour is on, so the other native_* slots can answer. Logs nothing.
- Call:
api->native_enabled() - Return type:
bool - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 206, counting from 0
- Callers in each binding:
- Rust:
native::enabled,native::enabled - Go:
Raw.NativeEnabled - Zig:
native.enabled
- Rust:
native_resolve_symbol¶
| C | |
|---|---|
The address of an engine function by its decorated symbol name, through the host's own resolution, ll::memory::SymbolView::resolve.
- Call:
api->native_resolve_symbol(mod, symbol, out) - Parameters:
- mod :
PierModHandle - symbol :
PierStr - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 207, counting from 0
- Callers in each binding:
- Rust:
native::resolve_symbol - Go:
Raw.NativeResolveSymbol - Zig:
native.resolveSymbol
- Rust:
native_resolve_signature¶
| C | |
|---|---|
The first match of a byte pattern in the engine executable. pattern is tokens separated by spaces, each two hexadecimal digits or a wildcard written "?" or "??", such as "48 8B ?? 08". A token of any other shape refuses the call; it is never read as a byte.
- Call:
api->native_resolve_signature(mod, pattern, out) - Parameters:
- mod :
PierModHandle - pattern :
PierStr - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 208, counting from 0
- Callers in each binding:
native_module_export¶
An export of a module already loaded into the process, through GetModuleHandle and GetProcAddress. An empty module names the engine executable. LeviLamina's own API is reached this way, as an export of LeviLamina.dll under its decorated name. The host never loads a module for this call.
- Call:
api->native_module_export(mod, module, name, out) - Parameters:
- mod :
PierModHandle - module :
PierStr - name :
PierStr - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 209, counting from 0
- Callers in each binding:
- Rust:
native::module_export - Go:
Raw.NativeModuleExport - Zig:
native.moduleExport
- Rust:
native_object¶
| C | |
|---|---|
The address of one engine service object, kind a PIER_NATIVE_OBJ_* value. PIER_NATIVE_NOT_FOUND while the object does not exist, as the level before a world loads, and for a client-only kind on a server host.
- Call:
api->native_object(mod, kind, out) - Parameters:
- mod :
PierModHandle - kind :
int32_t - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 210, counting from 0
- Callers in each binding:
- Rust:
native::object - Go:
Raw.NativeObject - Zig:
native.object
- Rust:
native_player¶
| C | |
|---|---|
The Player object of an online player, resolved like every other selector.
- Call:
api->native_player(mod, sel, out) - Parameters:
- mod :
PierModHandle - sel :
PierPlayerSel - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 211, counting from 0
- Callers in each binding:
- Rust:
native::player - Go:
Raw.NativePlayer - Zig:
native.player
- Rust:
native_actor¶
| C | |
|---|---|
The Actor object of a loaded actor.
- Call:
api->native_actor(mod, id, out) - Parameters:
- mod :
PierModHandle - id :
PierActorId - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 212, counting from 0
- Callers in each binding:
- Rust:
native::actor - Go:
Raw.NativeActor - Zig:
native.actor
- Rust:
native_dimension¶
| C | |
|---|---|
The Dimension object of a dimension id, custom dimensions included. A custom dimension the engine has not built yet is built by this call, the same as a block write into it would build it.
- Call:
api->native_dimension(mod, dim, out) - Parameters:
- mod :
PierModHandle - dim :
int32_t - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 213, counting from 0
- Callers in each binding:
- Rust:
native::dimension - Go:
Raw.NativeDimension - Zig:
native.dimension
- Rust:
native_block_source¶
| C | |
|---|---|
The BlockSource of a dimension id, under the same rule as native_dimension.
- Call:
api->native_block_source(mod, dim, out) - Parameters:
- mod :
PierModHandle - dim :
int32_t - out :
void**
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 214, counting from 0
- Callers in each binding:
- Rust:
native::block_source - Go:
Raw.NativeBlockSource - Zig:
native.blockSource
- Rust:
native_hook_install¶
| C | |
|---|---|
Installs a native detour on target through ll::memory::hook.
detour must have the exact signature and calling convention of target, which the host cannot check. priority is 0 highest to 400 lowest with 200 normal, the values of ll::memory::HookPriority; a value outside 0..400 refuses the call. On PIER_NATIVE_OK *out_original receives the address through which the detour calls the next detour or the engine, and *out_id the id native_hook_remove takes.
The host records which mod installed what. When a mod unloads, every detour it still holds is removed before its dll is unmapped. A call already running inside a detour on another thread is not waited for, so a mod unloaded at runtime removes its detours itself first or keeps them off other threads. One (target, detour) pair installs once; a second install of the same pair is refused.
- Call:
api->native_hook_install(mod, target, detour, priority, out_original, out_id) - Parameters:
- mod :
PierModHandle - target :
void* - detour :
void* - priority :
int32_t - out_original :
void** - out_id :
uint64_t*
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 215, counting from 0
- Callers in each binding:
- Rust:
native::hook_install - Go:
Raw.NativeHookInstall - Zig:
native.hookInstall
- Rust:
native_hook_remove¶
| C | |
|---|---|
Removes a detour this mod installed. PIER_NATIVE_NOT_FOUND for an id this mod does not hold, one already removed included. PIER_NATIVE_FAILED when the engine-side removal fails; the detour then stays recorded and is tried again at unload.
- Call:
api->native_hook_remove(mod, id) - Parameters:
- mod :
PierModHandle - id :
uint64_t
- mod :
- Return type:
int32_t - Section of abi.h: Native escape hatch (native_*); its section near the top of this file is the
- Position in the table: slot 216, counting from 0
- Callers in each binding:
- Rust:
native::hook_remove - Go:
Raw.NativeHookRemove - Zig:
native.hookRemove
- Rust:
PierNativeObject¶
native_object kinds.
| Name | Value | Description |
|---|---|---|
PIER_NATIVE_OBJ_MINECRAFT |
0 |
ll::service::getMinecraft |
PIER_NATIVE_OBJ_LEVEL |
1 |
ll::service::getLevel |
PIER_NATIVE_OBJ_SERVER_NETWORK_HANDLER |
2 |
ll::service::getServerNetworkHandler |
PIER_NATIVE_OBJ_SERVER_INSTANCE |
3 |
ll::service::getServerInstance |
PIER_NATIVE_OBJ_COMMAND_REGISTRY |
4 |
ll::service::getCommandRegistry |
PIER_NATIVE_OBJ_NETWORK_SYSTEM |
5 |
ll::service::getNetworkSystem |
PIER_NATIVE_OBJ_DB_STORAGE |
6 |
ll::service::getDBStorage |
PIER_NATIVE_OBJ_CLIENT_INSTANCE |
7 |
ll::service::getClientInstance, client hosts |
PIER_NATIVE_OBJ_MULTIPLAYER_LEVEL |
8 |
ll::service::getMultiPlayerLevel, client hosts: the level the client renders |
PIER_NATIVE_*¶
native_* return codes.
| Name | Value | Description |
|---|---|---|
PIER_NATIVE_OK |
0 |
done; the outputs are written |
PIER_NATIVE_DISABLED |
1 |
config.json of the host does not set native_detour to true |
PIER_NATIVE_NOT_FOUND |
2 |
no such symbol, pattern match, export, object or actor now |
PIER_NATIVE_REFUSED |
3 |
a null or malformed argument, an unknown kind, a foreign id |
PIER_NATIVE_FAILED |
4 |
the engine-side call failed: a detour that did not install |