Beef icon indicating copy to clipboard operation
Beef copied to clipboard

(aarch64) Beef receives wrong values from C++ returning struct by value

Open hunterbridges opened this issue 3 years ago • 0 comments

(Bug encountered on aarch64 Switch build)

I have this struct ABIStr that is defined as such: image


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

length = 0x00000008 size = 0x40000000 ptr = 0x00000000087253ad "TEST_KEY"


If I call the same function from Beef, the calling frame receives the struct as such: image

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

hunterbridges avatar Sep 10 '22 19:09 hunterbridges