Add JSON string dump C binding and avoid function lookup panic - #15
Merged
Conversation
samyycX
marked this pull request as ready for review
August 8, 2026 10:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
S2BinLib::dump_strings_to_jsonto rescan a loaded binary and write printable ASCII strings as a deterministic pretty-printed JSON object mapping string values to RVAs.s2binlib_dump_strings_to_json(binary_name, output_path), including UTF-8/null validation, automatic binary loading, error-code propagation, the static header declaration, and a README example.find_func_start_rvawith safe optional handling. It now falls back to the xref-derived function start and returns an error when neither source has a candidate.Why
The existing string dumper only populated an in-memory cache, so C consumers could not persist the result. The function-start lookup also unconditionally unwrapped an optional vtable candidate, which could panic when a function was discoverable only through xrefs or when no candidate existed.
Impact
C callers can now write all discovered printable ASCII strings for a binary to a caller-selected JSON path with:
Function-start lookup now fails through the existing
Result/C error-code path instead of panicking.Validation
cargo test -p s2binlib s2binlib::tests::— 3 passedcargo check --workspace— passed (existing warnings remain)cargo build -p s2binlib_binding— passeds2binlib_dump_strings_to_jsonis exported from the generated Windows DLL withdumpbin /exportsThe repository's full pre-existing unit suite still has three unrelated failures:
test_find_vtabledepends onF:/cs2server/..., and two Windows JIT tests fail while restoring memory protection.