Yes.
Next!
Marshaling is the process of "packaging" and "unpackaging" datatypes so they can be passed between managed (.NET) and unmanaged (native) code. That said, it's not trivial, and it's easy to get wrong with catastrophic results.
There is no "special code" that will work for all data in all circumstances - it has to be designed and organised so that it works in each specific case.
Start here:
https://msdn.microsoft.com/en-us/library/eaw10et3(v=vs.110).aspx[
^] And then try google - which has a lot of info on the subject.