The game
Which game it is, its files, and what it’s made with. game.gameInfo() gives a Game.Info. It’s cheap and doesn’t touch the disk, so call it whenever.
| Field | What |
|---|---|
id |
Wraith’s id, like steam-1245620, or its own name for games it knows, like ffxiv |
store, title |
Where it’s from, like steam, and the store’s name for it |
build |
The store’s build, like steam:18234455, the way a manifest’s builds lists them. Only Steam says so far |
exe, dir |
The exe’s full path, and its folder |
file_version, product_version |
From the exe, like 1.2.0.0. Empty if it has none |
game_engine |
Like unity, unreal, godot or rpg_maker, from the files beside the exe. Empty if it’s not one Wraith knows |
game_engine_variant, game_engine_version |
Like IL2CPP and 2021.3.16 for Unity. Empty if there’s none |
anticheat |
Anti-cheat beside the game or loaded in it, each with an id and name. Wraith doesn’t stop for it, but your plugin might want to |
graphics_api |
Like d3d11 or vulkan. Empty till the overlay’s first frame |
window |
The game window’s handle, an HWND. 0 till it’s found |
wraith_version |
Wraith’s own version |
sha512 gives the exe’s SHA-512 in hex, the way a manifest’s hashes lists it. It’s worked out in the background as the game starts, so it’s async.
import { Wraith } from "wraith";
const game = Wraith.game();
const info = game.gameInfo();if (info.game_engine === "unity" && info.game_engine_variant === "IL2CPP") { // GameAssembly.dll has the game's code}const hash = await game.sha512();local Wraith = require("wraith").Wraith
local game = Wraith.game()
local info = game:gameInfo()if info.game_engine == "unity" and info.game_engine_variant == "IL2CPP" then -- GameAssembly.dll has the game's codeend
task.spawn(function() local hash = game:sha512():await()end)var game = Game.Instance;var info = game.GameInfo();if (info.GameEngine == "unity" && info.GameEngineVariant == "IL2CPP"){ // GameAssembly.dll has the game's code}var hash = await game.Sha512Async();static sal::Future<void> look() { auto game = wraith::api().game(); auto info = game.gameInfo(); if (info.game_engine.view() == "unity" && info.game_engine_variant.view() == "IL2CPP") { // GameAssembly.dll has the game's code } auto hash = co_await game.sha512(); co_return {};}let game = wraith::api().game();let info = game.game_info();if unsafe { info.game_engine.get() } == "unity" && unsafe { info.game_engine_variant.get() } == "IL2CPP" { // GameAssembly.dll has the game's code}let _ = salamander::spawn(async move { let hash = wraith::api().game().sha512().await?; Ok::<(), wraith::GameError>(())});const game = ctx.wraith.game();const info = game.gameInfo();if (std.mem.eql(u8, info.game_engine, "unity") and std.mem.eql(u8, info.game_engine_variant, "IL2CPP")) { // GameAssembly.dll has the game's code}// From a task, not the render threadconst hash = try sdk.tasks.wait(game.sha512());Wraith_Game game = Wraith_Api_game(w);Wraith_Game_Info info = Wraith_Game_gameInfo(game);if (info.game_engine.len == 5 && memcmp(info.game_engine.ptr, "unity", 5) == 0) { /* a Unity game, IL2CPP if info.game_engine_variant says so */}sal_Promise hash = Wraith_Game_sha512(game); /* a sal_string, once it's settled */setSpeed makes the game run faster, up to 100, or slower. Wraith and your plugin keep real time. speed says what it’s at, and it goes back to 1 when your plugin goes. The player can change it too, from the speed slider. Players can read about it in Game speed.
How it’s done depends on the game. If a plugin for the game or its engine provides speed, like unity with Unity’s time scale, that’s used, and anything from 0, a pause, up goes. Otherwise Wraith speeds up or slows down the clocks games time themselves with, like Cheat Engine’s speedhack, down to 0.01, so only a provider can pause. Nearly every game follows the clocks, though a few read the time in ways they can’t change.
import { Wraith } from "wraith";
game.setSpeed(2);Wraith.log().info(`${game.speed()}`); // 2local Wraith = require("wraith").Wraith
game:setSpeed(2)Wraith.log():info(tostring(game:speed())) -- 2game.SetSpeed(2);var now = game.Speed();auto game = wraith::api().game();game.setSpeed(2);double now = game.speed(); // 2let game = wraith::api().game();game.set_speed(2.0).ok()?;let now = game.speed(); // 2try game.setSpeed(2);const now = game.speed();Wraith_Game game = Wraith_Api_game(w);Wraith_Game_setSpeed(game, 2);double now = Wraith_Game_speed(game); /* 2 */Engine and game plugins can handle the game’s speed by claiming its lease with claimSpeed, which is what lets the game pause. While you hold it, the handler gets each speed, starting with what it is now, and says whether it applied it. If it doesn’t, the clocks do. When you lose it, it gets 1, to put the game’s own speed back. It’s called from any thread, so keep it quick, and don’t set the speed from it.
game.claimSpeed((speed) => { wanted = speed; // put on next frame return true;}, null);game:claimSpeed(function(speed) wanted = speed -- put on next frame return trueend, nil)game.ClaimSpeed(speed =>{ wanted = speed; // put on next frame return true;}, null);static std::atomic<double> wanted = 1;
// in startwraith::api().game().claimSpeed(sal::keep<Wraith::Game::SpeedHandler>([](double speed) { wanted = speed; // put on next frame return true;}), {});use std::sync::Mutex;
use wraith::{GameSpeedHandler, LeaseChanged};
static WANTED: Mutex<f64> = Mutex::new(1.0);
fn claim() -> Option<()> { let handler = GameSpeedHandler::keep(|speed: f64| { *WANTED.lock().unwrap() = speed; // put on next frame true }); wraith::api().game().claim_speed(handler, LeaseChanged::default()).ok()?; Some(())}fn speedChanged(self: *Plugin, speed: f64) bool { // An atomic u64, put on next frame self.wanted.store(@bitCast(speed), .release); return true;}
// in startself.speed = try sdk.Lease.claimSpeed(.init(self, speedChanged), .none);static volatile double wanted = 1;
static bool on_speed(uintptr_t self, double speed) { (void)self; wanted = speed; /* put on next frame */ return true;}
static const Wraith_Game_SpeedHandler_table speed_table = { SAL_TABLE(Wraith_Game_SpeedHandler), .call = on_speed };
/* in start */Wraith_Lease lease;Wraith_Game_claimSpeed(Wraith_Api_game(w), (Wraith_Game_SpeedHandler){ 0, &speed_table }, (Wraith_Lease_Changed){ 0 }, &lease);Some games break when their speed changes, like ones played online. A game’s plugin can keep it off with setSpeedControl(false), so the slider and pause key are greyed out and setSpeed fails with SpeedOff. Turn it back on where it works, like in a photo mode, with setSpeedControl(true). Turning it off puts the speed back to normal. A game’s plugin’s say beats a game engine’s, which beats the rest, then the newest say wins. It goes when that plugin does. speedControl says whether it’s on now.
game.setSpeedControl(false); // as the plugin starts// entering the game's photo modegame.setSpeedControl(true);game:setSpeedControl(false) -- as the plugin starts-- entering the game's photo modegame:setSpeedControl(true)game.SetSpeedControl(false); // in Start// entering the game's photo modegame.SetSpeedControl(true);auto game = wraith::api().game();game.setSpeedControl(false); // in start// entering the game's photo modegame.setSpeedControl(true);let game = wraith::api().game();game.set_speed_control(false); // in start// entering the game's photo modegame.set_speed_control(true);game.setSpeedControl(false); // in start// entering the game's photo modegame.setSpeedControl(true);Wraith_Game game = Wraith_Api_game(w);Wraith_Game_setSpeedControl(game, false); /* in start *//* entering the game's photo mode */Wraith_Game_setSpeedControl(game, true);wraith.io · Mods on the Hub · Get Wraith
Made with ♥ by Asgard
