1

I have an IntPtr (c#) given from unmanaged code. I know that this is an reference to an Byte Array with 4096 elements.

Now i want to CONVERT these data from IntPtr to Byte[] WITHOUT Marshal.Copy. Because the memory in kernel space is already allocated. I only want to interprete those data as an byte array.

I know that there a function "InteropUtils.ConvertIntPtrToByteArray-Methode" but it is only available for smart Devices etc.

Maybe somebody had an better idea?

2

1 Answer 1

0

What you asked is not possible because an IntPtr represents an unmanaged memory region, while a byte[] array represents a managed memory region. It is not possible to treat an unmanaged region as a managed one.

You must either copy the data to a managed region (through Marshal.Copy), or use an unsafe code to manipulate it directly.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.