When passing a managed byte[] array through PInvoke to be filled in by Win32, does it need to be pinned?

前端 未结 3 669
迷失自我
迷失自我 2020-12-03 02:40

Suppose you\'re calling a Win32 function that will fill in your byte array. You create an array of size 32, empty. Then pass it in to the Win32 function to be filled int, an

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-03 03:35

    Sorry to answer my own question but I believe if the type is blittable, as byte[] is, then the array would be pinned while being marshalled by the runtime, so no pinning would be needed. An object on the other time would be different. Please correct me if I'm wrong.

提交回复
热议问题