public SspiSecurityBuffer[] GetBuffers() { SspiSecurityBuffer[] securityBuffers = new SspiSecurityBuffer[this.cBuffers]; int bufferLength = Marshal.SizeOf(typeof(SspiSecurityBuffer)); for (int i = 0; i < this.cBuffers; i++) { securityBuffers[i] = (SspiSecurityBuffer)Marshal.PtrToStructure( new IntPtr(this.pBuffers.ToInt64() + bufferLength * i), typeof(SspiSecurityBuffer)); } return(securityBuffers); }
/// <summary> /// Constructor /// </summary> /// <param name="secBuffers">SecBuffer array</param> public SecurityBufferDesc(params SecurityBuffer[] secBuffers) { this.ulVersion = Consts.SECBUFFER_VERSION; this.cBuffers = 0; this.pBuffers = IntPtr.Zero; if (secBuffers != null && secBuffers.Length != 0) { this.cBuffers = secBuffers.Length; int bufferLength = Marshal.SizeOf(typeof(SspiSecurityBuffer)); this.pBuffers = Marshal.AllocHGlobal(bufferLength * this.cBuffers); for (int i = 0; i < secBuffers.Length; i++) { SspiSecurityBuffer sspiSecurityBuffer = new SspiSecurityBuffer(secBuffers[i]); IntPtr pBuffer = new IntPtr(pBuffers.ToInt64() + bufferLength * i); Marshal.StructureToPtr(sspiSecurityBuffer, pBuffer, false); } } }