Skip to content

Managed

The game’s C# runtime: Mono, IL2CPP or CoreCLR. Classes go by C# name, like Game.Player or Game.Player/Stats for nested ones. Address text takes Class:Method+0x3a too.

Any thread, but calls queue on Wraith’s one runtime thread, so look things up once. Classes, fields and methods don’t move. Returned text and slices are good till the thread’s next call into Wraith.

Objects are addresses. CoreCLR’s GC moves them, so hold ones you keep and use heldAt before each use.

Get it with Api.managed().

runtimeKind(): Wraith.Managed.Kind
running(): Promise<void>
images(): Array<string>
classes(image: string): Array<string>
find(class_name: string): Wraith.Managed.Class
fields(class_name: string): Array<Wraith.Managed.Field>
methods(class_name: string): Array<Wraith.Managed.Method>
fieldOffset(class_name: string, field: string): number
staticAddress(class_name: string, field: string): number
findMethod(class_name: string, name: string, params: number): number
icall(class_name: string, method: string): number
typeObject(class_name: string): number
callNative(function_: number | bigint): number
invoke(class_name: string, method: string, target: number | bigint, args: Array<import("salamander").Given<Wraith.Managed.Value>>): Wraith.Managed.Value
hold(object: number | bigint): number
release(handle: number): void
heldAt(handle: number): number
classOf(object: number | bigint): string
readString(address: number | bigint): string
getField(object: number | bigint, field: string): Wraith.Managed.Value
setField(object: number | bigint, field: string, value: import("salamander").Given<Wraith.Managed.Value>): void

none till it’s running

Uses Managed.Kind.

Waits till the game’s started its runtime, after plugins load. NotRunning if it has none.

Async. Fails with ManagedError.

Loaded images, like Assembly-CSharp.dll

Fails with ManagedError.

An image’s classes by full name, nested ones too

Fails with ManagedError.

An image’s classes by full name, nested ones too

Fails with ManagedError. Uses Managed.Class.

Its own fields, not its parents’

Fails with ManagedError. Uses Managed.Field.

Its own methods, not its parents’

Fails with ManagedError. Uses Managed.Method.

Looks in parents too

Fails with ManagedError.

Where a static is now. May run the static constructor. Salamander’s built-in Unsupported for thread statics and IL2CPP before Unity 2019 or so.

Fails with ManagedError.

A method’s code, with params parameters or any if -1. Looks in parents too. Mono compiles it if needed.

Fails with ManagedError.

The native function behind an extern method, callable with its C signature, this first. Unity’s only on the game’s main thread.

Fails with ManagedError.

The System.Type object for a class.

Fails with ManagedError.

Calls function, taking nothing and giving a pointer-sized value, on Wraith’s runtime thread. Not for Unity’s main-thread calls.

Fails with ManagedError.

Calls a C# method by name, picking the best fitting overload. target is 0 for statics. Runs here if the runtime knows this thread, else on Wraith’s. Structs come back boxed. .ctor with a 0 target makes a new object.

Fails with ManagedError. Uses Managed.Value.

Keeps the object from being collected till release. Hold anything kept past the call it came from. Released when the plugin goes. Any thread, straight away.

Fails with ManagedError.

Fine to call twice.

Where a held object is now, which only changes under CoreCLR. Any thread, straight away.

Fails with ManagedError.

The object’s class’s full name

Fails with ManagedError.

The System.String at address, as UTF-8

Fails with ManagedError.

An instance field by name, parents included. Primitives and strings as themselves, structs as the address of their bytes, the rest as objects. Any thread.

Fails with ManagedError. Uses Managed.Value.

Sets one through the runtime so the GC sees it. Any thread, but Unity objects want the main thread.

Fails with ManagedError. Uses Managed.Value.

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

Code Error
1 NotRunning The game has none, or hasn’t started it yet
2 NotFound
3 Unreadable Not an object or a string
4 Failed
5 Threw invoke’s method threw, and the message says what

An enum of u8.

Value Name
0 none
1 mono
2 il2cpp
3 coreclr

Which of Value’s fields it is.

An enum of u8.

Value Name
0 none
1 flag
2 integer
3 number
4 text
5 object

An invoke argument or result. Integers cover whole numbers and enums, numbers floats, text strings, and objects the rest by address, structs and ref parameters included.

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 kind Managed.ValueKind
0x1 flag bool
0x8 integer i64
0x10 number f64
0x18 text string
0x28 object usize
kind: Wraith.Managed.ValueKind | Wraith.Managed.ValueKindName
flag: boolean
integer: bigint
number: number
text: string
object: number

A struct, 0x48 bytes, aligned to 8.

Offset Field Type
0x0 full_name string Like Game.Player, or Game.Player/Stats nested
0x10 name string Like Player
0x20 image string Like Assembly-CSharp.dll
0x30 parent string Its parent’s full name, or empty
0x40 size u32 Bytes in one, header included
0x44 value_type bool
full_name: string
name: string
image: string
parent: string
size: number
value_type: boolean

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 name string
0x10 type string Like System.Int32 or System.Collections.Generic.List<Game.Item>
0x20 offset usize From the object’s start, header included, even in value types. Statics: from the class’s static data, which staticAddress adds in.
0x28 is_static bool
0x29 literal bool A const, with no storage
name: string
type: string
offset: number
is_static: boolean
literal: boolean

A struct, 0x38 bytes, aligned to 8.

Offset Field Type
0x0 name string
0x10 return_type string
0x20 params []string Each parameter’s type
0x30 is_static bool Each parameter’s type
name: string
return_type: string
params: Array<string>
is_static: boolean

Made with ♥ by Asgard