private static int HeaderDelegate(IntPtr buf, int sz, int nmemb,
IntPtr parm)
{
int bytes = sz * nmemb;
byte[] b = new byte[bytes];
for (int i = 0; i < bytes; i++)
b[i] = Marshal.ReadByte(buf, i);
GCHandle gch = (GCHandle)parm;
Easy easy = (Easy)gch.Target;
if (easy == null)
return 0;
if (easy.m_pfHeader == null)
return bytes; // keep going
return easy.m_pfHeader(b, sz, nmemb, easy.m_headerData);
}