I am writing a wrapper on C # for a static C ++ library. Not familiar with C ++. In an unsafe context, a pointer to byte [] is returned in a parameter of type void *. How to get this array for further processing in C #? (This is the text that needs to be converted from ANSI to Unicode). Thanks in advance.
Prototype:
MPFUN int MPAPI SignBufferEx(void **out_buf, int *out_len);
Call in a running C ++ program:
void* buf = NULL; SignBufferEx(&buf, &ln);
Call in my:
[DllImport(pathdll)] public static unsafe extern int SignBufferEx(void** out_buf, int* out_len)
Added code, but it returns not what is expected: (
var buffor = new byte[ln]; var pBuffor = (byte*) buf; for (var i = 0; i < ln; i++) { buffor[i] = *(pBuffor+i); } Encoding textEnc = new UnicodeEncoding(); Console.Out.WriteLine("textEnc.GetString(buf) = {0}", textEnc.GetString(buffor)); sign = textEnc.GetString(buffor);