✅ P/Invoke, changing values in a struct overwrites overwrites other values
Heyo!
I'm working on a P/Invoke library for libMPV and it has a way to send it structured data instead of just strings as commands, but I'm kind of stuck at the struct layout.
The root looks like this (it has a union so there is a bunch of values at offset 0)
To send commands I have to sent it a NodeList (in array or map/dictionary form, I'm using array here so the keys value is unused)
I'm calling it method via:
The struct in the header file looks like this:
https://github.com/mpv-player/mpv/blob/ce7997649816e4d6c05071fbd4ecac0557120720/libmpv/client.h#L750
And the method is here:
https://github.com/mpv-player/mpv/blob/ce7997649816e4d6c05071fbd4ecac0557120720/libmpv/client.h#L930
I noticed that the Format value in
Should
My results vary between getting
I'm working on a P/Invoke library for libMPV and it has a way to send it structured data instead of just strings as commands, but I'm kind of stuck at the struct layout.
The root looks like this (it has a union so there is a bunch of values at offset 0)
To send commands I have to sent it a NodeList (in array or map/dictionary form, I'm using array here so the keys value is unused)
I'm calling it method via:
The struct in the header file looks like this:
https://github.com/mpv-player/mpv/blob/ce7997649816e4d6c05071fbd4ecac0557120720/libmpv/client.h#L750
And the method is here:
https://github.com/mpv-player/mpv/blob/ce7997649816e4d6c05071fbd4ecac0557120720/libmpv/client.h#L930
I noticed that the Format value in
arrayNode changes when NodeListValue is set, so I believe some value has the wrong size and data in the struct gets overwritten? And thats probably what breaks it, I'd assume something is wrong with my struct, but I just cant seem to find what, I looked at other (C#) libraries but they either implement it the same as me afaik or just skip over that methodShould
NodeListValue just be an IntPtr or something like that?My results vary between getting
Invalid Parameter as error from the lib or outright corrupt memory exceptions

