Some events include one or more parameters intended for use as a binary data buffer. Depending on the event, these parameters may contain data when the event is fired, or it may be expected that the application populates them with the desired amount of data during the event handler. Some events combine both paradigms, and expect the application to modify the data already present when the event is fired.
The documentation for such events will describe which of the above cases applies to each buffer parameters. Note that, in all cases, buffer parameters point to a pre-allocated block of unmanaged memory, the size of which is specified by the parameter immediately following the buffer parameter. In cases where data is to be written, be sure to write it directly to the pointed-to memory, don't change the value of the buffer parameter itself.
Buffer parameters are always of the IntPtr type; use the .NET Marshal.Copy() method to read and write data from and to the unmanaged memory region. When targeting newer .NET versions, such as .NET Standard 2.1 and later, applications can use the Span<T> and ReadOnlySpan<T> classes to access and modify the unmanaged memory region without extra data copying.