Esempio n. 1
0
            public void IputBoolean()
            {
                String sReg = l.lRegisters.Keys.First();

                // SKIP! TODO: Should not skip, actually. If it skips, something IS wrong
                if (!SmaliEngine.VM.vmStack.ContainsKey(sReg))
                {
                    Unimplemented();
                    return;
                }

                String sSrcValue = SmaliEngine.VM.Get(sReg);
                String sDstValue = l.aName;

                Dictionary <String, String> args = new Dictionary <String, String>();

                args[sReg] = sSrcValue;

                SmaliCall c = SmaliCall.Parse(sDstValue);

                SmaliEngine.VM.Buf = new StringBuilder();

                SmaliEngine.VM.Buf.AppendFormat("{0}{1} = {2};\n",
                                                (m.ParentClass.PackageName == c.ClassName && m.ParentClass.ClassName == c.Method ?
                                                 "this." :
                                                 (SmaliUtils.General.Name2Java(c.ClassName) + "." + c.Method + ".")),
                                                c.Variable,
                                                (sSrcValue == "0x1" ? "true" : "false")
                                                );

                //TODO: Well... todo. Lol.
                //Buffer.Append(ParseSmali(sDstValue, args));
            }
Esempio n. 2
0
            public void SputObject()
            {
                String sReg = l.lRegisters.Keys.First();

                // SKIP! TODO: Should not skip, actually. If it skips, something IS wrong
                if (!SmaliEngine.VM.vmStack.ContainsKey(sReg))
                {
                    Unimplemented();
                    return;
                }

                String sSrcValue = SmaliEngine.VM.Get(sReg);
                String sDstValue = l.lRegisters[sReg];

                Dictionary <String, String> args = new Dictionary <String, String>();

                args[sReg] = sSrcValue;

                SmaliCall c = SmaliCall.Parse(sDstValue);

                SmaliEngine.VM.Buf = new StringBuilder();

                SmaliEngine.VM.Buf.AppendFormat("{0}{1}{2} = {3};\n",
                                                c.Variable,
                                                m.ParentClass.PackageName == c.ClassName ? "" : (c.ClassName + "."),
                                                m.ParentClass.ClassName == c.Method ? "" : (c.Method + "."),
                                                sSrcValue
                                                );
            }
Esempio n. 3
0
 public void Method()
 {
     m.AccessModifiers        = l.AccessModifiers;
     m.NonAccessModifiers     = l.NonAccessModifiers;
     m.MethodCall             = SmaliCall.Parse(l.aExtra);
     SmaliEngine.VM._idxParam = 0;
 }
Esempio n. 4
0
            public void NewInstance()
            {
                SmaliCall     c  = SmaliCall.Parse(l.lRegisters[l.lRegisters.Keys.First()]);
                StringBuilder sb = new StringBuilder();

                sb.Append("new " + SmaliUtils.General.Name2Java(c.ClassName));
                sb.Append("." + c.Method + "()");
                SmaliEngine.VM.Put(l.lRegisters.Keys.First(), sb.ToString());
            }
Esempio n. 5
0
            public void Invoke() //TODO: Move this out into more generic functions?
            {
                String sReg = l.lRegisters.Keys.First();

                // SKIP! TODO: Should not skip, actually. If it skips, something IS wrong
                if (!SmaliEngine.VM.vmStack.ContainsKey(sReg))
                {
                    Unimplemented();
                    return;
                }

                SmaliCall c = SmaliCall.Parse(l.lRegisters[l.lRegisters.Keys.First()]);

                // It's a constructor, skip method name
                if ((c.CallFlags & SmaliCall.ECallFlags.Constructor) == SmaliCall.ECallFlags.Constructor)
                {
                    SmaliEngine.VM.Buf.Append(SmaliEngine.VM.Get(sReg));
                }
                else
                {
                    string regs = null;
                    try
                    {
                        regs = ParseRegistersAsArgs(l.lRegisters);
                    }
                    catch
                    {
                        Unimplemented();
                        return;
                    }
                    SmaliEngine.VM.Buf.AppendFormat("{0}({1});\n",
                                                    (m.ParentClass.PackageName == c.ClassName && m.ParentClass.ClassName == c.Method ?
                                                     "this." :
                                                     (SmaliUtils.General.Name2Java(c.ClassName) + "." + c.Method)),
                                                    regs
                                                    ); //We add this to the buffer one way or another, it just gets cleared if the next instruction is MoveResult.
                    //TODO: Maybe we should simply prepend the buffer with the variable for move result?
                    // We are actually returning something here, put this as the value of the last instruction to be acted on by move-result.
                    if (c.SmaliReturnType != SmaliLine.LineReturnType.Void)
                    {
                        SmaliEngine.VM.PutLastCall(c);
                        SmaliEngine.VM.PutLastRegisters(l.lRegisters);
                    }
                }
            }
Esempio n. 6
0
            public void SgetObject()
            {
                String    sReg      = l.lRegisters.Keys.First();
                String    sSrcValue = l.lRegisters[sReg];
                String    sDstValue = sReg;
                SmaliCall c         = SmaliCall.Parse(sSrcValue);
                string    prepend   = String.Empty;

                if (m.ParentClass.PackageName == c.ClassName && m.ParentClass.ClassName == c.Method)
                {
                    prepend = "this.";
                }
                else // I don't think sget-object should ever hit this?
                {
                    prepend = SmaliUtils.General.Name2Java(c.ClassName) + '.' + c.Method + '.';
                }
                SmaliEngine.VM.Put(sDstValue, prepend + c.Variable);
            }