xur_

> module

std::stub::unreal

Unreal Engine introspection and manipulation

use std::stub::unreal; feature unreal native only

std::stub::unreal provides runtime introspection of Unreal Engine 4 and 5 games via the unrealkit crate. It finds GNames and GObjects by AOB-scanning the game's code, then exposes the UObject reflection system: classes, properties, functions, and ProcessEvent invocation.

Only useful inside a running UE game process, i.e. from a script run by the stub (see xur.stub(7)). Everything but init() and init_from_pointers() needs the SDK initialised first: functions that return a Result fail with Error::NotInitialized, the rest raise.

Property values cross into Xur as bool, i64, f64, str (names and strings), bytes (anything else, raw), or a UObject; a null object reference reads as None.

> functions

# find_object(name: str) -> Option<UObject>

The first object whose short name matches.

# find_objects_by_class(class_name: str) -> list<UObject>

All objects whose class short name matches.

# init(version: i64, text_base: ptr, text_size: i64) -> Result<UnrealSdk, str>

Initialise the SDK by scanning text_size bytes of code at text_base for GNames and GObjects. version is 4 for UE4 or 5 for UE5; anything else raises, as does initialising twice.

# init_from_pointers(version: i64, gnames: ptr, gobjects: ptr) -> Result<UnrealSdk, str>

Initialise from known GNames and GObjects addresses, skipping the scan.

# objects() -> list<UObject>

All live UObjects.

# set_process_event(addr: i64) -> Result<(), Error>

Set the ProcessEvent function pointer used by UFunction.invoke(). It can only be set once (Error::AlreadySet).

# set_process_event_vtable(index: i64) -> Result<(), Error>

Set ProcessEvent from slot index of the first UObject's vtable (typically UE4 ~66–68, UE5 ~68–72).

> types

┌ enum Error

A recoverable Unreal error. Match it as `Err(unreal::Error::NotInitialized)`.

Error::NotInitializedThe SDK was not initialized — call `unreal::init()` first.
Error::NotFoundA lookup found nothing (e.g. no UObjects for a vtable read).
Error::OutOfRangeAn address or index was out of range.
Error::AlreadySet`ProcessEvent` was already set.
Error::NoNativePointerThe UFunction has no native pointer to hook.
Error::Hook(str)A hook operation failed, with its message.
┌ type UClass
# u_class.all_methods() -> Result<list<UFunction>, Error>

All functions, including inherited ones.

# u_class.all_properties() -> Result<list<UProperty>, Error>

All properties, including inherited ones.

# u_class.children() -> Result<list<str>, Error>

The class's own child fields, each as "name (FieldClass)".

# u_class.hierarchy() -> Result<list<str>, Error>

Inheritance chain as class names, starting with this class.

# u_class.instance_size() -> i64

Size of an instance in bytes.

# u_class.method(name: str) -> Option<UFunction>

Find a function by name (searches superclasses).

# u_class.methods() -> Result<list<UFunction>, Error>

This class's own functions.

# u_class.name() -> str

Class short name.

# u_class.properties() -> Result<list<UProperty>, Error>

This class's own properties.

# u_class.property(name: str) -> Option<UProperty>

Find a property by name (searches superclasses).

# u_class.super_class() -> Option<UClass>

The class this one derives from, if any.

┌ type UFunction
# u_function.flags() -> i64

UFunction flags bitmask.

# u_function.full_name() -> str

Full path name.

# u_function.hook(detour_addr: i64) -> Result<i64, Error>

Inline-hook the function's native implementation to jump to detour_addr. Returns the address of a trampoline to the original. The hook is permanent.

# u_function.invoke(obj: UObject, params?: bool | i64 | f64 | str | bytes | UObject) -> bool | i64 | f64 | str | bytes | UObject | None | ()

Call the function on obj through ProcessEvent. Arguments fill the input parameters in order (missing ones stay zeroed); the result is the return parameter, or () if there is none. Raises unless set_process_event() or set_process_event_vtable() was called first.

# u_function.name() -> str

Function short name.

# u_function.native_ptr() -> i64

Address of the native C++ implementation.

# u_function.num_params() -> i64

Number of parameters.

# u_function.params() -> Result<list<UProperty>, Error>

Parameter properties (including the return value).

# u_function.params_size() -> i64

Size of the parameter struct in bytes.

# u_function.ptr() -> i64

Raw address of the UFunction object.

# u_function.signature() -> Result<str, Error>

Human-readable signature (e.g. "void Jump()").

┌ type UObject
# u_object.class() -> UClass

The object's UClass.

# u_object.full_name() -> str

Full path name (e.g. "Class /Script/Engine.Actor").

# u_object.get(name: str) -> bool | i64 | f64 | str | bytes | UObject | None

Read a property by name, searching the class and its superclasses. Raises if there is no such property.

# u_object.is_a(class_name: str) -> Result<bool, Error>

Whether the object's class is, or derives from, the named class.

# u_object.name() -> str

Short name (e.g. "PlayerController_0").

# u_object.outer() -> Option<UObject>

The object's outer (the object it lives in), if any.

# u_object.ptr() -> u64

Raw memory address.

# u_object.set(name: str, value: bool | i64 | f64 | str | bytes | UObject)

Write a property by name. Raises if there is no such property.

┌ type UProperty
# u_property.element_size() -> i64

Size of one element in bytes.

# u_property.name() -> str

Property name.

# u_property.offset() -> i64

Byte offset within the owning object.

# u_property.ptr() -> i64

Raw memory address of the property descriptor.

# u_property.read(obj: UObject) -> bool | i64 | f64 | str | bytes | UObject | None

Read this property from an object.

# u_property.type_name() -> str

Property type (e.g. "FloatProperty", "BoolProperty").

# u_property.write(obj: UObject, value: bool | i64 | f64 | str | bytes | UObject)

Write this property on an object.

┌ type UnrealSdk

An opaque value; see the functions that return it.

> errors

unreal::Error is one of NotInitialized (call init() first), NotFound (e.g. no UObjects to read a vtable from), OutOfRange (a negative address or index), AlreadySet (ProcessEvent was already set), NoNativePointer (the UFunction has no native code to hook) or Hook(message).

> examples

use std::stub::unreal;
use std::re::proc;
use std::io;

fn stub_main() -> Result<()> {
    let main_mod = proc::open_current()?.modules()?[0];
    unreal::init(5, main_mod.base, main_mod.size)?;
    io::println("SDK initialised");

    // Dump objects
    for obj in unreal::objects() {
        io::println(obj.full_name());
    }

    // Inspect a class
    let player = unreal::find_object("MyCharacter").unwrap();
    let cls = player.class();
    for p in cls.all_properties()? {
        io::println("  {} : {}", p.name(), p.type_name());
    }
    for f in cls.all_methods()? {
        io::println("  {}", f.signature()?);
    }

    // Read/write properties
    let hp = player.get("Health");
    io::println("health: {}", hp);
    player.set("Health", 999.0);

    // Call a function
    unreal::set_process_event_vtable(68)?;
    let jump = cls.method("Jump").unwrap();
    jump.invoke(player);
    Ok(())
}