Skip to content

Go: Native escape hatch

Functions

NativeEnabledNow

Go
func NativeEnabledNow() bool

NativeEnabledNow reports whether the host answers the native calls, which its config.json decides.

  • Return type: bool

NativeSymbol

Go
func NativeSymbol(symbol string) (unsafe.Pointer, error)

NativeSymbol is the address of an engine function by its decorated symbol name.

  • Parameters:
    • symbol : string
  • Return type: (unsafe.Pointer, error)

NativeSignature

Go
func NativeSignature(pattern string) (unsafe.Pointer, error)

NativeSignature is the first match of a byte pattern such as "48 8B ?? 08" in the engine executable.

  • Parameters:
    • pattern : string
  • Return type: (unsafe.Pointer, error)

NativeExport

Go
func NativeExport(module, name string) (unsafe.Pointer, error)

NativeExport is an export of a module already loaded into the process; an empty module names the engine executable. LeviLamina's API is an export of LeviLamina.dll.

  • Parameters:
    • module : string
    • name : string
  • Return type: (unsafe.Pointer, error)

NativeObjectOf

Go
func NativeObjectOf(kind NativeObjectKind) (unsafe.Pointer, error)

NativeObjectOf is the address of one engine service object.

  • Parameters:
    • kind : NativeObjectKind
  • Return type: (unsafe.Pointer, error)

NativePlayerOf

Go
func NativePlayerOf(p Player) (unsafe.Pointer, error)

NativePlayerOf is the engine's Player object of an online player, valid while the player stays online.

  • Parameters:
    • p : Player
  • Return type: (unsafe.Pointer, error)

NativeActorOf

Go
func NativeActorOf(id ActorID) (unsafe.Pointer, error)

NativeActorOf is the engine's Actor object of a loaded actor.

  • Parameters:
    • id : ActorID
  • Return type: (unsafe.Pointer, error)

NativeDimensionOf

Go
func NativeDimensionOf(dim int32) (unsafe.Pointer, error)

NativeDimensionOf is the engine's Dimension object of a dimension id.

  • Parameters:
    • dim : int32
  • Return type: (unsafe.Pointer, error)

NativeBlockSourceOf

Go
func NativeBlockSourceOf(dim int32) (unsafe.Pointer, error)

NativeBlockSourceOf is the engine's BlockSource of a dimension id.

  • Parameters:
    • dim : int32
  • Return type: (unsafe.Pointer, error)

InstallNativeHook

Go
func InstallNativeHook(target, detour unsafe.Pointer, priority int32) (NativeHook, error)

InstallNativeHook installs detour on target at a HookPriority value. detour must be a C function with the exact signature and calling convention of target, and it reaches the engine through Original only. The host removes a detour this mod still holds when the mod unloads, and does not wait for a call already inside it on another thread.

  • Parameters:
    • target : unsafe.Pointer
    • detour : unsafe.Pointer
    • priority : int32
  • Return type: (NativeHook, error)

RemoveNativeHook

Go
func RemoveNativeHook(h NativeHook) error

RemoveNativeHook removes a detour this mod installed.

  • Parameters:
    • h : NativeHook
  • Return type: error

NativeError

Go
1
2
3
4
type NativeError struct {
    Op   string
    Code int32
}

NativeError is the answer of a native slot other than PIER_NATIVE_OK.

NativeError.Disabled

Go
func (e *NativeError) Disabled() bool

Disabled reports whether the host's config.json leaves native_detour off.

  • Return type: bool

NativeError.Error

Go
func (e *NativeError) Error() string
  • Return type: string

NativeObjectKind

Go
type NativeObjectKind int32

NativeObjectKind names one engine service object for NativeObjectOf.

Name Value Description
NativeMinecraft C.PIER_NATIVE_OBJ_MINECRAFT
NativeLevel C.PIER_NATIVE_OBJ_LEVEL
NativeServerNetworkHandler C.PIER_NATIVE_OBJ_SERVER_NETWORK_HANDLER
NativeServerInstance C.PIER_NATIVE_OBJ_SERVER_INSTANCE
NativeCommandRegistry C.PIER_NATIVE_OBJ_COMMAND_REGISTRY
NativeNetworkSystem C.PIER_NATIVE_OBJ_NETWORK_SYSTEM
NativeDBStorage C.PIER_NATIVE_OBJ_DB_STORAGE
NativeClientInstance C.PIER_NATIVE_OBJ_CLIENT_INSTANCE
NativeMultiPlayerLevel C.PIER_NATIVE_OBJ_MULTIPLAYER_LEVEL

NativeHook

Go
1
2
3
4
type NativeHook struct {
    ID       uint64
    Original unsafe.Pointer
}

NativeHook is one installed detour: the id RemoveNativeHook takes, and the address through which the detour calls the next detour or the engine.

HookPriority*

The priorities of ll::memory::HookPriority, for InstallNativeHook.

Name Value Description
HookPriorityHighest 0
HookPriorityHigh 100
HookPriorityNormal 200
HookPriorityLow 300
HookPriorityLowest 400