6

I've been looking through the Marshal class, but I can't seem to find a method that allows me to copy from an unmanaged array (IntPtr) to another unmanaged array (IntPtr).

Is this possible using .NET?

2 Answers 2

3

You can also DllImport RtlMoveMemory to get the job done:

[DllImport("Kernel32.dll", EntryPoint="RtlMoveMemory", SetLastError=false)]
static extern void MoveMemory(IntPtr dest, IntPtr src, int size);

This will also require FullTrust, however, but as you are working with unmanaged code, I'd expect you already have it.

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

Comments

-1

You can revert to using unsafe code in C#, if that is an option (typically requires FullTrust permission, which may not be available in all cases).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.