예제 #1
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 (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);
        }
예제 #2
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);
        }
예제 #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()
        {
            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);
            }
        }