Example #1
0
        /// <summary>
        /// Get buffers from buffer pointer.
        /// </summary>
        /// <returns>SecBuffers contained in SecBufferDesc</returns>
        internal        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);
        }
Example #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="secBuffers">SecBuffer array</param>
        internal 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);
                }
            }
        }
        internal 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>
        internal SecurityBufferDesc(params SecurityBuffer[] secBuffers)
        {
            this.ulVersion = NativeMethods.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);
                }
            }
        }