I'm having some trouble with this code:
//Creating a new ImageElement Struct
ImageElement oElement = new UM0516.ImageElement();
//Create a pointer and allocate enough room for the struct type
IntPtr pElement = Marshal.AllocHGlobal(Marshal.SizeOf(new UM0516.ImageElement()));
//Copy the contents of the struct into the allocated memory space
Marshal.StructureToPtr(oElement, pElement, true);
//Function that takes a file pointed to by handle, and does some sweet sweet things
//And returns a loaded struct pointed to by pElement
FILES_GetImageElement(handle, el, out pElement);
Here is where I get confused: I'll step through the code, and after I call that last function (which should change some bits in memory pointed to by pElement), I see a change to oElement!? I thought the Marshal.StructureToPtr "copies" data from a managed struct to memory. So are the two locations actually the same? Managed struct oElement and allocated memory pointed to by pElement?