public void Find()
        {
            var requiredTypes = new string[] {
                "System.Reflection.Assembly",
                "System.Object",
                "System.Int32",
                "System.String[]",
            };

            foreach (var type in module.Types)
            {
                if (type.HasEvents)
                {
                    continue;
                }
                if (!new FieldTypes(type).All(requiredTypes))
                {
                    continue;
                }

                MethodDef regMethod, handler;
                if (!BabelUtils.FindRegisterMethod(type, out regMethod, out handler))
                {
                    continue;
                }

                var resource = BabelUtils.FindEmbeddedResource(module, type);
                if (resource == null)
                {
                    continue;
                }

                var decryptMethod = FindDecryptMethod(type);
                if (decryptMethod == null)
                {
                    throw new ApplicationException("Couldn't find resource type decrypt method");
                }
                resourceDecrypter.DecryptMethod = ResourceDecrypter.FindDecrypterMethod(decryptMethod);
                InitXorKeys(decryptMethod);

                resolverType      = type;
                registerMethod    = regMethod;
                encryptedResource = resource;
                return;
            }
        }
Esempio n. 2
0
        public void Find()
        {
            var requiredTypes = new string[] {
                "System.Object",
                "System.Int32",
                "System.Collections.Hashtable",
            };

            foreach (var type in module.Types)
            {
                if (type.HasEvents)
                {
                    continue;
                }
                if (!new FieldTypes(type).Exactly(requiredTypes))
                {
                    continue;
                }

                MethodDef regMethod, handler;
                if (!BabelUtils.FindRegisterMethod(type, out regMethod, out handler))
                {
                    continue;
                }

                var decryptMethod = FindDecryptMethod(type);
                if (decryptMethod == null)
                {
                    throw new ApplicationException("Couldn't find resource type decrypt method");
                }
                resourceDecrypter.DecryptMethod = ResourceDecrypter.FindDecrypterMethod(decryptMethod);

                resolverType   = type;
                registerMethod = regMethod;
                return;
            }
        }