Ejemplo n.º 1
0
        private static unsafe int QueryContextChannelBinding_SECUR32(SafeDeleteContext phContext, ContextAttribute contextAttribute, Bindings *buffer, SafeFreeContextBufferChannelBinding refHandle)
        {
            int  num     = -2146893055;
            bool success = false;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                phContext.DangerousAddRef(ref success);
            }
            catch (Exception exception)
            {
                if (success)
                {
                    phContext.DangerousRelease();
                    success = false;
                }
                if (!(exception is ObjectDisposedException))
                {
                    throw;
                }
            }
            finally
            {
                if (success)
                {
                    num = UnsafeNclNativeMethods.SafeNetHandles_SECUR32.QueryContextAttributesA(ref phContext._handle, contextAttribute, (void *)buffer);
                    phContext.DangerousRelease();
                }
                if ((num == 0) && (refHandle != null))
                {
                    refHandle.Set(buffer.pBindings);
                    refHandle.size = buffer.BindingsLength;
                }
                if ((num != 0) && (refHandle != null))
                {
                    refHandle.SetHandleAsInvalid();
                }
            }
            return(num);
        }
        private unsafe static int QueryContextChannelBinding_SECURITY(SafeDeleteContext phContext, Interop.Secur32.ContextAttribute contextAttribute, Bindings *buffer, SafeFreeContextBufferChannelBinding refHandle)
        {
            int status = (int)Interop.SecurityStatus.InvalidHandle;

            // SCHANNEL only supports SECPKG_ATTR_ENDPOINT_BINDINGS and SECPKG_ATTR_UNIQUE_BINDINGS which
            // map to our enum ChannelBindingKind.Endpoint and ChannelBindingKind.Unique.
            if (contextAttribute != Interop.Secur32.ContextAttribute.EndpointBindings &&
                contextAttribute != Interop.Secur32.ContextAttribute.UniqueBindings)
            {
                return(status);
            }

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

            if (status == 0 && refHandle != null)
            {
                refHandle.Set((*buffer).pBindings);
                refHandle._size = (*buffer).BindingsLength;
            }

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

            return(status);
        }
Ejemplo n.º 3
0
        public static unsafe int QueryContextChannelBinding(SecurDll dll, SafeDeleteContext phContext, ContextAttribute contextAttribute, Bindings *buffer, SafeFreeContextBufferChannelBinding refHandle)
        {
            switch (dll)
            {
            case SecurDll.SECURITY:
                return(QueryContextChannelBinding_SECURITY(phContext, contextAttribute, buffer, refHandle));

            case SecurDll.SECUR32:
                return(QueryContextChannelBinding_SECUR32(phContext, contextAttribute, buffer, refHandle));

            case SecurDll.SCHANNEL:
                return(QueryContextChannelBinding_SCHANNEL(phContext, contextAttribute, buffer, refHandle));
            }
            return(-1);
        }
 public unsafe static int QueryContextChannelBinding(SafeDeleteContext phContext, Interop.Secur32.ContextAttribute contextAttribute, Bindings *buffer, SafeFreeContextBufferChannelBinding refHandle)
 {
     return(QueryContextChannelBinding_SECURITY(phContext, contextAttribute, buffer, refHandle));
 }