Vfs
Virtual files, and watching the game’s file I/O. Paths use forward slashes going out; either works going in. Any thread.
Vfs.Watch
Section titled “Vfs.Watch”cancel(): voidcancel()void Cancel()void cancel() constpub fn cancel(&self)fn cancel(self: Wraith.Vfs.Watch) voidvoid Wraith_Vfs_Watch_cancel(Wraith_Vfs_Watch self)cancel
Section titled “cancel”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>): voidputDir(path: string): voidremove(path: string): booleanread(path: string): Uint8Array | nulladdWatch(options: import("salamander").Given<Wraith.Vfs.WatchOptions>, handler: Wraith.Vfs.Handler): Wraith.Vfs.Watchput(path: string, bytes: (integer)[])putDir(path: string)remove(path: string): booleanread(path: string): stringaddWatch(options: Wraith.Vfs.WatchOptions, handler: Wraith.Vfs.Handler): Wraith.Vfs.Watchvoid Put(string path, System.ReadOnlySpan<byte> bytes)void PutDir(string path)bool Remove(string path)Salamander.Blob? Read(string path)Wraith.Vfs.Watch? AddWatch(Wraith.Vfs.WatchOptions options, Wraith.Vfs.Handler? handler)sal::Result<void, Wraith::VfsError> put(std::string_view path, std::span<const uint8_t> bytes) constsal::Result<void, Wraith::VfsError> putDir(std::string_view path) constbool remove(std::string_view path) constsal::Result<sal::Blob, Wraith::VfsError> read(std::string_view path) constsal::Result<Wraith::Vfs_Watch, Wraith::VfsError> addWatch(Wraith::Vfs_WatchOptions options, Wraith::Vfs_Handler handler) constpub fn put(&self, path: &str, bytes: &[u8]) -> Result<(), wraith::VfsError>pub fn put_dir(&self, path: &str) -> Result<(), wraith::VfsError>pub fn remove(&self, path: &str) -> boolpub fn read(&self, path: &str) -> Result<salamander::Blob, wraith::VfsError>pub fn add_watch(&self, options: wraith::VfsWatchOptions, handler: wraith::VfsHandler) -> Result<wraith::VfsWatch, wraith::VfsError>fn put(self: Wraith.Vfs, path: []const u8, bytes: []const u8) (Wraith.VfsError || rt.Failure)!voidfn putDir(self: Wraith.Vfs, path: []const u8) (Wraith.VfsError || rt.Failure)!voidfn remove(self: Wraith.Vfs, path: []const u8) boolfn read(self: Wraith.Vfs, path: []const u8) (Wraith.VfsError || rt.Failure)!rt.Blobfn addWatch(self: Wraith.Vfs, options: Wraith.Vfs.WatchOptions, handler: Wraith.Vfs.Handler) (Wraith.VfsError || rt.Failure)!Wraith.Vfs.Watchuint32_t Wraith_Vfs_put(Wraith_Vfs self, sal_string path, Slice_u8 bytes)uint32_t Wraith_Vfs_putDir(Wraith_Vfs self, sal_string path)bool Wraith_Vfs_remove(Wraith_Vfs self, sal_string path)uint32_t Wraith_Vfs_read(Wraith_Vfs self, sal_string path, sal_object *out)uint32_t Wraith_Vfs_addWatch(Wraith_Vfs self, Wraith_Vfs_WatchOptions options, Wraith_Vfs_Handler handler, Wraith_Vfs_Watch *out)Serves bytes at path, hiding any real file, until removed or the plugin goes.
Fails with VfsError.
putDir
Section titled “putDir”A virtual folder, so files the game makes in it are virtual too.
Fails with VfsError.
remove
Section titled “remove”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.
addWatch
Section titled “addWatch”Until it’s cancelled or the plugin goes.
Fails with VfsError. Uses Vfs.WatchOptions, Vfs.Handler, Vfs.Watch.
VfsError
Section titled “VfsError”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 |
Vfs.EventKind
Section titled “Vfs.EventKind”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 |
Vfs.Kinds
Section titled “Vfs.Kinds”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 |
Vfs.Denial
Section titled “Vfs.Denial”An enum of u8.
| Value | Name | |
|---|---|---|
| 0 | none |
|
| 1 | access_denied |
|
| 2 | not_found |
|
| 3 | sharing_violation |
|
| 4 | write_protected |
Vfs.WatchOptions
Section titled “Vfs.WatchOptions”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: numberpattern: stringloader: booleanqueries: booleankinds: integerpattern: stringloader: booleanqueries: booleanWraith.Vfs.Kinds Kindsstring Patternbool Loaderbool QueriesWraith::Vfs_Kinds kindssal::String patternbool loaderbool queriespub kinds: wraith::VfsKindspub pattern: salamander::Strpub loader: boolpub queries: boolkinds: Wraith.Vfs.Kindspattern: []const u8loader: boolqueries: boolWraith_Vfs_Kinds kindssal_string patternbool loaderbool queriesVfs.Event
Section titled “Vfs.Event”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.EventKindNamepath: stringrequested: stringfile: bigintread_access: booleanwrite_access: booleanvirtual: booleandirectory: booleanquery: booleanthread: numberoffset: bigintdata: Array<number>status: numberkind: Wraith.Vfs.EventKind|Wraith.Vfs.EventKindNamepath: stringrequested: stringfile: integerread_access: booleanwrite_access: booleanvirtual: booleandirectory: booleanquery: booleanthread: integeroffset: integerdata: (integer)[]status: integerWraith.Vfs.EventKind Kindstring Pathstring Requestedulong Filebool ReadAccessbool WriteAccessbool Virtualbool Directorybool Queryuint Threadlong Offsetbyte[] Datauint StatusWraith::Vfs_EventKind kindsal::String pathsal::String requesteduint64_t filebool read_accessbool write_accessbool virtual_bool directorybool queryuint32_t threadint64_t offsetsal::Slice<uint8_t> datauint32_t statuspub kind: wraith::VfsEventKindpub path: salamander::Strpub requested: salamander::Strpub file: u64pub read_access: boolpub write_access: boolpub r#virtual: boolpub directory: boolpub query: boolpub thread: u32pub offset: i64pub data: salamander::Slice<u8>pub status: u32kind: Wraith.Vfs.EventKindpath: []const u8requested: []const u8file: u64read_access: boolwrite_access: boolvirtual: booldirectory: boolquery: boolthread: u32offset: i64data: []const u8status: u32Wraith_Vfs_EventKind kindsal_string pathsal_string requesteduint64_t filebool read_accessbool write_accessbool virtualbool directorybool queryuint32_t threadint64_t offsetSlice_u8 datauint32_t statusVfs.Reply
Section titled “Vfs.Reply”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.DenialNameredirect: stringreplace: booleandata: Array<number>deny: Wraith.Vfs.Denial|Wraith.Vfs.DenialNameredirect: stringreplace: booleandata: (integer)[]Wraith.Vfs.Denial Denystring Redirectbool Replacebyte[] DataWraith::Vfs_Denial denysal::String redirectbool replacesal::Slice<uint8_t> datapub deny: wraith::VfsDenialpub redirect: salamander::Strpub replace: boolpub data: salamander::Slice<u8>deny: Wraith.Vfs.Denialredirect: []const u8replace: booldata: []const u8Wraith_Vfs_Denial denysal_string redirectbool replaceSlice_u8 dataVfs.Handler
Section titled “Vfs.Handler”On the thread doing the I/O, which waits for it.
Wraith.Vfs.HandlerWraith.Vfs.HandlerWraith.Vfs.HandlerWraith::Vfs_Handlerwraith::VfsHandlerWraith.Vfs.HandlerWraith_Vfs_Handlerwraith.io · Mods on the Hub · Get Wraith
Made with ♥ by Asgard
