Skip to content

Vfs

Virtual files, and watching the game’s file I/O. Paths use forward slashes going out; either works going in. Any thread.

cancel(): void

Waits for the handler if it’s running, unless called from inside it. Fine to call twice.

Get it with Api.vfs().

put(path: string, bytes: Array<number>): void
putDir(path: string): void
remove(path: string): boolean
read(path: string): Uint8Array | null
addWatch(options: import("salamander").Given<Wraith.Vfs.WatchOptions>, handler: Wraith.Vfs.Handler): Wraith.Vfs.Watch

Serves bytes at path, hiding any real file, until removed or the plugin goes.

Fails with VfsError.

A virtual folder, so files the game makes in it are virtual too.

Fails with VfsError.

A virtual file or folder and its contents, whoever put it. False if there wasn’t one.

A copy of a virtual file’s bytes, which the caller owns.

Fails with VfsError.

Until it’s cancelled or the plugin goes.

Fails with VfsError. Uses Vfs.WatchOptions, Vfs.Handler, Vfs.Watch.

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

Code Error
1 Unavailable The game’s file I/O isn’t being watched, like when it’s off in Settings
2 InvalidPath Not a full path, or too long
3 WrongKind A folder where a file should be, or the other way around
4 NotFound
5 Failed

An enum of u8.

Value Name
0 open Before an open. The reply can redirect or refuse it.
1 opened
2 failed An open that failed, with its status
3 read After a read. The reply can replace what it read.
4 write Before a write. The reply can refuse it.
5 closed The last handle to a file closed

Bits of a u8.

Bits Member Type
0 open bool
1 opened bool
2 failed bool
3 read bool
4 write bool
5 closed bool

An enum of u8.

Value Name
0 none
1 access_denied
2 not_found
3 sharing_violation
4 write_protected

A struct, 0x20 bytes, aligned to 8.

Offset Field Type
0x0 kinds Vfs.Kinds
0x8 pattern string Like C:/Game/data/*.pak. * matches anything, slashes too, ? one character. Case-insensitive. Empty is all.
0x18 loader bool Also while the loader opens a DLL. It holds a lock then, so don’t wait on other threads.
0x19 queries bool Also existence checks like GetFileAttributes, as opens with query set
kinds: number
pattern: string
loader: boolean
queries: boolean

A struct, 0x60 bytes, aligned to 8.

Offset Field Type
0x0 kind Vfs.EventKind
0x8 path string For open, where it’ll be opened after any earlier redirect.
0x18 requested string What the game asked for. Differs from path only when redirected.
0x28 file u64 The same for every handle to one open file. 0 for open and failed.
0x30 read_access bool
0x31 write_access bool
0x32 virtual bool
0x33 directory bool
0x34 query bool An existence check, with no handle coming of it
0x38 thread u32
0x40 offset i64 Where a read or write starts. -1 for the current position.
0x48 data []u8 What a read got or a write writes
0x58 status u32 The NTSTATUS for failed
kind: Wraith.Vfs.EventKind | Wraith.Vfs.EventKindName
path: string
requested: string
file: bigint
read_access: boolean
write_access: boolean
virtual: boolean
directory: boolean
query: boolean
thread: number
offset: bigint
data: Array<number>
status: number

Left zero, it goes ahead.

A struct, 0x30 bytes, aligned to 8.

Offset Field Type
0x0 deny Vfs.Denial For open and write
0x8 redirect string For open, where to open instead, which can be a virtual file
0x18 replace bool For read, bytes to put over what it read, as many as fit
0x20 data []u8
deny: Wraith.Vfs.Denial | Wraith.Vfs.DenialName
redirect: string
replace: boolean
data: Array<number>

On the thread doing the I/O, which waits for it.

Wraith.Vfs.Handler

Made with ♥ by Asgard