> module
std::stub::unreal
Unreal Engine introspection and manipulation
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
All objects whose class short name matches.
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.
Initialise from known GNames and GObjects addresses, skipping the scan.
Set the ProcessEvent function pointer used by UFunction.invoke(). It can only be set once (Error::AlreadySet).
> types
A recoverable Unreal error. Match it as `Err(unreal::Error::NotInitialized)`.
| Error::NotInitialized | The SDK was not initialized — call `unreal::init()` first. |
| Error::NotFound | A lookup found nothing (e.g. no UObjects for a vtable read). |
| Error::OutOfRange | An address or index was out of range. |
| Error::AlreadySet | `ProcessEvent` was already set. |
| Error::NoNativePointer | The UFunction has no native pointer to hook. |
| Error::Hook(str) | A hook operation failed, with its message. |
All properties, including inherited ones.
The class's own child fields, each as "name (FieldClass)".
Inheritance chain as class names, starting with this class.
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.
Parameter properties (including the return value).
Read a property by name, searching the class and its superclasses. Raises if there is no such property.
Whether the object's class is, or derives from, the named class.
Read this property from an object.
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(())
}