LiveSplit / asr

Helper crate to write auto splitters for LiveSplit One's auto splitting runtime.
https://livesplit.org/asr/asr
Apache License 2.0
10 stars 10 forks source link

Preliminary support for Unreal Engine #95

Closed Jujstme closed 6 months ago

Jujstme commented 6 months ago

This adds support for memory scanning in UE games, allowing to automatically resolve pointer paths. Support is provided for UE version from 2.43 and up.

Support for older UE version seems pretty easy to add anyway, although a bit of additional coding is required to deal with the difference in the FName tables.

Example:

async fn main() {
    loop {
        let process = Process::wait_attach("UnrealGame-Win64-Shipping.exe").await;
        let main_module =
            retry(|| process.get_module_address("UnrealGame-Win64-Shipping.exe")).await;

        process
            .until_closes(async {
                let module =
                    &unreal::Module::wait_attach(process, unreal::Version::V4_24, main_module)
                        .await;

                let money = UnrealPointer::<7>::new(
                    module.g_engine(),
                    &[
                        "GameViewport",
                        "GameInstance",
                        "LocalPlayers",
                        "0x0",
                        "PlayerController",
                        "Character",
                        "TotalMoney",
                    ],
                );

                loop {
                    if let Ok(money) = money.deref::<u32>(process, module) {
                        timer::set_variable("Total money:", &money.to_string());
                    }

                    next_tick().await;
                }
            })
            .await;
    }
}