コード例 #1
0
ファイル: ResourceType.cs プロジェクト: DKorablin/ApkReader
        private void Initialize(Int32 packageId, Byte[] buffer)
        {
            using (MemoryStream stream = new MemoryStream(buffer))
                using (BinaryReader reader = new BinaryReader(stream))
                {
                    this._header = Utils.PtrToStructure <ArscApi.ResTable_Type>(reader);
                    if (!this._header.IsValid)
                    {
                        throw new InvalidOperationException("HeaderSize, entryCount and entriesStart are not valid.");
                    }

                    // Skip config data
                    reader.BaseStream.Seek(this._header.header.headerSize, SeekOrigin.Begin);

                    this._entryIndices = new Int32[this._header.entryCount];
                    for (Int32 i = 0; i < this._header.entryCount; ++i)
                    {
                        this._entryIndices[i] = reader.ReadInt32();
                    }

                    this._simple  = new Dictionary <Int32, ResourceTypeEntrySimple>();
                    this._complex = new Dictionary <Int32, ResourceTypeEntryComplex>();

                    for (Int32 i = 0; i < this._header.entryCount; ++i)
                    {
                        if (this._entryIndices[i] == -1)
                        {
                            continue;
                        }

                        Int32 resource_id            = (packageId << 24) | (this._header.id << 16) | i;
                        ArscApi.ResTable_entry entry = Utils.PtrToStructure <ArscApi.ResTable_entry>(reader);

                        if (entry.IsComplex)
                        {
                            ArscApi.ResTable_map_entry mapEntry = Utils.PtrToStructure <ArscApi.ResTable_map_entry>(reader);

                            ArscApi.ResTable_map[] map = new ArscApi.ResTable_map[mapEntry.count];
                            for (Int32 j = 0; j < mapEntry.count; ++j)
                            {
                                map[j] = Utils.PtrToStructure <ArscApi.ResTable_map>(reader);
                            }

                            this._complex.Add(resource_id, new ResourceTypeEntryComplex(resource_id, entry, mapEntry, map));
                        }
                        else
                        {
                            ArscApi.Res_value value = Utils.PtrToStructure <ArscApi.Res_value>(reader);
                            this._simple.Add(resource_id, new ResourceTypeEntrySimple(resource_id, entry, value));
                        }
                    }
                }
        }
コード例 #2
0
ファイル: ResourceRow.cs プロジェクト: DKorablin/ApkReader
 internal ResourceRow(ArscApi.Res_value descriptor, String stringValue)
 {
     this._descriptor  = descriptor;
     this._stringValue = stringValue;
 }
コード例 #3
0
 internal ResourceTypeEntrySimple(Int32 resourceId, ArscApi.ResTable_entry entry, ArscApi.Res_value value)
     : base(resourceId, entry)
 {
     this._value = value;
 }