PInvoke question

S

shankgreen

My question is related to what happens under the hood when marshalling
happens.
When you pass a pointer to a structure from managed to unmanaged, and
if the unmanaged code modified the structure, is the structure copied
from the stack to unmanaged heap and then back or is it modified in
the stack itself.

If it is modifed within the stack itself, what about a managed
structure which has an array reference inside?
 
M

Mattias Sjögren

When you pass a pointer to a structure from managed to unmanaged, and
if the unmanaged code modified the structure, is the structure copied
from the stack to unmanaged heap and then back or is it modified in
the stack itself.

It depends on whether or not the type is "blittable" (ie if it only
contains types that have the same representation on the managed and
native side or not). This page in the docs provide a pretty good
overview

http://msdn2.microsoft.com/en-us/library/23acw07k(VS.80).aspx


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top