public static IList<SecurityPackageInfo> Enumerate()
 {
     var ptr = new IntPtr();
     try
     {
         var count = 0;
         var status = NativeMethods.EnumerateSecurityPackages(ref count, ref ptr);
         if (status != 0)
             throw Win32Exception.Create(status, "Failed to get enumerate packages.");
         return ptr.ToEnumerable<SecurityPackageInfo>(count).ToArray();
     }
     finally
     {
         if (ptr != IntPtr.Zero)
             NativeMethods.FreeContextBuffer(ptr);
     }
 }