Skip to content

Code

Assembly, patches and code memory, all put back when the plugin goes. Any thread. Returned text and slices are good till the thread’s next call into Wraith.

enable(): void
disable(): void
destroy(): void

Fails with CodeError.

Fails with CodeError.

Puts the code back for good. Fine to call twice.

Get it with Api.code().

assemble(source: string, address: number | bigint): Array<number>
patch(target: number | bigint, source: string, options: import("salamander").Given<Wraith.Patch.Options>): Wraith.Patch
patchBytes(target: number | bigint, bytes: Array<number>, options: import("salamander").Given<Wraith.Patch.Options>): Wraith.Patch
inject(target: number | bigint, source: string, options: import("salamander").Given<Wraith.Patch.Options>): Wraith.Patch
alloc(size: number, near: number | bigint): number
free(address: number | bigint): void
place(request: import("salamander").Given<Wraith.Code.PlaceRequest>): Wraith.Code.Placed
disassemble(address: number | bigint, count: number): Array<Wraith.Code.Instruction>
instructionLength(address: number | bigint): number

source as if it were at address.

Fails with CodeError.

Replaces code at target with asm, in place or in a cave. jmp original runs it as it was.

Fails with CodeError. Uses Patch.Options, Patch.

Writes exactly bytes over the code at target.

Fails with CodeError. Uses Patch.Options, Patch.

Runs asm in a cave before the instruction at target. jmp resume skips it. Only disabled and names count.

Fails with CodeError. Uses Patch.Options, Patch.

RWX memory, within a jump of near unless it’s 0.

Fails with CodeError.

Data and the code that reads it placed together so the code always reaches it. Nothing’s left if it fails.

Fails with CodeError. Uses Code.PlaceRequest, Code.Placed.

Up to count instructions (0 is 1), stopping early at unreadable memory or non-code.

Fails with CodeError. Uses Code.Instruction.

Up to count instructions (0 is 1), stopping early at unreadable memory or non-code.

Fails with CodeError.

What can go wrong, besides Cancelled, Unsupported and Gone.

Code Error
1 InvalidAsm
2 TooLong
3 Unreadable
4 UnexpectedBytes expect didn’t match what’s there
5 InvalidPattern An expect that doesn’t parse
6 AlreadyHooked Someone else hooked or patched it
7 TargetModified It changed since it was looked at
8 SplitsInstruction A size that ends inside an instruction
9 OutOfReach No room near enough
10 InvalidInstruction Not code
11 Failed

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 size u32 Bytes replaced, ending between instructions. 0 is what expect covers, or the one instruction.
0x8 expect string Bytes like 89 83 ?? ?? or asm like cmp ecx, eax that must be there first. Empty skips the check.
0x18 disabled bool Starts off rather than on
0x20 names []Addresses.Name Before the address list’s
size: number
expect: string
disabled: boolean
names: Array<Wraith.Addresses.Name>

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 address usize
0x8 length u32
0x10 bytes []u8
0x20 text string Intel syntax
address: number
length: number
bytes: Array<number>
text: string

A name for somewhere in data place places.

A struct, 0x18 bytes, aligned to 8.

Offset Field Type
0x0 name string
0x10 offset u32 Bytes into the data
name: string
offset: number

A struct, 0x18 bytes, aligned to 8.

Offset Field Type
0x0 size u32
0x4 alignment u32 0 is 8
0x8 names []Code.PlaceName Names its code can use
size: number
alignment: number
names: Array<Wraith.Code.PlaceName>

A struct, 0x40 bytes, aligned to 8.

Offset Field Type
0x0 target usize
0x8 source string
0x18 inject bool Goes before the instruction like inject, else replaces code like patch
0x1c size u32 Like Patch.Options
0x20 expect string
0x30 names []Addresses.Name After the data’s and before the address list’s
target: number
source: string
inject: boolean
size: number
expect: string
names: Array<Wraith.Addresses.Name>

A struct, 0x28 bytes, aligned to 8.

Offset Field Type
0x0 near usize What the data’s near when no code jumps to it
0x8 data []Code.PlaceData
0x18 code []Code.PlaceCode
near: number
data: Array<Wraith.Code.PlaceData>
code: Array<Wraith.Code.PlaceCode>

A struct, 0x20 bytes, aligned to 8.

Offset Field Type
0x0 data []usize Where each data went, in order
0x10 code []Patch Each code’s patch, in order. They start off.
data: Array<number>
code: Array<Wraith.Patch>

Made with ♥ by Asgard