コード例 #1
0
        protected internal override Cell ReadCellPayload(DexFile file, UInt32 rowIndex, Column column, Cell[] cells, ref UInt32 offset)
        {
            Cell result;

            Tables.encoded_catch_handler_row.columns colIdx = (Tables.encoded_catch_handler_row.columns)column.Index;
            switch (colIdx)
            {
            case Tables.encoded_catch_handler_row.columns.handlers:
                Int32    handler_size = (Int32)cells[(UInt32)Tables.encoded_catch_handler_row.columns.size].Value;
                UInt32[] indexes      = file.GetSectionTable(TableType.encoded_type_addr_pair).ReadInnerSection(file, ref offset, (UInt32)Math.Abs(handler_size));
                result = new Cell(column, (UInt32)indexes.Length, indexes);
                break;

            case Tables.encoded_catch_handler_row.columns.catch_all_addr:
                Int32 handler_size1 = (Int32)cells[(UInt32)Tables.encoded_catch_handler_row.columns.size].Value;
                if (handler_size1 <= 0)
                {
                    Int32 catch_add_addr = file.ReadULeb128(ref offset);
                    result = new Cell(column, (UInt32)catch_add_addr, (UInt32)catch_add_addr);
                }
                else
                {
                    result = new Cell(column, 0, null);
                }
                break;

            default:
                result = base.ReadCellPayload(file, rowIndex, column, cells, ref offset);
                break;
            }

            return(result);
        }
コード例 #2
0
        protected internal override Cell ReadCellPayload(DexFile file, UInt32 rowIndex, Column column, Cell[] cells, ref uint offset)
        {
            Cell result;

            switch ((code_row.columns)column.Index)
            {
            case code_row.columns.tries:
                UInt32   tries_size = cells[(UInt32)code_row.columns.tries_size].RawValue;
                UInt32[] indexes    = file.GetSectionTable(TableType.try_item).ReadInnerSection(file, ref offset, tries_size);
                result = new Cell(column, tries_size, indexes);
                break;

            case code_row.columns.handlers:
                UInt32 tries_size1 = cells[(UInt32)code_row.columns.tries_size].RawValue;
                if (tries_size1 > 0)
                {
                    Int32    handler_list_size = file.ReadULeb128(ref offset);
                    UInt32[] indexes1          = file.GetSectionTable(TableType.encoded_catch_handler_list).ReadInnerSection(file, ref offset, (UInt32)handler_list_size);

                    UInt32 p       = (UInt32)sizeof(UInt32);
                    UInt32 padding = ((offset) % p) != 0 ? (p - (offset) % p) : 0;
                    offset += padding;

                    result = new Cell(column, tries_size1, indexes1);
                    //throw new NotImplementedException();
                }
                else
                {
                    result = new Cell(column, 0, null);
                }
                break;

            default:
                result = base.ReadCellPayload(file, rowIndex, column, cells, ref offset);
                break;
            }
            return(result);
        }
コード例 #3
0
        internal Cell(DexFile file, Column column, ref UInt32 offset)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            this._column = column;

            switch (column.ColumnType)
            {
            case ColumnType.Byte:
                Byte bValue = file.Loader.ReadBytes(offset, 1)[0];
                this._rawValue = bValue;
                this._value    = bValue;
                offset++;
                break;

            case ColumnType.UInt16:
                UInt16 sValue = file.PtrToStructure <UInt16>(offset);
                this._rawValue = sValue;
                this._value    = sValue;
                offset        += sizeof(UInt16);
                break;

            case ColumnType.UInt32:
                UInt32 iValue = file.PtrToStructure <UInt32>(offset);
                this._rawValue = iValue;
                this._value    = iValue;
                offset        += sizeof(UInt32);
                break;

            case ColumnType.SLeb128:
                Int32 slValue = file.ReadSLeb128(ref offset);
                this._rawValue = (UInt32)slValue;                //HACK: Here can be signed integer
                this._value    = slValue;
                break;

            case ColumnType.ULeb128:
                Int32 ulValue = file.ReadULeb128(ref offset);
                this._rawValue = checked ((UInt32)ulValue);
                this._value    = ulValue;
                break;

            case ColumnType.String:
                Int32 utf16_size = file.ReadULeb128(ref offset);
                this._rawValue = (UInt32)utf16_size;
                if (utf16_size > 0)
                {
                    Byte[] bytes = file.Loader.ReadBytes(offset, (UInt32)utf16_size);
                    this._value = Encoding.UTF8.GetString(bytes);

                    offset += (UInt32)utf16_size;
                }
                break;

            case ColumnType.UInt16Array:
                UInt32 itemsCount = this._rawValue = file.Loader.PtrToStructure <UInt32>(offset);
                offset += (UInt32)sizeof(UInt32);
                UInt16[] type_idxs = new UInt16[itemsCount];

                if (itemsCount > 0)
                {
                    for (UInt32 loop = 0; loop < itemsCount; loop++)
                    {
                        type_idxs[loop] = file.Loader.PtrToStructure <UInt16>(offset);
                        offset         += (UInt32)sizeof(UInt16);
                    }

                    //TODO: Dex.TYPE.CODE_ITEM padding может быть, а может и не быть... Надо проверять...
                    UInt32 p       = (UInt32)sizeof(UInt32);
                    UInt32 padding = ((offset) % p) != 0 ? (p - (offset) % p) : 0;
                    offset += padding;
                }
                this._value = type_idxs;
                break;

            case ColumnType.UInt32Array:
                UInt32 itemsCount1 = this._rawValue = file.Loader.PtrToStructure <UInt32>(offset);
                offset += (UInt32)sizeof(UInt32);
                UInt32[] type_idxs1 = new UInt32[itemsCount1];

                for (UInt32 loop = 0; loop < itemsCount1; loop++)
                {
                    type_idxs1[loop] = file.Loader.PtrToStructure <UInt32>(offset);
                    offset          += (UInt32)sizeof(UInt32);
                }
                this._value = type_idxs1;
                break;

            default:
                throw new NotImplementedException(String.Format("Type {0} not implemented", column.ColumnType));
            }
        }