System.Net.Security.SafeSspiAuthDataHandle.SafeFreeContextBuffer.SafeFreeContextBuffer.QueryContextAttributes_SECURITY C# (CSharp) Method

QueryContextAttributes_SECURITY() private static method

private static QueryContextAttributes_SECURITY ( System.Net.Security.SafeDeleteContext phContext, Interop contextAttribute, byte buffer, SafeHandle refHandle ) : int
phContext System.Net.Security.SafeDeleteContext
contextAttribute Interop
buffer byte
refHandle System.Runtime.InteropServices.SafeHandle
return int
        private unsafe static int QueryContextAttributes_SECURITY(
            SafeDeleteContext phContext,
            Interop.SspiCli.ContextAttribute contextAttribute,
            byte* buffer,
            SafeHandle refHandle)
        {
            int status = (int)Interop.SECURITY_STATUS.InvalidHandle;

            try
            {
                bool ignore = false;
                phContext.DangerousAddRef(ref ignore);
                status = Interop.SspiCli.QueryContextAttributesW(ref phContext._handle, contextAttribute, buffer);
            }
            finally
            {
                phContext.DangerousRelease();
            }

            if (status == 0 && refHandle != null)
            {
                if (refHandle is SafeFreeContextBuffer)
                {
                    ((SafeFreeContextBuffer)refHandle).Set(*(IntPtr*)buffer);
                }
                else
                {
                    ((SafeFreeCertContext)refHandle).Set(*(IntPtr*)buffer);
                }
            }

            if (status != 0 && refHandle != null)
            {
                refHandle.SetHandleAsInvalid();
            }

            return status;
        }