Mega Code Archive

 
Categories / C# / Security
 

Marshal Str

using System; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; using System.Collections.Generic; public static class Utilities {     public unsafe static string MarshalStr(IntPtr p)     {         // instead of          // System.Runtime.InteropServices.Marshal.PtrToStringAuto(p)         sbyte* ps = (sbyte*)p;         int size = 0;         for (; ps[size] != 0; ++size)             ;         return new String(ps, 0, size);     } }