PInvoke question

  • Thread starter Thread starter shankgreen
  • Start date Start date
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?
 
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
 
Back
Top