Example #1
0
        void CreateMethod(string methodBody)
        {
            var method = new SmaliMethod(this);

            method.Parse(methodBody);

            Methods.Add(method);
        }
        public bool IsMethodAdequate(SmaliMethod method)
        {
            if (method.MethodName != MethodName)
            {
                return(false);
            }

            if (IsStatic.HasValue)
            {
                return(method.IsStatic == IsStatic);
            }

            return(true);
        }
        public MethodToHook(SmaliAnnotation annot, SmaliMethod interceptor)
        {
            TargetClass  = annot.Properties["clazz"].Trim();
            TargetMethod = annot.Properties["method"].Trim();
            Interceptor  = interceptor;

            TargetClassFormatted = string.Format("L{0};", TargetClass.Replace('.', '/'));

            string[] split = TargetMethod.Split(' ');

            string when = split[0].Trim();

            if (when == "after")
            {
                HookAfter = true;
            }
            else if (when == "before")
            {
                HookBefore = true;
            }
            else
            {
                throw new Exception("Not specified when to hook method");
            }

            if (split.Length >= 3)
            {
                if (split[1].Trim() == "static")
                {
                    IsStatic = true;
                }
                else if (split[1].Trim() == "nostatic")
                {
                    IsStatic = false;
                }
            }

            string signature = split[split.Length - 1].Trim();

            int firstParenthesis = signature.IndexOf('(');

            if (firstParenthesis >= 0)
            {
            }
            else
            {
                MethodName = signature;
            }
        }