Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return PCode slice contains the same value for each element due to ZSTs #1

Open
chc4 opened this issue Oct 20, 2024 · 0 comments
Open

Comments

@chc4
Copy link

chc4 commented Oct 20, 2024

RustPCodeEmitProxy::dump passes the slice start pointer and length to Rust, which converts it into a slice with vars: &[sleigh_sys::ffi::VarnodeData]. The VarnodeData type is declared as a zero-sized type for cxx FFI, however, and not a struct of the same size as what the C++ side has: this means that when you loop over the slice in Rust, each element is actually the start pointer length times, since it advances by 0 each time. This is visible in black-binary/sleigh#1 for example, where each varnode for the store operation is the address space varnode instead of [address space, pointer, data] like it should be.

I have a fork where I fixed the issue by having the C++ layer return a vars: &[&sleigh_sys::ffi::VarnodeData] instead, since advancing by pointer size is fine and allows it to continue using a ZST FFI type. It's mixed in with other things I added when messing around, however, and needs to be pulled out individually: chc4@498daa1 chc4/sleigh@3011940

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

No branches or pull requests

1 participant