int internal_OnWriteCallback(IntPtr ptrBuffer, int sz, int nmemb, IntPtr ptrUserdata) { if (_OnWriteCallback != null) { int bytes = sz * nmemb; byte[] b = new byte[bytes]; Marshal.Copy(ptrBuffer, b, 0, bytes); object userdata = GetObject(ptrUserdata); return _OnWriteCallback(b, bytes, userdata); } return 0; }