internal IntPtr ConvertPinnedSendPayloadToNative(byte[] buffer, int offset, int count)
{
if (!IsPinnedSendPayloadBuffer(buffer, offset, count))
{
// Indicates a violation in the API contract that could indicate
// memory corruption because the pinned sendbuffer is shared between managed and native code
throw new AccessViolationException();
}
Debug.Assert(Marshal.UnsafeAddrOfPinnedArrayElement(_pinnedSendBuffer.Array,
_pinnedSendBuffer.Offset).ToInt64() == _pinnedSendBufferStartAddress,
"'m_PinnedSendBuffer.Array' MUST be pinned during the entire send operation.");
return new IntPtr(_pinnedSendBufferStartAddress + offset - _pinnedSendBuffer.Offset);
}