Beef
Beef copied to clipboard
(aarch64) Beef receives wrong values from C++ returning struct by value
(Bug encountered on aarch64 Switch build)
I have this struct ABIStr that is defined as such:

If I call a C++ API function on the C++ side, the struct is returned as such:

length = 0x00000008
size = 0x40000000
ptr = 0x00000000087253ad "TEST_KEY"
If I call the same function from Beef, the calling frame receives the struct as such:

length = 0x00000008
size = 0x0875aeec
ptr = 0x00000010112e5750 "[invalid string]"
Expected:
length = 0x00000008
size = 0x40000000
ptr = 0x000000000875aeec "TEST_KEY"
It looks like the return value's size field is being dropped, and the first 4 bytes of its ptr are ending up in the receiver's size. Then receiver's ptr is just ending up with garbage data