Esempio n. 1
0
        internal void ParseCode(DoABCTag doabc)
        {
            if (doabc.Strings.ContainsValue("CURRENT_VERSION"))
            {
            }
            try
            {
                while (_byteReader.LeftBytes > 0)
                {
                    byte __opcode = _byteReader.GetByte();
                    if (OpCodes.Exists(__opcode))
                    {
                        OpCode __OpCode     = OpCodes.GetOpCode(__opcode);
                        char[] __parameters = __OpCode.parameters.ToCharArray();
                        __OpCode.datas = new object[__parameters.Length];
                        for (int __i = 0; __i < __parameters.Length; __i++)
                        {
                            object data        = null;
                            char   __parameter = __parameters[__i];
                            if (__parameter == 'n') // generic integer
                            {
                                data = _byteReader.GetInt30();
                            }
                            else if (__parameter == '2') //multiname
                            {
                                data = doabc.Multinames[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'N') //namespace
                            {
                                data = doabc.Namespaces[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'U') //uint
                            {
                                data = doabc.UIntegers[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'I') //int
                            {
                                data = doabc.Integers[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'f') //double
                            {
                                data = doabc.Doubles[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'm') //method
                            {
                                data = doabc.MethodInfos[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'c') //classinfo
                            {
                                data = doabc.Classes[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'i') //methodbody
                            {
                                _byteReader.GetUInt30();
                                //data = array_getvalue(file->method_bodies, swf_GetU30(tag));
                            }
                            else if (__parameter == 'u') // generic uinteger
                            {
                                data = _byteReader.GetInt30();
                            }
                            else if (__parameter == 'r') // local register
                            {
                                data = _byteReader.GetInt30();
                            }
                            else if (__parameter == 'b') // byte
                            {
                                data = _byteReader.GetByte();
                            }
                            else if (__parameter == 'j') // jump
                            {
                                data = _byteReader.GetU24();
                            }
                            else if (__parameter == 's') // string
                            {
                                data = doabc.Strings[_byteReader.GetUInt30()];
                            }
                            else if (__parameter == 'D') // debug
                            {
                                /*type, usually 1*/
                                byte __type = _byteReader.GetByte();
                                if (__type != 1)
                                {
                                    //fprintf(stderr, "Unknown debug type: %02x\n", type);
                                }
                                /*register name*/
                                //code->data[0] = strdup((char*)pool_lookup_string(pool, swf_GetU30(tag)));
                                _byteReader.GetUInt30();
                                /*register index*/
                                //code->data[1] = (void*)(ptroff_t)swf_GetU8(tag);
                                _byteReader.GetByte();
                                /*unused*/
                                _byteReader.GetUInt30();
                            }
                            else if (__parameter == 'S') // switch statement
                            {
                                uint __def            = _byteReader.GetU24();
                                uint __targets_number = _byteReader.GetUInt30();
                                for (uint __j = 0; __j < __targets_number; __j++)
                                {
                                    uint __target = _byteReader.GetU24();
                                }

                                /*
                                 * lookupswitch_t* l = malloc(sizeof(lookupswitch_t));
                                 * l->def = (code_t*)(ptroff_t)swf_GetS24(tag);
                                 * l->targets = list_new();
                                 * int num = swf_GetU30(tag) + 1;
                                 * int t;
                                 * for (t = 0; t < num; t++)
                                 *  list_append(l->targets, (code_t*)(ptroff_t)swf_GetS24(tag));
                                 * data = l;
                                 * */
                            }
                            else
                            {
                                //printf("Can't parse opcode param type \"%c\" (for op %02x %s).\n", *p, code->opcode, op->name);
                                return;
                            }
                            __OpCode.datas[__i] = data;
                            //code->data[pos++] = data;
                        }
                        Codes.Add(__OpCode);
                    }
                    else
                    {
                    }
                }
                if (Codes.Count > 0 && doabc.Strings.ContainsValue("CURRENT_VERSION"))
                {
                    for (int __i = 0; __i < Codes.Count; __i++)
                    {
                        Console.WriteLine(__i.ToString("00000") + ")  " + Codes[__i].name);
                    }
                }
            }
            catch
            {
            }
        }