Moving BSTR conv to native code in SecureStringToBSTR.
authorHenric Müller <hemuller@microsoft.com>
Fri, 10 Jun 2016 12:33:17 +0000 (14:33 +0200)
committerHenric Müller <hemuller@microsoft.com>
Tue, 9 Aug 2016 12:09:32 +0000 (14:09 +0200)
commitc5cdfaec1e0973ced3f97ef589cd0bece56067ad
tree1abb610546fbd34ce79daa50a719f1278391a453
parentfdd84f680e7cbe00daa110dba1ef4b7232628000
Moving BSTR conv to native code in SecureStringToBSTR.

Previous implementation laid out the BSTR structure
in directly memory in C# code. This layout was not correct
for windows.
Furthermore memory was allocated using AllocCoTaskMem but later freed
using SysFreeString which on windows are different memory areas.
Third issue is that SecureString asumes big-endian when copying the chars
to its internal byte buffer. So on little-endian environments,
a swap of bytes is needed before the buffer is sent to native side
for BSTR conversion. This should probably be handled internally in
SecureString instead.
mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
mono/metadata/cominterop.c
mono/metadata/icall-def.h
mono/metadata/marshal.h