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)); }
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); } }
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"); } }
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); }