コード例 #1
0
        /// <summary>
        /// Construct a PositionTranslator.
        /// </summary>
        /// <param name="randomInts">Random integers used in translation</param>
        public PositionTranslator(CryptoStreamDef streamType, UInt32[] randomInts)
        {
            if (randomInts == null)
            {
                throw new ArgumentNullException();
            }

            if (randomInts.Length != 5)
            {
                throw new Exception("Integer array must have a length of 5");
            }

            _randomInts = randomInts;
            _streamType = streamType;
        }
コード例 #2
0
ファイル: EazModule.cs プロジェクト: xuan2261/eazdevirt
        /// <summary>
        /// Try and find the type used for crypto streams.
        /// </summary>
        /// <returns>Crypto stream TypeDef, or null if none found</returns>
        public CryptoStreamDef FindCryptoStreamType()
        {
            foreach (var typeDef in this.Module.Types.Where(type =>
                                                            type.BaseType != null &&
                                                            type.BaseType.FullName.Equals(typeof(System.IO.Stream).FullName)))
            {
                if (CryptoStreamDefV2.Is(typeDef))
                {
                    return(new CryptoStreamDefV2(typeDef));
                }
                else if (CryptoStreamDef.Is(typeDef))
                {
                    return(new CryptoStreamDef(typeDef));
                }
            }

            return(null);
        }
コード例 #3
0
        /// <summary>
        /// Try and find the type used for crypto streams.
        /// </summary>
        /// <returns>Crypto stream TypeDef, or null if none found</returns>
        public CryptoStreamDef FindCryptoStreamType()
        {
            foreach (TypeDef type in Module.Types)
            {
                if (!type.HasMethods)
                {
                    continue;
                }
                foreach (MethodDef method in type.Methods)
                {
                    if (!method.HasBody || !method.Body.HasInstructions)
                    {
                        continue;
                    }
                    foreach (Instruction instruction in method.Body.Instructions)
                    {
                        if (instruction.OpCode == OpCodes.Callvirt && ((IMethod)instruction.Operand).Name == "get_CanRead")
                        {
                            return(new CryptoStreamDefV2(type));
                        }
                    }
                }
            }

            foreach (var typeDef in this.Module.Types.Where(type =>
                                                            type.BaseType != null &&
                                                            type.BaseType.FullName.Equals(typeof(System.IO.Stream).FullName)))
            {
                if (CryptoStreamDefV2.Is(typeDef))
                {
                    return(new CryptoStreamDefV2(typeDef));
                }
                else if (CryptoStreamDef.Is(typeDef))
                {
                    return(new CryptoStreamDef(typeDef));
                }
            }

            return(null);
        }
コード例 #4
0
ファイル: EazModule.cs プロジェクト: tralivali1234/eazdevirt
        /// <summary>
        /// Try and find the type used for crypto streams.
        /// </summary>
        /// <returns>Crypto stream TypeDef, or null if none found</returns>
        public CryptoStreamDef FindCryptoStreamType()
        {
            var typeDef = this.Module.Types.FirstOrDefault(type =>
                                                           type.BaseType != null &&
                                                           type.BaseType.FullName.Equals(typeof(System.IO.Stream).FullName));

            if (typeDef == null)
            {
                return(null);
            }

            if (CryptoStreamDefV2.Is(typeDef))
            {
                return(new CryptoStreamDefV2(typeDef));
            }
            else if (CryptoStreamDef.Is(typeDef))
            {
                return(new CryptoStreamDef(typeDef));
            }
            else
            {
                return(null);
            }
        }
コード例 #5
0
 /// <summary>
 /// Construct a PositionTranslator with the default random integers.
 /// </summary>
 /// <param name="streamType">Crypto stream type definition</param>
 public PositionTranslator(CryptoStreamDef streamType)
     : this(streamType, DefaultPseudoRandomInts)
 {
 }