wow, perfect.
Just found a note, that it is not allowed to store data pointers in RLP domain, cause the GC will rearrange the memory.
But as there is a possibility to pin down some memory area, I can do as I done before, ring-buffer and here we go. Same as your solution, only with the ability to have more than one buffer, if needed.
@ Gerhard - if you use the InvokeEx method to call a native function, and pass the buffer as the first parameter, the buffer will be passed as a pointer, and not copied. This pointer will still be valid after the native function returns control to managed code. This only works if the managed buffer is allocated as a static byte buffer.
Static variables are not garbage collected in .Net.
@ Gus - No, I’m not 100% sure. I’ve not been able to find a definitive answer from Microsoft. However, I did find other sources that seem to confirm that this is true, and I tested my RLP music driver for many hours, and never encountered an error due to the buffer being moved.