Skip to content

Tweak files

A .rwt file is a list of sections. Each starts with a line beginning @ and runs until the next one. // starts a comment.

To edit them outside the Workbench, the VS Code extension highlights them and has snippets for the common sections.

Here’s one that uses most of them:

@tweak "XP multiplier"
@key Ctrl+F8
@data
[Label("Multiplier"), Min(1), Max(100)] u32 multiplier = 2
@patch sig("8B 80 98 00 00 00") expect "mov eax, [rax+0x98]"
mov eax, [rax+0x98]
imul eax, [multiplier]
@js
function tick() {
// runs every frame while it's on
}
Section What it does
@tweak "Name" What it’s called in menus. Defaults to the file name.
@key F8 Its key, like F8 or Ctrl+Shift+K. Players can change it.
@mode toggle Stays on until you turn it off. This is the default.
@mode action Runs once and undoes its code changes, like a button.
@use ce Loads a script library before the tweak’s code. See Groups.
@globals shared In a group’s shared part, lets everything in the group see each other’s globals. See Groups.

More than one @tweak in a file makes it a group, where the tweaks share what’s above the first one. @group "Name" at the top names it, and further down it opens a group inside it that runs to its @end. See Groups.

@data adds values players can change from the Tweaks menu. They live in the game’s memory, so your asm can use them by name, like [multiplier] above. In JS and Lua they’re data.multiplier.

@data
[Label("Speed"), Min(0.5), Max(5)] f32 speed = 1
[Toggle, Key(F9)] bool fly = 0
[Hex] u32 flags = 0x10
[Choices("0:None", "1:Potion", "2:Elixir")] u16 item

Types are u8 to u64, i8 to i64, f32, f64 and bool. Values are kept per game, so they’re still there next time.

Use @data near game.exe if your asm needs the values close to the game’s code. If nothing near it is free, like in a game whose exe sits low in memory, they go where its far hooks go, so the tweak’s own @patch and @inject code still reaches them. Code patched in place that can’t reach them moves out next to them.

Section What it does
@patch where Replaces the instruction there with your code.
@inject where Runs your code before the instruction there. It still runs after.
@bytes where Writes raw bytes, like 90 90 or x"9090".
@hook where as i32 (i32 damage) Replaces a whole function with JS or Lua.

Code is asm by default. Numbers there work like they do in addresses, and db x"48 8B 05" writes hex bytes. Put @js or @lua on the first line of a @patch or @inject to write script instead. See Patch or inject? for when to use which.

@sym names an address so you don’t repeat it.

@sym hit = sig("89 83 98 00 00 00")
@inject hit
mov eax, [rbx+0x98]

In JS and Lua, @sym names are under sym, like sym.hit.

While a tweak is on, other tweaks and scripts can use its names too. A tweak in tweaks/xp.rwt makes xp.multiplier.

A tweak’s script is all JS or all Lua. @js or @lua runs when the tweak turns on, and a @hook’s body is in the same language. Two functions are special.

  • tick() runs every frame while it’s on.
  • off() runs when it’s turned off.
@lua
function tick()
-- runs every frame while it's on
end

Everything a script can use is there too, like memory and ui.

These are there without you making them, so @data and @sym can’t use them. JS and Lua get the same ones.

Name In What it is
original asm Where the old code is. jmp original runs it
resume asm Just past the old code. jmp resume carries on there
cpu Script in @patch and @inject The registers, like cpu.rax
original() resume() Script in @patch and @inject Go there once your code returns
original(...) @hook Calls the real function
data Script Your @data values, like data.multiplier
sym Script Your @sym addresses, like sym.hit
types Script Your @schema types
tick() off() Script Yours to define. Called each frame and when it’s turned off

What happens when your code runs off the end is in Patch or inject?.

@schema holds struct definitions in schema syntax. Scripts see them as types, and @hook can use them in its signature.

Anywhere a section wants a where, you can use:

  • game.exe+0x1234 for a spot in a module
  • sig("48 8B ?? ??") to find a byte pattern
  • [game.exe+0x10] + 8 to read a pointer and add to it
  • a name from @sym, @data or the Addresses list
  • math on any of them, like game.exe+0x10+4*0x1A

Numbers are decimal unless they’re hex, like 0x10 or 10h. Hex ending in h has to start with a digit, so it’s 0FFh and not FFh. + and - work as you’d expect, and *, / and % come first. Brackets group like (base+8)*2, while [ ] reads a pointer. More on picking these in Finding addresses.

Made with ♥ by Asgard