Exemplo n.º 1
0
        void CreateAnnotation(string annotationBody)
        {
            var annot = new SmaliAnnotation();

            annot.Parse(annotationBody);

            if (annot.AnnotationType == "Lcom/xquadplaystatic/Hook;")
            {
                Program.RegisterMethodToHook(new MethodToHook(annot, this));
            }

            Annotations.Add(annot);
        }
Exemplo n.º 2
0
        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;
            }
        }