Beispiel #1
0
        static int ByteArrayCompare(byte[] b1, byte[] b2)
        {
            if (b1.Length > b2.Length)
            {
                return(1);
            }
            else if (b1.Length < b2.Length)
            {
                return(-1);
            }

            return(Msvcrt.memcmp(b1, b2, b1.Length));
        }
Beispiel #2
0
        bool IsTransparentOrTruncatedFrame(byte[] buffer)
        {
            if (_videoBuffer.Length != _zeroBuffer.Length)
            {
                return(true);
            }

            // First check first 100 bytes - assuming that in most cases they will not be transparent
            // and therefore this will avoid having to check the entire frame
            if (IsStartTransparent(buffer, 100))
            {
                // If start is transparent compare the whole frame using P/invoke for performance
                // We don't check the length as we already know that it is equal
                return(Msvcrt.memcmp(buffer, _zeroBuffer, buffer.Length) == 0);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        public static void Initialize()
        {
            var baseHandler = Kernel32.AddVectoredExceptionHandler(IntPtr.Zero, BaseHandler);

            if (baseHandler == IntPtr.Zero)
            {
                throw new Win32Exception("AddVectoredExceptionHandler failed");
            }

            var size = 32768;

            if (!Kernel32.SetThreadStackGuarantee(&size))
            {
                throw new InsufficientExecutionStackException("SetThreadStackGuarantee failed", new Win32Exception());
            }

            if (Msvcrt._resetstkoflw() == 0)
            {
                throw new InvalidOperationException("_resetstkoflw failed");
            }
        }
Beispiel #4
0
 public bool Equals(PinnedKey other)
 {
     if (other == null)
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     if (Algorithm != other.Algorithm)
     {
         return(false);
     }
     if (Fingerprint.Length != other.Fingerprint.Length)
     {
         return(false);
     }
     if (Msvcrt.memcmp(Fingerprint, other.Fingerprint, (UIntPtr)Fingerprint.Length) != 0)
     {
         return(false);
     }
     return(true);
 }