The easiest way to pass an array of bytes is to declare the parameter in your import statement as a byte array.
[DllImport EntryPoint="func" CharSet=CharSet.Auto, SetLastError=true]
public extern static void Func(byte[]);
byte[] ar = new byte[1000];
Func(ar);
You should also be able to declare the parameter as an IntPtr and Marshal the data manually.
[DllImport EntryPoint="func" CharSet=CharSet.Auto, SetLastError=true]
public extern static void Func(IntPtr p);
byte[] ar = new byte[1000];
IntPtr p = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(byte)) * ar.Length);
Marshal.Copy(ar, 0, p, ar.Length);
Func(p);
Marshal.FreeHGlobal(p);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…