예제 #1
0
        bool IsEmptyClass(MethodDef emptyMethod)
        {
            if (!DotNetUtils.IsEmptyObfuscated(emptyMethod))
            {
                return(false);
            }

            var type = emptyMethod.DeclaringType;

            if (type.HasEvents || type.HasProperties)
            {
                return(false);
            }
            if (type.Fields.Count != 1)
            {
                return(false);
            }
            if (type.Fields[0].FieldType.FullName != "System.Boolean")
            {
                return(false);
            }
            if (type.IsPublic)
            {
                return(false);
            }

            int otherMethods = 0;

            foreach (var method in type.Methods)
            {
                if (method.Name == ".ctor" || method.Name == ".cctor")
                {
                    continue;
                }
                if (method == emptyMethod)
                {
                    continue;
                }
                otherMethods++;
                if (method.Body == null)
                {
                    return(false);
                }
                if (method.Body.Instructions.Count > 20)
                {
                    return(false);
                }
            }
            if (otherMethods > 8)
            {
                return(false);
            }

            return(true);
        }