Пример #1
0
        protected void RemoveHostSuffix(ABCFile abc, ASMethod connectMethod)
        {
            using (var inCode = new FlashReader(connectMethod.Body.Bytecode))
                using (var outCode = new FlashWriter(inCode.Length))
                {
                    int ifNeCount = 0;
                    while (inCode.Position != inCode.Length)
                    {
                        OPCode op = inCode.ReadOP();
                        outCode.WriteOP(op);
                        if (op == OPCode.IfNe && ++ifNeCount == 2)
                        {
                            var iFNeJumpCount = (int)inCode.ReadS24();
                            outCode.WriteS24(iFNeJumpCount + 6);
                            continue;
                        }
                        else if (op != OPCode.PushInt)
                        {
                            continue;
                        }

                        int pushIntIndex = inCode.Read7BitEncodedInt();
                        int integerValue = abc.Constants.Integers[pushIntIndex];
                        switch (integerValue)
                        {
                        case 65244:
                        case 65185:
                        case 65191:
                        case 65189:
                        case 65188:
                        case 65174:
                        case 65238:
                        case 65184:
                        case 65171:
                        case 65172:
                        {
                            pushIntIndex = abc.Constants.AddInteger(65290);
                            break;
                        }
                        }
                        outCode.Write7BitEncodedInt(pushIntIndex);
                    }
                    connectMethod.Body.Bytecode = outCode.ToArray();
                }
            RemoveDeadFalseConditions(connectMethod.Body);
        }
Пример #2
0
 protected void RemoveDeadFalseConditions(ASMethodBody body)
 {
     using (var inCode = new FlashReader(body.Bytecode))
         using (var outCode = new FlashWriter(inCode.Length))
         {
             while (inCode.Position != inCode.Length)
             {
                 OPCode op = inCode.ReadOP();
                 if (op != OPCode.PushFalse)
                 {
                     outCode.WriteOP(op);
                     continue;
                 }
                 op = inCode.ReadOP();
                 if (op != OPCode.PushFalse)
                 {
                     outCode.WriteOP(OPCode.PushFalse);
                     outCode.WriteOP(op);
                     continue;
                 }
                 op = inCode.ReadOP();
                 if (op != OPCode.IfNe)
                 {
                     outCode.WriteOP(OPCode.PushFalse);
                     outCode.WriteOP(OPCode.PushFalse);
                     outCode.WriteOP(op);
                     continue;
                 }
                 else
                 {
                     inCode.ReadS24();
                 }
             }
             body.Bytecode = outCode.ToArray();
         }
 }