Skip to content

Add managed string and array reads - #147

Open
ero-qt wants to merge 8 commits into
LiveSplit:masterfrom
ero-qt:managed-readers
Open

ero-qt wants to merge 8 commits into
LiveSplit:masterfrom
ero-qt:managed-readers

Conversation

@ero-qt

@ero-qt ero-qt commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Part of #149.

Adds read_string and read_array to both backends' Module. Without them, reading a System.String or a managed array is a fixed-size read at a memorized header offset, unchecked against the count and wrong at the other pointer width.

read_string reads the character count, then exactly that many UTF-16 characters. A count past the buffer, a negative count, and a null reference fail rather than truncate.

read_array does the same with the length, judged at pointer width before narrowing so a huge value cannot slip through as its low half. The element type is the caller's claim, like Process::read. Managed char is u16, and Rust char never matches.

Both take the address the reference is stored at and dereference at the module's own width, so 32-bit games need no special handling.

ArrayVec appears in a public signature for the first time. The crate already re-exports arrayvec.

cargo test --all-features runs the suite. The new tests cover strings and arrays on both runtimes, counts past the buffer, lengths at full width, and 32-bit targets.


Depends on #146.

@ero-qt
ero-qt force-pushed the managed-readers branch 4 times, most recently from 2e157c3 to 267a8b9 Compare September 14, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant