If I marshal this struct with StructureToPtr and then unmarshal it again with PtrToStructure, my first node has y = {1,2} whilst my second node has
StructureToPtr
PtrToStructure
You should also pack the struct or class before you use it. That works for me, almost as good as memcpy
[StructLayout(LayoutKind.Sequential, Pack = 1)] public class SomeClass { }