title: Marshal Unmanaged Unicode String in COM Task Allocator Memory to SecureString
body: <p>I an working with API calls to <code>advapi32.dll</code> for managing Windows Saved Credentials in order to automate certain windows applications which can use saved credentials, which is working fine.</p>
  
  <p>I am trying to update my code to use <code>SecureString</code> for password throughout, as I have no need to interact with the text contained in passwords at any point so it should be more secure if my application never holds the password in plain text.</p>
  
  <p>I am able to marshal a SecureString to COM task allocator memory to pass to the API calls with:</p>
  
  <pre><code>var unmanagedPassword = Marshal.SecureStringToCoTaskMemUnicode(userCredential.Password);
  </code></pre>
  
  <p>However, when it comes to reading that information back into the application, I cannot find a way to marshal such an unmanaged string back into a <code>SecureString</code> without copying the string into managed memory, be it as a string or byte array.</p>
  
  <p>Is there a safe way to do this that I am overlooking?</p>